Commit Graph

225 Commits

Author SHA1 Message Date
Camilla Löwy
9ad9f5c52a Wayland: Fix missing error reporting 2022-06-21 21:47:32 +02:00
Camilla Löwy
5002522f73 Wayland: Cleanup
Make Wayland code use 'native' in the same senses as the rest of GLFW.
2022-06-21 21:44:15 +02:00
Camilla Löwy
91f18fb576 Wayland: Fix error from glfwSetWindowAspectRatio
The aspect ratio was applied during resize but any call to
glfwSetWindowAspectRatio emitted a GLFW_FEATURE_UNIMPLEMENTED error.
2022-06-21 20:46:06 +02:00
Camilla Löwy
e37ba80b13 Wayland: Fix reporting of monitor scale changes
Content scale events would be emitted when a window surface entered or
left an output, but not when one of a window's current outputs had its
scale changed.
2022-06-21 20:46:06 +02:00
Camilla Löwy
229d628ec4 Wayland: Fix toggling of server-side decorations
This is a temporary local fix to have updates to GLFW_DECORATED mostly
work as intended.  The whole decoration state machine needs to be
restructured, but not by this commit.
2022-06-21 16:00:33 +02:00
Camilla Löwy
c28d420060 Wayland: Remove duplicate fullscreen check
This check is already performed in shared code.
2022-06-21 16:00:20 +02:00
Camilla Löwy
18df0baea6 Wayland: Cleanup 2022-06-20 00:57:17 +02:00
Camilla Löwy
a7b6f35500 Wayland: Fix size limits for fallback decorations
The size limits set on our XDG surface did not include the sizes of the
fallback decorations on all sides, when in use.  This led to its content
area being too small.

Related to #2127
2022-06-20 00:57:17 +02:00
Camilla Löwy
0f5b095042 Wayland: Fix erratic fallback decoration behavior
The handler for xdg_toplevel::configure treated the provided size as the
content area size when instead it is the size of the bounding rectangle
of the wl_surface and all its subsurfaces.

This caused the fallback decorations to try positioning themselves
outside themselves, causing feedback loops during interactive resizing.

Fixes #1991
Fixes #2115
Closes #2127
Related to #1914
2022-06-20 00:57:17 +02:00
Camilla Löwy
24cdc5afda Wayland: Rename window frame size constants 2022-06-20 00:57:17 +02:00
Camilla Löwy
75295f4878 Wayland: Remove unused code path 2022-06-20 00:57:17 +02:00
Camilla Löwy
040712ce99 Wayland: Cleanup 2022-06-20 00:57:17 +02:00
Camilla Löwy
2877fea550 Wayland: Remove superfluous comments
These are just repeating parts of the identifier.
2022-06-20 00:57:17 +02:00
Camilla Löwy
e33db6d7aa Wayland: Fix resize events before ack_configure
The surface was resized and the size event was emitted before we had
sent xdg_surface::ack_configure.  If user code then called some GLFW
function that commited the surface, those changes would all get applied
to the wrong configure event.

