Commit Graph

288 Commits

Author SHA1 Message Date
Camilla Löwy
86bf5698ec Fix glfwGetKeyName incorrectly emitting error
glfwGetKeyName emitted GLFW_INVALID_VALUE when passed GLFW_KEY_UNKNOWN
and any scancode not associated with a key token on that platform.

This causes physical keys with no associated key token to emit
GLFW_INVALID_VALUE when the key and scancode are passed directly from
the key event to glfwGetKeyName.  This breaks the promise made in the
reference documentation for glfwGetKeyName.

This commit removes that error for the whole range of valid scancodes.

Fixes #1785
2024-01-30 20:14:57 +01:00
Camilla Löwy
9afbcb442b Wayland: Clean up pointer axis handler 2024-01-29 21:05:35 +01:00
Camilla Löwy
8e6c8d7eff Remove reminders to use C89 for some source files
This is part of removing support for VS versions older than VS 2013.
See #2465 for details and feedback.

Related to #2465
2024-01-15 20:17:18 +01:00
Camilla Löwy
2c3eb75748 Wayland: Remove dependency on wayland-protocols
This brings the latest released versions of all used Wayland protocol
files into this repository, removing the need for the user to arrange
a sufficiently new version of wayland-protocols.

The wayland.xml protocol file was copied from wayland 1.22.0.
The additional protocol files were copied from wayland-protocols 1.32.

Because of how files are moved and renamed inside the wayland-protocols
repository, it will not always be possible to update all our protocol
files from a single release without also potentially updating related
code (acceptable) and prematurely breaking compatibility with
compositors that still only support an earlier incompatible version
(unacceptable).

The macro in src/CMakeLists.txt has been modified to hopefully make it
easier to add new protocol files.  This made it necessary to change the
name of a few of the generated header files.

Closes #2053
2024-01-13 22:13:56 +01:00
Camilla Löwy
d097e35743 Wayland: Fix heuristics for what counts as events
The Wayland implementation of glfwWaitEvents* keeps waiting until it
sees evidence that a significant event has been processed.  However,
this included updating an animated cursor (not a significant event)
but did not include previously buffered Wayland events or libdecor
events (definitely significant events).

This commit corrects these cases.
2023-11-30 18:52:43 +01:00
Camilla Löwy
23e40548b1 Wayland: Fix protocol error on undecorated window
When setting the visibility of a libdecor frame on a compositor that
supports XDG decorations, libdecor 0.1 will update the geometry of the
XDG surface.  GLFW attempted to set the visibility before having told
libdecor what size the content area is.  This caused a Wayland protocol
error when libdecor attempted to set the window size to 0x0.

This commit adds setting the content area size for the libdecor frame
directly after creation, allowing libdecor to know what it's doing.
2023-11-30 18:52:43 +01:00
Camilla Löwy
9fdc425931 Wayland: Use Wayland to wait for libdecor to init
Much of libdecor is initialized only after certain events have been
received from the compositor and some parts of libdecor 0.1 are unsafe
to use until this delayed initialization has completed.

Since libdecor does not provide an API to query if or be notified when
this has happened, GLFW processed events until its newly created
libdecor frame had created its XDG shell objects.

This commit switches to using a generic Wayland sync point created just
after libdecor (and presumably its plugin) has set up its delayed
initialization, instead of relying on the more specific implementation
detail mentioned above.

It also makes this wait mandatory before the first libdecor frame is
created instead of a pre-condition for certain libdecor frame calls,
hopefully removing even more dependence on implementation details.
2023-11-30 18:52:12 +01:00
Camilla Löwy
01d7c331fd Wayland: Fix zero being used in place of NULL 2023-11-16 20:49:23 +01:00
Camilla Löwy
3eaf1255b2 Wayland: Cleanup
Update naming and declarations to current standard.
2023-06-01 20:12:56 +02:00
Camilla Löwy
6b48f2be97 Wayland: Merge function called once
This brings together the two halves of the cursor setting logic for the
fallback decorations.
2023-06-01 20:12:22 +02:00
Camilla Löwy
00a663dafd Wayland: Fix fallback decorations emitting errors
A GLFW_CURSOR_UNAVAILABLE error would be emitted each time the cursor
moved over the fallback decorations if the standard cursor shape
appropriate for that part was missing on the system.

