354 Commits

Author SHA1 Message Date
Camilla Löwy 92dcf4ce74 Start 3.6 2026-08-03 19:04:50 +02:00
road2react b7ef2919b0 Wayland: Fix rounding of fractional scale sizes
The framebuffer size for fractional scale surfaces should be rounded to
the closest integer, not truncated as is currently done.

This implements the rounding formula that the discussions over at
wayland-protocols item 132 and MR 309 appear to be converging on.

Fixes #2713
Closes #2810
2026-07-28 17:18:05 +02:00
Jonas Ådahl ed6452b13c Wayland: Set the correct min/max size when non-resizable
Libdecor is a thin wrapper around xdg_toplevel, and expects the same
kind of information passed to it as if it was a xdg_toplevel. This
includes the min/max size when non-resizable, which was set when using
xdg_toplevel directly, but not when using libdecor. This fixes issues
with min/max size missing when mapping a non-resizable window.

Related to #2842
2026-06-26 16:30:12 +02:00
Camilla Löwy e94108d9db Wayland: Fix undecorated libdecor frame creation
In order to safely call libdecor_frame_set_visibility during window
creation, a libdecor frame state was synthesized and committed.

This commit instead postpones the call to libdecor_frame_set_visibility
until after the frame state received by the frame configure event has
been committed.  This appears to be a more polite approach.

Related to #2842
2026-06-26 16:30:12 +02:00
Camilla Löwy dc86d02ff1 Wayland: Fix some event types not being processed
If there was already an event available in the Wayland queue, that event
would be processed but other kinds of events (libdecor, key repeat,
joystick connection, etc.) would not be.

This commit restores the processing of all available events on every
call to glfw*Events.  It is partially based on #2842 by jadahl.

Because some libdecor plugins also process non-Wayland events, without
providing an fd for them, libdecor_dispatch is now called
unconditionally.

Fixes #2793
Closes #2795
Related to #2842
2026-06-26 16:26:43 +02:00
Tomáš Mráz de0c378aa2 Wayland: Conditionally define _GNU_SOURCE
This fixes a re-definition warning for the _GNU_SOURCE macro.

Edited by elmindreda: code formatting, author credit

Related to go-gl/glfw#359
Fixes #2833
2026-06-10 01:07:02 +02:00
Camilla Löwy 3130c004e1 Wayland: Fix missing flush in glfwHideWindow 2026-03-20 16:06:29 +01:00
Camilla Löwy bb8048122a Wayland: Fix glfwPostEmptyEvent leaking a proxy
The client-side proxy of the callback from each call to wl_display_sync
was never destroyed.

Fixes #2836
2026-03-20 16:04:12 +01:00
Camilla Löwy 50b0a135a5 Wayland: Fix deadlock causing timeout
If the frame was processed by wl_display_dispatch_queue_pending, this
would be treated as no frame having been received.

Oops.

This bug was introduced by fdd14e65b1.
2026-03-13 17:20:44 +01:00
Camilla Löwy fdd14e65b1 Wayland: Fix EGL buffer swap blocking indefinitely
When the swap interval was nonzero, EGL on Wayland would wait
indefinitely for a frame callback on a suspended window, causing
applications that call eglSwapBuffers to halt.

This re-implements the wait for a surface frame so that we can add
a reasonable timeout, while setting the EGL swap interval to zero.  That
allows applications to make progress despite the window being suspended.

Some insights for how to structure this workaround were gleaned from
dri2_wl_swap_buffers_with_damage in Mesa.

This initial implementation still has a race between glfwHideWindow and
glfwSwapBuffers when rendering on a separate thread.  This could lead to
a window becoming visible again after being hidden on the main thread.

Related to #1350
Fixes #2582
Fixes #2640
Fixes #2719
Fixes #2723
Fixes #2800
Fixes #2827
2026-03-06 14:31:27 +01:00
Camilla Löwy 05f57c0bee Wayland: Improve support for discrete scrolling
This adds support for high-resolution scroll input scaled to match
legacy discrete scroll input.  It is available on compositors that
support wl_seat version 8 or later.

High-resolution "discrete" values now replace non-scaled scroll
values when available.
2026-03-06 14:31:26 +01:00
Camilla Löwy 99cdcfb0a4 Wayland: Unify pointer input paths
This reduces pointer frame support to a small amount of plumbing.
2026-02-13 14:44:10 +01:00
Camilla Löwy 001f94eaa7 Wayland: Add support for pointer event frames
This adds support for wl_seat version 5, which adds pointer frames.
This allows two-dimensional scroll input to be emitted as single events
instead of one event per axis per motion.

