Commit Graph

573 Commits

Author SHA1 Message Date
Pierre Curto dcfe36c367 widget/material: split Decorations state and style
Move Decorations to the widget package and
rename material.Decorate to material.Decorations.
This makes decorations in line with how the
other widgets are used.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2022-01-31 14:21:19 +01:00
Jack Mordaunt 4f9d063e13 app: note the implications of custom rendering
Small note to make clear how the window behaviour
changes when you call for custom rendering.

Fixes: https://todo.sr.ht/~eliasnaur/gio/346
Signed-off-by: Jack Mordaunt <jackmordaunt.dev@gmail.com>
2022-01-31 14:16:10 +01:00
Elias Naur 9f1d6f5ebf app: [Wayland] minimize redraws, ack configure events immediately
There's no reason xdg_surface_ack_configure can't be called immediate,
do that. Then, replace calls to window wlWindow.draw with a redraw
field, to ensure only one redraw per event loop iteration.

References: https://todo.sr.ht/~eliasnaur/gio/351
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-31 14:08:28 +01:00
Elias Naur ba73227469 app: revert wrong fix for #340
This is effectively a revert of b2a99fddca,
which broke Window.Run.

Fixes: https://todo.sr.ht/~eliasnaur/gio/350
References: https://todo.sr.ht/~eliasnaur/gio/340
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-29 13:38:16 +01:00
Elias Naur f23a4f8452 app: delay Window.Close until after event processing
The fix for #340, b2a99fddca, deferred
all driver functions until after event processing. Deferring functions
breaks Window.Run which expects to complete during event processing.
This change is an alternative, more targeted fix, namely deferring just
Window.Close until after event processing.

A follow-up will revert the previous fix.

References: https://todo.sr.ht/~eliasnaur/gio/340
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-29 13:30:23 +01:00
Pierre Curto 7648a5e381 app: [macOS] fix initial ConfigEvent.Size
Upon initialization, the reported window size
was incorrect.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2022-01-29 12:41:32 +01:00
Pierre Curto 030fd8a171 widget/material: update Decorations
Fix actions not processed and move the Layout method from
Decorations to DecorationsStyle.

Also clarify the comment for the app.Window.Decorated option.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2022-01-29 12:21:08 +01:00
Pierre Curto 5ce1e98282 app: use material.Decorations on undecorated platforms
This patch implements a mechanism for customizing window
decorations.
If a window is configured with app.Decorated(true), then
the widget/material.Decorations are applied. On Wayland,
the option is automatically set when the server does not
provide window decorations.

Server side decorations are no longer requested.
The Decorated flag is set according to the
server's requests.

Wayland is now the default driver for UNIX platforms.

References: https://todo.sr.ht/~eliasnaur/gio/318
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2022-01-27 15:32:42 +01:00
Elias Naur 90ad0010ec app: disable Vulkan on X11
According to

https://gioui.org/issue/347 and
https://github.com/godotengine/godot/issues/43714

choosing the integrated Intel GPU on a multi-GPU system with NVIDIA
doesn't work well in X11. According to Godot, forcing the use of the
discrete (NVIDIA) GPU works around the problem. This change disables
Vulkan on X11 instead, which is a more conservative and targeted fix.

Disabling Vulkan on X11 will reduce testing of Vulkan, but

- Pierre is making Wayland the default driver on Linux, where Vulkan
is enabled.
- The OpenGL driver will be exercized more.

Fixes: https://todo.sr.ht/~eliasnaur/gio/347
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-27 12:32:13 +01:00
Elias Naur 1bad440ef6 app: ensure deferred functions are run outside of FrameEvents
Simplify callbacks.Event a bit while here.

