Commit Graph

95 Commits (master)

Author SHA1 Message Date
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 +07: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 +07: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 +07:00
Pāvels Nadtočajevs 1251348c96
[Wayland] Implement `keyboard_get_label_from_physical` 2025-12-10 13:19:35 +07:00
Dery Almas 99b109e981 Wayland: Work around window scale ambiguity 2025-12-06 00:54:50 +07:00
Dery Almas 9a814b4444 Wayland: Unify key handling logic
Previously we had different logic for direct key presses and client-side
key repetition, as one queued up input events and the other dispatched
them directly (client-side key repetition is run from the main thread).

I kinda figured out that this difference doesn't really matter, as we
can queue them up before the thread message dispatching logic. That's
exactly what we do now, which allows us to make a single method for both
of them, making the code much clearer and simplifying future maintenance.

This patch also includes a tiny fixup in the compose logic, which checks
for the validity of the generated key event before actually working with
it. The cases in which we can end up with an invalid reference are very
few, so it's not the end of the world, but it's still absolutely a good
idea to check, to avoid nasty surprises down the line.
2025-11-30 05:11:40 +07:00
Thaddeus Crews e1b3387513
Merge pull request #108704 from wjt/xdg-portal-inhibit
Support XDG Inhibit portal
2025-11-24 15:59:56 +07:00
ArchercatNEO 4dd5c83f72 Wayland: compile with libdecor=no 2025-11-22 08:29:05 +07:00
metamuffin 6145b0ca29
Add Image.load_exr_from_buffer and enable tinyexr by default 2025-11-21 18:58:26 +07:00
Dery Almas bbf65ae72f Wayland: Implement game embedding
This patch introduces a new protocol proxy, which multiplxes Wayland
clients into a single connection, allowing us to redirect calls (e.g.
create toplevel -> create subsurface). Mixed with some state tracking
and emulation, we can embed a full-featured client into the editor.
2025-11-19 21:24:18 +07:00
Will Thompson 1a3a254e26 Support XDG Inhibit portal
Previously, on Linux and BSD, inhibiting the screensaver was handled
using the org.freedesktop.ScreenSaver D-Bus API. Unfortunately, this API
is not available in a Flatpak sandbox. (This is because there is a
desire to tie inhibit sessions to a specific app and visible window; but
the org.freedesktop.ScreenSaver API does not support this.)

As a result, when using the Flatpak build of the Godot Editor (or a
Flatpak-ed build of a game) and using a controller to play a game, the
session will become idle after a few minutes.

The XDG desktop portal -- which is already used for color-picking, file
choosing, and querying the system theme -- has an Inhibit interface that
provides a superset of the functionality of the
org.freedesktop.ScreenSaver API, and is available to any sandboxed app.

Refactor code for making XDG portal requests that was previously
duplicated for the FileChooser and ColorPicker portal code. Check the
portal version to determine whether these portals can be used:

- FileChooser portal version 3 is required due to the use of the
  "directory" parameter.

- On the Settings portal, the only addition in version 2 is the
  ReadOne() method which is not used here, so version 1 suffices.

- On the Screenshot portal, the only addition in version 2 is the
  "interactive" parameter to the Screenshot() method; this code only
  uses the PickColor() method, so version 1 suffices.

Then, add support for the Inhibit portal. Use it if available and if
running in a sandbox. Prefer to use org.freedesktop.ScreenSaver if not
running in a sandbox, even if the portal is available, because (at least
in the GNOME 43 implementation of the portal) it does not work correctly
if the portal cannot map the request to a running app. This adds a small
amount of complexity to the implementation, but supporting both APIs is
necessary anyway (there are many systems in the wild that support
org.freedesktop.ScreenSaver but not the desktop portal).

Fixes https://github.com/godotengine/godot/issues/108634
2025-11-17 11:46:28 +07:00
Pāvels Nadtočajevs 281c74550a
Make `utterance_id` 64-bit. 2025-11-07 10:21:20 +07:00
Riteo Siuga 4df96fc7ab Wayland: Set window parent before commit
Fixes a timing issue where dialogs got configured right before having
their parent set. This gave compositors the time to resize/rearrange the
dialog as if it were a normal window, only to be marked as "floating"
right away. On niri, this manifested as huge dialog windows.

This is achieved with the addition of a `p_parent_id` parameter to
`window_create`, akin to its popup counterpart.

