Commit Graph

207 Commits

Author SHA1 Message Date
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
Camilla Löwy
fba79aaaec Wayland: Move surface creation function
This needs to be after createXdgSurface, which it will soon be calling.

(cherry picked from commit a3d1633e1d)
2022-02-15 20:52:54 +01:00
Camilla Löwy
ec934edfbf Wayland: Fix repeated key not released on defocus
Platform code should not generate key events with GLFW_REPEAT.
GLFW_PRESS is translated into GLFW_REPEAT by shared code based on the
key state cache.

This confused the automatic key release logic into not generating an
event with GLFW_RELEASE for a key being repeated when the window lost
input focus.

(cherry picked from commit 3f5dfeaf29)
2022-02-15 20:51:55 +01:00
Camilla Löwy
5f0b316c24 Wayland: Control key repeat via timerfd state
The key repeat logic is now controlled only via the key repeat timerfd.

(cherry picked from commit 850893a39f)
2022-02-15 20:50:58 +01:00
Camilla Löwy
5e8186af0a Wayland: Clean up event pump
Adapt style to the rest of the project.

(cherry picked from commit 79e7e65c9d)
2022-02-15 20:50:38 +01:00
Jason Francis
8ecb49d143 Wayland: Fix window hiding
Corrects the protocol violation when creating an xdg_surface from a
wl_surface that already has a buffer due to EGL buffer swaps.

This commit is based on PR #1731 by @ghost, but adapted and altered:
 - The XDG surface and role are now only created when a window is shown
   to prevent application lists from showing command-line applications
   with off-screen-only windows
 - The special case of Wayland+EGL buffer swap is now in the EGL code
   to mirror how X11 is handled
 - Adaption to run-time platform selection and separate credits file

Fixes #1492
Closes #1731

(cherry picked from commit 094aa6d3c7)
2021-12-24 01:59:16 +01:00
Camilla Löwy
3b806aef27 Wayland: Fix duplicate focus event on activation
(cherry picked from commit c2f0a0ae59)
2021-12-24 01:52:43 +01:00
Emmanuel Gil Peyrot
52133a3690 Wayland: Continue poll() if timerfd can’t be read
In the case the key repeat timerfd was interrupted before read(), the
cursor timerfd wasn’t read at all even when it could.

Related to #1711

(cherry picked from commit 68879081cb)
2021-12-24 01:45:22 +01:00
Waris Boonyasiriwat
6bb5f5d59d Wayland: Fix cursor offset when shape changes
The Wayland protocol spec[1] states that set_cursor must be called
with the serial number of the enter event.  However, GLFW is passing in
the serial number of the latest received event, which does not meet the
protocol spec.

[1] https://wayland.freedesktop.org/docs/html/apa.html#protocol-spec-wl_pointer

As a result, set_cursor calls were simply ignored by the compositor.

This fix complies with the protocol more closely by specifically caching
the enter event serial, and using it for all set_cursor calls.

Fixes #1706
Closes #1899

(cherry picked from commit e7758c506d)
2021-10-13 23:06:40 +02:00
Leonard König
b31d7ddc8c Wayland: Fix destroying CSDs in the correct order
On Wayland we implement Client-Side Decorations if the compositors do not
implement SSDs.  In that case, the destructors of the surfaces were called
in the wrong order, leading to a dereference of an already freed object.
We need to first destroy the subsurface before destroying the parent surface.

Related PR on kitty: https://github.com/kovidgoyal/kitty/pull/3066
Related issue on kitty: https://github.com/kovidgoyal/kitty/issues/3051

Closes #1798.

(cherry picked from commit 0dc1005c85)
2021-02-09 21:49:16 +01:00
Camilla Löwy
bd2fb9ebaf Wayland: Fix partial framebuffer size retrieval
(cherry picked from commit 5f60c22cfa)
2020-07-16 13:33:58 +02:00
Camilla Löwy
5dbca2e2c9 Wayland: Fix repeated keys reported to NULL window
This fixes a race between the key repeat logic and the surface leave
event handler, which could result in repeated keys being reported with
a window of NULL.

Fixes #1704.

(cherry picked from commit c72da994ba)
2020-06-30 17:04:04 +02:00
Luflosi
a8e5c530ee Replace %m conversion specifier with %s and strerror()
When compiling with `-Wall` and `-pedantic-errors`, gcc complains with
```
warning: ISO C does not support the '%m' gnu_printf format [-Wformat=]
```
because the `%m` conversion specifier is a GNU extension.

Closes #1702.

(cherry picked from commit d4f5074535)
2020-06-02 19:01:05 +02:00
Camilla Löwy
df4bda44fc Wayland: Fix pointing hand cursor shape
Related to #1432.

(cherry picked from commit 80fde12fda)
2019-12-03 17:19:14 +01:00
luz.paz
13a4e4e810 Fix typos
Found via `codespell -q 3 -S ./deps -L fo,numer,te,uint,wille`

