platform/upstream/weston.git
6 years agocompositor-drm: free filename in exit
Pekka Paalanen [Thu, 7 Dec 2017 14:05:29 +0000 (16:05 +0200)]
compositor-drm: free filename in exit

Spotted by Valgrind.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agocompositor-drm: fix uninitialized bytes on modeinfo
Pekka Paalanen [Tue, 5 Dec 2017 13:37:41 +0000 (15:37 +0200)]
compositor-drm: fix uninitialized bytes on modeinfo

Fixes the following Valgrind error:

==21607== Syscall param ioctl(generic) points to uninitialised byte(s)
==21607==    at 0x5E8C787: ioctl (in /lib64/libc-2.25.so)
==21607==    by 0x8220C17: drmIoctl (in /usr/lib64/libdrm.so.2.4.0)
==21607==    by 0x82263CD: drmModeSetCrtc (in /usr/lib64/libdrm.so.2.4.0)
==21607==    by 0x7B22095: drm_output_apply_state_legacy (compositor-drm.c:2107)
==21607==    by 0x7B2335D: drm_pending_state_apply (compositor-drm.c:2539)
==21607==    by 0x7B23AEB: drm_repaint_flush (compositor-drm.c:2773)
==21607==    by 0x4E4A3E4: output_repaint_timer_handler (compositor.c:2500)
==21607==    by 0x5081496: wl_event_source_timer_dispatch (event-loop.c:235)
==21607==    by 0x5081B61: wl_event_loop_dispatch (event-loop.c:633)
==21607==    by 0x50803A4: wl_display_run (wayland-server.c:1245)
==21607==    by 0x409DD8: main (main.c:2644)
==21607==  Address 0xffefff59a is on thread 1's stack
==21607==  in frame #2, created by drmModeSetCrtc (???:)
==21607==  Uninitialised value was created by a stack allocation
==21607==    at 0x7B2782F: drm_output_choose_initial_mode (compositor-drm.c:4842)

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
[Pekka: switch to memset]
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agocompositor-drm: move refresh rate computation
Pekka Paalanen [Fri, 10 Nov 2017 13:31:39 +0000 (15:31 +0200)]
compositor-drm: move refresh rate computation

Move it into to a new function. Following patches want to compute it
elsewhere as well.

No functional changes.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agocompositor-drm: drm_property_info_free() must reset
Pekka Paalanen [Thu, 7 Sep 2017 12:32:01 +0000 (15:32 +0300)]
compositor-drm: drm_property_info_free() must reset

This function needs to reset the structures to NULL, otherwise it is not
possible to re-use a once "freed" property info array.

Being able to re-use an array is useful when the memory allocation and
array lifetimes do not match. A specific example is drm_output that is
changed to allocate the CRTC on enable() and deallocate it on disable().
A drm_output might be enabled and disabled multiple times.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agocompositor-drm: refactor into drm_mode_list_destroy()
Pekka Paalanen [Mon, 11 Sep 2017 11:40:48 +0000 (14:40 +0300)]
compositor-drm: refactor into drm_mode_list_destroy()

I need to destroy the list from more places, so factor out the common
bits. No functional changes.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agocompositor-drm: factor out drm_output_init_crtc()
Pekka Paalanen [Tue, 5 Sep 2017 13:11:15 +0000 (16:11 +0300)]
compositor-drm: factor out drm_output_init_crtc()

Factor out drm_output_init_crtc() and drm_output_fini_crtc(), so that
the call sites can later be moved easily.

On fini, reset scanout_plane and cursor_plane to NULL, so that in the
future when the drm_output is not longer destroyed immediately after, we
free the planes for other use.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
[Pekka: set crtc_id/pipe at top, reset both on error]
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agocompositor-drm: factor out drm_output_init_gamma_size()
Pekka Paalanen [Tue, 5 Sep 2017 13:37:03 +0000 (16:37 +0300)]
compositor-drm: factor out drm_output_init_gamma_size()

Move this bit of code into its own function. The caller of this already
cluttered and origcrtc is not used for anything else.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agocompositor-drm: drm_output_enable updates unused_crtcs/connectors
Pekka Paalanen [Fri, 9 Feb 2018 11:31:50 +0000 (13:31 +0200)]
compositor-drm: drm_output_enable updates unused_crtcs/connectors

Let drm_output_enable() remove the CRTC and the connector from the
unused id arrays.

In the future when a list of drm_heads supersedes unused_connectors
array, the usedness of a connector will be determined by the enabled
state of the output the connector (head) is attached to. The enabled
state is turned on by drm_output_enable(). If unused_crtcs array was
still updated in drm_output_repaint(), the CRTC and connector usedness
would be tracked in different places. Logically the two belong together.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agoclients/desktop-shell: preserve background/panel in clone mode
Pekka Paalanen [Thu, 7 Dec 2017 13:30:18 +0000 (15:30 +0200)]
clients/desktop-shell: preserve background/panel in clone mode

In shared-CRTC clone mode there are several wl_output globals for one
weston_output. Only one panel and background is needed per
weston_output, so the extra wl_outputs do not get their own panel and
background.

When a head is unplugged, the corresponding wl_output is removed. If
that was the wl_output associated with the background and panel
surfaces, we must transfer the ownership to a remaining wl_output that
was a clone to avoid losing the background and panel completely.

The transfer relies on desktop-shell.so implementation to register
background and panel surfaces with the weston_output, not the
weston_head, so it does not actually matter the wl_output used to bind
the surfaces is going away.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agodesktop-shell: handle redundant panels
Pekka Paalanen [Thu, 7 Dec 2017 09:54:11 +0000 (11:54 +0200)]
desktop-shell: handle redundant panels

If for some reason the helper client weston-desktop-shell would create
more than one panel surface for the same weston_output, this code would
corrupt the surface destroy listener list by adding a link already in
one list into another list.

Instead, do not store the new, redundant panel surface and do not
subscribe to its destruction. Also, tell the helper that the surface is
redundant by configuring it with a 0x0 size, so that we don't waste
memory on a panel that is never used.

