Commit Graph

136 Commits

Author SHA1 Message Date
Thaddeus Crews 21dbe711c5 Merge pull request #113886 from deralmas/wl-touch
Wayland: Implement touch support
2026-04-15 14:02:35 -05:00
Thaddeus Crews 8e0030b4ee Merge pull request #118554 from deralmas/wl/complex-pointer-frames
Wayland: Handle complex pointer event frames
2026-04-14 07:11:03 -05:00
Dery Almas 3883ba2a34 Wayland: Handle complex pointer event frames
From the spec:

> The wl_pointer.enter and wl_pointer.leave events are logical events
> generated by the compositor and not the hardware. These events are
> also grouped by a wl_pointer.frame. When a pointer moves from one
> surface to another, a compositor should group the wl_pointer.leave
> event within the same wl_pointer.frame. However, a client must not
> rely on wl_pointer.leave and wl_pointer.enter being in the same
> wl_pointer.frame. Compositor-specific policies may require the
> wl_pointer.leave and wl_pointer.enter event being split across
> multiple wl_pointer.frame groups.

From my understanding™ this means that a compositor SHOULD group
leave/enter events together. Is this common? From my testing... Not
really. Notably, (only?) KDE does this.

Our pointer frame event assumed that we would be working with the
currently pointed window but since all events must be logically grouped
together I think it can really only group "normal" events related to the
*leave* event.

Now, whenever there's a pointer focus change, we send everything to the
old window, if it exists, otherwise the currently pointed one.

This approach seems to handle complex event frames with both leave and
enter events properly now, with good results on all compositors.

This patch also and makes it harder to get to a null check when the
window simply does not exists (the error was meant only for existing but
invalid windows), along with an helper method to aid in this.
2026-04-14 01:18:55 +02:00
Dery Almas ac913816d4 Wayland: Initialize libdecor earlier
It has its own bookkeeping which would not immediately initialize in
certain setups, leading to crashes.
2026-04-04 23:09:22 +02:00
ArchercatNEO 1d14370d55 Wayland: Fix building with libdecor=no 2026-04-03 10:08:11 +01:00
Thaddeus Crews 0f51ed6099 Merge pull request #113543 from bruvzg/win_icons
[DisplayServer] Add per window icon support.
2026-03-30 13:35:47 -05:00
Thaddeus Crews 5ee90d8e82 Merge pull request #117873 from deralmas/wl/send-reinforcements
Wayland: Unify clipboard sending code
2026-03-30 13:35:26 -05:00
Dery Almas b1c216d916 Wayland: Unify clipboard sending code
The primary and selection parts would constantly get out of sync.

Also fixes a wrong return value in `primary_get_mime`.
2026-03-27 04:33:52 +01:00
Rémi Verschelde c19a2705af Merge pull request #116692 from deralmas/wl/i-love-multithreading
Wayland: Fix race with buffer scaling
2026-03-26 16:01:14 +01:00
Rémi Verschelde 915f8dcba7 Merge pull request #116648 from gongpha/wayland-clipboard-fix
Fix clipboard history not updating on subsequent copies in Wayland
2026-03-26 16:01:08 +01:00
Pāvels Nadtočajevs d47b8d7a64 [DisplayServer] Add per window icon support. 2026-03-23 11:27:09 +02:00
ArchercatNEO 8be7b9f18c Wayland: Fix use-after-free of Ref<ColorManagementProfile>
Fixes #117676
PR #111964 made a Ref<ColorManagementProfile> which we intentionally
leaked across a client-server barrier owned, which caused a use-after-free.
Manually adding reference/unreference calls keeps the ptr valid without memory leaks.
2026-03-21 09:28:43 +00:00
Dery Almas ab135ca3c2 Wayland: Implement touch support 2026-03-20 15:42:20 +01:00
Dery Almas 2d74e56caf Wayland: Fix race with buffer scaling
We now pass the buffer scale along the window size to the display server
and set everything from there.

