Commit Graph

48 Commits

Author SHA1 Message Date
Simon Ser 488a23c169 pointer: drop enum wlr_axis_orientation
Instead, use enum wl_pointer_axis from the Wayland protocol.
2024-02-28 16:39:18 +00:00
Simon Ser ec5263e6b7 pointer: drop enum wlr_axis_relative_direction
Instead, use enum wl_pointer_axis_relative_direction from the
Wayland protocol.
2024-02-28 16:39:18 +00:00
Simon Ser 9f4cf242d9 pointer: drop enum wlr_axis_source
Instead, use enum wl_pointer_axis_source from the Wayland protocol.
2024-02-28 16:39:18 +00:00
Simon Ser 842093bb84 Define _POSIX_C_SOURCE globally
Stop trying to maintain a per-file _POSIX_C_SOURCE. Instead,
require POSIX.1-2008 globally. A lot of core source files depend
on that already.

Some care must be taken on a few select files where we need a bit
more than POSIX. Some files need XSI extensions (_XOPEN_SOURCE) and
some files need BSD extensions (_DEFAULT_SOURCE). In both cases,
these feature test macros imply _POSIX_C_SOURCE. Make sure to not
define both these macros and _POSIX_C_SOURCE explicitly to avoid
POSIX requirement conflicts (e.g. _POSIX_C_SOURCE says POSIX.1-2001
but _XOPEN_SOURCE says POSIX.1-2008).

Additionally, there is one special case in render/vulkan/vulkan.c.
That file needs major()/minor(), and these are system-specific.
On FreeBSD, _POSIX_C_SOURCE hides system-specific symbols so we need
to make sure it's not defined for this file. On Linux, we can
explicitly include <sys/sysmacros.h> and ensure that apart from
symbols defined there the file only uses POSIX toys.
2024-02-15 15:41:12 +01:00
Paul Cercueil 220df2aa0f
Add more POSIX compliance macros to fix uClibc support
- Add POSIX 1993.09 compliance macro in source files that use
  "struct timespec";
- Add POSIX 2001.12 compliance macro in source files that use
  "struct sigaction" and the SA_SIGINFO macro, or the fchmod()
  function;
- Add POSIX 2008.09 compliance macro in source files that use the
  getline() function.

These compliance macros are enough for wlroots to compile with the
git-master version of uClibc-ng.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
2024-02-12 17:41:45 +01:00
Simon Ser 00bb1b0f84 seat/pointer: add support for axis_relative_direction event 2024-01-23 08:37:29 +00:00
Alexander Orzechowski 1b0694b794 treewide: Migrate from sizeof(struct) to sizeof(*pointer) where practical 2023-10-03 01:51:07 -04:00
Kirill Primak 753f3cc4fa compositor: add wlr_surface_role.no_object
This commit allows to make a role as not represented by an object,
which fixes calling role commit handlers for roles like cursor
surfaces.

Fixes: 099b9de752
2023-06-14 14:06:28 +00:00
Kirill Primak 24a479a501 drag: don't set icon's role_data
Currently, an icon surface's role_data is set manually to a struct
wlr_drag_icon, which is hacky, incorrect (as role_data is supposed
to be the surface's role object, and drag icons don't have them), and
will be disallowed by future changes.
2023-06-08 20:03:18 +02:00
Kirill Primak 2acc74a3db Clear input regions if they're ignored 2023-06-06 13:33:31 +03:00
Kirill Primak af4181f388 drag: use unified map logic 2023-06-02 17:26:18 +00:00
Simon Ser 0e54b861e9 seat/keyboard: constify wlr_seat_keyboard_notify_enter() 2023-01-26 15:06:45 +00:00
Simon Ser 695d28c250 seat/keyboard: constify wlr_seat_keyboard_notify_modifiers() 2023-01-26 15:06:45 +00:00
bi4k8 8b12037cad wlr_seat: clear `drag->seat_client` when destroyed
This was previously a use-after-free in `wlr_drag.c`.
2022-11-16 01:56:18 +00:00
Kirill Primak 099b9de752 compositor: drop role object NULL checks in handlers
Instead, move the check to the caller.
2022-11-06 17:00:00 +03:00
Kirill Primak 92fbfda2ca drag-icon: use role object destroy handler 2022-11-06 17:00:00 +03:00
Alexander Orzechowski ef4baea0e2 Use wl_signal_emit_mutable 2022-08-18 07:16:16 -04:00
Kenny Levinsen 668b2740ff Set mapped before firing map/unmap events
This allows whatever the user calls from the signal handlers to react to observe
the new state rather than the old, e.g. that a surface is no longer mapped in
the unmap handler.
2022-08-06 00:19:38 +02:00
Kirill Primak 617eb4fb93 surface: deprecate wlr_surface.h 2022-01-13 10:06:41 +00:00
Isaac Freund c9ba9e82b6
wlr_drag: emit destroy after wl_data_device.leave 2021-11-22 22:43:39 +01:00
Kenny Levinsen d2ca220fda wlr_drag: Destroy drag after releasing grabs
wlr_drag sets up keyboard, pointer and touch grabs, which block 'enter'
events (and thus focus changes). For the compositor to be able to update
focus (e.g. to focus the drop target) from the destroy handler, the
grabs must be released before the destroy event is signalled.
2020-06-30 11:11:52 +02:00
Thomas Hebb dcae6f1431 Allow keyboard and pointer grabs to hook clear_focus()
This is necessary for some grabs, which currently have no way of knowing
when the pointer/keyboard focus has left a surface. For example, without
this, a drag-and-drop grab can erroneously drop into a window that the
cursor is no longer over.

