summaryrefslogtreecommitdiff
path: root/shared
AgeCommit message (Collapse)AuthorFilesLines
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>
2016-07-22shared/platform.h: add missing stdbool.h includeEmil Velikov1-0/+1
Required by the bool type, used through the header. Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Reviewed-by: Daniel Stone <daniels@collabora.com>
2016-07-13Revert "config-parser: Catch negative numbers assigned to unsigned config ↵Bryce Harrington1-11/+1
values" The reduction in range limits does have an effect for color values, which are expressed as hexadecimal values from 0x00000000 to 0xFFFFFFFF. By limiting the range to INT_MAX, color values of 0x80000000 and up are in fact lost. This reverts commit 6351fb08c2e302f8696b2022830e5317e7219c39. Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Yong Bakos <ybakos@humanoriented.com> Acked-by: Derek Foreman <derekf@osg.samsung.com> Tested-by: Yong Bakos <ybakos@humanoriented.com>
2016-07-12Require base-10 for strtol() callsBryce Harrington1-1/+1
The third arg to strtol() specifies the base to assume for the number. When 0 is passed, as is currently done in option-parser.c, hexadecimal and octal numbers are permitted and automatically detected and converted. This change is an expansion of f6051cbab84c0e577473b67f0585c0f329eb80fe to cover the remaining strtol() calls in Weston, where the routine is being used to read fds and pids - which are always expressed in base-10. It also changes the calls in config-parser, used by weston_config_section_get_int(), which in turn is being used to read scales, sizes, times, rates, and delays; these are all expressed in base-10 numbers only. The benefit of limiting this to base-10 is to eliminate surprises when parsing numbers from the command line. Also, by making the code consistent with other usages of strtol, it may make it possible to factor out the common code in the future. Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-07-12config-parser: Catch negative numbers assigned to unsigned config valuesBryce Harrington1-1/+11
strtoul() has a side effect that when given a string representing a negative number, it returns a negated version as the value, and does not flag an error. IOW, strtoul("-42", &val) sets val to 42. This could potentially result in unintended surprise behaviors, such as if one were to inadvertantly set a config param to -1 expecting that to disable it, but with the result of setting the param to 1 instead. 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-11Remove a wrong closing “extern "C"” in shared/xalloc.cEmmanuel Gil Peyrot1-5/+0
Signed-off-by: Emmanuel Gil Peyrot <emmanuel.peyrot@collabora.com> Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2016-07-08option-parser: Require integer option string values to be base-10Bryce Harrington1-2/+2
The third arg to strtol() specifies the base to assume for the number. When 0 is passed, as is currently done in option-parser.c, hexadecimal and octal numbers are permitted and automatically detected and converted. In weston and the weston clients and tests using option-parser.c, the options are all things that can be expected to be specified in base 10: widths, heights, counts, scales, font sizes, ports, ttys, connectors, etc. The subsurfaces client uses two modes, limited to values 0 and 1 only. The zuc testsuite has a --random parameter for specifying a seed, which is the only option where using hexadecimal or octal numbers might conceivably happen. The benefit of limiting this to base-10 is to eliminate surprises when parsing numbers from the command line. Also, by making the code consistent with other usages of strtol/strtoul, it may make it possible to factor out the common code in the future. Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
2016-07-08config-parser: Improve error checks for strtol/strtoul callsBryce Harrington1-2/+4
Check errno, which is set of over/underflow, out of range, etc. Also check for empty strings (the usages covered in this patch already also cover the case where there are non-digits present). Set errno to 0 before making the strto*l call in case of pre-existing errors (i.e. ENOTTY when running under the testsuite). This follows the error checking style used in Wayland (c.f. wayland-client.c and scanner.c). In tests, also check errno, and add testcases for parsing '0'. Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2016-03-17shared: Print .c file/line number in x* routinesBryce Harrington1-24/+4
Switches from inline to pre-processor definitions in order to utilize __FILE__ and __LINE__ from the .c file in order to display the location of memory allocation failures when failing. Now xmalloc, et al calls will produce: [weston-info] clients/weston-info.c:714: out of memory (1024) Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-03-17clients & tests: Unify multiple definitions of x*alloc and related functionsBryce Harrington2-0/+124
Direct fail_on_null calls now produce output like: [weston-info] clients/weston-info.c:714: out of memory xmalloc, et al produce output on failure like: [weston-info] out of memory (-1) Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-03-08platform: explicitly cast the return value of ↵Matthias Treydte1-4/+6
weston_platform_get_egl_proc_address This allows the header to be consumed by C++ compilers, because C++ does away with C's implicit cast from (void*). Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2016-03-08option-parser: Handle short double-arg optionsBryce Harrington1-3/+38
weston allows both short and long style options to take arguments. In the case of short options, allow an optional space between the option name and value. E.g., previously you could launch weston this way: weston -i2 -cmyconfig.ini now you can also launch it like this: weston -i 2 -c myconfig.ini Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
2016-03-07configure: Make jpeglib an optional dependency.Emmanuel Gil Peyrot1-7/+23
It doesn’t make sense to fail the entire build when jpeglib isn’t present, so this commit makes it optional just like libwebp in the previous one, disabled with --without-jpeg and forced with --with-jpeg. Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2016-02-22config-parser: Check malloc and strdup returnsBryce Harrington1-0/+22
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com> Reviewed-by: Marek Chalupa <mchqwerty@gmail.com>
2016-02-19configure: Make WebP support togglable, and improve its error message.Emmanuel Gil Peyrot1-2/+9
The current way was enabling WebP support whenever libwebp was found, giving no way to the user to disable it if they had the library installed but didn’t want to link against it. This adds a --without-webp configure option to never link against it, and a --with-webp one to fail the build if it isn’t found, the default being to use it if it is present. Additionally, we now tell the user when WebP support has been disabled and they try to load a WebP file. Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-12-08cairo-util: return theme location from frame_touch_downDerek Foreman2-9/+10
I'll be using this in a follow up patch that adds touch input to weston's wayland backend. Reviewed-by: Daniel Stone <daniels@collabora.com> Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
2015-11-13shared: work around EGL header idiosyncrasyAhmet Acar1-0/+1
When no X11 headers are present eglplatform.h will break unless certain defines are set prior to its inclusion. including wayland-egl.h defines WL_EGL_PLATFORM which will stop the attempted inclusion of the X11 headers. Maybe this isn't the best solution to the problem, but it's harmless and gets the job done. Closes bug: https://bugs.freedesktop.org/show_bug.cgi?id=92104 Reviewed-by: Derek Foreman <derekf@osg.samsung.com> (patch by Ahmet Acar, commit log by Derek Foreman)
2015-07-16log: Open log file CLOEXEC so child processes don't get the fdDerek Foreman2-8/+17
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Bryce Harrington <bryce@osg.samsung.com> Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
2015-07-16compositor,shared: add millihz_to_nsec()Pekka Paalanen1-0/+14
A helper to improbe readability. Cc: Daniel Stone <daniels@collabora.com> Cc: Mario Kleiner <mario.kleiner.de@gmail.com> Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2015-07-16shared: introduce timespec-util.hPekka Paalanen1-0/+61
Copyright is set according to the moved code from compositor.c. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2015-06-15Unified multiple definitions of container_of() macro.Jon Cruz2-4/+38
Removed duplicate definitions of the container_of() macro and refactored sources to use the single implementation. Signed-off-by: Jon A. Cruz <jonc@osg.samsung.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-06-15Moved the MIN() macro to the helper include.Jon Cruz1-0/+11
Removed multiple definitions of the MIN() macro from existing locations and unified with a single definition. Updated sources to use the shared version. Signed-off-by: Jon A. Cruz <jonc@osg.samsung.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-06-15Moved helper macro to a discrete include file.Jon Cruz3-4/+50
To help reduce code duplication and also 'kitchen-sink' includes the ARRAY_LENGTH macro was moved to a stand-alone file and referenced from the sources consuming it. Other macros will be added in subsequent passes. Signed-off-by: Jon A. Cruz <jonc@osg.samsung.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-06-15shared: Update boilerplate from MIT X11 license to MIT Expat licenseBryce Harrington16-256/+304
2015-06-06Whitespace correctionsMurray Calavera1-1/+1
Signed-off-by: Murray Calavera <murray.calavera@gmail.com>
2015-03-30toytoolkit: fix EGL surface creation for lazy driversManuel Bachmann1-2/+3
Some DRI drivers, including VMware vmwgfx, do not support calling eglQueryString() with a EGL_NO_DISPLAY parameter. Allow toytoolkit to create EGL surfaces with them, by falling back to the old creation method. Signed-off-by: Manuel Bachmann <manuel.bachmann@open.eurogiciel.org> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2015-03-30toytoolkit: fix new EGL extensions fallback typedefsManuel Bachmann1-2/+7
The dummy typedefs for "get_platform_display()" and "create_platform_window()" were badly defined, which prevented building Weston on older systems. Signed-off-by: Manuel Bachmann <manuel.bachmann@open.eurogiciel.org> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2015-03-27Pass config file from compositor to everythingPekka Paalanen2-0/+17
We have the Weston command line option '--no-config' which is meant to prevent loading weston.ini at all. It works for Weston itself, but it does not work for any clients that also want to read weston.ini. To fix that, introduce a new environment variable WESTON_CONFIG_FILE. Weston will set it to the absolute path of the config file it loads. Clients will load the config file pointed to by WESTON_CONFIG_FILE. If the environment variable is set but empty, no config file will be loaded. If the variable is unset, things fall back to the default "weston.ini". Note, that Weston will only set WESTON_CONFIG_FILE, it never reads it. The ability to specify a custom config file to load will be another patch. All programs that loaded "weston.ini" are modified to honour WESTON_CONFIG_FILE. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Jonny Lamb <jonny.lamb@collabora.co.uk> Reviewed-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp> Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-03-27shared: fail reading a directory as a config filePekka Paalanen1-0/+8
open() will happily open directories and other non-normal files. Attempting to parse them as config files makes no sense, so check that the opened file is indeed a regular file. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Jonny Lamb <jonny.lamb@collabora.co.uk> Reviewed-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp> Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-03-26platform: rename create_egl_window to create_egl_surfaceJonny Lamb1-6/+6
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2015-03-26platform: remove global variablesJonny Lamb1-26/+29
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2015-03-26platform: provide platform_base fallbacks and remove ifdefsJonny Lamb1-14/+33
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2015-03-20clients & tests: use eglCreatePlatformWindowSurfaceEXT when supportedJonny Lamb1-0/+23
Reviewed-by: Derek Foreman <derekf@osg.samsung.com> Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-03-20clients & tests: use eglGetPlatformDisplayEXT when supportedJonny Lamb1-0/+79
Reviewed-by: Derek Foreman <derekf@osg.samsung.com> Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-02-25shared: add file_create_dated() helperPekka Paalanen2-0/+158
For easy creation of unique new files. I'm looking at you, screenshooter. This code is based on timeline.c weston_timeline_do_open(). Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Tested-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp> Reviewed-by: Daniel Stone <daniels@collabora.com>
2014-11-19cairo-util: fix shadows for small clientsMarek Chalupa1-46/+83
If the client is small (< 128 pixels in any ward), then the shadows overlap and create dark lines behind clients. This is a problem mosly with pop-up menues. The lines become observable when the menu has less than three items. The other case is when the client doesn't restrict its size when resizing (try 'weston-eventdemo --max-width=1 --max-height=1' for example) This fixes a part of the bug: https://bugs.freedesktop.org/show_bug.cgi?id=78511 v2: - rework computing of the size of corners - rewrite some comments - rename tile_mask to render_shadow (in separate patch) Signed-off-by: Marek Chalupa <mchqwerty@gmail.com> Tested-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-11-19toytoolkit: rename tile_mask to render_shadowMarek Chalupa2-8/+8
This function is used and clearly designed only for drawing the shadows. Rename it so that it has name after what it does and also move some common code into the function. Signed-off-by: Marek Chalupa <mchqwerty@gmail.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-09-22clients: Maximize window when double touch on title barXiong Zhang2-0/+56
Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.com>
2014-09-11load_image: always print a message on failure if filename is not emptyBill Spitzak1-2/+12
It was rather inconsistent before. This may help users figure out why backgrounds and icons don't show up. A better api where the error can be queried might be nice, but this seems sufficient for current Weston use. [Pekka Paalanen: removed one stray space.] Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>