It's also the the foundation for future enhancements like properly
scaled discrete scroll events and server-side key repeat.

Fixes #2494
2026-02-13 14:44:09 +01:00
Camilla Löwy a98badf088 Wayland: Fix key repeat on very old compositors
The client-side key repeat timer fd was only created for wl_seat version
4 or later, but was then used unconditionally during event processing.

Rather than have this mechanism do nothing in a more correct way on
wl_seat version 3 or earlier (which is very old by now), this commit
creates the key repeat timer fd and then sets (hopefully gentle)
hardcoded repeat delay and rate.
2026-02-13 13:25:35 +01:00
Camilla Löwy 232164f62b Wayland: Remove duplicate cursor state
The shared window struct already tracks the current cursor.
2026-02-05 17:28:32 +01:00
Camilla Löwy abb9db0d75 Wayland: Fix fallback decoration button input
Fallback decoration mouse button actions were performed for both press
and release events.  The requests made using a mouse button release
serials were presumably (and correctly) discarded by the compositor.

This commit removes the generation of these nuisance requests.
2026-02-05 17:25:11 +01:00
Camilla Löwy 0aa77a9a3a Wayland: Release input devices where possible
On systems with wl_seat verison 3 or later, use release instead of
destroy on input devices when they are disconnected.
2026-02-04 18:08:37 +01:00
Camilla Löwy 7b370d8df0 Wayland: Simplify pointer surface state
Track which surface contains the pointer with one piece of state instead
of three partially overlapping ones.
2026-02-04 18:08:37 +01:00
Camilla Löwy 2d7ae8f2d0 Wayland: Cleanup
This is only a semantic change.  The values are the same.
2026-01-15 21:09:01 +01:00
Camilla Löwy dbadda2683 Formatting 2025-12-05 13:33:10 +01:00
Camilla Löwy 1ce855b0b1 Wayland: Fix missing checks for optional protocol 2025-12-04 20:30:12 +01:00
Camilla Löwy 7ef6efeb66 Wayland: Fix cursor position after a modal
If a modal surface like the window menu was active, clicking on the GLFW
window content area to close it would correctly emit the cursor enter
event but would not propagate the cursor position from the event.
2025-08-18 20:58:12 +02:00
Camilla Löwy 3cf9f6726d Wayland: Fix fallback decoration cursor updating
When a click through to the fallback decorations caused the end of
a modal like the window menu, the cursor shape would not be updated
until the next time the cursor moved.

This commit adds an update of the cursor for the pointer enter event for
fallback decoration surfaces, in addition to the updates at pointer
motion events.
2025-08-18 18:06:46 +02:00
Camilla Löwy bfa1c424e5 Wayland: Fix fallback decoration menu placement
The fallback decorations would place the menu at the wrong position, by
not translating the last decoration surface position into toplevel
surface coordinates.

This also limits the menu to the caption area of the top decoration
surface, similar to how other toolkits work.
2025-08-18 18:06:46 +02:00
Doug Binks 0d2d85d19c Revert "Wayland: Keyboard leave event handler now processes key repeats" 2025-08-15 11:27:59 +02:00
Jan Hendrik Farr 768e81a0eb Wayland: Fix key repeat halting
Key repeat shoud only be halted when the repeating key
is released, not when another key is released.
2025-08-14 15:35:04 +02:00
Camilla Löwy 161fb1b6f6 Wayland: Fix fallback decoration scroll events
The fallback decorations would emit scroll events as if scrolling had
occurred over the content area of the window.
2025-08-12 17:11:27 +02:00
Camilla Löwy 645a35a38e Wayland: Cleanup 2025-08-12 17:11:27 +02:00
Camilla Löwy 7523b0e6bd Wayland: Move fallback decoration pointer logic
Decluttered the wl_pointer handlers by moving the bulk of fallback
decoration related logic to separate functions.
2025-08-12 17:11:26 +02:00
Camilla Löwy 5190a30d8a Wayland: Move fallback decoration struct member
The cursorPreviousName member was only used for the fallback decorations
but was not grouped with other related members.
2025-08-12 17:11:26 +02:00
Camilla Löwy ddbb8e0f2c Wayland: Fix fallback decoration cursor position
If fallback decorations were in use, pointer motion over a decoration
surface would cause glfwGetCursorPos to provide incorrect cursor
positions.

