Commit Graph

696 Commits

Author SHA1 Message Date
Chris Waldon dbf6429026 app,gpu/headless: [linux] make EGL the default backend
This commit switches the priority of EGL and Vulkan so that EGL is always
tried first. This is because our EGL backend performs significantly better
than the Vulkan one, and we want the most performant experience to be the
default.

Our hypothesis is that the EGL backend is benefitting from lots of optimization
within the OpenGL driver that Vulkan drivers expect applications to perform
themselves. Rather than invest a bunch of time optimizing the Vulkan backend
right now, this change lets us focus on other priorities.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2022-09-08 11:41:35 +02:00
Elias Naur 911b526dc1 app: [macOS/iOS] remove redundant header include
The redundant include also broke CI.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-08-29 15:06:12 +02:00
Elias Naur 3b2f2efac7 app: [Wayland] maintain fallback decoration height during maximize
Window.decorations.height is supposed to be a constant during the
lifetime of the window, unlike w.decorations.Config.decoHeight that
varies depending on the decorations state (fallback or custom).
This change makes that so, fixing a problem where the fallback
decorations would fail to offset client content after a maximize
or minimize.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-08-19 10:51:53 +02:00
Inkeliz 65a4366e44 app: [android] fix insets
Previously, the Inset could be report wrongly when the bottom inset
is smaller than the top.

Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2022-08-07 23:26:05 +02:00
Elias Naur 61b2e37691 all: format comments with go fmt ./... using Go 1.19
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-08-06 12:26:03 +02:00
Inkeliz 3e9d4d966c app: [android] use GioView inside FrameLayout
Before that change, on Android, was impossible to overlay GioView with
a custom view. This change adds FrameLayout and renders GioView into
that, allowing to use addView from Android API.

Fixes: https://todo.sr.ht/~eliasnaur/gio/427
Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2022-08-02 17:04:51 +02:00
Elias Naur dbbae0519e app/permission/wakelock: add package for requesting wake locks
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-08-01 20:15:44 +02:00
Elias Naur 5326ca5fbe all: add support for macOS to flake.nix
The Nix version of the macOS toolchain has difficulties compiling
Objective-C modules; disable modules instead of figuring out why.
It also doesn't include any frameworks automatically; add them explicitly.

While here, move suppression of OpenGL deprecation to a GL-specific
file.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-08-01 01:33:21 +02:00
Elias Naur 0f51cb9084 app: [macOS] don't miss pointer presses
We used to track the pressed pointer buttons through the global function
[NSEvent pressedMouseButtons]. However, it's possible that at the time a pointer
press event is delivered, the pointer button is up again. To ensure a consistent
view of the pointer press state, track it through the buttonNumber property on
delivered events.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-07-26 11:47:05 +02:00
Inkeliz fc5689ea44 app: [windows] recover focus on click
Previously, Gio doesn't reclaim the focus when they lose that to a
parent window. In such a case, the child window can steal
keyboard focus, and Gio will never recover it.

Now, Gio will recover the focus when clicked.

Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2022-07-26 07:32:52 +02:00
Elias Naur 2993ba1838 app: [Wayland] account for fallback decoration height in window sizes
Pass through a fallback window decoration height to the Wayland backend,
so that it can account for it when determining surface size.

Fixes: https://todo.sr.ht/~eliasnaur/gio/435
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-07-18 23:17:04 +02:00
Elias Naur 63d2353864 app: ensure no window wakeups are in flight when destroying it
When a window is destroyed, it is no longer valid to call its wakeup
method.