(cherry picked from commit 7105ff2dfd)
2019-09-23 15:27:17 +02:00
Camilla Löwy
04522580ad Add C dialect reminders to each source file
Files built for Win32 must use C89 style declarations for compatibility
with VS 2010 and 2012, which are still supported by GLFW.

(cherry picked from commit 56aad76b16)
2019-05-27 16:33:22 +02:00
Camilla Löwy
44af6bb936 Wayland: Implement raw mouse motion control
Related to #1400.
Related to #1401.
2019-02-22 14:52:02 +01:00
Camilla Löwy
1155c83013 Rename raw input to raw mouse motion, cleanup
This renames 'raw input' to 'raw mouse motion' as there are other kinds
of raw input.  The update path is restructured to avoid reinitializing
all of disabled cursor mode.  Modification of shared state is moved out
into shared code.  Raw mouse motion is disabled by default for
compatibility.

Related to #1401.
2019-02-22 13:04:11 +01:00
Nathan Poirier
9e29f556fd Add GLFW_RAW_INPUT and glfwRawInputSupported
This adds runtime per-window control of whether accelerated or raw mouse
motion is provided when the cursor is disabled.

Fixes #1400.
Closes #1401.
2019-02-22 13:04:11 +01:00
Emmanuel Gil Peyrot
45bd991ea9 Wayland: Fix auto-iconify on kwin_wayland
We now keep track of the fullscreen and activated state and only iconify
if we were previously fullscreen and now we are either not fullscreen or
not activated anymore.

This is the proper way to do it, compared to the previous hack where we
didn’t iconify only if it was the first configure event received.
2019-02-15 18:12:09 +01:00
Emmanuel Gil Peyrot
edf0a07174 Wayland: Only auto-iconify fullscreen windows
Thanks to kwin for exposing a bug here!
2019-02-15 17:03:37 +01:00
Greg V
36ce73bbfd Wayland: use SHM_ANON on FreeBSD
This works like memfd on Linux.
2019-02-15 15:45:25 +01:00
Emmanuel Gil Peyrot
c08abffc50 Wayland: Implement clipboard copy 2018-10-24 14:03:08 +02:00
Emmanuel Gil Peyrot
8b54e28c4e Wayland: Implement clipboard paste 2018-10-24 14:03:08 +02:00
Ricardo Vieira
92b3fd02e5 wayland: save serial from all input sources 2018-10-24 14:03:08 +02:00
Emmanuel Gil Peyrot
dcd2a19d90 Wayland: Add support for xdg-decoration
This allows compositors which prefer to draw the decorations around
clients to do so, rather than letting GLFW draw its own decorations.
The appearance is thus entirely subject to the compositor used, but
should generally be better than the current solid colour decorations we
have, which we continue to use when the compositor doesn’t support this
protocol or tells us to draw the decorations ourselves.

This new protocol has been tested against wlroots’s rootston compositor.

Fixes #1257.
2018-10-01 16:37:24 +02:00
Emmanuel Gil Peyrot
3e884aea46 Wayland: Use memfd_create() and seals if available
This allows the compositor to avoid having to setup and teardown a
SIGBUS signal handler whenever it needs to read from this surface, as it
knows we won’t be able to shrink the file and so doesn’t have to protect
against that.