The cursor position is now only updated when the pointer is over the
content area of the window, similar to libdecor and XDG decorations.
2025-08-12 17:11:24 +02:00
Camilla Löwy 5245180c56 Formatting 2025-08-12 17:10:43 +02:00
Doug Binks 7b51a8eb31 Wayland: Keyboard leave event handler now processes key repeats
- Fixes #2736
2025-08-10 18:27:44 +02:00
Camilla Löwy ac10768495 Wayland: Fix memory leaks in data offer reading
The buffer storing the contents of the data offer being read could leak
if buffer reallocation or reading from the pipe failed.
2025-07-18 12:31:07 +02:00
Doug Binks feb2a6b728 Wayland: Reset key repeat timer on window destruction
Windows with keyboard focus may have an active key repeat timer.
This should be reset when the window is closed, or key repeat events
could be sent to a NULL window were it not for the quickfix in PR #2732.

Fixes #2741
Probably the source of #2727
2025-07-17 17:24:19 +02:00
Jan Schürkamp 506c11ba43 Wayland: Ignore key repeat events when no window has keyboard focus (#2732)
* Wayland: Ignore key repeat events when no window has keyboard focus
2025-07-05 19:16:08 +02:00
LocalSpook 21fea01161 Wayland: Replace _glfwKeySym2Unicode with xkbcommon
libxkbcommon already provides functions to convert keysyms to codepoints
and UTF-8. The library has offered these functions since 0.5.0[1], so
using them won't cause any compatibility problems.

[1] https://xkbcommon.org/doc/0.5.0/group__keysyms.html

Closes #2444
2024-11-29 12:05:20 +01:00
Camilla Löwy b35641f4a3 Wayland: Cleanup 2024-04-12 18:27:53 +02:00
Camilla Löwy 64906f8e64 Wayland: Cleanup 2024-04-12 18:25:06 +02:00
Camilla Löwy 51b6434ac4 Wayland: Fix possible segfault on drag enter
Found with Clang static analysis.
2024-04-11 19:12:17 +02:00
Camilla Löwy 68dcea0d7f Place assertions for handles after init check
This lets automated testing check that GLFW_NOT_INITIALIZED is emitted
for every public function.
2024-03-28 16:53:04 +01:00
Camilla Löwy 38ec7abd3b Fix missing assertions for native access functions 2024-03-28 16:53:04 +01:00
Camilla Löwy 42dc1ffaee Wayland: Fix leak of surface scaling objects 2024-03-28 16:53:04 +01:00
Camilla Löwy d24ee9953f Start 3.5 2024-02-29 15:42:28 +01:00
Camilla Löwy af5d250553 Wayland: Remove separate window title copy 2024-02-19 14:20:52 +01:00
Camilla Löwy 690a15f929 Wayland: Implement GLFW_RESIZABLE for XDG toplevel
This implements GLFW_RESIZABLE for all paths where we manage our own
xdg_toplevel, namely XDG decorations and fallback decorations.

Fixes #2203
2024-02-16 00:13:33 +01:00
Camilla Löwy b61f3fc479 Wayland: Fix invalid size protocol error
This could happen when resizing a window with fallback decorations.

Fixes #2204
2024-02-16 00:13:32 +01:00
Camilla Löwy a650c69cff Wayland: Decide final window size in one place 2024-02-16 00:12:50 +01:00
Camilla Löwy 2b3f919b60 Wayland: Add support for fractional scaling
This adds basic support for fractional-scale-v1.

Note that this introduces a potential discrepancy between window and
monitor content scales.
2024-02-14 22:35:46 +01:00
Camilla Löwy a9cc7c7260 Add GLFW_SCALE_FRAMEBUFFER window hint
This adds the GLFW_SCALE_FRAMEBUFFER window hint, enabling control of
framebuffer scaling across Wayland and macOS.  On macOS, this window
hint is a new name for GLFW_COCOA_RETINA_FRAMEBUFFER, and both hint
names will modify the same hint.

This is now a more symmetric counterpart to GLFW_SCALE_TO_MONITOR and,
weirdly, they each apply neatly to half of the supported platforms.

This commit is mostly documentation updates to better integrate and
contrast these two scaling mechanisms.
2024-02-14 22:35:46 +01:00