summaryrefslogtreecommitdiff
path: root/shared
Commit message (Collapse)AuthorAgeFilesLines
* frontend: Add FDSTR_INIT macroDaniel Stone2023-04-192-1/+3
| | | | | | This initialises fdstr to 'safe' values so we can reliably deinit them. Signed-off-by: Daniel Stone <daniels@collabora.com>
* clients: Add support for tablet cursor motion to window frames in libtoytoolkitLyude Paul2023-03-312-0/+42
| | | | | | | | | | | | | | When it comes to a window frame, a tablet tool and cursor act almost identical; they click things, drag things, etc. The tool type and extra axes don't serve any use in the context of a window frame, so tablet pointers share the frame_pointer structures used for the mouse pointer. Co-authored-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Lyude Paul <thatslyude@gmail.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Jonas Ådahl <jadahl@gmail.com> Signed-off-by: Bastian Farkas <bfarkas@de.adit-jv.com> Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
* shared/frame: add helper to get decoration sizes without shadowMichael Olbrich2023-03-222-2/+14
| | | | Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
* xwm: Add support for xwayland_shell_v1Derek Foreman2023-03-032-0/+2
| | | | | | Use the new protocol to prevent races in surface to window association. Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
* shared: extract hash table implementation from xwaylandMichael Tretter2023-03-033-0/+361
| | | | | | | The hash table implementation is useful for other modules as well. Move it from xwayland to the shared code. Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
* cairo-util: Add missing HAVE_PANGO guardMarius Vlad2023-02-201-0/+2
| | | | | | | | | For pango_cairo_font_map_set_default(). Fixes #720 Suggested-by: Pekka Paalanen <pekka.paalanen@collabora.com> Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
* matrix: Introduce weston_coordDerek Foreman2023-02-011-0/+16
| | | | | | | | | | | | | | | | | | | | | | All through weston we have code that passes int x, y or float x, y or wl_fixed_t x, y pairs. These pairs are frequently converted to/from wl_fixed_t and other types. We also have struct vec2d and struct weston_geometry which also contain coordinate pairs. Let's create a family of coordinate vector structures for coordinate pairs and use it anywhere we sensibly can. This has a few benefits - it helps remove intermediate conversion between fixed/float/int types. It lets us roll the homogenous coordinate normalization bits into helper functions instead of needing them open coded throughout the source. Possibly most importantly, it also allows us to do some compile time validation of what coordinate space we're working in. Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
* libweston/vertex-clipping: Use shared helperMarius Vlad2023-01-241-0/+13
| | | | | | And introduced a new helper, CLIP, with it. Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
* libweston: Factor out transform matrix setup codeDerek Foreman2023-01-161-0/+48
| | | | | | | We want to use this in other places too, instead of open coding it multiple times. Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
* libweston: Optimise matrix multiplicationEmmanuel Gil Peyrot2023-01-111-9/+9
| | | | | | | | | | | | | | The previous version used div() to separate the column and row of the current element, but that function is implemented as a libc call, which prevented the compiler from vectorising the loop and made matrix multiplication appear quite high in profiles. With div() removed, we are down from 64 calls to vfmadd132ss acting on one float at a time, to just 8 calls to vfmadd132ps when compiled with AVX2 support (or 16 mulps, 16 addps with SSE2 support only), and the function isn’t a hot spot any more. Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
* build: Add unreachable()Daniel Stone2023-01-101-0/+20
| | | | | | | unreachable() is used to hint to the compiler that a certain branch cannot ever be reached. The implementation is taken from Mesa. Signed-off-by: Daniel Stone <daniels@collabora.com>
* doc/sphinx: Include weston-config and shell-utils in docsMarius Vlad2023-01-091-0/+42
| | | | | | | libweston contains weston_config and weston_shell_utils utilities functions so include these in the sphinx documentation as well. Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
* libweston, shared: Move out weston_shell_get_binding_modifierMarius Vlad2023-01-092-1/+33
| | | | | | | | This doesn't really belong into shell-utils, so better move it out to shared/config-parser. Renamed to weston_config_get_binding_modifier to maintain the same namespace. Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
* libweston: Add function to find the output transform of a matrixDerek Foreman2022-11-251-0/+121
| | | | | | | | | | | | | | | When we build up a matrix from a series of operations, it's very useful to know if the combined operations still result in something that matches a wl_output_transform. This adds a function to test if a matrix leads to a standard output transform, and returns the transform if it does. Tests are provided that check if complex series of operations return expected results - the weston_matrix_needs_filtering function is tested at the same time. Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
* libweston: Add a function to test if transformed images need filtersDerek Foreman2022-11-251-0/+125
| | | | | | | | | | | If a transformation matrix causes a scale, a rotation not a multiple of 90 degrees or a non-integral translation then textures rendered with it would benefit from bilinear filtering. This test is done in a lazy fashion by examining elements of the matrix to check for a simple pattern that indicates these conditions are met. Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
* shared/cairo-util: Release any fontmap laying aroundMarius Vlad2022-11-101-0/+4
| | | | | | | | | | | | This is particularly useful when using the weston-editor which seems to cause an issue with cairo_debug_reset_static_data(), as that still seems to find out there are references laying around, causing a crash when exiting: ../../../../src/cairo-hash.c:217: _cairo_hash_table_destroy: Assertion `hash_table->live_entries == 0' failed Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
* shared/cairo-util: Re-use the PangoContext for layout creationMarius Vlad2022-11-102-11/+21
| | | | | | | | | | | | | Rather than creating a new PangoContext each time the menu redraw handler is triggered re-use it if one was created previously. All toytoolkit clients do create a layout (and implicitly a PangoContext) but only those that have menu redraw handler installed will create a new layout for each redraw of the menu, effectively creating a new PangoContext each time. Reported-by: Pekka Paalanen <pekka.paalanen@collabora.com> Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
* shared/cairo-util: Zero out the memory when creating a new themeMarius Vlad2022-11-101-3/+2
| | | | | | | Having the memory zeroed out just works better and avoids any possible illegal access. Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
* shared/cairo-util: Do not save/restore the cairo context twiceMarius Vlad2022-11-101-3/+0
| | | | | | | We are already doing that before calling theme_render_frame() so no need to do it again in layout creation. Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
* helpers: Add a u64 from 2 u32 helperDerek Foreman2022-10-272-1/+10
| | | | | | | We do this enough that having a single implementation for it is probably a win. Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
* matrix: Make matrix const in weston_matrix_transformDerek Foreman2022-09-231-1/+2
| | | | | | | This function doesn't need to change the matrix, so we might as well enforce that. Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
* compositor/shared: Suppress write(2) warningsMarius Vlad2022-09-231-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Fixes the following warnings when building with _FORTIFY_SOURCE and optimizations enabled: ../shared/xalloc.h:49:9: error: ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result] 49 | write(STDERR_FILENO, oommsg, strlen(oommsg)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ or ../compositor/main.c:427:25: error: ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result] 427 | write(STDERR_FILENO, fail_seteuid, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 428 | strlen(fail_seteuid)); | ~~~~~~~~~~~~~~~~~~~~~ ../compositor/main.c:434:25: error: ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result] 434 | write(STDERR_FILENO, fail_cloexec, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 435 | strlen(fail_cloexec)); | ~~~~~~~~~~~~~~~~~~~~~ ../compositor/main.c:442:25: error: ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result] 442 | write(STDERR_FILENO, fail_exec, strlen(fail_exec)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
* xwm: Perform a roundtrip to send a deferred WM_TAKE_FOCUSDerek Foreman2022-08-082-0/+2
| | | | | | | | | | | WM_TAKE_FOCUS requires a valid timestamp that isn't XCB_TIME_CURRENT. To get one, we set a property on the window and wait for the notification that it was set - this notification comes with a valid timestamp. Once we have that timestamp, delete the property, and fire off the slightly delayed WM_TAKE_FOCUS client request. Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
* shared/xalloc.h: do not rely on zalloc()Pekka Paalanen2022-07-201-3/+1
| | | | | | | | | | | | The definition of zalloc is trivial, so let's just have it here instead of loading libweston/zalloc.h. Now xalloc.h does not depend on any libweston header, which makes me feel slightly better. It's more clean. Who knows, maybe one day libweston/zalloc.h will be removed. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
* shared: rewrite fail_on_null() as abort_oom_if_null()Pekka Paalanen2022-07-201-19/+17
| | | | | | | | | | | | | | | | | | | | | Recently I learnt that fprintf() is not async-signal-safe. Maybe it also attempts to allocate memory sometimes. Hence, using it when we presumably are out of memory is wishful thinking. Therefore replace that with async-signal-safe code. If you have to check pointers from traditional signal handlers, now you could do that too! While doing this, we also lose the string formatting for line number. I would argue that printing file and line number is not that useful, if the system really is out of memory. If not out of memory, a core dump would give us much more detailed information about what went wrong. clients/window.c had some calls to fail_on_null() and these are simply replaced. They were used for checking that creating new wl_proxy by issuing a protocol request worked, and IIRC that only fails on out-of-memory, so the same rationale applies here. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
* ivi-shell: replace MEM_ALLOC() with mostly xcalloc()Pekka Paalanen2022-07-201-0/+1
| | | | | | | | | | | | | | | Drop the even more home-grown alloc wrapper and use the xalloc.h wrappers directly. xcalloc() is added and used, because calloc() will detect integer overflows in the size multiplication, while doing a simple multiplication in the caller is subject to overflows which may result in allocating not what was expected, subjecting to out-of-bounds access. All MEM_ALLOC() calls that had a meaningful multiplication in them were converted to xcalloc(), the rest to xzalloc(). Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
* custom-env: Add helper to parse combined env/arg stringsDaniel Stone2022-07-192-0/+84
| | | | | | | | | | Users like desktop-shell want to parse a provided string containing a combination of environment and arg, e.g.: ENV=stuff /path/to/thing --good Add support to custom-env for parsing this, with tests, so we can delete the custom implementation inside desktop-shell. Signed-off-by: Daniel Stone <daniels@collabora.com>
* custom-env: Add support for argument arrayDaniel Stone2022-07-192-4/+48
| | | | | | | | | | execve() takes the same form for arguments as environment: an array of constant pointers to mutable strings, terminated by a NULL. To make it easier for users who want to build up their own argument strings to pass to execve, add support for argument arrays to custom_env. Signed-off-by: Daniel Stone <daniels@collabora.com>
* custom-env: Prepare for handling args as well as environmentDaniel Stone2022-07-192-20/+20
| | | | | | | | | Rename the bits handling environment variables (currently, all of it), so we have room to handle args as well. No functional changes. Signed-off-by: Daniel Stone <daniels@collabora.com>
* process-util: Assert we don't finalize twiceDaniel Stone2022-07-191-0/+2
| | | | | | Make sure that we only try to finalize once. Signed-off-by: Daniel Stone <daniels@collabora.com>
* process-util: Move Xwayland fork helpers to sharedDaniel Stone2022-07-193-0/+235
| | | | | | | We'll want to reuse these inside desktop-shell as well as the Weston frontend. Signed-off-by: Daniel Stone <daniels@collabora.com>
* shared: introduce os_fd_clear_cloexec()Pekka Paalanen2022-07-122-0/+18
| | | | | | | This function will be used between fork() and exec() to remove the close-on-exec flag. The first user will be compositor/xwayland.c. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
* shared: fcntl uses int, not longPekka Paalanen2022-07-121-1/+1
| | | | | | | | | fcntl(2) manual says the return type is int, and that F_SETFD takes an int. So use int. Noticed by code inspection. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
* tests: Use memstream for config-parser testDaniel Stone2022-07-051-36/+65
| | | | | | | Using real files is unnecessarily heavy and error-prone. Fixes timeouts seen on CI with ASan. Signed-off-by: Daniel Stone <daniels@collabora.com>
* cairo-util: Clean up more Cairo detritus; almost all of itDaniel Stone2022-06-293-2/+21
| | | | | | | | | Pango, Cairo, and fontconfig, all want to leave thread-global data hanging around in order to maintain a cache. Try to clean up as much of it as we possibly can on exit, apart from the Pango language string which appears to be unfreeable, so has been added to LSan suppressions. Signed-off-by: Daniel Stone <daniels@collabora.com>
* cairo-util: Don't leak Pango objectsDaniel Stone2022-06-291-1/+18
| | | | | | | Rework PangoCairo context initialisation, so we don't leak either the Pango layout, or any of the derived objects it creates. Signed-off-by: Daniel Stone <daniels@collabora.com>
* shared: Make xalloc.h stand aloneDerek Foreman2022-06-283-53/+18
| | | | | | | | | | Make fail_on_null static inline and put it in xalloc.h so we can use the header exclusively instead of having to link with the library for it. This is so we can use xalloc in places (like the RDP backend) without having to bring in libshared. Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
* shared/xcb-xwayland: Add missing atomsMarius Vlad2022-06-231-0/+13
| | | | | | | | | | | | Particularly important was _XWAYLAND_ALLOW_COMMITS atom which caused some annoying flicker when resizing or hoovering over buttons. This was introduced with 'shared/xcb-xwayland: Split into common helpers' and somehow I missed those atoms. Fixes 49d6532254fa27e3a28a3fb26d0b9d253d002125 Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
* xwayland/window-manager: Add support for _NET_FRAME_EXTENTSDerek Foreman2022-06-222-0/+2
| | | | | | | | | | | https://specifications.freedesktop.org/wm-spec/1.4/ar01s05.html says "The Window Manager MUST set _NET_FRAME_EXTENTS to the extents of the window's frame", so this is probably something we should be doing. Some programs (such as some versions of Firefox) expect this to be present, and will render popups in wrong locations if it's not. Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
* shared/frame: Provide a function to get decoration sizes and use itDerek Foreman2022-06-222-14/+31
| | | | | | | | | | We need these values to calculate frame extents to properly set _NET_FRAME_EXTENTS, but we don't want to calculate them twice. Break out these bits from frame_resize_inside, and update it to use the new function. Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
* xwayland: support minimizingHideyuki Nagase2022-06-222-0/+2
| | | | | | | | | | Allow minimizing xwayland windows. Co-authored-by: Steve Pronovost <spronovo@microsoft.com> Co-authored-by: Brenton DeGeer <brdegeer@microsoft.com> Signed-off-by: Hideyuki Nagase <hideyukn@microsoft.com> Signed-off-by: Steve Pronovost <spronovo@microsoft.com> Signed-off-by: Brenton DeGeer <brdegeer@microsoft.com>
* shared/xcb-xwayland: Split into common helpersMarius Vlad2022-06-223-0/+269
| | | | | | | | Avoid duplication of atom retrieval. This is particuarly useful if one would one to reuse atom retrival in other parts, like tests. Signed-off-by: Marius Vlad <marius.vlad@collabora.com> Suggested-by: Daniel Stone <daniel.stone@collabora.com>
* shared/cairo-util: Hold onto our pattern reference until we're doneDerek Foreman2022-06-091-1/+3
| | | | | | | | | | | This doesn't actually fix a bug - cairo refcounts this. But I really don't like the look of code that drops a reference then continues to use it. While we're here, set a different pattern when we're done so the one we allocated loses its last reference. Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
* libweston: remove UNIT_TESTPekka Paalanen2022-05-311-7/+2
| | | | | | | | | This #define was used only by the matrix-test program, which was removed in the previous commit. Remove it as unused and fold away MATRIX_TEST_EXPORT. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
* gl_renderer: print more GL ES feature flagsPekka Paalanen2022-05-181-0/+6
| | | | | | | This is a human readable replacement for printing out the list of all available GL extensions that doesn't happen anymore by default. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
* Move shell-utils to its own directoryDaniel Stone2022-03-312-272/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | shell-utils contains a number of helpers which are currently in use by both desktop-shell and kiosk-shell. In order to extend this use to fullscreen-shell as well (which can benefit from reusing the weston_curtain infrastructure to be able to create solid-colour views which may or may not be opaque, as well as one function within fullscreen-shell which was copied wholesale to shell-utils), we need to create a separate Meson dependency object, and avoid the existing pattern of including the source from shared/ within the source list for each shell. This requires creating a new top-level directory for these shared helper functions which are required by each shell, but are not part of libweston in and of itself. shell-utils depends on libweston-desktop; libweston-desktop depends on libweston; libweston depends on shared. Thus it is not possible to expose a dependency object from the shared/ directory which declares a dependency on the libweston-desktop dependency, as Meson processes directories in order and resolves variable references as they are parsed. In order to break this deadlock, this commit creates a new top-level directory called 'shell-utils' containing only this file, which can be parsed by Meson after libweston-desktop (making the libweston-desktop Meson dependency variable available to the build file to declare a dependency on that), but before the shells (making the new Meson depenendency object available to each shell which wishes to use it). This commit contains no functional changes to any observable code. Signed-off-by: Daniel Stone <daniels@collabora.com>
* shell: Encapsulate weston_curtain in its own structDaniel Stone2022-03-312-14/+40
| | | | | | | This will allow us to create a solid weston_buffer as well, since we need to store that separately. Signed-off-by: Daniel Stone <daniels@collabora.com>
* shell: Make input capture optional for curtainsDaniel Stone2022-03-312-2/+7
| | | | | | | desktop-shell's focus surfaces want to reuse this, but they don't want to capture the input, instead allowing it to fall through. Signed-off-by: Daniel Stone <daniels@collabora.com>
* shell: Add alpha to weston_curtain_createDaniel Stone2022-03-312-4/+11
| | | | | | | Not all solid-colour views want to be opaque: sometimes we use them with non-opaque alpha values in order to shade views underneath them. Signed-off-by: Daniel Stone <daniels@collabora.com>
* shell: Move weston_curtain_create params into the structDaniel Stone2022-03-312-8/+9
| | | | | | | | | | Given that we have a struct for argument params, we might as well use it rather than have them split between the struct and native params. For consistency between the implementations, this also includes a shift from float to int positioning for the base offset within the compositor's global co-ordinate space. Signed-off-by: Daniel Stone <daniels@collabora.com>