Commit Graph

195 Commits

Author SHA1 Message Date
Camilla Löwy
51018f19d0 Wayland: Use named constants for version checks
The wayland-scanner output provides really nice, self-documenting
version macros, so we should use them whenever possible.

(cherry picked from commit ed39ff43f9)
2022-07-13 22:47:03 +02:00
Camilla Löwy
608007673f Wayland: Fix duplicate window content scale events
The window content scale event was emitted every time the window content
area was resized, even if its scale had not changed.

(cherry picked from commit 0b76e3a6f1)
2022-07-13 22:47:03 +02:00
Camilla Löwy
589385aada Wayland: Fix glfwSetWindowSize resizing fs windows
glfwSetWindowSize would change the size of fullscreen mode windows as
if they were windowed mode.

(cherry picked from commit 6857995498)
2022-07-13 22:47:03 +02:00
Camilla Löwy
15050f5711 Wayland: Fix missing fullscreen code path
glfwRestoreWindow assumed it was only called in windowed mode.

(cherry picked from commit fdc72edf81)
2022-07-13 22:47:03 +02:00
Camilla Löwy
562eca6f28 Wayland: Fix maximization by user being ignored
The internal maximization state was not updated when an event was
received that the user had changed the maximization state of a window,
and no maximization events were emitted.

This affected both the GLFW_MAXIMIZED attribute and glfwRestoreWindow.

(cherry picked from commit f39ffefb6a)
2022-07-13 22:47:03 +02:00
Camilla Löwy
dea602623d Wayland: Fix behavior of leaving full screen mode
These changes make GLFW fullscreen more consistent, but unfortunately
also make GLFW even more oblivious to user-initiated XDG shell
fullscreen changes.

Fixes #1995

(cherry picked from commit ddd087d662)
2022-07-13 22:47:03 +02:00
Emmanuel Gil Peyrot
581fed38be Wayland: Remove support for wl_shell
This is adapted to 3.3-stable from
599fb3de34 and
27295b508f.
2022-07-13 22:40:46 +02:00
Camilla Löwy
9f8ec83411 Wayland: Cleanup
(cherry picked from commit 523fdf50c1)
2022-07-12 20:29:22 +02:00
Camilla Löwy
6de6446aca Wayland: Fix missing lock key modifier bits
The modifier bits for lock keys were only set when the corresponding key
was reported as held down or latched, but not when it was released and
locked.

(cherry picked from commit e9c58bc181)
2022-06-10 17:11:25 +02:00
Camilla Löwy
b9ea733ca8 Move last bits of window setup to platform code
This avoids glfwCreateWindow emitting GLFW_PLATFORM_ERROR on Wayland
because shared code was calling unimplemented or unavailable platform
functions during final setup.

It also makes it consistent with the final setup of full screen windows.

This is adapted to 3.3-stable from
09653b8c54.
2022-06-10 17:11:01 +02:00
Camilla Löwy
05422e2824 Wayland: Add support for file drop events
This adds support for file path drop events in text/uri-list format.

It is based on work by Pilzschaf in #2040.

Closes #2040

(cherry picked from commit 4cb36872a5)
2022-06-09 19:39:28 +02:00
Camilla Löwy
2b504e41d5 Wayland: Clean up listener struct initialization
Adapt style to match the rest of the project.

(cherry picked from commit 0f38382e25)
2022-06-09 19:34:29 +02:00
Camilla Löwy
50d5de7cd4 Wayland: Make data offer reading a generic utility
This will be needed for drag and drop reception as well.

(cherry picked from commit f010335b8c)
2022-06-09 19:32:18 +02:00
Camilla Löwy
4d0e98d90c Wayland: Move window related code to window module
The Wayland backend was the only one where half the window and input
related code was in the init module.  As those bits want to share more
utility code with the window module, the interface between them grows.

To prevent that, this gathers nearly all window and input related code
into the window module.

This is adapted to 3.3-stable from
b7a3af9b79.
2022-06-09 19:29:12 +02:00
Camilla Löwy
c0c0d172a1 Wayland: Remove check for error that cannot happen
Famous last words.

(cherry picked from commit 967282c2e6)
2022-05-06 19:34:06 +02:00
Camilla Löwy
9e852ec39e Wayland: Remove error reporting of external bugs
Not sure that GLFW should be reporting that another client has made an
invalid receive request.