These errors served no useful purpose and have been removed.
2023-06-01 20:12:13 +02:00
TheBrokenRail
0b94e1b29b Wayland: Fix detection of joysticks after init
Closes #2198
2023-03-31 16:18:46 +02:00
Camilla Löwy
fbdb53b9ca Wayland: Add initial support for libdecor
This is partly based on the implementation of libdecor support in
PR #1693 by @ christianrauch.

Where available, the libdecor library is loaded at init and becomes the
preferred method for window decorations.  On compositors that support
XDG decorations, libdecor in turn uses those.  If not, libdecor has
a plug-in archtecture and may load additional libraries to either use
compositor-specific decorations or draw its own.

If necessary, support for libdecor can be disabled with the
GLFW_WAYLAND_LIBDECOR init hint.  This is mostly in case some part of
the dynamic loading or duplication of header material added here turns
out to cause problems with future versions of libdecor-0.so.0.

Fixes #1639
Closes #1693
Related to #1725
2023-03-27 22:03:36 +02:00
Camilla Löwy
cd466cf9fd Wayland: Simplify decoration side detection
This commit simplifies the detection of which element of a fallback
decorated window the pointer has entered.  Instead of looping through
the list of windows, the user pointer of fallback decoration surfaces is
set to the GLFW window object.
2023-03-27 22:03:36 +02:00
Camilla Löwy
39f0e86228 Wayland: Clean up enum value names 2023-03-27 22:03:36 +02:00
Camilla Löwy
efa9297a41 Wayland: Simplify per-window ouput scales tracking
This replaces (one case of) manual management of weak links between
windows and monitors, both objects with complex life times, with
wl_object pointers used as opaque key values.
2023-03-27 22:03:36 +02:00
Camilla Löwy
91c837ace5 Wayland: Use tags to verify proxy ownership
This is in preparation for adding support for libdecor, which creates
its own proxies on our display.  It will likely also be helpful to some
people using native access on Wayland.

This is partly based on the implementation of libdecor support in
PR #1693 by @ christianrauch.
2023-03-27 22:03:36 +02:00
Camilla Löwy
6d9083af03 Wayland: Remove duplicate setting of user data
The surface user data is already set by wl_surface_add_listener.
2023-03-27 22:03:36 +02:00
Camilla Löwy
4cf510511c Wayland: Stop manually tracking interface versions
This is already tracked by the proxies we care about.
2023-03-27 22:03:36 +02:00
Camilla Löwy
c1a79c1c41 Wayland: Emit size event when setting aspect ratio 2023-03-27 22:03:36 +02:00
Camilla Löwy
8397b39afa Wayland: Fix some missing window refresh events 2023-03-27 22:03:36 +02:00
Camilla Löwy
735fc101f5 Wayland: Fix decorations not always being created
If a window was initially fullscreen then it would not get an XDG
decoration object.  If the window was later switched to windowed mode it
would then get fallback decorations instead of XDG ones.
2023-03-27 22:03:36 +02:00
Camilla Löwy
228428fa4f Wayland: Simplify test for fallback decorations
The GLFW fallback decorations only exist when the window is visible,
decorated and in windowed mode.
2023-03-27 22:03:36 +02:00
Takuro Ashie
41d8da1cea
Wayland: Fix wrong array size for _GLFWofferWayland
Closes #2225
2022-12-16 13:40:36 +01:00
Camilla Löwy
c812b9d87c Add conditional compilation for platform units
This is a step towards being able to compile GLFW manually without
needing to duplicate a lot of platform- or OS-specific logic.
2022-09-15 22:24:39 +02:00
Camilla Löwy
3a60992a41 Wayland: Add error for unsupported feature 2022-07-25 18:02:57 +02:00
Camilla Löwy
3a5c726d1b Wayland: Remove unreachable code
This platform function is only called if the cursor is enabled.
2022-07-25 18:02:57 +02:00
Camilla Löwy
7be6a2cabe Wayland: Clean up pointer helper function order 2022-07-25 18:02:57 +02:00
Camilla Löwy
488008e0a2 Add cursor mode GLFW_CURSOR_CAPTURED
This adds a cursor mode that provides a visible cursor confined to the
content area of the window.

