Commit Graph

73 Commits

Author SHA1 Message Date
Simon Ser 4377b55292 util/global: remove wl_display arg from wlr_global_destroy_safe
Since [1], we can get the wl_display directly from the wl_global.

[1]: 2b22160fb6
2021-12-14 13:13:50 +00:00
Raphael Robatsch 4a8e681a5f util/token: don't leak /dev/urandom fd to children
Closes #3324.
2021-11-14 12:30:03 +01:00
Simon Ser fdc22449d6 util/box: introduce wlr_fbox_empty
Same as wlr_box_empty, but for wlr_fbox.
2021-09-22 10:45:39 -06:00
Simon Ser 55ca93469c util/shm: add allocate_shm_file_pair
This function behaves like allocate_shm_file, except it also
returns a read-only FD. This is useful to share the same segment
of memory with many Wayland clients.
2021-09-05 22:06:25 +02:00
Kirill Primak 664307f968 util/box: introduce wlr_fbox_transform()
A floating-point version of wlr_box_transform().
2021-08-24 10:36:06 +02:00
Kirill Primak 111d4eafd7 util/addon: find both by owner and impl
This allows to have multiple addons of different types with the same
owner.
2021-08-11 18:12:57 +02:00
Kirill Primak a6a80850b7 util: add wlr_addon 2021-08-10 19:15:48 +02:00
Dylan Araps e5063ef3a3 util/time: make NSEC_PER_SEC static
This fixes static linking with libseat.

Closes #3072
2021-07-28 09:01:59 +02:00
Simon Zeni e192d87731 move wlr_box from /types to /util 2021-07-06 21:43:17 +02:00
Simon Ser a6ed4ae308 util/array: add array_remove_at 2021-07-01 10:35:39 -04:00
Ryan Farley b29ac8fbac util/uuid: replace with util/token, remove libuuid
Use 128-bit hexadecimal string tokens generated with /dev/urandom
instead of UUIDs for xdg-foreign handles, removing the libuuid
dependency. Update readme and CI. Closes #2830.

build: remove xdg-foreign feature