This codepath will only be used on Linux ≥ 3.17 with glibc ≥ 2.27, and
possibly other kernels and libc.  The former code will continue to be
used as a fallback, either if memfd_create() fails or if it isn’t
available.
2018-10-01 13:13:19 +02:00
Emmanuel Gil Peyrot
ab16fcc8db Wayland: Check for buffer creation failure
This prevents unusable decoration objects from being created, and
invalid cursors from being returned to the user.
2018-09-29 22:59:02 +02:00
Emmanuel Gil Peyrot
754b7feaa1 Wayland: Rename handlers for more unicity 2018-09-29 21:01:03 +02:00
Emmanuel Gil Peyrot
4d3f0fb5df Wayland: Split long lines for function declaration 2018-09-29 18:11:13 +02:00
Emmanuel Gil Peyrot
15cad02235 Wayland: Use HiDPI cursors for standard cursors 2018-09-11 14:28:44 +02:00
Emmanuel Gil Peyrot
e0b83bbe8d Wayland: Use HiDPI cursors on decorations 2018-09-11 14:28:44 +02:00
Emmanuel Gil Peyrot
5ea6e6cda2 Wayland: Add support for animated standard cursors 2018-09-09 13:12:20 +02:00
Emmanuel Gil Peyrot
dede6d6886 Wayland: Add a timerfd for animated cursors 2018-09-09 13:12:20 +02:00
Emmanuel Gil Peyrot
2926ce4838 Prevent resizing smaller than 1×1 2018-02-25 16:54:44 +01:00
Emmanuel Gil Peyrot
a0dbffb8f2 Set decorations as opaque, to optimise composition 2018-02-25 16:54:44 +01:00
Emmanuel Gil Peyrot
dfc7eacd50 Do not leak the 1×1 buffer used for decorations 2018-02-25 16:54:44 +01:00
Emmanuel Gil Peyrot
0c4ca85149 Fix _glfwPlatformSetWindowMonitor to correctly destroy/recreate decorations 2018-02-25 16:54:44 +01:00
Emmanuel Gil Peyrot
c9d691e65e Fix window size calculation when wp_viewporter isn’t supported 2018-02-25 16:54:44 +01:00
Emmanuel Gil Peyrot
60e82ba472 Handle scaling factor (hidpi) correctly 2018-02-25 16:54:44 +01:00
Emmanuel Gil Peyrot
f51c219b1c Handle maximized size correctly 2018-02-25 16:54:44 +01:00
Emmanuel Gil Peyrot
31cea7fa24 Remove decorations when fullscreen 2018-02-25 16:54:44 +01:00
Emmanuel Gil Peyrot
58b21d336c Factorise moving to fullscreen 2018-02-25 16:54:44 +01:00
Emmanuel Gil Peyrot
8ed91e8a77 Only create decorations if wp_viewporter is supported 2018-02-25 16:54:44 +01:00
Emmanuel Gil Peyrot
4e31dc5e6e Make it possible to toggle window decorations 2018-02-25 16:54:44 +01:00
Emmanuel Gil Peyrot
1f8ec20b55 Correctly destroy subsurfaces on window destroy 2018-02-25 16:54:44 +01:00
Emmanuel Gil Peyrot
4a42364a19 Return correct values for frame size 2018-02-25 16:54:44 +01:00
Emmanuel Gil Peyrot
9f7ec6b094 Implement window decorations 2018-02-25 16:54:44 +01:00
Emmanuel Gil Peyrot
9a7656364e Split shm buffer creation out of _glfwPlatformCreateCursor 2018-02-25 16:54:44 +01:00
Emmanuel Gil Peyrot
2de3605b4c Make createAnonymousFile static 2018-02-25 16:54:44 +01:00
Emmanuel Gil Peyrot
f67b610dd4 Wayland: Handle repeats which missed a timer 2018-02-24 21:06:25 +01:00
Emmanuel Gil Peyrot
90f5edc0b8 Wayland: Use a timerfd for key repeat 2018-02-24 21:06:25 +01:00
Emmanuel Gil Peyrot
f5d3954568 Stop checking for resizing
Fixes #1197
2018-02-06 12:57:17 +01:00
Emmanuel Gil Peyrot
eb7c9994bf Prevent auto-iconify from firing on window creation 2018-01-29 03:59:47 +01:00
Emmanuel Gil Peyrot
f2617a671f Add a roundtrip after creating the xdg-surface
The specification says we must not attach a buffer until we’ve received
a configure event.
2018-01-29 03:59:47 +01:00
Emmanuel Gil Peyrot
4778d02c67 Ignore _glfwPlatformShowWindow when already visible 2018-01-29 03:59:47 +01:00
Emmanuel Gil Peyrot
f710db6504 Ignore configure events of 0×0px 2018-01-29 03:59:47 +01:00
Emmanuel Gil Peyrot
0e759c9422 Don’t set min/max size on GLFW_DONT_CARE 2018-01-29 03:59:47 +01:00
Emmanuel Gil Peyrot
ae44a28125 Wayland: Add an alternate surface role using xdg-shell
This protocol matches desktops much better than the deprecated
wl_shell, fixing a bunch of race conditions, removing undefined
behaviour, adding missing features, and generally providing a much more
user-friendly experience.

Since most compositors don’t support it yet, the wl_shell_surface role
is kept as fallback for now.
2018-01-29 03:59:47 +01:00
Emmanuel Gil Peyrot
a199efae44 Wayland: Emit an error when wl_shell is absent or unusable 2018-01-29 03:59:47 +01:00
Emmanuel Gil Peyrot
407a3e2860 Load libwayland-cursor at runtime 2018-01-29 02:34:10 +01:00
Emmanuel Gil Peyrot
5fbf4ddde8 Load libwayland-egl at runtime 2018-01-29 02:34:10 +01:00
Camilla Löwy
973bf29622 Remove use of non-standard function strdup
Related to #873.
2018-01-17 11:56:35 +01:00
Emmanuel Gil Peyrot
6c421f131d Wayland: Implement scale callback
Closes #1181.
2018-01-09 22:39:35 +01:00
Camilla Löwy
ee9dffcd66 Add GLFW_HOVERED for polling cursor hover state
This window attribute corresponds to the cursor enter/leave callback.