(cherry picked from commit 8d216054ad)
2022-05-06 19:34:06 +02:00
Camilla Löwy
4d68daedc9 Wayland: Clean up clipboard writing
(cherry picked from commit 34418951cc)
2022-05-06 19:34:06 +02:00
Camilla Löwy
f145e1f930 Wayland: Add strerror output to error descriptions
(cherry picked from commit e0889736fd)
2022-05-06 19:34:06 +02:00
Camilla Löwy
915e43885c Wayland: Clean up clipboard reading
(cherry picked from commit c132135332)
2022-05-06 19:34:06 +02:00
Camilla Löwy
857fae4920 Wayland: Simplify clipboard string allocation
(cherry picked from commit 4651165272)
2022-05-06 19:34:06 +02:00
Camilla Löwy
a31c648127 Wayland: Improve handling of pending data offers
The code assumed that all data offers were selections that supported
plaintext UTF-8.

The initial data offer events are now handled almost tolerably.  Only
selection data offers are used for clipboard string and only if they
provide plaintext UTF-8.  Drag and drop data offers are now rejected as
soon as they enter a surface.

Related to #2040

(cherry picked from commit 8d87be1268)
2022-05-06 19:34:06 +02:00
Camilla Löwy
c89899a428 Wayland: Return our clipboard without roundtrips
(cherry picked from commit 89d3ea8d69)
2022-05-06 19:34:06 +02:00
Camilla Löwy
75b27849f6 Wayland: Fix error paths not closing sending fd
Whatever error happens on our end, we should still close the fd so the
other end can move on.

(cherry picked from commit 990dc4b388)
2022-05-06 19:34:05 +02:00
Camilla Löwy
f51ec79951 Wayland: Rename listener user data parameters
(cherry picked from commit a4460b694e)
2022-05-06 19:34:05 +02:00
Camilla Löwy
3599fe4a78 Wayland: Clean up pointer declarations
Adapt style to match the rest of the project.

(cherry picked from commit 4506175023)
2022-05-06 19:34:05 +02:00
Camilla Löwy
1ee540bf48 Wayland: Rename data transfer parameters
No rationale beyond personal preference.

(cherry picked from commit ba11e60859)
2022-05-06 19:34:05 +02:00
Camilla Löwy
32bedd9a94 Wayland: Fix phrasing of error messages
This is adapted to 3.3-stable from
2d45681bc3.
2022-05-06 19:34:05 +02:00
Camilla Löwy
25db8f8014 Wayland: Fix partial writes of clipboard string
The string pointer used to write the contents of our clipboard data
offer was never updated, causing it to repeat parts of the beginning of
the string until the correct number of bytes had been written.

(cherry picked from commit 4c110bba41)
2022-05-06 19:34:05 +02:00
Camilla Löwy
2430d6b7f7 Wayland: Remove superfluous global struct member
It seems unlikely that strlen will be a bottleneck when sending
clipboard contents.

(cherry picked from commit 738b1c73b5)
2022-05-06 19:34:05 +02:00
Camilla Löwy
53bd67ccfe Wayland: Fix double free on data source error
If data source creation fails, the string containing the data for it
would be freed a second time during termination.

(cherry picked from commit b386371f57)
2022-05-06 19:34:05 +02:00
Camilla Löwy
22f718dcf4 Wayland: Fix handling of clipboard set to self
Passing any part of the result of glfwGetClipboardString to
glfwSetClipboardString would result in, at best, a use-after-free error.

(cherry picked from commit 9c95cfb9f1)
2022-05-06 19:34:05 +02:00
Camilla Löwy
3006c02bc2 Add shared min and max functions for int
(cherry picked from commit 3ee5031fd7)
2022-05-03 15:33:08 +02:00
Camilla Löwy
9cfd4c49b0 Wayland: Improve event processing with timeout
If the polling was interrupted by a signal or by incomplete or unrelated
data on any file descriptor, handleEvents could return before the full
timeout had elapsed.

This retries the Wayland prepare-to-read and poll until the full timeout
has elapsed or until any event was processed.  Unfortunately, due to how
the Wayland client API is designed, this also includes the delete_id
for the frame callback created by eglSwapBuffers.