With no external dependencies required, there's no reason not to always
build it. Remove WLR_HAS_XDG_FOREIGN as well.
2021-04-11 19:09:36 +02:00
Simon Ser 6721444114 build: simplify HAS_LIBUUID definition
We can just use to_int() instead of having two if branches.
2021-04-06 20:34:47 +02:00
Simon Ser 6f873078d4 build: use dictionnary for features instead of configuration_data
This allows us to easily iterate on all features and only deal with
bools.
2021-02-15 16:32:33 +01:00
Rouven Czerwinski dd920f602e util: fix uuid support for freebsd
Fixes:
  FAILED: subprojects/wlroots/libwlroots.so.7.p/util_uuid.c.o
  cc -Isubprojects/wlroots/libwlroots.so.7.p -Isubprojects/wlroots -I../subprojects/wlroots -Isubprojects/wlroots/include -I../subprojects/wlroots/include -Isubprojects/wlroots/protocol -I../subprojects/wlroots/protocol -I/usr/local/include -I/usr/local/include/libepoll-shim -I/usr/local/include/libdrm -I/usr/local/include/pixman-1 -Xclang -fcolor-diagnostics -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Werror -std=c11 -g -DWLR_USE_UNSTABLE -Wundef -Wmissing-include-dirs -Wold-style-definition -Wpointer-arith -Winit-self -Wstrict-prototypes -Wendif-labels -Wstrict-aliasing=2 -Woverflow -Wmissing-prototypes -Wno-missing-braces -Wno-missing-field-initializers -Wno-unused-parameter '-DWLR_REL_SRC_DIR="../subprojects/wlroots/"' -Wno-missing-field-initializers -Wno-missing-braces -DHAS_LIBUUID=0 '-DICONDIR="/usr/local/share/icons"' -fPIC -pthread -D_THREAD_SAFE -MD -MQ subprojects/wlroots/libwlroots.so.7.p/util_uuid.c.o -MF subprojects/wlroots/libwlroots.so.7.p/util_uuid.c.o.d -o subprojects/wlroots/libwlroots.so.7.p/util_uuid.c.o -c ../subprojects/wlroots/util/uuid.c
  ../subprojects/wlroots/util/uuid.c:28:2: error: implicit declaration of function 'assert' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
          assert(strlen(str) + 1 == 37);
          ^
  ../subprojects/wlroots/util/uuid.c:28:2: error: this function declaration is not a prototype [-Werror,-Wstrict-prototypes]
  ../subprojects/wlroots/util/uuid.c:29:25: error: sizeof on array function parameter will return size of 'char *' instead of 'char [static 37]' [-Werror,-Wsizeof-array-argument]
          memcpy(out, str, sizeof(out));
                                 ^
  ../subprojects/wlroots/util/uuid.c:15:25: note: declared here
  bool generate_uuid(char out[static 37]) {
                          ^
  ../subprojects/wlroots/util/uuid.c:29:26: error: 'memcpy' call operates on objects of type 'char' while the size is based on a different type 'char *' [-Werror,-Wsizeof-pointer-memaccess]
          memcpy(out, str, sizeof(out));
                 ~~~              ^~~
  ../subprojects/wlroots/util/uuid.c:29:26: note: did you mean to provide an explicit length?
          memcpy(out, str, sizeof(out));

Fixes #2616
2021-01-08 20:51:51 +01:00
Ilia Bozhinov 37602e153b types: add wlr_xdg_foreign_registry 2021-01-05 20:32:56 +01:00
Ilia Bozhinov bf4e2e0eac util: add support for generating UUIDs
Co-authored-by: Jason Francis <cycl0ps@tuta.io>
2021-01-05 20:32:56 +01:00
Simon Ser f0c1b32120 util/time: add timespec_from_nsec 2020-12-18 10:37:08 +01:00
Simon Ser 00ccb89288 util/region: add wlr_region_scale_xy 2020-06-17 09:10:54 -06:00
Tudor Brindus 363bf44a35 util/time: move `timespec_sub` to time utilities 2020-06-06 00:09:19 +02:00
Tudor Brindus c9c31f803e util/time: de-duplicate `timespec_to_msec` 2020-06-06 00:09:19 +02:00
Tudor Brindus dc13bb827d util: fix and move `get_current_time_msec` into a util file
This commit makes `get_current_time_msec` correctly return milliseconds
as opposed to microseconds. It also considers the value of `tv_sec`, so
we don't lose occasionally go back in time by one second. Finally, the
function is moved into `util/time.cc` so that it can be reused elsewhere
without having to consider these pitfalls.
2020-06-06 00:09:19 +02:00
Tudor Brindus 5c942bd597 util/log: use bright black rather than black for WLR_DEBUG
On some terminals under default settings, black is truly rendered as
`#000`, making it unreadable when the background is also black.

Refs swaywm/sway#5141.
2020-05-24 14:53:40 +02:00
Simon Ser 904312a0b2 util/log: write log importance
When colors aren't used, write the log importance to stderr. This makes
it easier to grep for errors and avoids mistaking error messages for
debug messages.
2020-05-01 16:45:57 +02:00
Simon Ser e7f8cc6801 util/log: improve time prefix
Log milliseconds. This is useful when debugging a rendering loop.

Print the time relative to the compositor start-up.
2020-03-07 00:25:01 +01:00
Manuel Stoeckl f22a5d1704 Fix output rotation direction
The Wayland protocol specifies output transform rotations to be
counterclockwise and applied to the surface. Previously, wlroots
copied Weston and incorrectly made rotations act clockwise on
surfaces. This commit fixes that.

This change will break compositors which expect transform rotations
to be clockwise, and the rare applications that make use of surface
transforms.
2020-02-17 21:43:05 +01:00
Simon Ser 29726e6816 util: add wlr_output_destroy_safe
This adds a generic helper to destory transient globals.

See [1]. This patch depends on [2] and [3].

[1]: https://gitlab.freedesktop.org/wayland/wayland/issues/10
[2]: https://gitlab.freedesktop.org/wayland/wayland/merge_requests/28
[3]: https://gitlab.freedesktop.org/wayland/wayland/merge_requests/30
2020-02-17 20:52:37 +01:00
Scott Anderson cff1c2f740 meson: Various improvements
Bumps minimum version to 0.51.0

- Remove all intermediate static libraries.
  They serve no purpose and are just add a bunch of boilerplate for
  managing dependencies and options. It's now managed as a list of
  files which are compiled into libwlroots directly.

- Use install_subdir instead of installing headers individually.
  I've changed my mind since I did that. Listing them out is annoying as
  hell, and it's easy to forget to do it.

- Add not_found_message for all of our optional dependencies that have a
  meson option. It gives some hints about what option to pass and what
  the optional dependency is for.

- Move all backend subdirectories into their own meson.build. This
keeps some of the backend-specific build logic (especially rdp and
session) more neatly separated off.

- Don't overlink example clients with code they're not using.
  This was done by merging the protocol dictionaries and setting some
  variables containing the code and client header file.
  Example clients now explicitly mention what extension protocols they
  want to link to.

- Split compositor example logic from client example logic.

- Minor formatting changes
2019-12-23 07:48:29 -05:00
Dorota Czaplejewicz fadd4706ed virtual_keyboard: Accept keycode 0 2019-11-27 16:49:12 +01:00
Antonin Décimo b400c26b23 Simplify check 2019-08-12 09:37:21 +09: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
Manuel Stoeckl bb05617414 Use -fmacro-prefix-map to strip build path
This commit matches sway's 2dc4978d8af326c310057ca8fd22a4c7f5d09335.

To help ensure a reproducible build (when debug info is disabled),
the meson build script now uses the -fmacro-prefix-map command line
argument supported by GCC to strip the build-path dependent bytes
of each __FILE__ string used by wlr_log and related functions.

A rather ugly algorithm is used to compute the relative path between
the build and source folders, because meson has no specific function
for this.

When the compiler does not support -fmacro-prefix-map, fall back
to shifting the start of each __FILE__ string by the length of the
relative path to the source directory.
2019-07-17 21:00:09 -04:00
Ashkan Kiani 06a13203dd Use a set to track pointer button state.
In addition to `button_count`, we keep track of the current buttons
pressed just as in `wlr_keyboard`.

Add `set_add` and `set_remove` to assist with this. These functions can
only be used with values greater than 0 (such as the button/key masks
for keyboards and pointers).

Partially addresses:
- https://github.com/swaywm/wlroots/issues/1716
- https://github.com/swaywm/wlroots/issues/1593
2019-06-16 00:59:53 +03:00
emersion 43bd1d807a util/log: setup wayland log handler 2019-04-07 16:09:00 -06:00
sghctoma bc5e84225c Use ftruncate to set shared memory object's size
The posix_fallocate function should only be used with regular files.
2018-11-09 18:29:19 +01:00
sghctoma b25e230df8 Force ftruncate for shared mem. objects on FreeBSD
FreeBSD does not allow to use posix_fallocate on shared memory objects.
2018-11-08 13:48:21 +01:00
emersion 346ec21c4c
util: use shm_open for in-memory files
shm_open is a POSIX function creating an in-memory file. Using it simplifies
the code and removes the dependency on XDG_RUNTIME_DIR. The only downside is
that we need to generate a random name for the shm file.
2018-10-28 22:39:54 +01:00
Las afa2e399aa Fix implicit conversion of floats to ints in calls to pixman_region32_contains_point
I do not think the conversion is specifically defined, but on my system and SirCmpwn's
the floats are rounded instead of floored, which is incorrect in this case, since
for a range from 0 to 256, any value greater or equal to 0 and less than 256 is valid.
I.e. [0;256[, or 0 <= x < 256, but if x is e.g. -0.1, then it will be rounded to 0, which
is invalid. The correct behavior would be to floor to -1.
2018-09-18 13:05:44 +02:00
Las fa2e6e7d9d Implement pointer-constraints protocol in wlroots and rootston 2018-09-18 10:14:33 +02:00
random human e44ab5d584
Add function wlr_log_get_verbosity()
Returns the verbosity passed to wlr_log_init().
2018-09-01 21:03:52 +05:30
emersion a3b90bace3 util: include config in os-compatibility.c 2018-07-21 20:39:00 +01:00
emersion e02c486b60 Use posix_fallocate when available 2018-07-21 13:30:49 +01:00
Markus Ongyerth 74ca2f8fcf Another round of feedback from acrisci 2018-07-14 09:52:34 +02:00
emersion 7cbef15206
util: add wlr_ prefix to log symbols 2018-07-09 22:49:54 +01:00
Dominique Martinet 399de4d11b util/create_tmpfile: set restrictive umask for these files
Even if the file is removed right away, a race with someone using inotify
is definitely possible, so play safe and restrict umask for our tmpfiles

Found through static analysis.
2018-06-30 11:38:21 +09:00
emersion b0d99f5c67
Remove wlr_ prefix from local symbols 2018-04-25 23:00:46 +01:00
emersion 4555fc8a54
Fix damage tracking for rotated surfaces
It was broken because the damage extents were rotated about its
own center, not about the center of the surface.

This adds a new wlr_region_rotated_bounds that rotates regions.
This allows us to have only one code path (for both non-rotated
views and rotated views) and optimizes rendering for rotated
views.
2018-03-26 15:31:08 -04:00
Guido Günther 2688f6163f Rename _strip_path to wlr_strip_path
since it's a public function
2018-02-21 10:25:52 +01:00
Drew DeVault 1d9be89e2d
Revert "ELF Visibility" 2018-02-19 18:01:27 -05:00
Scott Anderson 86269052eb Explicitly export EFL symbols 2018-02-19 14:26:40 +13:00
emersion c2e1474010
Reformat all #include directives 2018-02-12 21:29:23 +01:00