This should avoid races where the buffer scale changes while we handle
window rect changes.
2026-03-20 14:24:38 +01:00
Thaddeus Crews fb4a304dee Merge pull request #111965 from Ivorforce/memnew-typed
Make `memnew(RefCounted)` return `Ref`, to improve ownership safety
2026-03-19 15:39:15 -05:00
Lukas Tenbrink 05c33acbb1 Make memnew(RefCounted) return Ref, to force callers to take ownership of it through a reference. 2026-03-18 20:34:08 +01:00
Dery Almas 29e1bc5a23 Wayland: Deduplicate cleanup logic
We now reuse the `global_remove` event handler. This removes a
considerable amount of duplication, minimizes human error (such as
cleaning up a global in one place but not the other), and helps test the
dynamic global removal logic.
2026-03-16 23:51:08 +01:00
Thaddeus Crews 5d0a321575 Merge pull request #102987 from ArchercatNEO/wayland-hdr
[LinuxBSD] Add support for HDR output (Wayland)
2026-03-16 11:32:54 -05:00
ArchercatNEO eee3384e20 HDR output for linuxbsd (wayland) 2026-03-13 16:48:58 +00:00
Dery Almas eb680bc8c3 Wayland: Improve mapping robustness and synchronization
We assumed that a window will be ready after a single roundtrip but
that's actually not guaranteed by the XDG shell protocol.

This patch waits for an arbitrary timeout (10s) before erroring out and
forcefully closing the window. Since this exercised quite some code
paths, it also reworks some window handling logic and fixes a bunch of
synchronization issues.
2026-03-13 08:25:04 +01:00
Rémi Verschelde 727b06a79f Move ProcessID typedef out of OS
This allows decoupling a number of files from `os.h`.
2026-03-04 15:00:45 +01:00
Rémi Verschelde 8c0f175c94 Decouple RenderingServer from as much of the codebase as possible
Notably decouples it from:
- AccessibilityServer
- DisplayServer
- Viewport
- Window
2026-03-03 12:48:07 +01:00
Rémi Verschelde a447ac95ec Move DisplayServer enums and typedefs to DisplayServerEnums
This will allow decoupling `display_server.h` from a number of headers in the
codebase which only require those enums and not all the DisplayServer API.
2026-03-03 12:44:02 +01:00
Kongfa Waroros 9c40e1d25b Fix clipboard history not updating on subsequent copies in Wayland 2026-02-23 04:45:49 +07:00
Thaddeus Crews 41f4ca3247 Merge pull request #116236 from deralmas/the-chosen-one
Wayland: Only handle the current output mode
2026-02-16 10:19:35 -06:00
Thaddeus Crews b769ae2d5f Merge pull request #116309 from deralmas/wl/sdrawkcab
Wayland: Swap backward and forward mouse buttons
2026-02-16 10:19:30 -06:00
Kiisu_Master 4dceee5252 Add pointer warping on wayland 2026-02-15 18:16:27 +01:00
Dery Almas fe0acc1003 Wayland: Swap backward and forward mouse buttons
They were bound in reverse. No idea how I originally chose which was
which.

This patch also orders the switch cases by their underlying codes: left,
right, middle, side, extra.
2026-02-15 09:28:52 +01:00
Dery Almas dc8e7ef2ce Wayland: Only handle the current output mode
Some compositors (e.g. COSMIC) can report *all* supported output modes,
not just the current mode. This is valid, albeit deprecated, so let's
add a check and ignore any non-current output events.
2026-02-13 02:52:40 +01:00
Dery Almas 27b1916465 Wayland: Update popup scale information on creation
Popups start with their size and position already scaled based on the parent.
We forgot to update the popup's scale itself, leading to a double-scale.
2026-01-22 06:28:27 +01:00
Rémi Verschelde a1e209b7fe Merge pull request #115090 from deralmas/wayland-ime-bruh-moment
Wayland: Fix IME
2026-01-19 10:46:13 +01:00
Dery Almas 3a2a53f901 Wayland: Fix IME
The spec tells us to ignore certain events if we didn't get an `enter`
event first. Certainly we need to at least acknowledge the `enter` event
itself 😅
2026-01-18 09:47:23 +01:00
Dery Almas 8a448032c2 Wayland: Allow non-interactive window resizing
Despite what I thought in the past, it is allowed, as long as we follow
certain limitations depending on the toplevel's state.

As usual I peppered the code with comments expaining what those
limitations are.