This means glfwWaitEvents* are still not fully functional on Wayland.
See #1911 for more details.

(cherry picked from commit 71742d9a27)
2022-03-13 16:38:02 +01:00
Camilla Löwy
eac18b9324 Wayland: Fix glfwPostEmptyEvent not always working
The display sync requests in glfwPostEmptyEvent could just accumulate as
the display was never flushed on secondary threads.

This adds a proper flush after each sync request.

Fixes #1520
Closes #1521

(cherry picked from commit a32cbf6d4f)
2022-03-13 16:36:17 +01:00
Camilla Löwy
499a5a7917 Formatting
(cherry picked from commit 7ce1f3e1cf)
2022-03-13 16:35:41 +01:00
Camilla Löwy
b0af476799 Wayland: Adopt the poll wrapper from X11
This is adapted to 3.3-stable from
bb9d699ae6.
2022-03-13 16:25:19 +01:00
Camilla Löwy
9dd3f25d6d Wayland: Cancel display fd read before callbacks
Cancel the prepared-to-read state on the calling thread before starting
to call back to user code.

Emitting close requests here is not a good choice but that is for
a future commit to address.

(cherry picked from commit 203a7c59d2)
2022-03-13 16:19:31 +01:00
Camilla Löwy
7302a8f520 Wayland: Fix potential incomplete display flushing
The flushing of a Wayland display may need to be done in several steps,
signalled by it failing with EAGAIN.

(cherry picked from commit 3c2913dcb9)
2022-03-13 16:18:56 +01:00
Camilla Löwy
09470b68c1 Wayland: Clean up monitor scale update
(cherry picked from commit 20adc18aa5)
2022-03-13 15:39:58 +01:00
Camilla Löwy
9340324380 Wayland: Fix error type for allocation failure
(cherry picked from commit 152f50cd01)
2022-03-13 15:37:39 +01:00
Camilla Löwy
e155c19f8e Wayland: Fix text input not following key repeat
The manual key repeat implementation did not call text input.

(cherry picked from commit 1a7da42e6e)
2022-02-15 21:22:26 +01:00
Camilla Löwy
5066f57371 Clean up internal Unicode code point handling
Call code points by their name and store them as uint32_t.

(cherry picked from commit fe7be39793)
2022-02-15 21:08:17 +01:00
Camilla Löwy
1f7ce12cbc Wayland: Implement key name support
(cherry picked from commit 17a9e34fbc)
2022-02-15 21:02:07 +01:00
Camilla Löwy
86a1d3b628 Wayland: Fix GLFW_VISIBLE affecting full screen
Full screen window creation was not ignoring the GLFW_VISIBLE hint.

(cherry picked from commit 715b874db3)
2022-02-15 20:57:26 +01:00
Camilla Löwy
f5dab59071 Wayland: Fix missing damage event on window show
By definition a hidden window on Wayland does not have valid framebuffer
contents.

This adds a window damage (refresh) event when a window is shown, to
request an initial frame for the now visible window.

(cherry picked from commit 25c521cbe5)
2022-02-15 20:56:21 +01:00
Camilla Löwy
658c931561 Wayland: Fix window not visible after initial swap
A window created with GLFW_VISIBLE set was not made visible by the
initial buffer swap during context attribute refresh.

Regression introduced by @elmindreda in
094aa6d3c7.

(cherry picked from commit c05acf6246)
2022-02-15 20:55:35 +01:00
Camilla Löwy
0c46a730de Wayland: Remove window monitor array pre-alloc
The array will be allocated by surfaceHandleEnter when needed.

(cherry picked from commit 12c2ccd609)
2022-02-15 20:55:16 +01:00
Camilla Löwy
1fa4312b29 Wayland: Remove superfluous initialize to NULL
The whole window struct has already been cleared to zero.

(cherry picked from commit 216ea3d735)
2022-02-15 20:53:55 +01:00
Camilla Löwy
eb6fc17746 Wayland: Move window title cloning to creation
(cherry picked from commit c1ecd4673e)
2022-02-15 20:53:13 +01:00
Camilla Löwy
ed785a2c79 Wayland: Gather framebuffer transparency logic
(cherry picked from commit 7bede13b1d)
2022-02-15 20:53:08 +01:00