Fixes #1166.
2018-01-09 18:02:52 +01:00
Emmanuel Gil Peyrot
65166858ff Wayland: Add support for the idle-inhibit protocol
Closes #955.
2017-11-20 22:27:37 +01:00
Camilla Löwy
11e47f08b1 Add glfwGetWindowOpacity and glfwSetWindowOpacity
This adds support for setting the opacity of the whole window, including
any decorations.

Fixes #1089.
2017-11-15 15:46:01 +01:00
Camilla Löwy
31cbb20ba2 Deprecate window parameter of clipboard functions 2017-11-10 02:52:16 +01:00
Camilla Löwy
bf09dba95b Cleanup 2017-10-26 18:05:56 +02:00
Camilla Löwy
16bf872117 Add content scale queries
This adds glfwGetWindowContentScale and glfwGetMonitorContentScale for
querying the recommended drawing scale factor for DPI-aware rendering.

Parts of this patch are based on code by @ferreiradaselva.

Fixes #235.
Fixes #439.
Fixes #677.
Fixes #845.
Fixes #898.
2017-10-26 17:26:36 +02:00
Emmanuel Gil Peyrot
95e282d5a0 Wayland: Add transparency support
Closes #788.
2017-10-01 01:39:27 +01:00
Camilla Löwy
32e78aeb2e Add GLFW_TRANSPARENT attribute and documentation
This completes support for window framebuffer transparency on Windows,
macOS and X11.  Note that the hint/attribute may be renamed before
release to clarify its relationship to GLFW_OPACITY.

Fixes #197.
Closes #1079.
Related to #663.
Related to #715.
Related to #723.
Related to #1078.
2017-09-27 21:54:04 +02:00
Camilla Löwy
e3be6b8ae0 Cleanup
Break up some overly long lines.
2017-09-17 15:14:22 +02:00
Camilla Löwy
82284b86eb Cleanup
Thanks to glfwGetKeyScancode we can now pass only a scancode to the
platform layer for glfwGetKeyName.
2017-07-13 01:26:06 +02:00
Camilla Löwy
baa9cd8968 Cleanup
Closes #988.
2017-05-11 20:10:04 +02:00
Felipe Ferreira da Silva
412eb6a611 Add glfwRequestWindowAttention
Related to #988.
2017-05-11 13:36:39 +02:00
Emmanuel Gil Peyrot
0e0862cfc7 Wayland: Fix broken build
Regression caused by e9560ef021.
2017-03-03 17:51:40 +00:00
Emmanuel Gil Peyrot
f4c5e6568e Wayland: Commit shell surface creation
This fixes any program using hidden windows, like tests/windows.c.
2017-01-26 18:13:15 +00:00
Camilla Löwy
9e56099edd Add glfwSetWindowAttrib
This function allows updating the GLFW_DECORATED, GLFW_RESIZABLE,
GLFW_FLOATING and GLFW_AUTO_ICONIFY attributes for existing windows.

Fixes #537.
2016-12-06 15:59:18 +01:00
Emmanuel Gil Peyrot
a49601ba87 Wayland: Rename snake_case identifiers to camelCase for consistency 2016-10-12 14:13:52 +01:00
Camilla Berglund
e6a32db7b9 Cleanup 2016-09-07 16:49:29 +02:00
Camilla Berglund
bb3cb8f233 Cleanup
Clean up code and documentation for glfwGetKeyScancode and add
implementation for Wayland and Mir.

Related to #830.
2016-09-07 16:46:48 +02:00
Michael Stocker
e745b0dd47 Add glfwGetKeyScancode
Allows retrieval of platform scancode from GLFW_KEY_*.  Implemented for
Win32, Cocoa and X11.  Stubs for Mir and Wayland.

Closes #830.
2016-09-07 16:38:22 +02:00
Camilla Berglund
5ff7d9505f Simplify Vulkan extension checks
Related to #478.
2016-09-07 16:31:18 +02:00
Camilla Berglund
53fafad915 Start 3.3 2016-08-18 23:55:49 +02:00
Camilla Berglund
fcdef1d0a0 Fix potential context resource leaks
There is a gap between the creation of the context and the call to
_glfwRefreshContextAttribs.
2016-08-05 11:23:05 +02:00
Camilla Berglund
d5e00e6b0f Initialize context creation APIs on demand 2016-07-20 13:10:51 +02:00
Camilla Berglund
bda031f4ac Cleanup 2016-05-29 15:34:08 +02:00
Camilla Berglund
797ee8d8e3 Move all cursor positioning to platform code
Due to Wayland, shared code cannot rely on cursor positioning being
supported by the underlying platform.

This implicitly fixes #617 as it moves cursor centering into
_glfwPlatformSetCursorMode, thus separating it from the stale value of
_glfw.cursorWindow.

Fixes #617.
2016-05-29 15:33:49 +02:00