Commit Graph

20 Commits

Author SHA1 Message Date
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
Alexander Orzechowski 1b0694b794 treewide: Migrate from sizeof(struct) to sizeof(*pointer) where practical 2023-10-03 01:51:07 -04:00
Simon Ser fe06e5f49a Use wl_container_of() instead of casts
This slightly improves type safety.

The culprits were found with:

    git grep -E '\([a-z0-9_ ]+ \*\)\W?[a-z]'
2023-07-11 20:16:17 +02:00
Väinö Mäkelä 5120addfbb data-control: Handle inert seats 2023-06-03 10:43:12 +00:00
Alexander Orzechowski ef4baea0e2 Use wl_signal_emit_mutable 2022-08-18 07:16:16 -04:00
Simon Ser 5cde35923c Simplify globals implementation by removing destructors
Some globals are static and it doesn't make sense to destroy them before
the wl_display. For instance, wl_compositor should be created before the
display is started and shouldn't be destroyed.

For these globals, we can simplify the code by removing the destructor
and stop keeping track of wl_resources (these will be destroyed with the
wl_display by libwayland).
2019-11-25 09:01:46 -05:00
Antonin Décimo 3fc977d7da Fix memory leak 2019-08-12 09:37:21 +09:00
Manuel Stoeckl edb30a6828 Implement serial validation for selection requests
This change tracks, for each wlr_seat_client, the most recent serial
numbers which were sent to the client. When the client makes a
selection request, wlroots now verifies that the serial number
associated with the selection request was actually provided to that
specific client. This ensures that the client that was most
recently interacted with always has priority for its copy selection
requests, and that no other clients can incorrectly use a larger serial
value and "steal" the role of having the copy selection.

Also, the code used to determine when a given selection is superseded
by a newer request uses < instead of <= to allow clients to make
multiple selection requests with the same serial number and have the
last one hold.

To limit memory use, a ring buffer is used to store runs of sequential
serial numbers, and all serial numbers earlier than the start of the
ring buffer are assumed to be valid. Faking very old serials is
unlikely to be disruptive.

Assuming all clients are correctly written, the only additional
constraint which this patch should impose is that serial numbers
are now bound to seats: clients may not receive a serial number
from an input event on one seat and then use that to request
copy-selection on another seat.
2019-06-30 15:01:05 -04:00
Ivan Molodetskikh b59370088e Update data-control 2019-02-15 11:58:33 +01:00
Ivan Molodetskikh 9e49ceb129 data-control: add primary selection support
data-control: separate out a data_offer struct

This is a prerequisite to adding primary selection support.

data-control: separate out data_control_source

This is a prerequisite to adding primary selection support, since that
doesn't use wlr_data_source, but rather wlr_primary_selection_source.

Update the data-control protocol

data-control: add primary selection support

Merge create_offer and create_primary_offer

Extract code into data_control_source_destroy()

Fix pointer style

Move resource neutralization to destructor

Store wl_resource in the data_offer

Extract data_offer destruction into a function
2019-02-10 17:12:05 +01:00
emersion 790f0c52a1
De-duplicate data source MIME types 2019-01-30 22:10:52 +01:00
emersion 5fdf22b5d3
data-control-v1: handle NULL sources in set_selection 2019-01-26 11:25:39 +01:00
emersion 703a160078
data-control-v1: use new wlr_data_source API 2019-01-24 12:15:18 +01:00
emersion 4cb0697e57 data-device, primary-selection: add request_set_selection
This makes compositors able to block and/or customize set_selection requests
coming from clients. For instance, it's possible for a compositor to disable
rich selection content (by removing all MIME types except text/plain). This
commit implements the design proposed in [1].

Two new events are added to wlr_seat: request_set_selection and
request_set_primary_selection. Compositors need to listen to these events and
either destroy the source or effectively set the selection.

Fixes https://github.com/swaywm/wlroots/issues/1138

[1]: https://github.com/swaywm/wlroots/issues/1367#issuecomment-442403454
2019-01-24 11:38:23 +01:00
emersion 69e7fd61b7
data-control-v1: update to latest protocol proposal 2018-12-30 02:52:03 +01:00
emersion 340281b48a
data-control-v1: fix data source not properly destroyed 2018-12-30 02:48:04 +01:00
emersion a28167c255
data-control-v1: allow clearing selection 2018-12-30 02:48:03 +01:00
emersion aa2dafb7c8
data-control-v1: fix crash in manager_handle_get_data_control 2018-12-30 02:48:03 +01:00
emersion 1e581ad95c
data-control-v1: fix crash after wlr_data_control_v1_destroy 2018-12-30 02:48:03 +01:00
emersion 99d879c887
data-control-v1: initial protocol implementation 2018-12-30 02:48:03 +01:00