This is the plumbing needed to properly fix swaywm/sway#5220. The
existing fix, swaywm/sway#5222, relies on every grab's `enter()` hook
allowing a `NULL` surface. This is not guaranteed by the API and, in
fact, is not the case for the xdg-shell popup grab and results in a
crash when the cursor leaves a surface and does not immediately enter
another one while a popup is open (#2161).

This fix also adds an assertion to wlr_seat_pointer_notify_enter() that
ensures it's never called with a `NULL` surface. This will make Sway
crash much more until it fixes its usage of the API, so we should land
this at the same time as a fix in Sway (which I haven't posted yet).
2020-06-05 17:20:26 +02:00
Simon Ser 16e5e9541b Add -Wmissing-prototypes
This requires functions without a prototype definition to be static.
This allows to detect dead code, export less symbols and put shared
functions in headers.
2019-11-20 02:05:03 +00:00
Simon Ser ca45f4490c Remove all wayland-server.h includes
The documentation for wayland-server.h says:

> Use of this header file is discouraged. Prefer including
> wayland-server-core.h instead, which does not include the server protocol
> header and as such only defines the library PI, excluding the deprecated API
> below.

Replacing wayland-server.h with wayland-server-core.h allows us to drop the
WL_HIDE_DEPRECATED declaration.
2019-07-27 15:49:32 -04:00
emersion d6de640440
data-device: unbreak wl_data_source.cancel during drag-and-drop 2019-02-20 18:42:34 +01:00
emersion 44ec3afb27
data-device: fix drag cleanup if not started 2019-02-20 18:42:34 +01:00
emersion 6291e84532
data-device: refactor wlr_drag 2019-02-20 18:42:29 +01:00
emersion 81ed1efe4f
xwayland, data-device: fix surface state on unmap
This commit makes sure surface->mapped is true when the unmapped event is
emitted. This is necessary because listeners can only damage surfaces that are
mapped. This is similar to the fact that the destroy event is emitted before
any destruction is actually made.

Fixes https://github.com/swaywm/sway/issues/3568
2019-02-18 13:14:35 +01:00
emersion 556bf3ac31
data-device: destroy previous source when starting drag
This supersedes f24e17259e and
04c9ca4198. These commits were manually removing
wlr_data_source destroy handlers when starting a new drag. This is error-prone.

Instead, this commit destroys the previous source whenever we start a new drag.
2019-02-05 18:43:06 +01:00
John Chen f24e17259e Fix swaywm/sway#3545. 2019-02-02 14:05:31 +01:00
emersion 29952dee19
data-device: only allow one drag at a time 2019-01-30 15:24:18 +01:00
emersion c505ce3019
data-device: fix use-after-free on drop 2019-01-30 15:24:14 +01:00
emersion 909b3b16f3
data-device: add wlr_data_offer.type 2019-01-24 12:18:40 +01:00
emersion 84f278eca1
data-device: remove data_source_send_offer 2019-01-24 12:12:55 +01:00
emersion 1150ff13ce
data-device: make sources inert, rename cancel to destroy 2019-01-24 12:12:55 +01:00
emersion 5d26da9d15
data-device: allow multiple devices for the same seat
This commit makes it possible for a single client to have multiple data devices
for the same seat. This fixes issues with Firefox.

This mainly removes wlr_data_source.offer. We make sure we create one data
offer per device. We now make the offer inert when the source is destroyed.

Fixes the second half of https://github.com/swaywm/wlroots/issues/1041
2018-11-26 12:35:48 +01:00
emersion 2d0c5ec78e
Use _POSIX_C_SOURCE, use shm_open 2018-11-06 08:29:23 +01:00
nyorain f6168c2afe Fix #1129 and remove sx, sy from wlr_drag_icon
sx, sy used to store the buffer offset of the drag surface which was
then be added (by rootston) to the drag icon position.
Buffer offsets are handled already in surface_intersect_output
(output.c) so they were added twice for dnd surfaces.
2018-09-07 14:48:28 +02:00
emersion 33db4263a0
surface: replace wlr_surface_set_role_committed with wlr_surface_role 2018-07-07 22:45:16 +01:00
emersion adf0423f7c
surface: better buffer position handling 2018-07-04 19:12:17 +01:00
emersion 3c0d672ebd
surface: make pending and current embedded structs 2018-07-04 19:12:17 +01:00
Tony Crisci 7c888a39c6 update drag position at the right times 2018-06-05 23:45:03 -04:00
Tony Crisci 319ebdf476 add back map event 2018-06-05 22:50:29 -04:00
Tony Crisci 1c75d4e54a rename drag-icon map to unmap 2018-06-05 18:17:42 -04:00
Dominique Martinet 51b9883ea0 seat: allow clients to bind to seat multiple times
This lets clients bind to a seat multiple times by re-using the existing
wlr_seat_client whenever a duplicate request happens.
Previously, an independant wlr_seat_client would be created and only
events from one would be processed.

Fixes #1023.
2018-06-04 22:31:36 +09:00
emersion db84379242
Send axis source event 2018-05-12 13:53:21 +01:00
emersion 0b58579564
Add support for discrete axis values 2018-05-12 13:34:58 +01:00
emersion 1e563e7ecf
data-device: split into multiple files 2018-05-02 18:04:10 +01:00