Commit Graph

850 Commits

Author SHA1 Message Date
Walter Werner SCHNEIDER 420f4c32f4 app: [Wayland] don't recreate EGL surface during resize
Fixes: https://todo.sr.ht/~eliasnaur/gio/656
Signed-off-by: Walter Werner SCHNEIDER <contact@schnwalter.eu>
2025-07-01 15:56:50 +02:00
Elias Naur ea979b436d app: [Windows] show the maximize button even when MaxSize is set
According to @kkeybbs, pressing the maximize button on Windows only
resizes the window up to its maximum bounds. That means we can leave the
button available, and only hide it when the window has a fixed size.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2025-07-01 09:22:38 +02:00
Elias Naur d50ef687b8 app: [macOS] limit full screen window size when MaxSize is set
There are two max window size settings on macOS, `contentMaxSize` and
`maxFullScreenContentSize`. Set the latter to avoid a window being
resized larger than its maximum in full screen mode.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2025-07-01 09:16:48 +02:00
Marc 809a6d0dc7 app: [Windows] add minimal support for devices with touch screens
The Windows Pointer API
(https://learn.microsoft.com/en-us/windows/win32/api/_inputmsg/) was used
to allow the detection of events when interacting with touch screens. This
also opens the gates for supporting other types of input devices (e.g. pens
and touchpads). Mouse events are now part of the pointer events (primary
events trigger WM_POINTER<DOWN|UP>, whereas secondary ones vanilla
WM_POINTERUPDATE, and cancellations WM_POINTERCAPTURECHANGED).
A fourth and fifth button (usually found in modern mice) has also been added
for completeness, though their integration in other OS-es shall be the
objective of future patches.

Signed-off-by: Marc <marc.leroy@samantree.com>
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2025-05-27 19:16:47 +02:00
Admin f73287be87 all: clean up code, upgrade to modern Go
Signed-off-by: ddkwork
2025-05-05 19:46:39 +02:00
Marcel Juffermans 35ec76e516 app: [Windows] correctly center window on startup
When the window is created position it *before* processing the actions
to perform (which may include system.ActionCenter). Note that the
actions are performed in the callback windowProc().

Fixes: https://todo.sr.ht/~eliasnaur/gio/646
Signed-off-by: Marcel Juffermans <mjuffermans@paradigmone.com.au>
2025-04-24 17:06:56 +02:00
Dave Akers cc6048bc25 app: [Wayland] remove window.seat in favor of wlSeat.pointerFocus
Signed-off-by: Dave Akers <dave@dazoe.net>
2025-04-09 10:09:10 +02:00
Dave Akers 016714a668 app: [Wayland] use correct serial for wl_pointer_set_cursor, take 2
To fix #644 the serial passed to wl_pointer_set_cursor must come from
the pointer enter event. To do this we need a place to keep the serial
so I've added a field to the wlSeat struct to hold on to it.

Ref: https://wayland.app/protocols/wayland#wl_pointer:request:set_cursor
Ref: https://wayland-book.com/seat/pointer.html

Fixes: https://todo.sr.ht/~eliasnaur/gio/644
Signed-off-by: Dave Akers <dave@dazoe.net>
2025-04-03 23:59:44 +02:00
Dave Akers a3117d3823 app: [Wayland] use correct serial for wl_pointer_set_cursor
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2025-04-02 21:27:53 +02:00
Elias Naur 72a72a2bc2 app: [macOS] don't discard IME session for consistent snippets
An IME session must be discarded when its text content no longer matches
the underlying text component content. However, the check for matching
was too pessimistic; the IME session would be discarded if the new
snippet from the text component was not equal to the snippet reported to
the IME. This change implements a refined check that only discards a
session if the content of the overlap between the new and old snippets
don't match.

Fixes an IME issue reported by Zhang Zj.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2025-02-23 19:16:02 +01:00
kurth4cker 4f720af6f2 app: fix miss included doc comment
License identifier is shown in documentation at[1]. This patch fixes it.

1: https://pkg.go.dev/gioui.org/app#hdr-Permissions

Signed-off-by: kurth4cker <kurth4cker@gmail.com>
2025-02-15 08:49:34 +00:00
Elias Naur af446e8b87 app: [macOS] correct error handling for newMtlContext
Fixes: https://todo.sr.ht/~eliasnaur/gio/632
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2025-02-10 14:00:12 +01:00
vasijob225 95354d80bd app: [Windows] hide the maximize button when MaxSize is set
Also, disable window frame resizing when MaxSize equals MinSize.

Fixes: https://todo.sr.ht/~eliasnaur/gio/631
Signed-off-by: vasijob225 <vasijob225@protonmail.com>
2025-02-02 14:19:44 +01:00
Elias Naur f200f0e9a3 app: [Windows] don't draw minimized windows
Fixes: https://todo.sr.ht/~eliasnaur/gio/621
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2025-01-14 11:29:45 +01:00
Elias Naur 1ae2b9b8fe app: [macOS] don't draw when minimized
References: https://todo.sr.ht/~eliasnaur/gio/621
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2025-01-14 11:29:45 +01:00
Elias Naur fe4bf00c70 app: [macOS] propagate unhandled key shortcuts
By propagation, we restore the system behaviour for shortcuts the program
don't want, for example the system beep.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2025-01-14 11:12:34 +01:00
Elias Naur 8107ec2206 app: [macOS] remove support for key bindings
The fix for #616 went to far by attempting to support macOS key bindings
through doCommandBySelector. Issue #625 is a consequence, but more
fundamentally, key bindings does not work with support for key.Release
events.

Remove key binding translation and fix #626, and add a check whether an
IME swallowed a key event, keeping #616 fixed.

While here, replace the KEY_ constants with ASCII codes.

Fixes: https://todo.sr.ht/~eliasnaur/gio/625
References: https://todo.sr.ht/~eliasnaur/gio/616
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2025-01-13 23:24:25 +01:00
Chris Waldon a206e5e847 app: [Windows] use NewLazySystemDLL for kernel32.dll
In order to avoid DLL preloading attacks, we should always load our system
dependencies using the helper that only searches the system library path.

Thanks to Mohsen Mirzakhani and Utkarsh Satya Prakash for bringing this to
our attention.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2025-01-09 09:54:15 +01:00
Elias Naur 7337c06daf app: [macOS] send keypress events for modifier keys
This change generates keypress and release events for modifier keys in macOS.
Specifically the Control, Alt, Shift and Command keys.

Signed-off-by: Jeff Williams <kanobe@gmail.com>
2024-12-04 18:12:15 +01:00
Elias Naur 94355e5201 internal/vk: remove methods on C types, for Go 1.24 compatibility
Go 1.24 no longer allows methods on C types (golang.org/issue/60725).

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2024-11-26 10:31:04 +01:00
Elias Naur 8daff13af6 app: [windows] ensure no callbacks after DestroyEvent
Setting the callback handler to nil in DestroyEvent should have no effect,
but may help debugging #603.

Also don't call the default window handler for WM_DESTROY since we're
already handling it.

References: https://todo.sr.ht/~eliasnaur/gio/603
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2024-10-25 22:06:57 +02:00
Elias Naur aa158e0c9c app: fix race condition between Window.Invalidate and event loop
References: https://todo.sr.ht/~eliasnaur/gio/603
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2024-10-25 20:38:37 +02:00
Elias Naur 520efdfa75 app: fix typo
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2024-10-25 20:29:21 +02:00
Elias Naur d7a1ec7461 app: [macos] don't relay key events handled by the IME
Widgets such as Editor use certain key events such as the backspace key
to implement text editing. On macOS, such key events are sometimes used
by an input method, and in those cases the key effect would be applied
twice: first by the IME and then the Editor.

Report such key events through the doCommandBySelector callback, which
receives key events not handled by the IME.

References: https://todo.sr.ht/~eliasnaur/gio/616
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2024-10-25 19:39:20 +02:00
Elias Naur d4c5e54375 app: remove dead code
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2024-10-25 19:39:20 +02:00
Elias Naur 44ac50506d app: [android] ensure a new frame is always scheduled when visible and animating
Possible fix to #614.

References: https://todo.sr.ht/~eliasnaur/gio/614
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2024-10-25 12:16:54 +02:00
inkeliz 38e4b1c6a4 app: [android] fix compatibility with older Android versions
Previously, setHighRefreshRate requires APIs restricted
to Android 30, or higher.

Tested on Android 6.0.1 (released on 2015).

Signed-off-by: inkeliz <inkeliz@inkeliz.com>
2024-10-25 11:44:13 +02:00
Elias Naur c7277581f8 app: [Window] don't report Win32ViewEvent before window configuration
Fixes: https://todo.sr.ht/~eliasnaur/gio/609
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2024-10-22 19:05:27 +02:00
Elias Naur a5f7e7b2c7 app: [Windows] compute min, max window sizes correctly when un-minimzing
Fixes: https://todo.sr.ht/~eliasnaur/gio/608
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2024-10-22 19:05:27 +02:00
Elias Naur 0781e62b56 app: [Windows] don't ignore Min|MaxSize options
The support for minimum and maximum window sizes were broken by a recent
change. Found while investigating #608.

References: https://todo.sr.ht/~eliasnaur/gio/608
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2024-10-22 19:05:27 +02:00
Elias Naur 6efcb65c4b Revert "app: [Windows] don't draw after WM_DESTROY destroyed the window"
This reverts commit 635df374952019ff8d274646ea9ce040744daa0f because it
didn't fix #603 after all.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2024-10-22 19:05:27 +02:00
Elias Naur f6e9f6861d app: close the window before reporting a GPU error
When a GPU error occurs forcing the reporting of a DestroyEvent is not
appropriate, because the backend that controls the underlying window
is not aware of the error and will continue to report events.

Replace the crude DestroyEvent by stashing the error and asking the
window nicely to close. The, report the stashed error in the
otherwise regular DestroyEvent.

Hopefully, this second attempt fixes #603.

Fixes: https://todo.sr.ht/~eliasnaur/gio/603
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2024-10-22 19:05:27 +02:00
Elias Naur 8cf449034c app: [Windows] remove redundant code
Change f7aa4b5c8 changed the fullscreen implementation to no longer require
the position and size of the fullscreen window.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2024-10-22 19:05:27 +02:00
Elias Naur 6722c7960a widget: [API] change Decorations to leave the user in control of window state
As suggested by ~egonelbre, Decorations should not be the source of truth
for the windows state, because external gestures may also change state.

This breaking change removes Decorations.Perform and exposes Maximized
as a bool which is the user's responsibility to set.

Fixes: https://todo.sr.ht/~eliasnaur/gio/600
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2024-10-22 19:05:27 +02:00
Elias Naur 97044e53b5 app: [Windows] track window state changes initiated by the OS
Like the previous change, update the Windows backend to track and report
window state changes initiated by the OS.

References: https://todo.sr.ht/~eliasnaur/gio/600
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2024-10-22 19:05:27 +02:00
Elias Naur af6dda67a5 app: [macOS] track window state changes initiated by the operating system
Before this change, the window state was explicitly updated whenever
Window.Option was called. However, the system may also change window
state as a result of user gestures, but those changes did not result in
ConfigEvents reflecting them.

Remove the explicit state updates and track them when the system tells
us it has changed.

This is a step towards fixing #600 which require accurate window state
tracking.

References: https://todo.sr.ht/~eliasnaur/gio/600
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2024-10-22 19:05:27 +02:00
Elias Naur 042ed4ab49 app: [Windows] don't draw after WM_DESTROY destroyed the window
There may be a window of time from WM_DESTROY is received to the WM_QUIT
message is delivered by PostQuitMessage. If so, we must not call w.draw.

Fixes: https://todo.sr.ht/~eliasnaur/gio/603
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2024-10-22 19:05:27 +02:00
Elias Naur 6aa027136e app: [Windows] remove redundant code
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2024-10-22 19:05:27 +02:00
Elias Naur 9dceca6c95 Revert "app: [Windows] suppress double-click behaviour for custom decorations"
This reverts commit 82cbb7b8da.

As Egon Elbre points out in

https://todo.sr.ht/~eliasnaur/gio/600#event-377179

this is not the right fix.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2024-10-22 19:05:19 +02:00
Elias Naur 82cbb7b8da app: [Windows] suppress double-click behaviour for custom decorations
Fixes: https://todo.sr.ht/~eliasnaur/gio/600
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2024-07-13 18:09:13 +02:00
Chris Waldon 6c19821a6c app: [Wayland] prevent recursive scroll event processing
This commit zeroes the accumulated scroll distance on the window before invoking the
event delivery code, since the event delivery code is able to call back into the scroll
processing. Prior to this change, the callback could re-processing the scroll delta
while magnifying it by a factor of 10.

Fixes: https://todo.sr.ht/~eliasnaur/gio/599
Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2024-07-13 11:03:14 +02:00
Elias Naur 86349775b7 app: ensure Invalidate can be invoked when window is closing
This commit ensures that it is safe to invoke Invalidate() from another goroutine
while a Gio window may be in the process of closing. It can be difficult to prevent
this from happening, as window handles can easily be managed by a type that doesn't
know the exact moment of window close (it might be waiting on the window event loop
to return, but that hasn't happened yet). Without this change, the nil window
driver results in a panic in this situation.

Co-authored-by: Chris Waldon <christopher.waldon.dev@gmail.com>
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2024-07-02 15:06:52 +02:00
Chris Waldon 4a1b4c2642 app: add cross-platform empty view event detection
Custom rendering applications need to be prepared to handle empty view events,
as an empty view event is sent during window shutdown. However, the current
implementation requires applications to write a platform-specific helper
function for each supported platform in order to check whether a received
view event is empty. This commit provides a safe, convenient, cross-platform
method that applications can use to detect this special view event and respond
to it.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2024-06-28 08:46:36 +02:00
Elias Naur c900d58fb3 app: [macOS] fix ANGLE renderering
Setting CAMetalLayer.presentWithTransaction to YES breaks ANGLE rendering.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2024-06-27 17:48:08 +02:00
Elias Naur 74ccc9c2c7 app: use empty frame when FrameEvent.Frame isn't called
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2024-06-27 16:37:48 +02:00
Elias Naur 3f671afea8 app: ignore Invalidate for Windows not yet created
While here, don't overflow the Windows event queue.

Fixes: https://todo.sr.ht/~eliasnaur/gio/596
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2024-06-27 16:37:48 +02:00
Elias Naur 42357a29e0 app: reset Window when DestroyEvent is received
Fixes: https://todo.sr.ht/~eliasnaur/gio/595
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2024-06-27 10:41:22 +02:00
Chris Waldon 5542aac772 app: queue system actions before first call to Event()
This commit ensures that attempting to perform a system window action prior
to the first call to Event() does not panic. It adopts a similar strategy to
handling Option() prior to the first call to Event(): make a slice of the arguments
and apply them during window initialization.

Fixes: https://todo.sr.ht/~eliasnaur/gio/593
Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2024-06-20 12:18:42 +02:00
Elias Naur e878dbc598 app: [macOS] ignore focus changes not meant for the Gio view
Extracted from https://github.com/gioui/gio/pull/138 by inkeliz.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2024-06-16 15:15:40 +02:00
Elias Naur e6da07a85a app: [iOS] add support for buildmode exe
Up until now, the iOS part has relied on a tool such as gogio to
synthesize a main function. This change adds support for running direcetly
in exe mode, while retaining support for embedded Gio in C programs.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2024-06-02 12:55:36 +02:00