summaryrefslogtreecommitdiff
path: root/shared
AgeCommit message (Collapse)AuthorFilesLines
2018-10-25Merge branch 'weston5.0' into tizenguanxw24-585/+1606
2018-07-09helpers: Move static_assert definition to sharedDaniel Stone1-0/+34
Collect the fallback definitions of static_assert() from desktop-shell and the test shell, and move them to helpers.h. This allows code throughout the tree to use static_assert() for build-time assertions, where it is supported by the compiler. As GCC goes out of its way to only add static_assert() when C11 has been explicitly requested - which we don't do - make sure to use the more widely available _Static_assert() if that is provided. This will be used in future patches to ensure two array lengths don't go out of sync. Signed-off-by: Daniel Stone <daniels@collabora.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2018-06-20shared: remove weston_config_get_libexec_dir()Pekka Paalanen2-14/+0
Now that WESTON_MODULE_MAP supersedes WESTON_BUILD_DIR for libexec binaries, we don't need to check in WESTON_BUILD_DIR anymore. There was only one user of weston_config_get_libexec_dir(), so remove the whole function. There is no reason to export it. Due to libshared.la being pulled into libweston, this probably was libweston ABI unintended. Regardless, libweston major has already been bumped. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Daniel Stone <daniels@collabora.com> Reviewed-by: Emre Ucan <eucan@de.adit-jv.com> Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
2018-02-20shared: Add timespec_eq helper functionAlexandros Frantzis1-0/+13
Add a helper function to check if two struct timespec values are equal. This helper function will be used in upcoming commits that implement the input_timestamps_unstable_v1 protocol. Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2018-02-09xwm: Fix icon surface ownershipEmmanuel Gil Peyrot2-0/+18
The cairo surface used for the icon must be completely given to the frame as soon as said frame has been created. To prevent both the window and the frame from sharing ownership of the icon, we set window->icon_surface back to NULL right after creating or changing the frame, only keeping it there when no frame has been created yet. Fixes https://lists.freedesktop.org/archives/wayland-devel/2018-January/036655.html Reported-by: Derek Foreman <derekf@osg.samsung.com> Tested-by: Derek Foreman <derekf@osg.samsung.com> Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
2018-02-09file-util: allow specifying path separately in file_create_dated()Aleksander Morgado2-8/+14
Instead of assuming the file prefix contains the path and filename prefix, give these two items separately. A NULL or empty string path may still be given to refer to the current directory. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Reviewed-by: Daniel Stone <daniels@collabora.com>
2018-02-07shared: Update all users of DATADIRDerek Foreman1-4/+29
Replace every use of DATADIR to create a filename with a call to the new function that allows overriding DATADIR with an env var at runtime. No attention is paid to asprintf failure. This restores make distcheck to a passing state after commit 6b58ea began checking cairo surfaces for validity and exchanged undefined behaviour we shouldn't have been dependent on for consistent test failure. Signed-off-by: Derek Foreman <derekf@osg.samsung.com> Acked-by: Daniel Stone <daniels@collabora.com> Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net> [Pekka: split if-branches into two lines] Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2018-02-07shared: Add a function to prefix filenames with datadirDerek Foreman2-0/+22
Currently we look for png files in their install directory, and we manufacture filenames with string pasting at compile time. This new function will allow overriding the compile time setting with the env var WESTON_DATA_DIR so we can do neat tricks like allow our test suite to pass when we haven't yet installed icons system-wide. Signed-off-by: Derek Foreman <derekf@osg.samsung.com> Acked-by: Daniel Stone <daniels@collabora.com> Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net> [Pekka: split if-branch into two lines.] Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2018-01-18xwm: Add icon support to the frameEmmanuel Gil Peyrot2-15/+41
This fetches the _NET_WM_ICON property of the X11 window, and use the first image found as the frame icon. This has been tested with various X11 programs, and improves usability and user-friendliness a bit. Changes since v1: - Changed frame_button_create() to use frame_button_create_from_surface() internally. - Removed a check that should never have been commited. Changes since v2: - Request UINT32_MAX items instead of 2048, to avoid cutting valid icons. - Strengthen checks against malformed input. - Handle XCB_PROPERTY_DELETE to remove the icon. - Schedule a repaint if the icon changed. Changes since v3: - Keep the previous Cairo surface until the new one has been successfully loaded. - Use uint32_t for cardinals. Unsigned is the same type except on 16-bit machines, but uint32_t is clearer. - Declare length as uint32_t too, like in xcb_get_property_reply_t. Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
2017-12-18shared: Add timespec_to_proto helper functionAlexandros Frantzis1-0/+24
Add helper function to convert from struct timespec values to tv_sec_hi, tv_sec_lo, tv_nsec triplets used for sending high-resolution timestamp data over the wayland protocol. Replace existing conversion code with the helper function. Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-12-18shared: Add timespec_from_proto helper functionAlexandros Frantzis1-0/+15
Add helper function to convert tv_sec_hi, tv_sec_lo, tv_nsec triplets, used for sending high-resolution timestamp data over the wayland protocol, to struct timespec values. Replace existing conversion code with the helper function. Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-12-05xwm: Use Pango to draw title string if availableLouis-Francis Ratté-Boulianne1-5/+55
If Weston is built with Pango, use it to render the title for X11 applications and Weston toy toolkit clients. It allows us to ellipsize the title when there isn't enough space to show the whole string. Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com> Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-12-05xwm: Deal with title in a smarter way when there isn't enough spaceLouis-Francis Ratté-Boulianne3-14/+26
The title in X11 windows and Wayland application using Weston toy toolkit were placing the title in a very naive fashion. It was only try to center the string in the title bar. This patch: * Makes sure the title isn't renderer underneath buttons; * Move the title to the left if the titlebar isn't large enough; * Clip the end of the title if needed. Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com> Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-12-04option-parser: replace int/0/1 with bool/false/trueEric Engestrom1-19/+20
These are already used as bools by all callers, let's make that official. Signed-off-by: Eric Engestrom <eric@engestrom.ch> Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-12-04config-parser: fix `short_name` typeEric Engestrom1-1/+1
This field is populated with chars, compared to chars and printed as a char. It should probably be a char. Signed-off-by: Eric Engestrom <eric@engestrom.ch> Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-11-27shared: Add helpers to convert between various time units and timespecAlexandros Frantzis1-0/+47
Add helper functions to make it easy and less error-prone to convert between values in various time units (nsec, usec, msec) and struct timespec. These helpers are going to be used in the upcoming commits to transition the Weston codebase to struct timespec. Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-11-27shared: Add timespec_is_zero helperAlexandros Frantzis1-0/+12
Add a helper function to check if a struct timespec is zero. This helper will be used in the upcoming commits to transition the Weston codebase to struct timespec. Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-10-02shared: struct timespec is in time.hYann E. MORIN1-0/+1
On the musl C library, tests/timespec-text.c does not build, with the following error: In file included from tests/timespec-test.c:36:0: ./shared/timespec-util.h:41:21: warning: ‘struct timespec’ declared inside parameter list will not be visible outside of this definition or declaration timespec_sub(struct timespec *r, ^~~~~~~~ [...] Indeed, struct timespec is defined in time.h, so we must include it. Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-09-29gl-renderer: Emit GPU rendering begin and end timeline timepointsAlexandros Frantzis1-0/+12
Use EGL fence sync objects to emit timepoints for the beginning and the end of rendering on the GPU. The timepoints are emitted asynchronously using the sync file fds associated with the fence sync objects. The sync file fds are acquired using the facilities provided by the EGL_ANDROID_native_fence_sync extension. The asynchronous timepoint submissions are stored in a list in gl_output_state until they are executed, and any pending submissions that remain at output destruction time are cleaned up. If timelining is inactive or the required EGL extensions are not present, then GPU timepoint processing and emission are skipped. Note that the GPU timestamps returned by sync files are in the CLOCK_MONOTONIC clock domain, and are thus compatible with the timeline timestamps (which also are in the CLOCK_MONOTONIC domain). Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com> Reviewed-by: Daniel Stone <daniels@collabora.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-09-29gl-renderer: Add support for fence sync extensionsAlexandros Frantzis1-0/+16
Check for the EGL_KHR_fence_sync and EGL_ANDROID_native_fence_sync extensions and get pointers to required extension functions. These extensions allow us to acquire GPU timestamp information asynchronously, and are required by the upcoming work to add rendering begin/end timepoints to the weston timeline. Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-06-12gl-renderer: allow importing fourth dmabuf planeVarad Gautam1-0/+5
EGL_EXT_image_dma_buf_import_modifiers supports importing upto four dmabuf planes into an EGLImage. v2: correct PLANE3_PITCH token (Daniel Stone) Signed-off-by: Varad Gautam <varad.gautam@collabora.com> Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-06-12gl-renderer: allow importing dmabufs with format modifiersVarad Gautam1-0/+6
pass over the modifier attributes to EGL. v2: ensure same modifier is passed for all planes (Daniel Stone) Signed-off-by: Varad Gautam <varad.gautam@collabora.com> Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-06-12gl-renderer: support format and modifier queriesVarad Gautam1-0/+7
EGL_EXT_image_dma_buf_import_modifiers allows querying the formats and modifiers supported by the platform. expose these to the compositor. v2: - change calloc args (Daniel Stone) - check for modifier support before querying formats (Daniel Stone) Signed-off-by: Varad Gautam <varad.gautam@collabora.com> Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-05-23weston: Add support for "--foo bar" style optionsLyude Paul1-0/+32
A little earlier today I ended up spending a lot of time trying to figure out why weston wasn't managing to launch over SSH and telling me that I did not have a --tty option specified, despite me passing the option strings ["--tty", "3"]. Turns out weston just doesn't support that. So, add support for this kind of format in addition to "--foo=bar" to save others from making the same mistake I did. Changes since v1: - Add comment about unreachable boolean check in long_option_with_arg() - Convert boolean check in long_option_with_arg() to assert Signed-off-by: Lyude <lyude@redhat.com> Reviewed-by: Eric Engestrom <eric@engestrom.ch> Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
2017-03-24os: Check for EINTR on ftruncate()Derek Foreman1-1/+3
The man page indicates that ftruncate() can set errno to EINTR, so test for this. I have not actually been able to provoke an EINTR error from ftruncate() in testing though. Signed-off-by: Derek Foreman <derekf@osg.samsung.com> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
2017-03-24os: Check for EINTR on posix_fallocate()Derek Foreman1-1/+3
posix_fallocate() can return EINTR and need to be restarted - I've hit this when running weston-terminal under gdb. Signed-off-by: Derek Foreman <derekf@osg.samsung.com> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
2017-03-13timespec: Add timespec subtraction helpersDaniel Stone1-0/+26
Add helpers to subtract two timespecs, then return the difference in either milliseconds or nanoseconds. These will be used to compare timestamps during the repaint cycle. Signed-off-by: Daniel Stone <daniels@collabora.com> Suggested-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-03-13timespec: Add timespec_to_msec helperDaniel Stone1-0/+13
Paralleling timespec_to_nsec, converts to milliseconds. Signed-off-by: Daniel Stone <daniels@collabora.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> [Pekka: added doc about flooring] Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-03-08timespec: Add timespec_add_msec helperDaniel Stone1-0/+12
Add a (timespec) = (timespec) + (msec) helper, to save intermediate conversions in its users. Signed-off-by: Daniel Stone <daniels@collabora.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-03-08timespec: Add timespec_add_nsec helperDaniel Stone1-0/+21
Add a (timespec) = (timespec) + (nsec) helper, to save intermediate conversions to nanoseconds in its users. Signed-off-by: Daniel Stone <daniels@collabora.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-02-21config-parser: Export weston_config_next_sectionEmmanuel Gil Peyrot1-0/+1
This symbol wasn’t exported from the weston binary, most likely due to an oversight in 6e2c12496bbef3cc913cfe9d5f0aeb4d8b23b368, and because internal modules can link against libshared.la directly it hasn’t been found ever since. This commit makes it possible for external modules to iterate over the configuration file. Signed-off-by: Emmanuel Gil Peyrot <emmanuel.peyrot@collabora.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Acked-by: Bryce Harrington <bryce@osg.samsung.com>
2017-01-30Move weston-egl-ext.h to sharedDaniel Stone1-0/+170
Given that it's used by clients, it's really the very definition of shared. Signed-off-by: Daniel Stone <daniels@collabora.com> Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
2017-01-03shared: fix a typo in a commentAbdur Rehman1-1/+1
Signed-off-by: Abdur Rehman <arehmanq199@gmail.com> Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
2017-01-03shared/helpers.h: fix a typo in a commentAbdur Rehman1-1/+1
Signed-off-by: Abdur Rehman <arehmanq199@gmail.com> Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
2016-11-21shared/platform.h: introduce weston_platform_destroy_egl_surface()Emil Velikov1-0/+14
Introduce the weston_platform_destroy_egl_surface() wrapper to complement the weston_platform_create_egl_surface() one. We'll use the former with the next patches trhoughout weston to consistently destroy the surface as needed. Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Reviewed-by: Daniel Stone <daniels@collabora.com>
2016-09-26shared/platform: include weston-egl-ext.h only if ENABLE_EGL is definedKrzysztof Konopko1-1/+1
Including `weston-egl-ext.h` causes compilation failure for configurations with EGL disabled. Verified with `--disable-egl`, `--disable-x11-compositor` and `--disable-drm-compositor`. Signed-off-by: Krzysztof Konopko <kris@youview.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-09-24string-helpers.h: Fix usage on musl libcKylie McClain1-0/+1
On musl, int32_t is defined in stdint.h. Signed-off-by: Kylie McClain <kylie@somasis.com> Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
2016-09-24share/cairo-util: Use wl_pointer_button_state enum directlyQuentin Glidic2-13/+9
This silences two warnings: clients/window.c:2450:20: warning: implicit conversion from enumeration type 'enum wl_pointer_button_state' to different enumeration type 'enum frame_button_state' [-Wenum-conversion] button, state); ^~~~~ clients/window.c:2453:15: warning: implicit conversion from enumeration type 'enum wl_pointer_button_state' to different enumeration type 'enum frame_button_state' [-Wenum-conversion] button, state); ^~~~~ Warning produced by Clang 3.8. Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net> Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com>
2016-08-27config-parser: Drop debug textBryce Harrington1-1/+0
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
2016-08-15shared/image: Silence maybe-uninitialized warningQuentin Glidic1-2/+1
shared/image-loader.c: In function 'load_image': shared/image-loader.c:434:12: warning: 'image' may be used uninitialized in this function [-Wmaybe-uninitialized] } else if (!image) { ^ Warning produced by GCC 5.3 and 6.1, with -Og. Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net> Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com>
2016-08-14desktop-shell: Port to libweston-desktopQuentin Glidic1-0/+11
All the shell protocol details, Xwayland glue and popups (and their grab) are now handled in libweston-desktop. Fullscreen methods (for wl_shell) are removed for now. Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net> Reviewed-by: Jonas Ådahl <jadahl@gmail.com> Acked-by: Giulio Camuffo <giulio.camuffo@kdab.com> Differential Revision: https://phabricator.freedesktop.org/D1209
2016-08-06Switch to use safe_strtoint instead of strtolBryce Harrington2-8/+4
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-08-06Add safe_strtoint() helperBryce Harrington1-0/+70
Adds a safe strtol helper function, modeled loosely after Wayland scanner's strtouint. This encapsulates the various quirks of strtol behavior, and streamlines the interface to just handling base-10 numbers with a simple true/false error indicator and a uint32_t return by reference. Test cases are loosely derived from an earlier patch by Imran Zaman. Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-08-06option-parser: Improve error checking for strtol callBryce Harrington1-2/+9
Make the error checking consistent with other strtol() calls. Note that since strtol(nptr, &endptr) sets endptr == nptr if there were no digits, this catches the case where the string was blank, so there's no need to test *value != '\0'. Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-07-26include stdint.h for int32_t/uint32_tJussi Kukkonen6-0/+7
Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com> Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
2016-07-26Re-apply "config-parser: Catch negative numbers assigned to unsigned config ↵Bryce Harrington1-1/+11
values" [With hexadecimal color values now handled via their own routine, re-introduce the negative unsigned numbers fix.] strtoul() has a side effect that when given a string representing a negative number, it treats it as a high value hexadecimal. IOW, strtoul("-42", &val) sets val to 0xffffffd6. This could potentially result in unintended surprise behaviors. Catch this by using strtol() and then manually check for the negative value. This logic is modelled after Wayland's strtouint(). Note that this change unfortunately reduces the range of parseable numbers from [0,UINT_MAX] to [0,INT_MAX]. The current users of weston_config_section_get_uint() are anticipating numbers far smaller than either of these limits, so the change is believed to have no impact in practice. Also add a test case for negative numbers that catches this error condition. Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2016-07-26config-parser: Add weston_config_section_get_colorBryce Harrington2-0/+43
Previously weston_config_section_get_uint was serving dual purpose for parsing both unsigned decimal integer values (ids, counts, seconds, etc.) and hexadecimal values (colors), by relying on strtoul's auto-detection mechanism. However, this usage is unable to catch certain kinds of error conditions, such as specifying a negative number where an unsigned should be used. And for colors in particular, it would misparse hex values if the leading 0x was omitted. E.g. "background-color=99999999" would render a near-black background (effectively 0x05f5e0ff) instead of medium grey, and "background-color=ffffffff" would be treated as an error rather than white. "background-color=0x01234567", "background-color=01234567", and "background-color=1234567" each resulted in the value being parsed as hexadecimal, octal, and decimal respectively, resulting in colors 0x01234567, 0x00053977, and 0x0012d687 being displayed. This new routine forces hexadecimal to be used in all cases when parsing color values, so "0x01234567" and "01234567" result in the same color value, "99999999" is grey, and "ffffffff" is white. It also requires exactly 8 or 10 digits (other lengths likely indicate typos), or the value "0" (black). Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2016-07-22shared/platform.h: remove the local EGL platform (re)definitionsEmil Velikov1-13/+1
Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Reviewed-by: Daniel Stone <daniels@collabora.com>
2016-07-22shared/platform.h: use weston_check_egl_extension over strstrEmil Velikov1-3/+3
The later can give false positives. Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Reviewed-by: Daniel Stone <daniels@collabora.com>
2016-07-22gl-renderer: move check_extension() to shared/Emil Velikov1-0/+28
... prefixing it with a "weston_". This way we can reuse it across the board, instead of the current strstr. The latter of which can give us false positives, thus it will be resolved with next commit(s). Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Reviewed-by: Daniel Stone <daniels@collabora.com>