(Clone mode is a valid reason why weston-desktop-shell could do that.)

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agodesktop-shell: handle redundant backgrounds
Pekka Paalanen [Thu, 7 Dec 2017 09:44:18 +0000 (11:44 +0200)]
desktop-shell: handle redundant backgrounds

If for some reason the helper client weston-desktop-shell would create
more than one background surface for the same weston_output, this code
would corrupt the surface destroy listener list by adding a link already
in one list into another list.

Instead, do not store the new, redundant background surface and do not
subscribe to its destruction. Also, tell the helper that the surface is
redundant by configuring it with a 0x0 size, so that we don't waste
memory on a background that is never used.

(Clone mode is a valid reason why weston-desktop-shell could do that.)

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agoclients/desktop-shell: avoid invalid sized panel
Pekka Paalanen [Thu, 7 Dec 2017 10:39:15 +0000 (12:39 +0200)]
clients/desktop-shell: avoid invalid sized panel

If for some reason the desktop-shell plugin would configure a panel with
an invalid size, just destroy the whole panel and forget about it for
this wl_output.

A following patch will cause desktop-shell to configure 0x0 panel when
it deems the panel redundant.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agoclients/desktop-shell: avoid invalid sized background
Pekka Paalanen [Thu, 7 Dec 2017 10:15:01 +0000 (12:15 +0200)]
clients/desktop-shell: avoid invalid sized background

If for some reason the desktop-shell plugin would configure a background
with an invalid size, just destroy the whole background and forget
about it for this wl_output.

A following patch will cause desktop-shell to configure 0x0 background
when it deems the background redundant.

Fortify weston-desktop-shell against not every output having a
background.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agogl-renderer: Fix crash in dmabuf format query for fallback formats
Philipp Kerling [Fri, 9 Feb 2018 20:59:17 +0000 (21:59 +0100)]
gl-renderer: Fix crash in dmabuf format query for fallback formats

Since formats is an out parameter, we need to copy to the alloc'ed
memory and not over the pointer address.

Signed-off-by: Philipp Kerling <pkerling@casix.org>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agoxwm: Fix icon surface ownership
Emmanuel Gil Peyrot [Wed, 24 Jan 2018 22:29:53 +0000 (23:29 +0100)]
xwm: Fix icon surface ownership

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>
6 years agocompositor-drm: move state_invalid setting to deinit
Pekka Paalanen [Fri, 9 Feb 2018 10:29:10 +0000 (12:29 +0200)]
compositor-drm: move state_invalid setting to deinit

Setting state_invalid to true is moved together with the code adding new
unused CRTCs and connectors in drm_output_deinit(). Logically these two
operations belong together: state_invalid is required for the new unused
item to be turned off.

This does not hinder initial turning off of outputs, because on
compositor start-up, state_invalid is initialized to true, making calls
to drm_output_disable() for non-enabled outputs a no-op.

Previous changes already ensure that if a compositor does not explicitly
enable an output, the CRTC and connector will be turned off even without
an explicit disable (provided there is a at least one enabled output).

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agocompositor-drm: let repaint cycle disable crtcs
Pekka Paalanen [Fri, 9 Feb 2018 10:29:09 +0000 (12:29 +0200)]
compositor-drm: let repaint cycle disable crtcs

Rather than smashing the state to disable a CRTC immediately, just
delegate that to the normal repaint cycle by setting state_invalid =
true. drm_pending_state_apply() will pick up the unused_crtcs.

A caveat here is that we have no enabled outputs at all, we will never
enter repaint, and so CRTCs do not actually get turned off until we get
at least one output to drive.

However, this should help the problem reported here:
https://lists.freedesktop.org/archives/wayland-devel/2018-January/036713.html
Arguably it is better to leave an output spuriously on in rare cases
rather than fail modeset completely in somewhat more common cases.

My personal motivation for this change is that it helps if we later move
CRTC allocation to output enable/deinit instead of create/destroy,
because then the CRTC will not be available here for initial turn-off as
the output has not been enabled to begin with.

Cc: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
6 years agodesktop-shell: Correctly migrate views to other outputs when output is disabled/disco...
Marius Vlad [Thu, 8 Feb 2018 16:46:42 +0000 (18:46 +0200)]
desktop-shell: Correctly migrate views to other outputs when output is disabled/disconnected

Our case is when the view is the same as output being disabled/disconnected.
There's not need to check the views' output with the output being disabled
because weston_view_assign_output() already changes the output of the view when
the output has been disabled/disconnected hence the check is not needed at all.

The views' output will always be different than the output being disabled.

By the time shell_output_destroy_move_layer() gets called the views' output has
already changed to a "free" output. Tested this by unplugging/disabling the
output on purpose.

Signed-off-by: Marius Vlad <marius-cristian.vlad@nxp.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agolibweston: remove restore functionality
Pekka Paalanen [Wed, 7 Feb 2018 10:51:15 +0000 (12:51 +0200)]
libweston: remove restore functionality

This was used from the crash handlers, which do not exist anymore.
Nothing calls restore, so delete the dead code.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agoweston: remove SEGV and ABRT handlers
Pekka Paalanen [Wed, 7 Feb 2018 10:51:14 +0000 (12:51 +0200)]
weston: remove SEGV and ABRT handlers

Catching an ABRT is kind of ok, catching a SEGV is russian roulette. We
have been quite lucky with it, but I've started hitting crashes inside
malloc() which causes a deadlock when our SEGV handler needs to malloc()
as well (weston_log_timestamp()).

One reason to catch SEGV and ABRT was to attempt to restore the VT on
the DRM-backend. Nowadays that job is done by logind or weston-launch.

The signal handler also printed a backtrace, which for me personally has
been extremely helpful. Arguably it's not necessary though, when we have
core files and services that catch cores. For instance, if using
systemd, 'coredumpctl gdb' is delightfully easy for getting into the
saved core.

Therefore, this code does more harm than it is useful, so remove it. We
also drop an optional dependency to libunwind.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agoscreenshot: save screenshot files in XDG_PICTURES_DIR
Aleksander Morgado [Tue, 23 Jan 2018 00:05:22 +0000 (01:05 +0100)]
screenshot: save screenshot files in XDG_PICTURES_DIR