Thanks to Jack Mordaunt for identifying the race.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-07-18 19:02:07 +02:00
Elias Naur c73125e1c3 app: [X11] send DestroyEvent after ViewEvent{}
Matches the other platforms.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-07-17 14:52:17 +02:00
Elias Naur 2adf4efcbd app: [Wayland] shrink reize gesture area
As reported by Chris Waldon, the resize area is big enough to make
it hard or impossible to grab and drag any scroll bars.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-07-01 11:16:28 +02:00
Elias Naur 2957d007a2 app: [Wayland] only start resize gesture on pointer down
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-07-01 11:15:19 +02:00
Elias Naur cab1184818 app: [Wayland] don't process resize gestures when decorated
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-07-01 08:02:23 +02:00
Chris Waldon a5f8aa35e1 app: [Wayland] scale pointer hotspot coordinates
This commit updates the way that we change cursors so that the
hotspot of the cursor is properly set to surface-local coordinates.
The previous raw hotspot coordinates are relative to the cursor
image buffer data, and do not take the buffer's scaling factor
into account.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2022-07-01 07:55:37 +02:00
Elias Naur d8766f6d2d app: [macOS] fix Intel build
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-29 22:25:11 +02:00
Elias Naur fa3978e18e app: [macOS] use NSWindow.zoom for Maximized
NSWindow.zoom is what the native window control calls when maximizing.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-29 07:47:45 +02:00
Elias Naur 78d1eab950 app: call driver Perform and Configure after idling
Before this change, Perform and Configure could be called during the
event processing where additional events would be queued. However,
a Maximize animation on macOS works by repeatedly sending draw
requests, and they must not be postponed.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-29 07:35:33 +02:00
Elias Naur 4d593927ae app: [Windows] fix window state update after window restore
This patch ensures a correct transition from Minimized to Windowed.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-28 18:32:45 +02:00
Elias Naur 5dc8e0e39d app: [Windows] always send ConfigEvent after Configure
This case was missed in 69e4a3cff3.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-28 18:32:45 +02:00
btop 29f4a1d07b app: fix iOS build
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-28 18:32:33 +02:00
Elias Naur fa538f219f app: remove ackEvent, tighten error check
ackEvent is not necessary, a nil event.Event doesn't allocate.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-26 10:14:02 +02:00
Elias Naur 546d971e49 app: [Wayland] ensure monitor scale changes propagate to active windows
This broke during an earlier refactor.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-26 09:18:02 +02:00
Chris Waldon 9151009b2a app: [Wayland] respect XCURSOR_* environment variables
This commit adds support for the commonly-used XCURSOR_THEME and
XCURSOR_SIZE environment variables. Wayland lacks a protocol-level
way to standardize cursor size right now, but these variables are
used consistently by many applications and compositors. Many users
(including me) will find that their environment is already configuring
these for them, and will get consistent cursor sizing for free.

I explored a lot of ways to tackle this, but it looks like nobody has
ever gotten around to implementing the cursor theme protocol discussed
here:

https://wayland-devel.freedesktop.narkive.com/VuMSOO55/possible-wayland-extension-to-publish-mouse-pointer-size

Given that it doesn't seem to be resolved anytime soon, supporting a
widely-used convention to tweak these things seems reasonable to me.

I say that it fixes issue 382 because it enables the user to make
Gio's cursor size match the rest of their system.

Fixes: https://todo.sr.ht/~eliasnaur/gio/382
Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2022-06-26 09:13:43 +02:00
Chris Waldon 414a91c49e app: [Wayland] use HiDPI cursor on HiDPI screen
This commit scales both the loaded cursor theme and the cursor
surface appropriately so that the cursor image is not blurry on
HiDPI screens.