This postpones size changes until after the ack.
2022-06-20 00:57:17 +02:00
Camilla Löwy
afb127769a Wayland: Add tracking of XDG fullscreen state 2022-06-20 00:57:17 +02:00
Camilla Löwy
ed39ff43f9 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.
2022-06-20 00:57:17 +02:00
Camilla Löwy
0b76e3a6f1 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.
2022-06-20 00:57:17 +02:00
Camilla Löwy
6857995498 Wayland: Fix glfwSetWindowSize resizing fs windows
glfwSetWindowSize would change the size of fullscreen mode windows as
if they were windowed mode.
2022-06-20 00:57:17 +02:00
Camilla Löwy
fdc72edf81 Wayland: Fix missing fullscreen code path
glfwRestoreWindow assumed it was only called in windowed mode.
2022-06-20 00:57:17 +02:00
Camilla Löwy
f39ffefb6a 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.
2022-06-20 00:57:17 +02:00
Camilla Löwy
ddd087d662 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
2022-06-20 00:57:17 +02:00
Camilla Löwy
523fdf50c1 Wayland: Cleanup 2022-06-20 00:57:17 +02:00
Camilla Löwy
736a88b067 Fix return type of functions returning bool values 2022-06-08 22:14:38 +02:00
Camilla Löwy
e9c58bc181 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.
2022-06-08 19:20:01 +02:00
Camilla Löwy
09653b8c54 Move last bits of window setup to platform code
This avoids glfwCreateWindow emitting GLFW_FEATURE_UNAVAILABLE or
GLFW_FEATURE_UNIMPLEMENTED 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.
2022-04-28 21:58:06 +02:00
Camilla Löwy
4cb36872a5 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
2022-04-03 20:09:42 +02:00
Camilla Löwy
0f38382e25 Wayland: Clean up listener struct initialization
Adapt style to match the rest of the project.
2022-04-03 20:09:42 +02:00
Camilla Löwy
f010335b8c Wayland: Make data offer reading a generic utility
This will be needed for drag and drop reception as well.
2022-04-03 20:09:42 +02:00
Camilla Löwy
b7a3af9b79 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.
2022-04-03 20:09:42 +02:00
Camilla Löwy
967282c2e6 Wayland: Remove check for error that cannot happen
Famous last words.
2022-04-03 20:09:41 +02:00
Camilla Löwy
8d216054ad Wayland: Remove error reporting of external bugs
Not sure that GLFW should be reporting that another client has made an
invalid receive request.
2022-04-03 20:09:41 +02:00
Camilla Löwy
34418951cc Wayland: Clean up clipboard writing 2022-04-03 20:09:41 +02:00
Camilla Löwy
e0889736fd Wayland: Add strerror output to error descriptions 2022-04-03 19:45:09 +02:00
Camilla Löwy
c132135332 Wayland: Clean up clipboard reading 2022-04-03 19:45:09 +02:00
Camilla Löwy
4651165272 Wayland: Simplify clipboard string allocation 2022-04-03 19:45:09 +02:00
Camilla Löwy
8d87be1268 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
2022-04-03 19:45:09 +02:00
Camilla Löwy
89d3ea8d69 Wayland: Return our clipboard without roundtrips 2022-04-03 19:45:09 +02:00
Camilla Löwy
990dc4b388 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.
2022-04-03 19:45:09 +02:00
Camilla Löwy
a4460b694e Wayland: Rename listener user data parameters 2022-04-03 19:45:09 +02:00
Camilla Löwy
4506175023 Wayland: Clean up pointer declarations
Adapt style to match the rest of the project.
2022-04-03 19:44:56 +02:00
Camilla Löwy
ba11e60859 Wayland: Rename data transfer parameters
No rationale beyond personal preference.
2022-04-03 18:14:50 +02:00
Camilla Löwy
2d45681bc3 Wayland: Fix phrasing and type of error messages 2022-04-03 18:14:50 +02:00
Camilla Löwy
4c110bba41 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.
2022-04-03 18:14:50 +02:00
Camilla Löwy
738b1c73b5 Wayland: Remove superfluous global struct member
It seems unlikely that strlen will be a bottleneck when sending
clipboard contents.
2022-04-03 18:14:50 +02:00
Camilla Löwy
b386371f57 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.
2022-04-03 18:14:50 +02:00
Camilla Löwy
9c95cfb9f1 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.
2022-04-03 18:14:50 +02:00
Camilla Löwy
3ee5031fd7 Add shared min and max functions for int 2022-03-15 22:22:13 +01:00
Camilla Löwy
71742d9a27 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.
2022-03-03 22:58:09 +01:00
Camilla Löwy
a32cbf6d4f 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
2022-03-03 22:24:09 +01:00
Camilla Löwy
7ce1f3e1cf Formatting 2022-03-03 22:24:09 +01:00