If XDG_PICTURES_DIR not given, it will use the current directory, as
it was before.

Signed-off-by: Aleksander Morgado <aleksander@aleksander.es>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agofile-util: allow specifying path separately in file_create_dated()
Aleksander Morgado [Tue, 23 Jan 2018 00:05:21 +0000 (01:05 +0100)]
file-util: allow specifying path separately in file_create_dated()

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>
6 years agoscreenshot: save each new screenshot in a different file
Aleksander Morgado [Tue, 23 Jan 2018 00:05:20 +0000 (01:05 +0100)]
screenshot: save each new screenshot in a different file

Instead of overwriting the 'wayland-screenshot.png' file over and
over, store each requested screenshot in a filename based on timestamp
and sequence number.

Signed-off-by: Aleksander Morgado <aleksander@aleksander.es>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agoivi-shell: fix the layer assignment change from one screen to another
Emre Ucan [Fri, 26 Jan 2018 14:04:59 +0000 (15:04 +0100)]
ivi-shell: fix the layer assignment change from one screen to another

if the layer is in order of some screen we need to remove it
from there and mark the screen order as dirty so it will be removed
in commit_screen_list call later
layer should only be assigned to one screen at a time

Signed-off-by: Eugen Friedrich <efriedrich@de.adit-jv.com>
Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoivi-shell: don't expilicitly assign outputs to views
Emre Ucan [Wed, 7 Feb 2018 15:54:30 +0000 (16:54 +0100)]
ivi-shell: don't expilicitly assign outputs to views

it is assigned in weston_view_assign_outputs

Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoivi-shell: don't schedule compositor repaint
Emre Ucan [Fri, 26 Jan 2018 14:04:57 +0000 (15:04 +0100)]
ivi-shell: don't schedule compositor repaint

it is not necessary to repaint all outputs after
each commit_changes. Only outputs with modified
views has to be repainted.

We need to call weston_view_update_transform
for assigning views to outputs first.
Then, We can call weston_view_schedule_repaint
to trigger repaint for outputs.

Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoivi-shell: change layer visibility to bool
Emre Ucan [Fri, 26 Jan 2018 14:04:56 +0000 (15:04 +0100)]
ivi-shell: change layer visibility to bool

ivi_layout_layer_set_visibility has bool
as argument.

Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoxwayland: Fix crash on weston shutdown
Derek Foreman [Mon, 5 Feb 2018 21:59:29 +0000 (15:59 -0600)]
xwayland: Fix crash on weston shutdown

commit e7fff215ada3fd3d1b2af664888f960c082f9065 made initializing the
selection_listener conditional, but didn't make its clean-up
conditional at shutdown.  Simply initializing the listener's list
link at init time makes this harmless.

To see this, run weston -Bheadless-backend.so and then connect to it
with an X client.  When killing weston it will attempt shutdown but
die with a segfault.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agoivi-shell: remove ivi_shell_setting
Emre Ucan [Thu, 25 Jan 2018 13:37:38 +0000 (14:37 +0100)]
ivi-shell: remove ivi_shell_setting

it has only developermode option parameter.
The parameter is only used in init_ivi_shell.
Therefore, we can basically remove the struct,
and check the option locally in the function.

Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoivi-shell: don't load controller modules
Emre Ucan [Thu, 25 Jan 2018 13:36:14 +0000 (14:36 +0100)]
ivi-shell: don't load controller modules

controller modules can be loaded as weston modules
from the main function of weston.

Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agotests: load ivi-shell test plugins as weston module
Emre Ucan [Thu, 25 Jan 2018 13:36:13 +0000 (14:36 +0100)]
tests: load ivi-shell test plugins as weston module

It is better to load ivi controller modules as a
generic weston module. Then, we do not need to
have a specific ivi way of loading modules.

Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agohmi-controller: load as weston module
Emre Ucan [Thu, 25 Jan 2018 13:36:12 +0000 (14:36 +0100)]
hmi-controller: load as weston module

weston loads hmi-controller as a weston module.
IVI-shell does not need to load it explicitly.

Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agohmi-controller: remove ivi_layout_interface global
Emre Ucan [Thu, 25 Jan 2018 13:36:11 +0000 (14:36 +0100)]
hmi-controller: remove ivi_layout_interface global

Put the interface into hmi_controller struct.
It is better to have it in an object.

Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoivi-shell: register ivi_layout_interface
Emre Ucan [Thu, 25 Jan 2018 13:36:10 +0000 (14:36 +0100)]
ivi-shell: register ivi_layout_interface

Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agobuild: Clean up -DDATADIR in makefiles
Derek Foreman [Tue, 6 Feb 2018 21:18:39 +0000 (15:18 -0600)]
build: Clean up -DDATADIR in makefiles

Now only libshared (and libshared_cairo) requires this.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoshared: Update all users of DATADIR
Derek Foreman [Tue, 6 Feb 2018 21:18:38 +0000 (15:18 -0600)]
shared: Update all users of DATADIR

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>
6 years agotests: Set WESTON_DATA_DIR for tests
Derek Foreman [Tue, 6 Feb 2018 21:18:37 +0000 (15:18 -0600)]
tests: Set WESTON_DATA_DIR for tests

Set the env var to override the system data directory so we can run
tests with uninstalled icons.

We don't yet use the code that checks this env var, so make distcheck
will still fail.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoshared: Add a function to prefix filenames with datadir
Derek Foreman [Tue, 6 Feb 2018 21:18:36 +0000 (15:18 -0600)]
shared: Add a function to prefix filenames with datadir

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>
6 years agocompositor-drm: Atomic modesetting support
Daniel Stone [Wed, 16 Nov 2016 11:55:20 +0000 (11:55 +0000)]
compositor-drm: Atomic modesetting support