`window_create` now also accepts a single `Size2i` parameter instead of
two integers, in line with the rest of the `WaylandThread` API. The
original idea was to have a very "barebones" API, akin to the `drivers/`
directory, but that didn't pan out.
2025-10-28 04:10:28 +07:00
Thaddeus Crews 5935a32e32
Core: Cleanup headers in `core/config`
- `MainLoop` now forward-declared in `OS`
2025-10-06 09:20:56 +07:00
chocola-mint ead282ff13 Remove `file_access.h` and `script_backtrace.h` includes from `logger.h`. 2025-10-05 17:49:23 +07:00
Thaddeus Crews 373ff727f0
Merge pull request #110875 from vmedea/2025-wayland-inhibit-idle
wayland: Inhibit idle in DisplayServerWayland::screen_set_keep_on
2025-09-30 18:35:02 +07:00
Mara Huldra c64ff4b069 wayland: Inhibit idle in DisplayServerWayland::screen_set_keep_on
Without this, the screen does go into idle after a few minutes on a RPi5 with default install (wayland w/ labwc), even
though `screen_keep_on` is set. DBUS is enabled but apparently, the screensaver call is not enough.
2025-09-24 22:17:38 +07:00
Thaddeus Crews ce157a446f
Merge pull request #107096 from ArchercatNEO/xdg-toplevel-icon
Wayland: Implement the xdg-toplevel-icon-v1 protocol
2025-09-22 08:50:10 +07:00
Pāvels Nadtočajevs 76433b0ede
Fix Wayland build with OpenGL disabled. 2025-09-06 18:37:49 +07:00
ArchercatNEO 188b47a29b Wayland: Implement the xdg-toplevel-icon-v1 protocol
Closes #87747
Requires a compositor which supports xdg-toplevel-icon-v1.
As of this commit only KWin supports this protocol.
2025-08-22 09:45:28 +07:00
Pāvels Nadtočajevs 0edb6bd4a0
[Linux/BSD] Initialize DBus only once. 2025-08-22 09:26:11 +07:00
Dery Almas 98537b2e0c Wayland: Fix error condition in window_get_current_screen
Leftover from when the Wayland backend was single-window only.
2025-07-14 15:56:43 +07:00
Rémi Verschelde c596d93478
Merge pull request #106175 from akien-mga/linux-build-no-dbus
Linux: Fix build with `dbus=no` or `threads=no`
2025-06-09 00:44:12 +07:00
Pāvels Nadtočajevs 2d93e004b9
Cleanup and unify `DisplayServer` screen methods and documentation. 2025-06-02 08:03:48 +07:00
Rémi Verschelde 8b93b67e14
Merge pull request #106315 from Riteo/popping-up-everywhere
Wayland: Fix error spam when closing popup
2025-05-13 01:05:49 +07:00
Riteo c3b04e6e1e Wayland: fix error spam when closing popup
Previously we did not check whether the value actually changed or not
and thus would get constant errors for no reason.
2025-05-12 05:11:24 +07:00
Pāvels Nadtočajevs 5441a82cfb
Do not call `accessibility_set_window_rect` on Wayland, fix main windows accessibility context creation. 2025-05-11 12:51:46 +07:00
Rémi Verschelde e9e8ddc5be
Linux: Fix build with `dbus=no` or `threads=no` 2025-05-09 15:26:13 +07:00
Riteo Siuga d4dabd15aa Wayland: Ensure pointed window's existence in mouse_get_position
Should fix a crash with certain compositors.
2025-05-03 20:24:44 +07:00
tthhr e7a3729175 fix:Compile error in wayland display server when compiling linuxbsd platform after disabling dbus 2025-04-30 14:22:52 +07:00
Riteo Siuga 48882f3ca4 Wayland: Handle fifo_v1 and clean up suspension logic
Before, the WSI was unfortunately quite broken and we had work around it
by manually pacing frames. Needless to say it was not an ideal solution.

Now, the WSI can make use of the new fifo_v1 protocol to work properly.
If it's available, we'll trust the WSI by disabling manual frame pacing.

While we're at it, let's clean up the suspension code a bit by removing
some duplicated stuff and handling the suspension state through a switch
case.
2025-04-20 18:05:35 +07:00
Pāvels Nadtočajevs 4310cb82b8
AccessKit integration for macOS, Linux, and Windows. 2025-04-08 20:25:47 +07:00
Riteo 84d3adcf2f Wayland: Implement native sub-windows
The backend is now mature enough to not explode with multiple windows
but the `DisplayServer` API still cannot meet some guarantees required
by the various Wayland protocols we use. To meet those guarantees this
patch adds three new elements to the DisplayServer API, with relative
handling logic for `Window` and `Popup` nodes:

 - `WINDOW_EVENT_FORCE_CLOSE`, which tells a window to *forcefully*
close itself and ensure a proper cleanup of its references, as Wayland
enforces this behavior;

 - `WINDOW_FLAG_POPUP_WM_HINT`, which explicitly declares a window as a
"popup", as Wayland enforces this distinction and heuristics are not
reliable enough;

 - `FEATURE_SELF_FITTING_WINDOWS`, which signals that the compositor can
fit windows to the screen automatically and that nodes should not do
that themselves.

