Commit graph

114 commits

Author SHA1 Message Date
Emil Velikov 07448943e5 shared/platform.h: remove the local EGL platform (re)definitions
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2016-07-22 15:29:19 +01:00
Emil Velikov d0fcdc955e shared/platform.h: use weston_check_egl_extension over strstr
The later can give false positives.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2016-07-22 15:28:45 +01:00
Emil Velikov f0c3a1c112 gl-renderer: move check_extension() to shared/
... 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-22 15:28:32 +01:00
Emil Velikov 10772dba04 shared/platform.h: add missing stdbool.h include
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-22 15:23:27 +01:00
Bryce Harrington 03793e3998 Revert "config-parser: Catch negative numbers assigned to unsigned config 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 6351fb08c2.

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-13 14:40:28 -07:00
Bryce Harrington 375759e636 Require base-10 for strtol() calls
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 f6051cbab8
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-12 18:46:13 -07:00
Bryce Harrington 6351fb08c2 config-parser: Catch negative numbers assigned to unsigned config values
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-12 15:50:05 -07:00
Emmanuel Gil Peyrot 7fc000c826 Remove a wrong closing “extern "C"” in shared/xalloc.c
Signed-off-by: Emmanuel Gil Peyrot <emmanuel.peyrot@collabora.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2016-07-11 13:22:37 -07:00
Bryce Harrington f6051cbab8 option-parser: Require integer option string values to be base-10
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-08 17:44:10 -07:00
Bryce Harrington cbc053781e config-parser: Improve error checks for strtol/strtoul calls
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-07-08 11:10:38 -07:00
Bryce Harrington ae5d7198f7 shared: Print .c file/line number in x* routines
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-17 14:17:02 +02:00
Bryce Harrington e99e4bf2b9 clients & tests: Unify multiple definitions of x*alloc and related functions
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-17 14:13:13 +02:00
Matthias Treydte cd9424ef2a platform: explicitly cast the return value of 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-08 23:23:26 -08:00
Bryce Harrington 38298ec0b4 option-parser: Handle short double-arg options
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-08 16:32:16 -08:00
Emmanuel Gil Peyrot 66e1614122 configure: Make jpeglib an optional dependency.
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-03-07 12:05:52 -08:00
Bryce Harrington 3f2062ccb2 config-parser: Check malloc and strdup returns
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Marek Chalupa <mchqwerty@gmail.com>
2016-02-22 13:30:51 -08:00
Emmanuel Gil Peyrot 58b7a156c5 configure: Make WebP support togglable, and improve its error message.
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>
2016-02-19 18:33:00 -08:00
Derek Foreman 9690641bfc cairo-util: return theme location from frame_touch_down
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-12-08 13:04:34 -06:00
Ahmet Acar 64d78bba9c shared: work around EGL header idiosyncrasy
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-11-13 10:25:46 -06:00
Derek Foreman 6bc33d63cf log: Open log file CLOEXEC so child processes don't get the fd
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-16 19:28:36 -07:00
Pekka Paalanen d7894d052a compositor,shared: add millihz_to_nsec()
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-16 13:55:05 +03:00
Pekka Paalanen aa21f6249f shared: introduce timespec-util.h
Copyright is set according to the moved code from compositor.c.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2015-07-16 13:55:05 +03:00
Jon Cruz 867d50eea7 Unified multiple definitions of container_of() macro.
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-15 17:11:58 -07:00
Jon Cruz d618f688d5 Moved the MIN() macro to the helper include.
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-15 17:11:52 -07:00
Jon Cruz 35b2eaa989 Moved helper macro to a discrete include file.
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-15 17:11:45 -07:00
Bryce Harrington 6c6164c5ba shared: Update boilerplate from MIT X11 license to MIT Expat license 2015-06-15 13:04:18 -07:00
Murray Calavera 883ac02d22 Whitespace corrections
Signed-off-by: Murray Calavera <murray.calavera@gmail.com>
2015-06-06 12:39:51 -07:00
Manuel Bachmann 5d1d2ca325 toytoolkit: fix EGL surface creation for lazy drivers
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-30 15:42:16 +03:00
Manuel Bachmann e812859527 toytoolkit: fix new EGL extensions fallback typedefs
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-30 15:26:15 +03:00
Pekka Paalanen 6c71aaeec5 Pass config file from compositor to everything
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-27 09:38:12 +02:00
Pekka Paalanen 49f6d62e9d shared: fail reading a directory as a config file
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-27 09:38:02 +02:00
Jonny Lamb abff883d2c platform: rename create_egl_window to create_egl_surface
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2015-03-26 09:54:49 +02:00
Jonny Lamb 759fbf4d0f platform: remove global variables
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2015-03-26 09:54:49 +02:00
Jonny Lamb 0e2ab36df7 platform: provide platform_base fallbacks and remove ifdefs
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2015-03-26 09:54:49 +02:00
Jonny Lamb 4bdcb5732b clients & tests: use eglCreatePlatformWindowSurfaceEXT when supported
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-03-20 13:57:24 -07:00
Jonny Lamb 51a7ae5f89 clients & tests: use eglGetPlatformDisplayEXT when supported
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-03-20 13:56:38 -07:00
Pekka Paalanen 899b50b126 shared: add file_create_dated() helper
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>
2015-02-25 14:47:50 +02:00
Marek Chalupa eaea470510 cairo-util: fix shadows for small clients
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-19 15:46:30 +02:00
Marek Chalupa 0d7fe8d925 toytoolkit: rename tile_mask to render_shadow
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-11-19 15:39:36 +02:00
Xiong Zhang 382de46a2f clients: Maximize window when double touch on title bar
Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.com>
2014-09-22 10:19:44 +03:00
Bill Spitzak 28371f7d55 load_image: always print a message on failure if filename is not empty
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>
2014-09-11 13:01:47 +03:00
Bill Spitzak 3011493e9b parse_options: fail on more malformed options
Fail on trailing text after numbers, such as --width=100mm