Add support for using the atomic-modesetting API to apply output state.
Unlike previous series, this commit does not unflip sprites_are_broken,
until further work has been done with assign_planes to make it reliable.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Co-authored-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Co-authored-by: Louis-Francis Ratté-Boulianne <louis-francis.ratte-boulianne@collabora.com>
Co-authored-by: Derek Foreman <derek.foreman@collabora.co.uk>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor-drm: Add blob_id member to drm_mode
Daniel Stone [Wed, 16 Nov 2016 10:54:10 +0000 (10:54 +0000)]
compositor-drm: Add blob_id member to drm_mode

For atomic modesetting support, the mode is identified by a blob
property ID, rather than being passed inline. Add a blob_id member to
drm_mode to handle this, including refactoring mode destruction into a
helper function.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor-drm: Discover atomic properties
Pekka Paalanen [Tue, 15 Nov 2016 22:07:49 +0000 (22:07 +0000)]
compositor-drm: Discover atomic properties

Set the atomic client cap, where it exists, and use this to discover the
plane/CRTC/connector properties we require for atomic modesetting.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Co-authored-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor-drm: Don't restore original CRTC mode
Daniel Stone [Fri, 27 Jan 2017 15:11:33 +0000 (15:11 +0000)]
compositor-drm: Don't restore original CRTC mode

When leaving Weston, don't attempt to restore the previous CRTC
settings. The framebuffer may well have disappeared, and in every
likelihood, whoever gets the KMS device afterwards will be repainting
anyway.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor-drm: Consistent failure paths for output creation
Daniel Stone [Mon, 5 Feb 2018 13:01:02 +0000 (13:01 +0000)]
compositor-drm: Consistent failure paths for output creation

Rather than a smattering of error handlers, use consistent jump labels
for error paths in create_output_for_connector().

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reported-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor-drm: Use apply_state for starting repaint
Daniel Stone [Tue, 29 Nov 2016 20:17:32 +0000 (20:17 +0000)]
compositor-drm: Use apply_state for starting repaint

Rather than open-coding it ourselves, use the new apply_state helper in
drm_output_start_repaint.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reported-by: Fabien DESSENNE <fabien.dessenne@st.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor-drm: Move repaint state application to flush
Daniel Stone [Tue, 8 Nov 2016 17:46:10 +0000 (17:46 +0000)]
compositor-drm: Move repaint state application to flush

Split repaint into two stages, as implied by the grouped-repaint
interface: drm_output_repaint generates the repaint state only, and
drm_repaint_flush applies it.

This also moves DPMS into output state. Previously, the usual way to
DPMS off was that repaint would be called and apply its state, followed
by set_dpms being called afterwards to push the DPMS state separately.
As this happens before the repaint_flush hook, with no change to DPMS we
would set DPMS off, then immediately re-enable the output by posting the
repaint. Not ideal.

Moving DPMS application at the same time complicates this patch, but I
couldn't find a way to split it; if we keep set_dpms before begin_flush
then we break DPMS off, or if we try to move DPMS to output state before
using the repaint flush, we get stuck as the repaint hook generates an
asynchronous state update, followed immediately by set_dpms generating a
synchronous state update.

In drm_output_update_complete, the *_pending flags are cleared
before any of the pending actions are taken; this ensures that the
actions cannot recurse.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor-drm: Disable unused CRTCs/connectors
Daniel Stone [Mon, 5 Feb 2018 15:46:20 +0000 (15:46 +0000)]
compositor-drm: Disable unused CRTCs/connectors

If we have an unused CRTC or connector, explicitly disable it during the
end of the repaint cycle, or when we get VT-switched back in.

This commit moves state_invalid from an output property to a backend
property, as the unused CRTCs or connectors are likely not tracked by
drm_outputs. This matches the mechanics of later commits, where we move
to a global repaint-flush hook, applying the state for all outputs in
one go.

The output state_invalid flag originally provoked full changes on output
creation (via setting the flag at output enable time) and session enter.

For the new-output case, we will not have any FB in output->state_cur,
so we still take the same path in repaint as if state_invalid were set.
At session enter, we preserve the existing behaviour: as
start_repaint_loop will fail when state_invalid is set, all outputs will
be scheduled for repaint together, and state_invalid will not be cleared
until after all outputs have been repainted, inside repaint_flush.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor-drm: Track unused connectors and CRTCs
Daniel Stone [Tue, 14 Feb 2017 17:51:30 +0000 (17:51 +0000)]
compositor-drm: Track unused connectors and CRTCs

Rather than a more piecemeal approach at backend creation, explicitly
track connectors and CRTCs we do not intend to use, so we can ensure
they are disabled where appropriate.

When we have an updated list of connector and CRTC IDs, we add any which
are not owned by an enabled drm_output to the list. We remove them from
the list when drm_output_repaint() is called for that output, and re-add
them when the output is disabled or destroyed.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agotests: Support weston_test request for adding a test seat
Alexandros Frantzis [Fri, 26 Jan 2018 16:48:00 +0000 (18:48 +0200)]
tests: Support weston_test request for adding a test seat

Support adding a test seat using the weston_test.device_add request.
This will be used in tests in upcoming commits where we will need to
re-add the seat after having it removed.

We only support one test seat at the moment, so this commit also
introduces checks to ensure the client doesn't try to create multiple
test seats or try to remove an already removed test seat.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agolibweston: Make weston_touch destruction safe
Alexandros Frantzis [Fri, 26 Jan 2018 16:47:57 +0000 (18:47 +0200)]
libweston: Make weston_touch destruction safe

Ensure the server can safely handle client requests for wl_touch
resources that have become inert due to a weston_touch object
destruction.

This change involves, among other things, setting the weston_touch
object, instead of the weston_seat object, as the user data for wl_touch
resources. Although this is not strictly required at the moment (since
no code is using the wl_touch user data), it makes the code safer:

 * It makes more sense conceptually.
 * It is consistent with how wl_pointer resources are handled.
 * It allows us to clear the user data during weston_touch
   destruction, so other code can check whether the resource is
   inert.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agolibweston: Make weston_keyboard destruction safe
Alexandros Frantzis [Fri, 26 Jan 2018 16:47:56 +0000 (18:47 +0200)]
libweston: Make weston_keyboard destruction safe

Ensure the server can safely handle client requests for wl_keyboard
resources that have become inert due to a weston_keyboard object
destruction.