Fixes: https://todo.sr.ht/~eliasnaur/gio/348
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-27 12:13:20 +01:00
Pierre Curto 3bb0171e7a layout: reorder fields in Inset to match system.Insets
This makes it simple to convert from one into the other.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2022-01-25 09:54:05 +01:00
Pierre Curto 0010ec1389 app: [Wayland] update the window mode when un-minimized
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>
2022-01-22 08:10:02 +01:00
Jan Kåre Vatne 862fa832c9 app: [Windows] don't include decorations in window sizes
Fixes: https://todo.sr.ht/~eliasnaur/gio/345
Signed-off-by: Jan Kåre Vatne <jkvatne@online.no>
2022-01-21 14:58:44 +01:00
Elias Naur 30daaef4ab app: [Android] implement key release events
Not terribly useful on Android, but easy to do.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-20 14:21:44 +01:00
Pierre Curto 8c2d9a9a57 app: apply WindowModes at startup
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>
2022-01-20 11:05:09 +01:00
Pierre Curto c0f3ec88e9 io/pointer: add new pointers
Add resize pointer cursor names for resize operations
in preparation for the window decorations patch.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2022-01-19 10:39:32 +01:00
Pierre Curto f4088f94ba minor fixes
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>
2022-01-19 10:39:07 +01:00
Elias Naur 1de8c9f3b0 app: process one event at a time
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>
2022-01-18 12:27:54 +01:00
Pierre Curto b15a9cb595 app: update Window for macOS, X11 and Wayland
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>
2022-01-18 12:00:20 +01:00
Jan Kåre Vatne c4f98d3c1e app: [API] add minimized window mode, change methods to options
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>
2022-01-15 17:30:22 +01:00
Jeff Williams 13183522dd app: send keypress events for modifier keys
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>
2022-01-15 16:56:47 +01:00
Pierre Curto fcaadb3698 app: remove unused types and func arguments
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2022-01-15 16:55:13 +01:00
Elias Naur 9209fd9143 app: [Android don't map the empty string to Java null
Map it to the empty string in Java, which is less surprising.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-13 19:47:48 +01:00
Elias Naur 23bd7aa1d4 app: don't call Window.driverDefer for cursor updates
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>
2022-01-13 19:47:48 +01:00
Elias Naur d951d07c93 app: don't call Window.driverDefer for direct callbacks
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>
2022-01-13 16:03:12 +01:00
Elias Naur b2a99fddca app: run driver callbacks after event processing
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>
2022-01-11 09:03:18 +01:00
Elias Naur c3bbff4cf9 app: remove duplicate error check
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-08 16:44:36 +01:00
Elias Naur 454e75dd14 app: don't process Window state updates before client is ready for events
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>
2022-01-08 16:24:08 +01:00
Elias Naur 11f39582b8 app: [macOS] pace display link
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>
2022-01-07 18:16:40 +01:00
Elias Naur 11aec807b2 app: deliver one event at a time to client
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>
2022-01-07 18:09:18 +01:00
Elias Naur 8d8aeef66b app,gpu,internal/egl: lock OS thread when making OpenGL context current
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>
2022-01-05 11:49:29 +01:00
Elias Naur 7751d73740 app: [Wayland] don't change cursor when there is no pointer
Fixes: https://todo.sr.ht/~eliasnaur/gio/333
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-04 18:24:05 +01:00
Elias Naur 4f5baa9a51 app: let drivers control Window directly
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>
2022-01-04 17:01:05 +01:00
Elias Naur 72b2f2c1bf app: ensure SetDriver is called before sending events
This used to not matter, but a follow-up change will require a valid
driver to process events.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-04 15:48:01 +01:00
Elias Naur 787295a6e8 app: fix typo
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-03 16:23:37 +01:00
Inkeliz 6913c856a2 app: [android] fix vulkan crash when activity/surface is recreated
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>
2021-12-30 09:50:11 +01:00
Pierre Curto 3a20330d82 app: detect fullscreen mode for macOS and Windows
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>
2021-12-26 10:20:54 +01:00
Pierre Curto 0117de71d3 app: add String method to WindowMode and Orientation
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-12-21 10:09:45 +01:00
Jeff Williams f5c9d2725c app: X11 clipboard: write to primary selection
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>
2021-12-14 11:49:07 +01:00
Inkeliz 2a32ece084 app: [iOS] replace ViewEvent.View with add ViewController field
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>
2021-12-10 06:16:26 +01:00
Elias Naur e6e69812af app: expose semantic information to Android platforms
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>
2021-12-01 17:57:04 +01:00
Pierre Curto ebb7f40e9d app: implement Window.Close for Wayland
This is a followup from a question sent to the mailing list.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-11-26 22:28:47 +01:00
Pierre Curto a699f771c6 app: add Maximize and Center methods support for macOS and X11
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>
2021-11-16 18:41:22 +01:00
Inkeliz f4c82adeff app/internal/windows: don't crash on app.Fullscreen on windows/386
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>
2021-11-16 16:31:13 +01:00
Inkeliz 40bc2e1f88 app: [iOS] implement ViewEvent
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>
2021-11-13 10:36:44 +01:00
Jan Kåre Vatne 9835cd5996 app: add Window.Maximize and Center, add Windows implementation
Signed-off-by: Jan Kare Vatne <jkvatne@online.no>
2021-11-10 17:03:23 +01:00
Elias Naur 1d0769ae89 app: use tabs consistently in GioView.java
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-11-03 14:12:31 +01:00
Dylan Staley 4d22a926a9 app: [android] handle touch events from stylus
Fixes gio#291

Signed-off-by: Dylan Staley <88163+dstaley@users.noreply.github.com>
2021-10-16 08:43:51 +02:00
Elias Naur ebad5afdf3 app: [Vulkan] don't exit early on VK_SUBOPTIMAL_KHR
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>
2021-10-09 10:46:37 +02:00
Elias Naur d6e6ca848a app: don't miss driver defers
Fixes gio#281

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-09-30 18:21:18 +02:00