When a window goes from the Minimized state to Windowed
as the user brings it back up, the internal state needs
to reflect that change and generate the corresponding
Config event.
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
As reported on slack by Rajiv Kanchan, when a WindowMode
is used with app.NewWindow, it does not get applied.
Delay the Configure method to make sure it is.
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
Add resize pointer cursor names for resize operations
in preparation for the window decorations patch.
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
Make sure that the title is set if changed while in
Maximized mode.
Don't overwrite the config.Size when going from
Minimized to Windowed mode.
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
Commit 11aec807b2 added a waiting flag to avoid
processing platform events recursively. However the flag was only true when the
window goroutine is blocked waiting for client events, so deferred window
functions such as Window.Option may still runs multiple times for recursive
events.
This change renames the flag to busy and sets it during the entire processing
of an event, including recursive events and deferred window functions.
Fixes: https://todo.sr.ht/~eliasnaur/gio/344
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Commit #c4f98d3c1eab201419be255fafb139f7e10ad273 added
the Minimized and Maximized options for the Windows platform.
This change adds those for the remaining desktop platforms.
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
The window modes are extended, following microsoft conventions.
We have Fullscreen, Overlapping, Maximized and Minimized.
These modes can be set via options when a new window is creates,
or modified later by calling helper functions like w.Maximize() and w.Center()
The window configuration is automatically updated when a user
modifies the window by dragging or clicking the icons on the window's title-bar,
minimizing or maximizing the window.
Any change, either by the user or the application will emit a ConfigChange event.
This is implemented and tested on Windows only.
API change. the app.Window methods Maximize and Center are replaced with similar
options. For example, to maximize a window use
w.Option(app.Maximized.Option())
Also, Maximize and Center implementations for X11 and macOS are left for a future
change.
Fixes: https://todo.sr.ht/~eliasnaur/gio/315
Signed-off-by: Jan Kåre Vatne <jkvatne@online.no>
This change causes modifier keys (Control, Shift, Alt, Super) to be sent
to the application as key.Event events. These will still continue to be
used as modifiers for other key and pointer events as they are today.
This commit also adds a minor cleanup to use constants for function
keys in the OS-specific keypress handling functions.
Signed-off-by: Jeff Williams <kanobe@gmail.com>
Like d951d07c93, calls to Window.updateCursor happens on the
evennt loop thread, and so must not go through Window.driverDefer.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
The internal calls to ReadClipboard and WriteClipboard happen during a callback
from the event loop. This change avoids the roundtrip through driverDefer.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Running, for example, Window.Close during a FrameEvent processing doesn't end
well on platforms that immediately destroys the window. This change defers
callbacks to after the completing the current event.
Fixes: https://todo.sr.ht/~eliasnaur/gio/340
Signed-off-by: Elias Naur <mail@eliasnaur.com>
On Android, a call to update soft keyboard state may result in focus events.
Before this change, the client would still be blocked in FrameEvent.Frame,
resulting in a deadlock.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
On macOS the display link that drives redraws runs on a separate thread, and
must switch to the main thread to invalidate its view. This change makes sure
the display link can never call invalidate faster than we can draw.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
If the client calls, say, Window.Configure during a frame which in turn results
in a ConfigEvent, the program deadlocks. This change implements a queue of
events to be delivered after processing another.
Fixes: https://todo.sr.ht/~eliasnaur/gio/337
Signed-off-by: Elias Naur <mail@eliasnaur.com>
OpenGL stores the current context in thread-local memory, but commit
4f5baa9a51 removed a runtime.LockOSThread from app.Window that ensured
the goroutine that drives the context stays on the operating thread that
has the context current. This change restores the thread lock.
As a bonus, this change makes the OpenGL contexts responsible for locking
the thread at MakeCurrent, thereby removing LockOSThread calls from GPU
backend-agnostic code.
Fixes: https://todo.sr.ht/~eliasnaur/gio/334
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Before this change, Window driver callbacks would all go through
channels to be processed by Window.run. However, Window.run may call
into the driver, which again may invoke a Window callback. These
re-entrant calls have been a source of deadlocks and subtle errors,
resulting in increasingly complex channel logic. This change eliminates
the goroutine split between Window and the driver, allowing callbacks
between Window and the driver without restrictions.
The goroutine split between Window and the driver is historical and
was meant to tame the complicated callback logic of drivers into a nice
for-select loop. However, the complexity isn't worth the gain, and there is
no concurrency concerns because there is always a 1:1 correspondance between
a driver goroutine and its Window object.
Fixes: https://todo.sr.ht/~eliasnaur/gio/329
Signed-off-by: Elias Naur <mail@eliasnaur.com>
On Android it's possible that the Activity/View must be restore. But,
before that patch, an new VkSurfaceKHR is created but never used and
that may lead to crash, in an attempt to destroy/use one invalid
surface.
Fixes: https://todo.sr.ht/~eliasnaur/gio/327
Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
When an application goes into or out of fullscreen mode,
Gio now emits a ConfigEvent with the current window mode.
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
This change is to augment the X11 clipboard write behaviour.
When writing to the clipboard both the primary and clipboard
selections are published so that non-GIO applications that read
the primary selection (i.e. such as terminal emulators using
middle-mouse clicks) can read the data from a GIO app.
Signed-off-by: Jeff Williams <kanobe@gmail.com>
For mixing native UI with Gio UI, the UIViewController is sometimes
needed, not just the UIView. This change replace the View field of
ViewEvent with ViewController.
Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
Previous changes added semantic API and semantic information to Gio
widgets. This change maps the information to Android accessibility
classes so that TalkBack can traverse and interact with Gio programs.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Commit 9835cd59 added support for the Window.Maximize and
Window.Center methods for Windows only.
This patch also adds support for macOS and X11.
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
Before this patch, use of `app.Fullscreen` would result in "Failed to
find SetWindowLongPtrW procedure in user32.dll" when running on 32 bit
Windows.
Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
ViewEvent exposes native window handle for platform specific uses. This
change implements ViewEvent for iOS.
Fixes gio#305
Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
The mapErr helper may map the error to nil, in which case the caller
should continue, not exit.
This change split up error mapping into mapErr which never maps to nil,
and mapSurfaceErr which handles the VK_KHR_swapchain errors and may map
to nil.
Maybe fixes gio#287
Signed-off-by: Elias Naur <mail@eliasnaur.com>
CFTypeRefs may not always contain valid pointers, so they must not be
stored in pointer types lest the Go runtime treats them as such.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Before this change, it was unclear who owned the platform specific
VkSurfaceKHR object, leading to a double-free in the error path for
devices with no Vulkan support. This change moves the ownership to the
platform specific code.
Add vk.EnumeratePhysicalDevices while here (refactor was part of
debugging of the double-free).
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This change implements a Vulkan port for the two renderers, old and
compute. Run with GIORENDERER=forcecompute to test the compute renderer.
To shake out bugs faster, it is also made the default on systems that
support it. To disable Vulkan and force the use of OpenGL, use the
`novulkan` tag:
$ go run -tags novulkan gioui.org/example/kitchen
Don't forget to file an issue describing the issue that prompted the use
of the tag.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Unlike Raise, Close and other fire-and-forget methods on Window,
Config calls driverRun because it needs to wait for the result.
However, driverRun isn't guaranteed to block in all contexts.
This change avoids the synchronization dance altogether by removing the
Config method and introducing a ConfigEvent event. The event also makes
it clear when the configuration changes.
Signed-off-by: Elias Naur <mail@eliasnaur.com>