This change involves, among other things, setting the weston_keyboard
object, instead of the weston_seat object, as the user data for
wl_keyboard resources.  Although this is not strictly required at the
moment (since no code is using the wl_keyboard user data), it makes the
code safer:

 * It makes more sense conceptually.
 * It is consistent with how wl_pointer resources are handled.
 * It allows us to clear the user data during weston_keyboard
   destruction, so other code can check whether the resource is inert.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agodesktop-shell: remove surface listener when surface is destroyed
Tomohito Esaki [Wed, 31 Jan 2018 06:15:45 +0000 (15:15 +0900)]
desktop-shell: remove surface listener when surface is destroyed

There may be race condition between destroying surface and destroying
output. If handle_output_destroy() is called after surface is destroyed,
illegal memory access occurs when surface destroy signals is
unregistered from the panel/background. This patch fixes this issue and
removes unnecessary initialization for panel surface listener.

Signed-off-by: Tomohito Esaki <etom@igel.co.jp>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoUse $(SED) to make sure GNU sed is used
Greg V [Sun, 17 Dec 2017 19:04:36 +0000 (22:04 +0300)]
Use $(SED) to make sure GNU sed is used

FreeBSD's default sed is not compatible with this expression.

Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agoxwayland: Explicitly link with xcb-shape
Daniel Stone [Thu, 18 Jan 2018 12:32:08 +0000 (12:32 +0000)]
xwayland: Explicitly link with xcb-shape

XWM uses xcb-shape as of 332d1892bb, to exclude the shadow from the
input region. However, it does not explicitly link xcb-shape for the new
symbols; on one of my machines this is pulled in as a transient
dependency (masking the issue), but apparently not the other.

Solve it by explicitly linking xcb-shape and requiring it in configure.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Fixes: 332d1892bb ("xwm: do not include shadow in input region")
Cc: Ian Ray <ian.ray@ge.com>
6 years agoxwm: Add icon support to the frame
Emmanuel Gil Peyrot [Fri, 1 Dec 2017 18:20:40 +0000 (19:20 +0100)]
xwm: Add icon support to the frame

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>
6 years agocompositor-drm: Add to_drm_mode helper
Daniel Stone [Wed, 16 Nov 2016 11:51:27 +0000 (11:51 +0000)]
compositor-drm: Add to_drm_mode helper

Much like we already have to_drm_output and to_drm_backend.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoxwm: do not include shadow in input region
Ian Ray [Thu, 18 Jan 2018 11:44:04 +0000 (11:44 +0000)]
xwm: do not include shadow in input region

The window frame was created with position and size which include
an offset for margins and shadow.  Set the input region to ignore
shadow.

[daniels: Fixed type mismatch, removed unused variable.]

Signed-off-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Tested-by: Scott Moreau <oreaus@gmail.com>
6 years agocompositor: Implement runtime output transform changes
Ilia Bozhinov [Sun, 25 Jun 2017 12:21:39 +0000 (12:21 +0000)]
compositor: Implement runtime output transform changes

Up to now we could set the transform only on output initialization.
However, on certain situations(like tablets and convertible laptops),
screen orientation can change while the compositor is running and thus
the need for change of the output transform arises.

When the transform changes, we must update the output geometry,
output->region and output->previous_damage, as well as send this change
to clients. We also have to check whether any of the pointers are inside
the output which is being rotated. If this is the case, they are moved
to the new center, because otherwise the pointer is stuck outside of the
screen ans "lost" to the user.

What is more, after calling this function compositors should check if
any view is now outside of the screen and move it according to their
wish.

Signed-off-by: Ilia Bozhinov <iliyabo@hotmail.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Acked-by: Daniel Stone <daniels@collabora.com>
6 years agogl-renderer: return conservative format list if dmabuf import modifiers unsupported
Philipp Zabel [Wed, 17 Jan 2018 16:54:32 +0000 (17:54 +0100)]
gl-renderer: return conservative format list if dmabuf import modifiers unsupported

If the EGL_EXT_image_dma_buf_import_modifiers extension is not
supported, let gl_renderer_query_dmabuf_formats return a hardcoded
fallback list. That list contains ARGB8888, XRGB8888, and if the
GL_EXT_texture_rg extension is supported, YUYV, NV12, YUV420, and
YUV444.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agolinux-dmabuf: send deprecated format events
Michael Tretter [Wed, 17 Jan 2018 16:54:31 +0000 (17:54 +0100)]
linux-dmabuf: send deprecated format events

Although the format event is deprecated, some clients, especially the
GStreamer waylandsink, only support zwp_linux_dmabuf_v1 version 1 and
require the deprecated format event.

Send format events instead of the modifier event, if the client binds on
a protocol version before version 3, skipping formats that only support
non-linear modifiers.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agodmabuf: set modifier to invalid for not supporting clients
Emre Ucan [Tue, 9 Jan 2018 13:00:30 +0000 (14:00 +0100)]
dmabuf: set modifier to invalid for not supporting clients

modifier_hi and modifier_lo are set to 0 by clients,
which are not supporting modifiers. Modifier attributes
of buffers of these clients set to 0 too in linux-dmabuf.c

import_simple_dmabuf function in gl-renderer.c compares
modifier attribute of the buffer with DRM_FORMAT_MOD_INVALID.
DRM_FORMAT_MOD_INVALID is equal to ((1ULL<<56) - 1).
Therefore, modifer 0 is accepted as valid. Then, the function
checks support for eglQueryDmaBufModifiersEXT.
If it is not supported import_simple_dmabuf function is returning
NULL.

This patch sets the modifier attribute to DRM_FORMAT_MOD_INVALID
for clients which are not supporting modifiers. Without this patch
linux-dmabuf protocol is not working for not supporting clients.

Fixes: b138d7afb3a2a7d51dccb12f08d70c2d86766901 ("gl-renderer: Ignore INVALID modifier")
Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Tested-by: Tomohito Esaki <etom@igel.co.jp>
6 years agogl-renderer: always enable unpack subimage and RG textures in ES3 contexts
Arnaud Vrac [Wed, 17 Jan 2018 18:36:35 +0000 (19:36 +0100)]
gl-renderer: always enable unpack subimage and RG textures in ES3 contexts