References: https://todo.sr.ht/~eliasnaur/gio/382
Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2022-06-26 09:13:43 +02:00
Elias Naur 3f38e67ce0 io/system: add ActionInputOp to register window move gesture areas
The app.Window.Perform(ActionMove) is the wrong abstraction for
initiating a move gesture: Windows needs to know the move gesture
area at pointer move, and macOS needs to know the pointer button
down event that triggers the move gesture. This change replaces
Perform(ActionMove) with a new system.ActionInputOp that marks an
area movable.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-25 19:40:46 +02:00
Elias Naur b53cdfef8d io/system: remove resize actions
Allowing clients to initiate resize gestures is a waste: macOS
doesn't support them, and the only reason we added them was to
implement client-side decorations for Wayland. Now all desktop
platforms implement resize gestures as needed, and we no longer
need the system.Action actions.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-25 18:41:32 +02:00
Elias Naur b34dc63531 app: [Wayland] hard-code border resize gestures
We're about to remove the system.Action machinery for initiating resize
gestures. This is the Wayland implementation that hard-codes the border
drag gesture for resizing.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-25 18:41:32 +02:00
Elias Naur fd3a3eb1b9 app: [Windows] support resize gestures for undecorated windows
We're about to remove the client-controlled system.Action machinery
for resize gestures initiated by the client. This is the replacement
implementation for Windows, where the behaviour is hard-coded to
mimic the decorated automatic handling.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-25 18:41:32 +02:00
Elias Naur 45443a2c3a app: [Windows] don't recompute window size during fullscreen switch
The redraw machinery takes care of it automatically.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-25 18:41:32 +02:00
Elias Naur 5bdf5950b2 app: [Windows] support app.Decorated(false)
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-25 18:41:32 +02:00
Elias Naur 2973c7fa5a app: [Windows] consolidate window mode switch branches
This change is a refactor to make undecorated window support easier
to implement.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-25 18:41:32 +02:00
Elias Naur 5e7bf1716e app: [Windows] don't re-compute window size when maximizing
The redraw machinery will take care of it like any other resize.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-25 18:41:32 +02:00
Elias Naur 8ef0ad43cb app: [Windows] share extended window styles across Win32 calls
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-25 18:41:32 +02:00
Elias Naur df43ba8be0 app: [Windows] don't add or remove the WS_MAXIMIZE flag
ShowWindow(SW_SHOWMAXIMIZED/SW_SHOWNORMAL) is what changes the
window size and state.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-25 18:41:32 +02:00
Elias Naur 5cf657065e app: [Windows] use SWP_NOZORDER instead of SWP_NOOWNERZORDER
As I read the SetWindowPos documentation, SWP_NOZORDER is the correct
flag for keeping the z-order of the window.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-25 18:41:32 +02:00
Elias Naur 59480066b4 app: [Windows] don't assume fullscreen when not WS_OVERLAPPEDWINDOW
We're about to remove the WS_OVERLAPPEDWINDOW style for undecorated
windows, in which case the fullscreen assumption will no longer hold.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-25 18:41:32 +02:00
Elias Naur 69e4a3cff3 app: guarantee a ConfigEvent for every Window.Configure call
Not only is the client guaranteed a ConfigEvent, but app.Window
can assume that an unsupported decoration change will be corrected
(by a ConfigEvent with Decorated forced to the supported value).

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-25 18:41:22 +02:00
Elias Naur c5e07ba01f app: [macOS] add support for ActionMove
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-24 21:41:56 +02:00
Elias Naur 8457df2d1f app: [macOS] add support for undecorated windows
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-24 20:56:16 +02:00
Elias Naur 6a5d3f996a app: don't draw fallback decorations for undecorated windows.
Until now, fallback decorations were only needed for Wayland client-side
decorations. We're about to support app.Decorated(false) one some platforms,
where Window should not fall back to drawing its own decorations.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-23 21:10:57 +02:00
Elias Naur 9f91fecdb3 app: [Wayland] don't allow changes to decoration mode
We're about to enable platform support for switching native
window decorations on and off. However, the Wayland platform
only supports server-side switching of decoration mode, not
(yet) client-side. Thus, don't switch mode even when asked to.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-23 20:33:20 +02:00
Elias Naur 371de3462b app: replace driver.Close with Perform(ActionClose)
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-23 19:04:30 +02:00
Elias Naur 43116400d0 app: fix racing app.Window.Perform and app.Window.Option
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-23 17:58:45 +02:00
Elias Naur e31aa35622 app: draw fallback decorations on top
Before this change, client-side decorations for Wayland were drawn
before client content, which was prevented from drawing over
decorations with a clip. While visually correct, resize handles would't
work as long as client listeners are near the window edges to swallow
pointer input.

This change makes app.Window draw decorations last, fixing resizing
and saves a clipping operation. This is an alternative to the original
fix for #361, commit 20d4bc2.

References: https://todo.sr.ht/~eliasnaur/gio/361
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-23 13:41:34 +02:00
Chris Waldon 6a6ddc3f19 app: [Wayland] scale min/max window size correctly
The xdg_toplevel expects the min/max window size in DP rather
than pixels. The scaling factor would be applied twice because
we supplied pixels that we scaled ourselves, resulting in windows
twice the expected size on HiDPI screens. This bug probably went
for so long without being detected because it only manifests if
you actually set a minimum or maximum size.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2022-06-23 10:10:22 +02:00
Chris Waldon 55c96adb91 app: [Wayland] handle multiple global registry event orders
Not all wayland compositors advertise the global registry events
in the same order. In particular, river and sway differ in that
sway advertises the data_device_manager before the seat, and river
does it after. This commit updates our code to correctly bind
the data_device so that we can work with the clipboard regardless
of the registry event order.

Special thanks to Isaac Freund (river maintainer) for helping me
find the root of this problem. You can see Isaac's extremely helpful
and detailed analysis here:

https://github.com/riverwm/river/issues/554#issuecomment-1059750874

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2022-06-23 10:10:11 +02:00
Elias Naur bf6371c8e9 app: restore IME snippet after an EditorReplace
Commit 0273203743 removed the snippet
restore event, which broke IME on macOS and Windows.

Fixes: https://todo.sr.ht/~eliasnaur/gio/424
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-15 11:30:12 +02:00