Fixes #58
2022-07-25 18:02:57 +02:00
Camilla Löwy
a46f829de8 Refactor cursor mode paths
This is the refactoring part of adding GLFW_CURSOR_CAPTURED, separated
out to help keep 3.3-stable similar to the main branch.

Related to #58.
2022-07-25 18:02:57 +02:00
Camilla Löwy
03af6b3d4c Wayland: Fix leaks of pointer related objects 2022-07-25 18:02:35 +02:00
Camilla Löwy
09ebf3f0bf Wayland: Fix error for missing protocol
A protocol not being available is not a platform error.  The platform is
doing fine; we're just sad that it lacks a feature we want.
2022-07-25 18:00:59 +02:00
Camilla Löwy
e85b645b8a Wayland: Clean up pointer locking
Shorten names and allow C99 declarations.  Replace helper function with
the NULL check it was hiding.  Separate cursor hiding from pointer
locking.
2022-07-25 17:53:04 +02:00
Michael Pennington
b9ed25d2e9 Wayland: Add GLFW_WAYLAND_APP_ID window hint
This adds a window hint string for the xdg_toplevel::app_id, which is
used by desktop environments to connect windows with application icons
and other information.  This is similar to the WM_CLASS property on X11.

A few very minor fixes were done by @elmindreda during merge.

Fixes #2121
Closes #2122
2022-07-24 17:51:54 +02:00
Camilla Löwy
26b85215c0 Wayland: Static function more static when static 2022-07-22 18:00:40 +02:00
Camilla Löwy
7cc8b053b8 Wayland: Clean up shared memory buffer creation 2022-07-15 16:17:12 +02:00
Camilla Löwy
40b5a8a37c Wayland: Fix reappearing key repeat
If the key or character callback performs actions that indirectly
updates the key repeat timer, those changes would be undone once the key
callback returned.

This fixes the order of operations so that key repeat is fully set up
before the key related events are emitted.
2022-07-13 21:54:55 +02:00
Camilla Löwy
9180923ea0 Wayland: Clean up key repeat logic 2022-07-13 21:54:55 +02:00
Camilla Löwy
a1a73ee862 Wayland: Make text input logic static
Since the seat listener was moved into wl_window.c there is no reason
for text input to have external linkage.
2022-07-13 21:51:04 +02:00
Camilla Löwy
e47cb7c1e2 Wayland: Update state before emitting events 2022-07-13 20:47:10 +02:00
Camilla Löwy
4df24735ef Wayland: Do not emit events for destroyed window
During platform window destruction, all of its callbacks have already
been removed, so emitting events for it does nothing.
2022-07-13 20:47:10 +02:00
Camilla Löwy
d77aaa770f Wayland: Fix non-standard struct initialization 2022-07-13 12:53:25 +02:00
Camilla Löwy
88a39006e3 Wayland: Cleanup 2022-07-11 20:54:21 +02:00
Camilla Löwy
5c948a6e6e Wayland: Fix comment typo 2022-07-11 20:54:21 +02:00
Camilla Löwy
da6713cd09 Wayland: Do not decorate fullscreen windows
If a fullscreen window with GLFW_DECORATED set had its XDG decorations
changed to client mode by the compositor, it would seemingly receive
GLFW fallback decorations as if it was windowed mode.

This is possibly related to #2001.
2022-06-21 21:50:51 +02:00
Camilla Löwy
d578c2ddfe Wayland: Only create EGL window if using EGL 2022-06-21 21:50:50 +02:00
Camilla Löwy
74b4ceb835 Wayland: Cleanup
This moves what is effectively showing the window to where that is done
on other platforms, i.e. last in the platform CreateWindow function.
2022-06-21 21:49:06 +02:00
Camilla Löwy
c4fbe80d90 Wayland: Make function behavior match name
The logic that checks the decorated attribute belongs on the outside
along with other related checks (fullscreen, monitor, decoration mode).
2022-06-21 21:49:06 +02:00
Camilla Löwy
be7f4513c0 Wayland: Remove premature surface commit calls
Note that the handling of configure events, acks and commits is still
not ideal.  This is just a small step in, hopefully, a good direction.

Fullscreen toggling via glfwSetWindowMonitor now works on Weston, but
mostly incidentally.
2022-06-21 21:49:06 +02:00
Camilla Löwy
47193f15de Wayland: Rename function to its purpose 2022-06-21 21:49:06 +02:00