The GL_EXT_unpack_subimage and GL_EXT_texture_rg are part of the core ES
3.0 specification, so also check the GL driver version in addition to
the extension string to determine if those features are supported.

This allows using those extensions on some GL drivers that do not expose
them in the extensions string, but still support OpenGLES3.

Signed-off-by: Arnaud Vrac <avrac@freebox.fr>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agogl-renderer: move GL_EXT_texture_rg extension check
Arnaud Vrac [Wed, 17 Jan 2018 18:36:34 +0000 (19:36 +0100)]
gl-renderer: move GL_EXT_texture_rg extension check

This is a GL extension and not EGL, so it should be checked after the
EGL context has been created.

Signed-off-by: Arnaud Vrac <avrac@freebox.fr>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agogl-renderer: try to create a GLES3 context
Arnaud Vrac [Wed, 17 Jan 2018 18:36:33 +0000 (19:36 +0100)]
gl-renderer: try to create a GLES3 context

GL drivers might allow using GLES3 features even in GLES2 contexts, but
that's not always the case. To make sure we can use GLES3, first try to
create a GLES3 context and then fallback to GLES2 on failure.

The reported GL version is used to determine which GLES version is
actually available.

Signed-off-by: Arnaud Vrac <avrac@freebox.fr>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agogl-renderer: save OpenGL version in renderer context
Arnaud Vrac [Wed, 17 Jan 2018 18:36:32 +0000 (19:36 +0100)]
gl-renderer: save OpenGL version in renderer context

This will allow to make some assumptions in further patches when GLES3
is available.

Signed-off-by: Arnaud Vrac <avrac@freebox.fr>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agocompositor-drm: Don't repaint if no damage
Daniel Stone [Mon, 14 Nov 2016 17:46:59 +0000 (17:46 +0000)]
compositor-drm: Don't repaint if no damage

If we don't have any damage for the primary plane, then don't force a
repaint; simply reuse the old buffer we already have.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor-drm: Remove NULL checks in switch_mode
Daniel Stone [Sat, 7 Oct 2017 13:01:45 +0000 (14:01 +0100)]
compositor-drm: Remove NULL checks in switch_mode

Calling switch_mode with no output or mode never makes any sense. Drop
the NULL checks.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor-drm: Use drm_plane for scanout plane
Daniel Stone [Tue, 16 Jan 2018 15:37:33 +0000 (15:37 +0000)]
compositor-drm: Use drm_plane for scanout plane

Use a real drm_plane to back the scanout plane, displacing
output->fb_{last,cur,pending} to their plane-tracked equivalents.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor-drm: Use drm_plane for cursor plane
Daniel Stone [Tue, 19 May 2015 19:02:41 +0000 (20:02 +0100)]
compositor-drm: Use drm_plane for cursor plane

Change the type of cursor_plane from a weston_plane (base tracking
structure) to a drm_plane (wrapper containing additional DRM-specific
details), and make it a dynamically-allocated pointer.

Using the standard drm_plane allows us to reuse code which already deals
with drm_planes, e.g. a common cleanup function.

This patch introduces a 'special plane' helper, creating a drm_plane
either from a real KMS plane when using universal planes, or a fake plane
otherwise. Without universal planes, the cursor and primary planes are
hidden from us; this helper allows us to pretend otherwise.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor-drm: Introduce drm_plane_is_available
Daniel Stone [Sat, 7 Oct 2017 11:59:02 +0000 (12:59 +0100)]
compositor-drm: Introduce drm_plane_is_available

Helper for the pattern of checking whether or not a plane can be used on
an output during the current repaint cycle.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor-drm: Introduce drm_plane_state structure
Daniel Stone [Mon, 14 Nov 2016 16:57:01 +0000 (16:57 +0000)]
compositor-drm: Introduce drm_plane_state structure

Track dynamic plane state (CRTC, FB, position) in separate structures,
rather than as part of the plane. This will make it easier to handle
state management later, and much more closely tracks what the kernel
does with atomic modesets.

The fb_last pointer previously used in drm_plane now becomes part of
output->state_last, and is not directly visible from the plane itself.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor-drm: Introduce drm_output_state structure
Daniel Stone [Fri, 11 Nov 2016 19:11:49 +0000 (19:11 +0000)]
compositor-drm: Introduce drm_output_state structure

Currently this doesn't actually really do anything, but will be used in
the future to track the state for both modeset and repaint requests.
Completion of the request gives us a single request-completion path for
both pageflip and vblank events.

This merges the timing paths for scanout and plane-but-but-atomic-plane
content.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor-drm: Add shutting_down flag
Daniel Stone [Thu, 5 Oct 2017 15:27:21 +0000 (16:27 +0100)]
compositor-drm: Add shutting_down flag

Does what it says on the box: is true when the compositor is shutting
down.

When we begin to use universal planes, we need divergent destruction
paths. With universal planes, the drm_planes are created at backend
initialisation time, and destroyed with the backend. However, without
universal planes, we create per-output drm_planes to hold the
primary/scanout and cursor planes, whose lifetime is tied to the output.

We will use the new shutting_down flag to determine if output
destruction is hot-unplug or compositor shutdown, and make a decision on
whether or not to destroy the special planes.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoUnconditionally add linux-dmabuf’s protocol to BUILT_SOURCES
Emmanuel Gil Peyrot [Sun, 7 Jan 2018 11:09:27 +0000 (12:09 +0100)]
Unconditionally add linux-dmabuf’s protocol to BUILT_SOURCES

This was preventing weston-info from building if both
weston-simple-dmabuf-drm and weston-simple-dmabuf-v4l2 were disabled at
build-time.

Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
Reported-by: Cedric Sodhi <manday@openmail.cc>
Tested-by: Cedric Sodhi <manday@openmail.cc>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
6 years agoconfigure: fix sys/sysmacros.h check
Pekka Paalanen [Mon, 18 Dec 2017 08:02:58 +0000 (10:02 +0200)]
configure: fix sys/sysmacros.h check