Fail on any text after booleans, such as --flag=false

Also fixed reading of memory after the null terminator of a long
option with no = sign in it.

[Pekka Paalanen: some whitespace style fixes.]

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-09-11 12:36:55 +03:00
Xiong Zhang bfb4ade1a0 clients: Maximize window when double click on title bar
Signed-off-by: Xiong Zhang <panda0626@gmail.com>
Tested-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-09-04 17:11:22 +03:00
Derek Foreman c7210434d4 tests: allow running make check without make install
desktop shell and weston keyboard both refer to themselves prefixed by
LIBEXECDIR, however this is only valid once installed.  make check will
currently either fail or run pre-existing versions.

This patch adds a way to override that location by setting the env var
WESTON_BUILD_DIR - which is then set by the test env script so make check
will test the versions in the build directory regardless of whether they're
installed or not.

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-08-22 17:47:33 +03:00
Boyan Ding 850a514137 cairo-util: Draw solid titlebar for frames with only buttons
Previously geometry was changed to leave space for titlebar if a frame
has only buttons but no title. This patch fixes theme_render_frame to
avoid transparent titlebar.

Signed-off-by: Boyan Ding <stu_dby@126.com>
2014-08-19 16:45:15 +03:00
Boyan Ding 9c5aedfff2 cairo-util: Set geometry_dirty in frame_set_title
Title can decide the geometry of a frame because it may affect the
existence of titlebar, so setting geometry_dirty in frame_set_title for
potential change.

Signed-off-by: Boyan Ding <stu_dby@126.com>
2014-07-05 01:05:07 -07:00
Boyan Ding c4902124f9 cairo-util: Fix geometry for frames with buttons but without title
There exist frames which have buttons without title such as a simple
X application piped through xwayland which doesn't specify a title.
We draw the title bar with buttons, but hide it under the window
because geometry thinks a window needs titlebar only if it has title.

This patch change the condition, making it titlebar is needed if a
frame has title or has button(s), which makes more sense.

Signed-off-by: Boyan Ding <stu_dby@126.com>
2014-07-05 01:05:06 -07:00
Jasper St. Pierre f11ad43ed0 cairo-util: Don't show a resize cursor on edges when we're maximized
This is substantially confusing to users, namely me.

krh: Edited to just set grip size to zero.
2014-04-30 21:02:37 -07:00
Jasper St. Pierre a4d9723341 cairo-util: Kill a duplicate test
If !(x < margin), then clearly margin <= x. No need to test for it again.
2014-04-30 20:54:01 -07:00
Andrew Wedgbury 9cd661e746 Make sure config.h is included before any system headers
There was an issue recently in screen-share.c where config.h was not
being included, resulting in the wrong definition for off_t being used on
32 bit systems. I checked and I don't think this problem is happening
elsewhere, but to help avoid this sort of problem in the future, I went
through and made sure that config.h is included first whenever system
headers are included.

The config.h header should be included before any system headers, failing
to do this can result in the wrong type sizes being defined on certain
systems, e.g. off_t from sys/types.h

Signed-off-by: Andrew Wedgbury <andrew.wedgbury@realvnc.com>
2014-04-07 10:22:28 -07:00