Regarding popups, AFAICT there are no major limitations, although we
should eventually use the new `reposition` method, which autoadjusts the
popup to follow the screen's borders and whatnot. I didn't do that in
this patch as it requires some elbow grease, especially if we want to do
it synchronously.
2026-01-14 11:20:06 +01:00
Rémi Verschelde 571c574f96 Merge pull request #113950 from deralmas/wl-misc-fixes/not-listening
Wayland: Ignore IME events without a valid window
2026-01-13 11:06:00 +01:00
Rémi Verschelde 865dbfc2fb Merge pull request #113949 from deralmas/wl-misc-fixes/too-much-debugging
Wayland: Remove `GODOT_DEBUG_EMBEDDER_SINGLE_INSTANCE` debug option
2026-01-13 11:05:54 +01:00
Riteo 0e21840973 Wayland: Add environment variable to disable libdecor loading
Libdecor has some quirks and depending on the setup it might be useful
to switch to the xdg-shell branch. Recompiling the whole engine without
libdecor is not an acceptable way to do that.
2025-12-16 19:12:49 +01:00
Rémi Verschelde 3e2f769ddf Merge pull request #113947 from deralmas/wl-misc-fixes/cleanup-forgor
Wayland: Add missing destroy calls for text input and tablet
2025-12-16 11:26:53 +01:00
Rémi Verschelde d84a8a63fa Merge pull request #113946 from deralmas/wl-misc-fixes/mfw-mutating-a-copy
Wayland: Fix accidental copy during global remove
2025-12-16 11:26:47 +01:00
Rémi Verschelde 5d5db072f3 Merge pull request #113656 from deralmas/gray-goo-scenario
Wayland: Work around window scale ambiguity
2025-12-16 11:26:42 +01:00
Rémi Verschelde 61b5f80a50 Merge pull request #113256 from deralmas/wl-keyboard-stuff
Wayland: Misc keyboard touchups
2025-12-16 11:26:31 +01:00
Thaddeus Crews 206f1b5a7c Merge pull request #113977 from deralmas/wl-misc-fixes/shhhhh
Wayland: Silence `window_get_wl_surface` on invalid window
2025-12-15 08:01:05 -06:00
Dery Almas 874dd28d66 Wayland: Silence window_get_wl_surface on invalid window
Makes it more consistent with the rest of the `WaylandThread` methods
(so that we can silently check for the window's existence).

Fixes errors when trying to capture the pointer when no surface has been
pointed yet (its logic assumed that this method was silent).

We double-check everywhere anyway but I added it in some places where we
can't either guarantee that it'll check (to avoid segfaults) or that
would be useful to report directly.
2025-12-13 10:10:29 +01:00
Dery Almas 55360ec825 Wayland: Ignore IME events without a valid window
The spec says "After leave event, compositor must ignore requests from
any text input instances until next enter event."

Fixes an error on jay, which at least on 1.11.0 sends
`zwp_text_input_v3::done` after `zwp_text_input_v3::leave`, which we
didn't ignore, leading to a commit without a valid window id.
2025-12-12 19:40:02 +01:00
Dery Almas a8e1d23855 Wayland: Remove GODOT_DEBUG_EMBEDDER_SINGLE_INSTANCE debug option
This is _extremely_ specific, and was meant to be removed after a review
in the game embedder PR. No idea how it found its way back in.
2025-12-12 19:23:26 +01:00
Dery Almas 1d1cd7cc1a Wayland: Add missing destroy calls for text input and tablet
Thank you Kiisu_Master for finding this!
2025-12-12 19:22:19 +01:00
Dery Almas b439a71db3 Wayland: Fix accidental copy during global remove
We were accidentally mutating a copy during cleanup of the viewporter
and fractional scale manager.

Thank you Aaron Franke for finding this out :D
2025-12-12 19:06:29 +01:00
Pāvels Nadtočajevs 1251348c96 [Wayland] Implement keyboard_get_label_from_physical 2025-12-10 13:19:35 +02:00
Berke Güzel 48c50bacba Wayland: Fix laggy window resize
scale_changed and size_changed were incorrectly initialized to true,
causing redundant WindowRectMessage and DPI change events to be pushed
on every configure event regardless of actual changes.
2025-12-07 13:29:19 +03:00
Dery Almas 99b109e981 Wayland: Work around window scale ambiguity 2025-12-06 00:54:50 +01:00
Rémi Verschelde 1c7ef74f4f Merge pull request #113346 from deralmas/wl-keyboard-saga/unify-keys
Wayland: Unify key handling logic
2025-12-01 11:50:11 +01:00