This patch is a copy of
https://cgit.freedesktop.org/mesa/drm/commit/?id=7040fea0280bad527ed4b3d5eee7d7bfbf303efc
by Adam Jackson.

Commit 43c5a65b034a243700cf9c5bfbe6bcefb15f1161 "configure.ac: use
AC_HEADER_MAJOR to detect major()/minor()" started using AC_HEADER_MAJOR
to detect the header where major() is defined. This caused a regression
on systems where glibc is still providing a deprecated definition of
major() through sys/types.h, leading to a bunch of compiler warnings:

/home/pq/git/weston/libweston/launcher-logind.c: In function ‘launcher_logind_open’:
/home/pq/git/weston/libweston/launcher-logind.c:182:13: warning: In the GNU C Library, "major" is defined
 by <sys/sysmacros.h>. For historical compatibility, it is
 currently defined by <sys/types.h> as well, but we plan to
 remove this soon. To use "major", include <sys/sysmacros.h>
 directly. If you did not intend to use a system-defined macro
 "major", you should undefine it after including <sys/types.h>.
  fd = launcher_logind_take_device(wl, major(st.st_rdev),

The issue has been discussed earlier on
https://lists.gnu.org/archive/html/autoconf/2016-09/msg00013.html

Work around the issue by causing the warning to trigger a build failure
inside AC_HEADER_MAJOR test, so that we get MAJOR_IN_SYSMACROS defined.

Cc: Adam Jackson <ajax@redhat.com>
Cc: Emil Velikov <emil.l.velikov@gmail.com>
Cc: Sergei Trofimovich <slyfox@gentoo.org>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
6 years agoweston: add --drm-device option for DRM-backend
Pekka Paalanen [Tue, 28 Mar 2017 15:14:37 +0000 (18:14 +0300)]
weston: add --drm-device option for DRM-backend

Developers with testing rigs having multiple graphics cards plugged in
often want to test things on a specific card. We have ways to choose a
card through seat assignments, but configuring that run by run is
awkward.

Add a command line option for opening a specific DRM device.

v2: call it --drm-device instead of --device

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agocompositor-drm: add specific_device configuration option
Pekka Paalanen [Tue, 28 Mar 2017 15:04:27 +0000 (18:04 +0300)]
compositor-drm: add specific_device configuration option

Developers with testing rigs having multiple graphics cards plugged in
often want to test things on a specific card. We have ways to choose a
card through seat assignments, but configuring that run by run is
awkward.

Add a new DRM backend option to try to open a specific device, and quit
if it fails.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agotests: Add test for pointer axis events
Alexandros Frantzis [Mon, 18 Dec 2017 10:16:55 +0000 (12:16 +0200)]
tests: Add test for pointer axis events

Add test to verify the server correctly emits pointer axis events.  This
requires updating the weston-test protocol with a new request for
pointer axis events.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agotests: Add test for touch event timestamps
Alexandros Frantzis [Wed, 13 Dec 2017 11:27:58 +0000 (13:27 +0200)]
tests: Add test for touch event timestamps

Add test to verify that the server correctly sets the timestamps of
touch events. This requires updating the weston-test protocol with a new
request for touch events.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agotests: Add test for keyboard key event timestamps
Alexandros Frantzis [Wed, 13 Dec 2017 11:27:57 +0000 (13:27 +0200)]
tests: Add test for keyboard key event timestamps

Add test to verify that the server correctly sets the timestamps of
keyboard key events. This requires updating the weston-test protocol to
support passing key event timestamps.

simple_keyboard_test now uses the create_client_with_keyboard_focus()
helper function which changes the initial state of the surface to be
focused. This leads to one additional iteration of the test loop when
starting, during which the surface is deactivated, i.e., loses focus.
After this initial iteration the test continues as before.

Furthermore, simple_keyboard_test now uses the send_key() helper
function which performs a roundtrip internally. To account for this, the
client_roundtrip() function is now directly called in the loop only when
it is still required, i.e., when deactivating the surface.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agotests: Add checks for pointer motion and button event timestamps
Alexandros Frantzis [Wed, 13 Dec 2017 11:27:55 +0000 (13:27 +0200)]
tests: Add checks for pointer motion and button event timestamps

Enhance the existing pointer motion and button event tests to
additionally verify the event timestamps. This requires updating the
weston-test protocol to support passing motion and button event
timestamps.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoshared: Add timespec_to_proto helper function
Alexandros Frantzis [Wed, 13 Dec 2017 11:27:54 +0000 (13:27 +0200)]
shared: Add timespec_to_proto helper function

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>
6 years agoshared: Add timespec_from_proto helper function
Alexandros Frantzis [Wed, 13 Dec 2017 11:27:53 +0000 (13:27 +0200)]
shared: Add timespec_from_proto helper function

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>
6 years agordp compositor: add a man page and add links to that page
David Fort [Fri, 15 Dec 2017 14:23:59 +0000 (15:23 +0100)]
rdp compositor: add a man page and add links to that page

6 years agotests: Use separate test cases for pointer motion and button tests
Alexandros Frantzis [Mon, 4 Dec 2017 13:34:04 +0000 (15:34 +0200)]
tests: Use separate test cases for pointer motion and button tests

Split pointer motion and pointer button tests so that each test case is
more focused and self-contained.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agotests: Move wl_pointer tests to their own file
Alexandros Frantzis [Mon, 4 Dec 2017 13:34:03 +0000 (15:34 +0200)]
tests: Move wl_pointer tests to their own file

Move wl_pointer tests from event-test.c to their own pointer-test.c
file. This move makes the test organization clearer and more consistent,
and will make addition of further pointer tests easier.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agolibweston: drop return type from ::query_dmabuf_{formats, modifiers}
Emil Velikov [Tue, 5 Dec 2017 14:26:16 +0000 (14:26 +0000)]
libweston: drop return type from ::query_dmabuf_{formats, modifiers}

Nobody checks for the bool returned by these functions. At the same
time: a) the functions set the respective num_foo to zero on error and
b) callers honour that variable.