Given the size of this feature, this patch also includes various
`WaylandThread` reworks and fixes including:

 - Improvements to frame wait logic, with fixes to various stalls and a
configurable (through a `#define`) timeout amount;

 - A proper implementation of `window_can_draw`;

 - Complete overhaul of pointer and tablet handling. Now everything is
always accumulated and handled only on each respective `frame` event.
This makes their logic simpler and more robust.

 - Better handling of pointer leaving and pointer enter/exit event
sending;

 - Keyboard focus tracking;

 - More solid window references using IDs instead of raw pointers as
windows can be deleted at any time;

 - More aggressive messaging to window nodes to enforce rects imposed by
the compositor.
2025-04-04 20:23:25 +07:00
Pāvels Nadtočajevs 52009b52d2
Detect KDE/LXQt and swap OK/Cancel buttons to Windows style. 2025-04-03 12:47:11 +07:00
Pāvels Nadtočajevs 4638ade13f
Enable TTS on demand, instead of fully disabling it when project setting is not set. 2025-04-01 15:24:46 +07:00
Thaddeus Crews 49fcd4ce46
Merge pull request #101546 from bruvzg/portal_color_picker
[Linux] Implement native color picker.
2025-03-17 10:52:29 +07:00
Pāvels Nadtočajevs 18f6c33d72
[DisplayServer] Implement `get_accent_color` on Linux. 2025-03-14 09:05:03 +07:00
bruvzg 3e4e6e6c0c Improve native file dialog parent window selection. 2025-03-06 17:15:39 +07:00
Riteo cbd68eb403 Wayland: Fix engine stalls wihle waiting frames
There were two edge cases in the frame waiting logic (aka manual frame
throttling or emulated vsync) which would cause the editor to stall in
one way or another:

 1. Waiting right after starting the editor would cause a deadlock
between both threads until something happened in the Wayland event
queue, in turn unblocking the Wayland thread and kickstartin the whole
thing;

 2. Starting the editor (and probably other long-loading stuff) without
low consumption mode would suspend the window and never commit its
surfaces, thus never signaling the compositor that we want frame events.
2025-02-11 01:33:36 +07:00
Pāvels Nadtočajevs 05ca80632d [Linux] Implement native color picker. 2025-02-03 16:30:44 +07:00
Thaddeus Crews 480843cf2b
Merge pull request #101812 from bruvzg/portal_chk
[FreeDesktop portal] Check for `FileChooser` and `Settings` interface availability instead of assuming it's always available.
2025-02-03 08:16:10 +07:00
Thaddeus Crews 4f3dddbbff
Merge pull request #101987 from Riteo/imagine-using-rids
Wayland: Check custom cursor resource reference for cache invalidation
2025-01-31 09:15:52 +07:00
Pāvels Nadtočajevs 86f56efbaa [FreeDesktop portal] Check for `FileChooser` and `Settings` interface availability instead of assuming it's always available. 2025-01-31 07:52:40 +07:00
Adam Scott 47f553ae0b
Delegate to the DisplayServer the task of handling mouse_mode
- Add `MOUSE_MODE_MAX` and various index checks
2025-01-28 11:22:27 +07:00
Riteo c8087567c9 Wayland: Check custom cursor resource reference for cache invalidation
Images don't have RIDs and this way of checking stuff broke the cursor
cache. Let's do like all other platforms and check the resource
reference instead.
2025-01-24 15:10:46 +07:00
Riteo Siuga 368a59e6f9 Wayland: Release pressed events on application focus out
Looks like I always assumed wrongly that the compositor would send us
key release events when unfocusing... It did not.
2025-01-20 01:38:25 +07:00
Pāvels Nadtočajevs 133ea4f17a [Wayland] Fix excessive IME updates. 2025-01-17 15:29:06 +07:00
Pāvels Nadtočajevs 2e99d84e87 [DisplayServer] Add missing `FEATURE_WINDOW_DRAG` flag to Windows, X11 and Wayland display servers. 2025-01-14 15:26:32 +07:00
Riteo e5ac45e822 Wayland: Unsuspend only for the same reason as suspension
Before, we would check both methods together, leading to loops.

Now we track the actual reason we suspended and only unsuspend when
that same reason triggers. For example, if we suspend because of the
suspended flag we'll unsuspend only because it got unset. Conversely, if
we suspend because of a timeout we'll unsuspend only if we get a new
frame event.

We do this because, while some compositors properly report a "suspended"
state (hinting us to stop repainting), most don't and we need a "safety
net" anyways as we do not want to constantly stay at 1fps (the max time
we'll wait before giving up) either.
2025-01-08 13:53:01 +07:00
Pāvels Nadtočajevs 7f0b4e58b0 Implement `DisplayServer.window_start_resize`. 2025-01-07 07:58:02 +07:00