aboutsummaryrefslogtreecommitdiff
path: root/util
AgeCommit message (Collapse)Author
2024-02-15Define _POSIX_C_SOURCE globallySimon Ser
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-15util/log: drop unnecessary _XOPEN_SOURCESimon Ser
snprintf() is actually ISO C99. We still need POSIX for clock_gettime().
2023-11-23util/transform: add wlr_output_transform_coords()Simon Ser
We hand-roll this in multiple places.
2023-11-23util/transform: move over wl_output_transform helpersSimon Ser
These aren't really tied to wlr_output.
2023-11-22xdg-toplevel: check that title provided actually is UTF-8Manuel Stoeckl
While the xdg-shell protocol requires this, it does not yet have a dedicated error code for invalid titles; this commit makes wlroots send a generic error instead.
2023-10-26util/token: rename TOKEN_STRLEN to TOKEN_SIZESimon Ser
TOKEN_STRLEN is not actually the strlen() of the token. It's the size taken by the token included the final zero byte. Change the name to make this clearer, and remove unnecessary +1's.
2023-10-08util/addon: make wlr_addon_set_finish() saferKirill Primak
wl_list_for_each_safe() breaks if an item immediately after the current one is removed, see https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4358#note_2106260.
2023-10-05util: add struct to track union of rectanglesManuel Stoeckl
The new struct rect_union is designed to make it easier to efficiently accumulate a list of rectangles, and then operate on an exact cover of their union. Using rect_union, the times needed to added t rectangles, and then compute their exact cover will be O(t), and something between Ω(t) and O(t^2), depending on the rectangle arrangement. If one tries to do the same by storing a pixman_region32_t and updating it with pixman_region32_union_rect(), then total time needed would be between Ω(t^2) and O(t^3), depending on the input. Without changing the public API (data structure + rectangle ordering rules) for pixman_region32_t, it is impossible to improve its worst case time.
2023-07-07Use struct initializers instead of memset()Simon Ser
This is a bit more type-safe.
2023-06-29util/log: fix buffer overflowEvyatar Stalinsky
2023-06-05util: add timespec_to_nsecRose Hudson
2023-05-24util/box: transform empty boxes' originsKirill Primak
Not a huge fan of this, but changing this behavior would be a breaking change to a stable API. Fixes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3650
2023-05-23util/box: always treat NULL boxes as emptyKirill Primak
2023-05-23util/box: simplify empty box case in wlr_box_intersection()Kirill Primak
2023-05-23wlr_{box, fbox}_equal: Consider empty boxes NULLAlexander Orzechowski
2023-05-23wlr_{box, fbox}_equal: Handle NULLAlexander Orzechowski
2022-12-22addon: Remove extra newline from loggingAlexander Orzechowski
2022-12-22addon: Add more loggingAlexander Orzechowski
2022-12-22util/addon: ensure the set is empty after finishKirill Primak
2022-12-09util/region: forbid "shrinking" a region with wlr_region_expand()Kirill Primak
The logic isn't correct.
2022-12-06util/env: make env_parse_switch() return a size_tSimon Ser
This function is guaranteed to never return a negative value. This is important because we use arr[env_parse_switch(...)] in a few places.
2022-12-05addon: Allow NULL owner of addonKenny Levinsen
An owner is not always required or practical. Rather than have the user set a bogus owner in these cases, allow the user to set a NULL owner.
2022-11-25util/time: use int64_t return value for get_current_time_msec()Simon Ser
0xFFFFFFFF milliseconds is 4,294,967,295 ms so about 50 days. A little bit too close for comfort. Use int64_t instead of uint64_t to avoid C's implicit conversion footguns in computations.
2022-11-11util/region: constifySimon Ser
2022-08-29util/set: overhaulKirill Primak
2022-08-29util/array: unclutterKirill Primak
2022-08-22util: Introduce env helpersAlexander Orzechowski
2022-08-19util/array: Add array_realloc for wl_arrayKenny Levinsen
array_realloc will grow the array for the target size like wl_insert_add, but will also shrink the array if the target size is sufficiently smaller than the current allocation.
2022-08-18Remove wlr_signal_emit_safeAlexander Orzechowski
2022-08-15util/box: Introduce wlr_fbox_equalAlexander Orzechowski
2022-08-15util/box: Introduce wlr_box_equalAlexander Orzechowski
2022-06-07util/global: fix memory leak on display destroy in wlr_global_destroy_safeSimon Ser
If the display is destroyed before wlr_global_destroy_safe's timer fires, the struct destroy_global_data is leaked. This shouldn't cause issues in practice because the timer will never fire, but makes it harder to spot compositor memory leaks.
2022-05-24util: Fix infinite loop in recursive functionSteven Newbury
When testing Xwayland multi-HiDPI support with Wine + SimCity4 I encountered a 100% CPU lockup from sway. This turned out to be triggering a bug in the wlroots pointer contraint code. region_confine() contains multiple recursive calls where arguments are modified and resubmitted to the function. One of the calls is however made using the original arguments, if/when this triggers it results in the same codepath being followed each loop so the condition always applies. It makes much more sense if this was intended to apply the clamped values x,y instead of the original x1,y1, and indeed this fixes the infinite loop and results in correct behaviour.
2022-05-23util/addon: avoid calling finish() twiceKirill Primak
No functional change.
2022-05-12util/shm: clear mode permission bits in allocate_shm_file_pairSimon Ser
This ensures the file cannot be re-opened with write permissions. Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3429
2022-04-28Zero-initialize structs in init functionsSimon Ser
Ensures there is no field left to its previous undefined value after calling an init function.
2022-04-26util/addon: fix public includeSimon Ser
Everything in wlr/ is public and should be included via angle-bracket include directives.
2021-12-14util/global: remove wl_display arg from wlr_global_destroy_safeSimon Ser
Since [1], we can get the wl_display directly from the wl_global. [1]: https://gitlab.freedesktop.org/wayland/wayland/-/commit/2b22160fb690a76247aa9bd0be3069ff43e8239f
2021-11-14util/token: don't leak /dev/urandom fd to childrenRaphael Robatsch
Closes #3324.
2021-09-22util/box: introduce wlr_fbox_emptySimon Ser
Same as wlr_box_empty, but for wlr_fbox.
2021-09-05util/shm: add allocate_shm_file_pairSimon Ser
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-08-24util/box: introduce wlr_fbox_transform()Kirill Primak
A floating-point version of wlr_box_transform().
2021-08-11util/addon: find both by owner and implKirill Primak
This allows to have multiple addons of different types with the same owner.
2021-08-10util: add wlr_addonKirill Primak
2021-07-28util/time: make NSEC_PER_SEC staticDylan Araps
This fixes static linking with libseat. Closes #3072
2021-07-06move wlr_box from /types to /utilSimon Zeni
2021-07-01util/array: add array_remove_atSimon Ser
2021-04-11util/uuid: replace with util/token, remove libuuidRyan Farley
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-06build: simplify HAS_LIBUUID definitionSimon Ser
We can just use to_int() instead of having two if branches.
2021-02-15build: use dictionnary for features instead of configuration_dataSimon Ser
This allows us to easily iterate on all features and only deal with bools.