Just drop the return type - it's useless.

Note: this is an ABI break.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agogl-renderer: use correct pixel shader for NV12 format uploaded to RG texture
Arnaud Vrac [Wed, 29 Nov 2017 14:25:35 +0000 (15:25 +0100)]
gl-renderer: use correct pixel shader for NV12 format uploaded to RG texture

Signed-off-by: Arnaud Vrac <rawoul@gmail.com>
Fixes: 00a03d2f724 ("gl-renderer: add support of WL_SHM_FORMAT_NV12")
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agogl-renderer: fix pixel format used in texture uploads when using R/RG textures
Arnaud Vrac [Wed, 29 Nov 2017 14:25:34 +0000 (15:25 +0100)]
gl-renderer: fix pixel format used in texture uploads when using R/RG textures

In glTexImage2D / glTexSubImage2D calls, the only pixel formats allowed
for the GL_R8 and GL_RG internal formats are respectively GL_RED and
GL_RG [1].

Make sure we match this requirement, as some drivers will fail with the
current code.

[1] https://www.khronos.org/registry/OpenGL-Refpages/es3.0/html/glTexImage2D.xhtml, Table 2

Signed-off-by: Arnaud Vrac <rawoul@gmail.com>
Fixes: 00a03d2f724 ("gl-renderer: add support of WL_SHM_FORMAT_NV12")
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agolibweston-desktop/xwayland: Make sure racy surfaces are properly mapped
Quentin Glidic [Fri, 8 Dec 2017 10:10:53 +0000 (11:10 +0100)]
libweston-desktop/xwayland: Make sure racy surfaces are properly mapped

This fixes a race between Xwayland committing the surface content via
the wl_surface, and the XWM setting the role of the surface.
We now keep track of the (first) content commit on the surface and
forward it to the shell when we finally get the role.
There is no need to track later changes, as the only way for Xwayland to
unmap a surface is to destroy it.

Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Acked-by: Daniel Stone <daniels@collabora.com>
6 years agoconfigure.ac: drop spurious bracket
Guido Günther [Fri, 8 Dec 2017 19:46:34 +0000 (20:46 +0100)]
configure.ac: drop spurious bracket

Otherwise configure output looks like

    checking for library containing pam_open_session... -lpam
    ./configure: line 18064: ]: command not found
    checking for COLORD... yes

Signed-off-by: Guido Günther <agx@sigxcpu.org>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agolibweston-desktop: add signal for title/app-id changes
Matt Hoosier [Tue, 5 Sep 2017 13:05:49 +0000 (08:05 -0500)]
libweston-desktop: add signal for title/app-id changes

As discussed on
https://lists.freedesktop.org/archives/wayland-devel/2017-August/034720.html,
it's useful for the shell implementation to know when these change,
for example to relay the information on to taskbars or similar.

To avoid ABI changes or the need to make the weston_desktop_surface
definition public, new functions are introduced for attaching
listeners to these signals.

Signed-off-by: Matt Hoosier <matt.hoosier@gmail.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
6 years agoxwm: Use Pango to draw title string if available
Louis-Francis Ratté-Boulianne [Mon, 13 Nov 2017 21:20:56 +0000 (16:20 -0500)]
xwm: Use Pango to draw title string if available

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>
6 years agoxwm: Deal with title in a smarter way when there isn't enough space
Louis-Francis Ratté-Boulianne [Mon, 13 Nov 2017 21:20:55 +0000 (16:20 -0500)]
xwm: Deal with title in a smarter way when there isn't enough space

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>
6 years agoxwm: Maximize windows when double-clicking on title bar
Louis-Francis Ratté-Boulianne [Mon, 13 Nov 2017 21:20:50 +0000 (16:20 -0500)]
xwm: Maximize windows when double-clicking on title bar

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agoxwm: Only send configure a window if the new size is different
Louis-Francis Ratté-Boulianne [Mon, 13 Nov 2017 21:20:52 +0000 (16:20 -0500)]
xwm: Only send configure a window if the new size is different

If we configure a window with the same size and wait for the
sync alarm to go off, the resizing is gonna block. The event is
only handled is the size actually changed.

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agoxwm: Handle third data entry in client messages
Ilia Bozhinov [Sat, 24 Jun 2017 17:53:02 +0000 (17:53 +0000)]
xwm: Handle third data entry in client messages

A single client message can be used to modify two properties at once.
That's why when processing such messages we have to check both the second
and the third data entry for states that we must handle.

Signed-off-by: Ilia Bozhinov <iliyabo@hotmail.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agodesktop-shell: Handle the fullscreen to maximized case safely
Derek Foreman [Fri, 6 Oct 2017 19:37:45 +0000 (14:37 -0500)]
desktop-shell: Handle the fullscreen to maximized case safely

When a client transitions from maximized to fullscreen to maximized (run
weston-terminal, maximize it, hit f11 twice) we're sending size 0,0 for
the unfullscreen configure, which still has maximized set.

This results in clients correctly picking any size they like, and weston
disconnecting them for it.

Instead, pass the correct maximized size.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agodesktop-shell: refactor maximized size calculation into its own function
Derek Foreman [Fri, 6 Oct 2017 19:37:44 +0000 (14:37 -0500)]
desktop-shell: refactor maximized size calculation into its own function

We need to calculate maximized size to resolve a bug with unsetting
fullscreen, might as well share the code.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agotests: add a create_test_surface function
Emilio Pozuelo Monfort [Fri, 3 Feb 2017 15:10:37 +0000 (16:10 +0100)]
tests: add a create_test_surface function

This doesn't attach a buffer to the surface. This is needed for the
next commit, where we have a test case with a surface that doesn't
have a buffer attached.

Signed-off-by: Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agoinput: Do not override keyboard focus on restore
Quentin Glidic [Fri, 21 Jul 2017 12:02:40 +0000 (14:02 +0200)]
input: Do not override keyboard focus on restore

If we start a special (grabbing) client when Weston is unfocused, it
would lose focus when coming back to Weston.

Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Daniel Stone <daniels@collabora.com>