platform/upstream/weston.git
6 years agolibweston: add heads_changed_signal
Pekka Paalanen [Tue, 15 Aug 2017 10:00:02 +0000 (13:00 +0300)]
libweston: add heads_changed_signal

Add a hook for compositors to get a callback when heads are added or
their connection status changes, to which compositors likely want to
react to by enabling or disabling outputs (API for that to be added
later).

As many head changes as possible should be coalesced into a single
heads_changed call. Therefore the callback is made from an idle task.
This anticipates a future atomic output configuration API, where the
global output configuration is tested and set atomically instead of one
by one.

weston_pending_output_coldplug() needs to manually execute the
heads_changed call so that initial outputs are created before any
plugins get their start-up idle tasks ran. This is especially important
for ivi-shell which does not support output hotplug, and for tests to
guarantee the expected outputs.

v8:
- Change the callback function pointer into a wl_signal. The API is
  changed and renamed.

v6:
- fix a typo
- add comment in weston_pending_output_coldplug()

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v6 Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
v6 Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: add compositor list of heads
Pekka Paalanen [Mon, 14 Aug 2017 13:05:35 +0000 (16:05 +0300)]
libweston: add compositor list of heads

weston_compositor needs to maintain a list of all available heads, so
that a compositor can pick and choose which heads to take into or out of
use at arbitrary times. The heads may be on or off, and connected or
disconnected.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: add weston_head_is_enabled()
Pekka Paalanen [Thu, 15 Feb 2018 13:18:20 +0000 (15:18 +0200)]
libweston: add weston_head_is_enabled()

Enabled is orthogonal from connected. A connected head could be
disabled, or a disconnected head could in the future be enabled.

Compositors quite likely want to check if a head is already enabled
before starting to take it into use.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: add weston_head::connected
Pekka Paalanen [Mon, 14 Aug 2017 12:45:14 +0000 (15:45 +0300)]
libweston: add weston_head::connected

Heads may be disconnected or connected and the compositor needs to be
able to know the state to know which heads to take into use.

Currently a single head is automatically created with an output, and
outputs are only ever created as connected and destroyed on
disconnection, so it suffices to set connected to true. In the future,
backends are expected to create heads for both connected and
disconnected connectors, so that a connector can be forced on without it
being actually connected.

v6:
- split weston_head_is_enabled() to a new patch

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: add name to weston_head
Pekka Paalanen [Mon, 14 Aug 2017 11:43:13 +0000 (14:43 +0300)]
libweston: add name to weston_head

Heads need to be named, so they can be referenced in logs and
configuration sources.

When clone mode is implemented, output and head names may differ.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agocms-colord: find a good head
Pekka Paalanen [Tue, 4 Apr 2017 13:36:07 +0000 (16:36 +0300)]
cms-colord: find a good head

The 'head' member of 'struct weston_output' is going to go unused and
then disappear, so stop using it and find a head from the proper list.

However, this leaves a problem in cms-colord: if you have multiple
monitors driver with the same CRTC, what do you say to the color
management system? The monitors could be different, but all the color
LUTs etc. are in the CRTC and are shared, as is the framebuffer.

Do the simple hack here and just use whatever head happens to be the
first in the list.

The warning is printed in get_output_id(), because if heads are added or
removed while the output is enabled, the id could change.

v6:
- add weston_output_get_first_head(), at first use
- add warning message for nr. heads > 1

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>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: strdup head make, model, serial_number
Pekka Paalanen [Tue, 4 Apr 2017 13:26:23 +0000 (16:26 +0300)]
libweston: strdup head make, model, serial_number

Duplicate these strings to decouple their lifetime from whatever the
backends used. This should prevent hard to catch use after frees and
such problems in the future.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v5 Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: properly orphan wl_output resources
Pekka Paalanen [Mon, 4 Dec 2017 13:28:13 +0000 (15:28 +0200)]
libweston: properly orphan wl_output resources

Remove the wl_resource in the head's resource list when we are
removing the wl_output global. We sent global removal events to clients,
the resources should become dummies until clients reap them. Reset user
data so that clients triying to use dummy objects don't hit e.g. a freed
head pointer.

This fixes a theoretical issue: if an enabled output is disabled and
then gets enabled again, mode changes and wl_surface.enter/leave would
still attempt to use the dummy objects. If a client destroyed a dummy
object, we don't have the destructor to remove it from the resource
list, and libweston would hit freed memory.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v5 Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: introduce weston_output::head_list
Pekka Paalanen [Tue, 28 Mar 2017 13:27:25 +0000 (16:27 +0300)]
libweston: introduce weston_output::head_list

The intention is that in the future backends will dynamically allocate
weston_heads based on the resources they have. The lifetime of a
weston_head will be independent of the lifetime of a weston_output it
may be attached to. Backends allocate objects derived from weston_head,
like they currently do for weston_output. Backend will choose when to
destroy a weston_head.

For clone mode, struct weston_output gains head_list member, which is
the list of attached heads that will all show the same framebuffer.
Since heads are growing out of weston_output, management functions are
added.

Detaching a head from an enabled output is allowed to accommodate
disappearing heads. Attaching a head to an enabled output is disallowed
because it may need hardware reconfiguration and testing, and so
requires a weston_output_enable() call.

As a temporary measure, we have one weston_head embedded in
weston_output, so that backends can be migrated individually to the new
allocation scheme.

v8:
- Do not send wp_presentation_feedback.sync_output events for multiple
  wl_output globals in weston_presentation_feedback_present().

v6:
- adapt to upstream changes in weston_output_set_transform()
- use wl_list_for_each_safe in weston_output_release()
- removed weston_output_get_first_head() as it's not needed yet

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v5 Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
v7 Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: refactor weston_mode_switch_finish
Pekka Paalanen [Tue, 28 Mar 2017 12:27:10 +0000 (15:27 +0300)]
libweston: refactor weston_mode_switch_finish

Split out a new function. This is a pure refactoring, no change in
behaviour.

This helps a following patch that adds a loop over output->head_list.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v5 Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: make wl_output point to weston_head
Pekka Paalanen [Mon, 27 Mar 2017 13:31:25 +0000 (16:31 +0300)]
libweston: make wl_output point to weston_head

The user data of a wl_resource representing a wl_output protocol object
used to be a pointer to weston_output. Now that weston_output is being
split, wl_output more accurately refers to weston_head which is a single
monitor.

Change the wl_output user data to point to weston_head.
weston_output_from_resource() is replaced with
weston_head_from_resource().

This change is not strictly necessary, but architecturally it is the
right thing to do. In the future there might appear the need to refer to
a specific head of a cloned pair, for instance.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v5 Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: use head in wl_output global
Pekka Paalanen [Mon, 27 Mar 2017 09:24:34 +0000 (12:24 +0300)]
libweston: use head in wl_output global

As a wl_output represents weston_head, use a weston_head pointer as the
wl_output global's user data.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v5 Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: move wl_output to weston_head
Pekka Paalanen [Mon, 27 Mar 2017 09:15:38 +0000 (12:15 +0300)]
libweston: move wl_output to weston_head

The wl_output protocol interface exposes things like monitor make,
model, sub-pixel layout and physical dimensions. Obviously wl_output is
meant to represent a monitor.

The abstraction of a monitor is weston_head. Therefore move the wl_output
global and the bound resources list into weston_head.

When clone mode gets implemented in the future, this means that monitors
driven by the same CRTC will still be represented as separate wl_output
globals. This allows to accurately represent the hardware.

Clone mode that used separate, not frame-locked, CRTCs to drive two
monitors as clones would necessarily also be exposed as separate
wl_output since they have different timings.

v6:
- adapt to upstream changes in weston_output_set_transform()

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v5 Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agolibweston: introduce weston_head
Pekka Paalanen [Fri, 24 Mar 2017 13:39:24 +0000 (15:39 +0200)]
libweston: introduce weston_head

In order to support clone modes, libweston needs the concept of a head
that is separate from weston_output. While weston_output manages buffers
and the repaint state machine, weston_head will represent a single
monitor. In the future it will be possible to have a single
weston_output drive one or more weston_heads for a clone mode that
shares the framebuffers between all cloned heads.

All the fields that are obviously properties of the monitor are moved
from weston_output into weston_head.

As moving the fields requires one to touch all the backends for all the
assingments, introduce setter functions for them while we are here. The
setters are identical to the old assignments, for now.

As a temporary measure, weston_output embeds a single head. Also the
ugly casts in weston_head_set_monitor_strings() will be removed by a
follow-up patch.

Libweston major version is bumped, because weston_output struct layout
is changed.

v7:
- Bump libweston major version.

v6:
- adapt to upstream changes in weston_output_set_transform()

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v5 Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
v6 Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Derek Foreman <derekf@osg.samsung.com>
6 years agoconfigure.ac: Bump libweston version to match weston version
Derek Foreman [Mon, 9 Apr 2018 21:13:09 +0000 (16:13 -0500)]
configure.ac: Bump libweston version to match weston version

configure won't work if weston's version is higher than libweston's.

6 years agoconfigure.ac: Reopen master for regular development
Derek Foreman [Mon, 9 Apr 2018 18:13:40 +0000 (13:13 -0500)]
configure.ac: Reopen master for regular development

6 years agoconfigure.ac: bump to version 4.0.0 for the official release
Derek Foreman [Mon, 9 Apr 2018 16:55:01 +0000 (11:55 -0500)]
configure.ac: bump to version 4.0.0 for the official release

6 years agoterminal: Fix unintended fallthrough to cursor restore
Daniel Stone [Tue, 3 Apr 2018 18:38:09 +0000 (19:38 +0100)]
terminal: Fix unintended fallthrough to cursor restore

ef57a9b788 added support for window operations such as reporting the
title in escape mode. It implemented this by which-window-op case,
inside the existing which-escape-code case. Whilst it would break out of
the former window-op case, it never broke out of the latter escape-code
case. This would lead to window ops (such as reporting title) falling
through to restoring the saved cursor position.

This doesn't seem at all right, and also fixes a warning with GCC 8.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
6 years agoconfigure.ac: bump to version 3.0.93 for the RC1 release
Derek Foreman [Mon, 2 Apr 2018 18:00:01 +0000 (13:00 -0500)]
configure.ac: bump to version 3.0.93 for the RC1 release

6 years agoPartially revert "xwm: Add icon support to the frame" and friends
Derek Foreman [Fri, 30 Mar 2018 16:56:22 +0000 (11:56 -0500)]
Partially revert "xwm: Add icon support to the frame" and friends

This (partially) reverts commit bef761796c2ada6344d227142af4a0f40b9760dd.
This (partially) reverts commit 4d1cd36c9ea041688f92cd8981e43b5fe3b52409.
This (partially) reverts commit 44fc1be913ab2faad0414f50e51d58310302d065.
This (partially) reverts commit 6b58ea8c43ac81e519bd418efbf24687a5d731b8.

The new xwm icon code has proven to be leaky and incomplete, and while
we have patches under consideration to fix the rest of its known problems
they still require changes and review cycles.  Currently the known
leaks have been squashed, but it still picks wrong sized icons and
does no scaling, which can lead to very strange rendering.  At window
close time the wrong sized icon appears above the window during fade out.

This patch reverts the mostly solid bits and keeps the unfinished
bits behind in favor of a simpler revert than removing the whole
thing.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
6 years agoRevert "xwm: do not include shadow in input region"
Derek Foreman [Wed, 28 Mar 2018 14:33:56 +0000 (09:33 -0500)]
Revert "xwm: do not include shadow in input region"

This reverts commit 332d1892bbb380b32ff1c9f99d20184b447535dd.
And re-introduces the bug it was intended to fix, see:
https://lists.freedesktop.org/archives/wayland-devel/2017-December/036402.html

Reverting this because it causes harm to all xwayland clients - the
input region no longer gets adjusted when resizing windows.

start an xterm, resize it larger, you can no longer interact with the
new area of the window (including the server side decor).

6 years agoxwm: Fix two more icon related memory leaks
Derek Foreman [Tue, 27 Mar 2018 16:09:32 +0000 (11:09 -0500)]
xwm: Fix two more icon related memory leaks

Hopefully sort the last leaks introduced in commit 6b58ea8c

The window could be destroyed before it had a frame but after it had an icon
(I could trigger this with firefox), and the window could be assigned an icon
twice before it had a frame (I could trigger this with terminology).

The latter leak was
Reported-by: Scott Moreau <oreaus@gmail.com>
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoivi-shell: remove dead assignments in layer transition
Emre Ucan [Tue, 20 Mar 2018 14:29:41 +0000 (15:29 +0100)]
ivi-shell: remove dead assignments in layer transition

Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor: initialize ret in repaint_timer_handler
Emre Ucan [Tue, 20 Mar 2018 14:29:40 +0000 (15:29 +0100)]
compositor: initialize ret in repaint_timer_handler

If output_list of compositor is empty, value of
ret is read without initialization.

Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agogl-renderer: set num_images after import_simple_dmabuf
Emre Ucan [Tue, 20 Mar 2018 14:29:39 +0000 (15:29 +0100)]
gl-renderer: set num_images after import_simple_dmabuf

we have to set num_images after import_simple_dmabuf
call. Otherwise, egl_images will not be correctly
referenced in gl_renderer_attach_dmabuf.

(Found by clang source code analyzer)

Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoinput: fix use-after-free issue at pointer_cancel
Emre Ucan [Tue, 20 Mar 2018 14:28:24 +0000 (15:28 +0100)]
input: fix use-after-free issue at pointer_cancel

If the constraint is an one-shot constraint, constraint
is freed in disable_pointer_constraint function.
Therefore, we should not try to read freed memory at
"switch (constraint->lifetime)" statement.

The removed code is anyway superfluous. Because
surface destroy signal is only removed, when constraint
is an one-shot constraint.

(Found by clang source code analyzer)

Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agohmi-controller: remove dead assignments in add_launchers
Emre Ucan [Tue, 20 Mar 2018 14:28:23 +0000 (15:28 +0100)]
hmi-controller: remove dead assignments in add_launchers

assigned values of x, y, ret and layout_surface are
never read.

(Found by clang source code analyzer)

Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor-drm: remove dead assigment in drm_fb_create_dumb
Emre Ucan [Tue, 20 Mar 2018 14:28:22 +0000 (15:28 +0100)]
compositor-drm: remove dead assigment in drm_fb_create_dumb

ret is overwritten by drmModeAddFB2 call

(Found by clang source code analyzer)

Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoxwm: Fix memory leak
Scott Moreau [Fri, 23 Mar 2018 19:41:43 +0000 (13:41 -0600)]
xwm: Fix memory leak

A memory leak introduced by 6b58ea8c led to me finding a bigger leak,
which is xwm was calling frame_create() without calling frame_destroy().
This meant that the associated icon_surface was not being destroyed,
leaving the destroy handler for it broken. Here we fix this by calling
frame_destroy() when the window is destroyed and free the reply in
the icon_surface destroy handler.
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoRevert "xwm: Fix memory leak"
Pekka Paalanen [Tue, 20 Mar 2018 08:12:37 +0000 (10:12 +0200)]
Revert "xwm: Fix memory leak"

This reverts commit d2cb711d813e750b1e303e6200c027fd27a21f8e.

I missed the call to cairo_image_surface_create_for_data() which assumes
the data will remain present until the cairo surface is destroyed. It
seems the existence of data depends on the reply not being freed.

This will need a more involved fix.

Sorry, I noticed this just seconds after I pushed the patch.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoxwm: Fix memory leak
Scott Moreau [Tue, 20 Mar 2018 00:06:03 +0000 (18:06 -0600)]
xwm: Fix memory leak

Fix memory leak introduced by 6b58ea8c. weston_wm_handle_icon() was
calling xcb_get_property_reply() without freeing the reply.

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoconfigure.ac: bump to version 3.0.92 for the beta release
Derek Foreman [Mon, 19 Mar 2018 20:41:17 +0000 (15:41 -0500)]
configure.ac: bump to version 3.0.92 for the beta release

6 years agosimple-dmabuf-drm: use appropriately sized buffer (freedreno)
Guido Günther [Mon, 19 Mar 2018 16:45:19 +0000 (17:45 +0100)]
simple-dmabuf-drm: use appropriately sized buffer (freedreno)

Use stride instead of width for buffer calculation.

[Derek Foreman edited the commit log and removed the leftover
initialization of 'size']

Signed-off-by: Guido Günther <agx@sigxcpu.org>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
6 years agosimple-dmabuf-drm: Always define ALIGN
Guido Günther [Mon, 19 Mar 2018 16:45:18 +0000 (17:45 +0100)]
simple-dmabuf-drm: Always define ALIGN

Other backends might want to use it.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
6 years agoFix an uninitialized variable
Dima Ryazanov [Sun, 18 Mar 2018 04:20:29 +0000 (00:20 -0400)]
Fix an uninitialized variable

"has_discrete" gets set to true in if/else if, but gets left unset otherwise.
So let's initialize it to false.

(This was caught by valgrind.)

Signed-off-by: Dima Ryazanov <dima@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agosimple-dmabuf-drm: use getopt_long
Guido Günther [Fri, 16 Mar 2018 17:56:50 +0000 (18:56 +0100)]
simple-dmabuf-drm: use getopt_long

Signed-off-by: Guido Günther <agx@sigxcpu.org>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agosimple-dmabuf-drm: use opt bitmask instead of is_immediate
Guido Günther [Fri, 16 Mar 2018 17:56:49 +0000 (18:56 +0100)]
simple-dmabuf-drm: use opt bitmask instead of is_immediate

Signed-off-by: Guido Günther <agx@sigxcpu.org>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoAllow simple-dmabuf-drm to pass y_inverted flag
Guido Günther [Fri, 16 Mar 2018 17:56:48 +0000 (18:56 +0100)]
Allow simple-dmabuf-drm to pass y_inverted flag

This allows to check if ZWP_LINUX_BUFFER_PARAMS_V1_FLAGS_Y_INVERT is
interpreted correctly by the compositor.

We introduce an OPT_* bitmask to hold this flag and possible future
command line flags.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years ago.gitignore weston-simple-dmabuf-drm
Guido Günther [Fri, 16 Mar 2018 12:12:41 +0000 (13:12 +0100)]
.gitignore weston-simple-dmabuf-drm

Got renamed in f9dec67990a54afe14d4d2db694bf696ae418bcd

Signed-off-by: Guido Günther <agx@sigxcpu.org>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoweston: Add a help string for --xwayland
Dima Ryazanov [Fri, 16 Mar 2018 04:16:29 +0000 (00:16 -0400)]
weston: Add a help string for --xwayland

Signed-off-by: Dima Ryazanov <dima@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agosimple-dmabuf-drm: use vfunc for drm_device_destroy
Guido Günther [Thu, 15 Mar 2018 16:33:20 +0000 (17:33 +0100)]
simple-dmabuf-drm: use vfunc for drm_device_destroy

Remove ifdef clutter and makes sure it's only called for the active
backend.

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agosimpla-dmabuf-drm: Use more weston like coding style
Guido Günther [Thu, 15 Mar 2018 16:33:19 +0000 (17:33 +0100)]
simpla-dmabuf-drm: Use more weston like coding style

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agosimple-dmabuf-drm: allow multiple backends
Guido Günther [Thu, 15 Mar 2018 16:33:18 +0000 (17:33 +0100)]
simple-dmabuf-drm: allow multiple backends

This allows to enable freedreno and intel backends at the same time
building the prerequisites for adding further ones.

[Pekka: fix configure.ac if statements]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoconfigure.ac: fix have_dbus if dbus support is disabled
Michael Tretter [Wed, 14 Mar 2018 09:07:47 +0000 (10:07 +0100)]
configure.ac: fix have_dbus if dbus support is disabled

If dbus support is explicitly disabled, $have_dbus should be no, but was
empty. systemd-login support depends on dbus, but the check does not
trigger correctly, if $have_dbus is empty.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor: do not free output region twice in weston_output_set_transform()
Ilia Bozhinov [Wed, 14 Mar 2018 08:59:52 +0000 (10:59 +0200)]
compositor: do not free output region twice in weston_output_set_transform()

This is already done when weston_output_init_geometry() is called.
Actually this is a fix for 8564a0d, because without this patch, the
compositor sometimes crashes when setting output transform

Signed-off-by: Ilia Bozhinov <ammen99@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agobuild: honour libinput header location
Jan Engelhardt [Thu, 15 Mar 2018 13:45:28 +0000 (13:45 +0000)]
build: honour libinput header location

Add the respective CFLAGS to the build, otherwise it will error out as
seen below.

src/libinput-seat.c:30:22: fatal error: libinput.h: No such file or directory

v2: add the CFLAGS only as needed, suggested by Pekka

Cc: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Cc: Jan Engelhardt <jengelh@inai.de>
[Emil Velikov: polish commit message, v2]
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agolibweston/compositor: Place timeline recording after checking if stamp is valid
Marius Vlad [Tue, 6 Mar 2018 16:56:23 +0000 (18:56 +0200)]
libweston/compositor: Place timeline recording after checking if stamp is valid

The timestamp could be either NULL if there's no mode set, or 0 when output gets
awaken. It either crashes weston or we get vblanks at [0, 0] for that output.

Signed-off-by: Marius Vlad <marius-cristian.vlad@nxp.com>
CC: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
[Pekka: note, most start_repaint_loop pass in current time, not 0]
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agolibweston-desktop/xdg-shell-v6: Fix crash when surface has buffer at creation
Derek Foreman [Tue, 13 Mar 2018 16:34:47 +0000 (11:34 -0500)]
libweston-desktop/xdg-shell-v6: Fix crash when surface has buffer at creation

When a surface has a buffer at creation time we send an error, which results
in a disconnection and all resources being destroyed.

Since we send that error and return before performing the configure_list init
weston_desktop_xdg_surface_destroy() will walk an uninitialized list and
dereference a NULL pointer.

Initializing the list earlier prevents this from happening.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
6 years agoclients: consolidate timer code part 2
Pekka Paalanen [Fri, 9 Mar 2018 11:17:26 +0000 (13:17 +0200)]
clients: consolidate timer code part 2

Continue moving bits to use toytimer instead of carelessly open-coded
equivalent. Many of the copies were flawed against the race mentioned
in toytimer_fire().

This patch handles window.c's key repeat, confine demo, and
desktop-shell panel clock.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Acked-by: Daniel Stone <daniels@collabora.com>
6 years agoclients: consolidate timer code part 1
Pekka Paalanen [Fri, 9 Mar 2018 09:54:40 +0000 (11:54 +0200)]
clients: consolidate timer code part 1

There are multiple copies for the timerfd handling code, and I need a
timer in one more app. Consolidate all the timerfd code into window.c to
reduce the duplication. Many of the copies were also flawed against the
race mentioned in toytimer_fire().

This patch handles clickdot and window.c's tooltip timer and cursor
timer.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Acked-by: Daniel Stone <daniels@collabora.com>
6 years agocompositor-wayland: Ignore pointer enter on destroyed surface
Daniel Stone [Fri, 9 Mar 2018 10:08:37 +0000 (10:08 +0000)]
compositor-wayland: Ignore pointer enter on destroyed surface

Due to race conditions, it is (vanishingly unlikely but) possible to
receive a wl_pointer.enter event referring to a wl_surface we have just
destroyed. If this happens, wl_surface will be NULL. Detect this, clear
out our focus, and return.

Other pointer and keyboard events are robust against destroyed surfaces.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Cc: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
[Pekka: remove call to input_set_cursor()]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoinput: never set keyboard focus without wl_resource
Pekka Paalanen [Thu, 22 Feb 2018 14:55:15 +0000 (16:55 +0200)]
input: never set keyboard focus without wl_resource

Do not attempt to set keyboard focus to a surface that has no
wl_resource. The destroy listener hangs off the wl_resource, so if that
is not present, nothing will clean up the pointer when the
weston_surface gets destroyed and it goes stale.

As keyboard_focus_resource_destroyed() sets the focus to NULL, this
patch should be enough to guarantee that the keyboard focus surface will
always have a wl_resource.

I have confirmed the added branch in weston_keyboard_set_focus() can be
hit, but doing so is hard.

My test case has weston/x11 with two outputs, and weston/wayland
--sprawl running on top of that, then closing the parent compositor
output windows one by one. Sometimes it hits, often it does not. Having
the window closing animation enabled may help to hit it.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agocompositor-wayland: handle wl_keyboard.enter(NULL)
Pekka Paalanen [Thu, 22 Feb 2018 14:54:17 +0000 (16:54 +0200)]
compositor-wayland: handle wl_keyboard.enter(NULL)

Destroying an output (wl_surface) can race against the parent compositor
sending wl_keyboard.enter. When this race is lost, wayland-backend
receives wl_keyboard.enter with a NULL wl_surface for the surface it
just destroyed.

Handle this case by ignoring such enter events. Since it is
theoretically possible to follow enter with key events, drop those too.

The modifiers event is sent before enter, so we cannot drop that on the
same condition.

wl_keyboard.leave handler seems to already handle the NULL focus case,
but there is a question if the notify_keyboard_focus_out() call should
be avoided.

This patch fixes a hard to reproduce crash. I was running weston/x11
with two outputs, and weston/wayland --sprawl inside that, then closing
the parent compositor windows one by one. Sometimes it would trigger
this crash.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agoautoconf: Remove configure line forgotten in bb707dc0fe331c9af112a0552b7aa6fde755dd83
Emmanuel Gil Peyrot [Mon, 5 Mar 2018 19:02:40 +0000 (20:02 +0100)]
autoconf: Remove configure line forgotten in bb707dc0fe331c9af112a0552b7aa6fde755dd83

Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agogl-renderer: Create a high priority context
Chris Wilson [Thu, 1 Mar 2018 08:28:30 +0000 (08:28 +0000)]
gl-renderer: Create a high priority context

EGL_IMG_context_priority allows the client to request that their
rendering be considered high priority. For ourselves, this is important
as we are interactive and any delay in our rendering causes input-output
jitter; a less than smooth user interactive. So if the driver supports
setting the context priority, try and create our EGLContext as high
priority. The driver may reject our request due to system restrictions,
in which case it will fallback to normal priority, but if successful it
will reschedule our rendering and all of its dependencies to execute
earlier, especially important when the GPU is being hogged by background
clients.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor-drm: Remove no_addfb2 handling
Daniel Stone [Thu, 17 Nov 2016 18:17:16 +0000 (18:17 +0000)]
compositor-drm: Remove no_addfb2 handling

If AddFB2 ever fails for any reason, we fall back to legacy AddFB, which
doesn't support the same swathe of formats, or multi-planar formats, or
modifiers.

This can happen with arbitrary client buffers, condemning us to the
fallback forever more. Remove this, at the cost of an unnecessary ioctl
for users on old kernels without AddFB2; unfortunately, we cannot detect
the complete absence of the ioctl, as the return here is -EINVAL rather
than -ENOTTY.

A check for whether or not the format is valid has been replaced with an
assert, as its callers either check that the format is non-zero, return
a FourCC format code from GBM, or use a static FourCC format.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor-drm: Rename region variable
Daniel Stone [Tue, 8 Nov 2016 21:19:22 +0000 (21:19 +0000)]
compositor-drm: Rename region variable

Make it a bit more clear what the purpose of the variable is.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agocompositor-drm: Don't need safe view-list traversal
Daniel Stone [Thu, 1 Dec 2016 12:33:54 +0000 (12:33 +0000)]
compositor-drm: Don't need safe view-list traversal

Nothing in this loop reorders views within the compositor's view_list.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoconfigure.ac: bump to version 3.0.91 for the alpha release
Derek Foreman [Mon, 26 Feb 2018 18:56:12 +0000 (12:56 -0600)]
configure.ac: bump to version 3.0.91 for the alpha release

6 years agocompositor-rdp: Correct mouse scrolling direction
Jason Gerecke [Fri, 9 Feb 2018 16:14:41 +0000 (08:14 -0800)]
compositor-rdp: Correct mouse scrolling direction

The direction of scrolling in the RDP compositor appears to be inverted.
When using Weston directly in X, sending X11 button 4 cuases window
contents to scroll up and button 4 to be reported to xwayland clients.
Conversely, when using Weston through RDP (xfreerdp client), sending
X11 button 4 causes window contents to scroll down and button 5 to be
reported to xwayland clients. The xfreerdp client does not seem to be
the cause of this since scrolling works correctly when connecting to
a Windows host.

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Reviewed-by: David Fort <contact@hardening-consulting.com>
6 years agocompositor-drm: handle null cursor_plane
Greg V [Mon, 19 Feb 2018 14:59:42 +0000 (17:59 +0300)]
compositor-drm: handle null cursor_plane

Was crashing when I tried to take a screenshot.

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agolibweston: Implement touch timestamps for input_timestamps_unstable_v1
Alexandros Frantzis [Tue, 20 Feb 2018 12:07:03 +0000 (14:07 +0200)]
libweston: Implement touch timestamps for input_timestamps_unstable_v1

Implement the zwp_input_timestamps_manager_v1.get_touch_timestamps
request to subscribe to timestamp events for wl_touch resources. Ensure
that the request handling code can gracefully handle inert touch
resources.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agolibweston: Implement pointer timestamps for input_timestamps_unstable_v1
Alexandros Frantzis [Tue, 20 Feb 2018 12:06:26 +0000 (14:06 +0200)]
libweston: Implement pointer timestamps for input_timestamps_unstable_v1

Implement the zwp_input_timestamps_manager_v1.get_pointer_timestamps
request to subscribe to timestamp events for wl_pointer resources.
Ensure that the request handling code can gracefully handle inert
pointer resources.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agolibweston: Implement keyboard timestamps for input_timestamps_unstable_v1
Alexandros Frantzis [Tue, 20 Feb 2018 12:05:50 +0000 (14:05 +0200)]
libweston: Implement keyboard timestamps for input_timestamps_unstable_v1

Implement the zwp_input_timestamps_manager_v1.get_keyboard_timestamps
request to subscribe to timestamp events for wl_keyboard resources.
Ensure that the request handling code can gracefully handle inert
keyboard resources.

This commit introduces a few internal helper functions which will also
be useful in the implementation of the remaining
zwp_input_timestamps_manager_v1 requests.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agolibweston: Introduce input-timestamps support
Alexandros Frantzis [Fri, 16 Feb 2018 16:44:16 +0000 (18:44 +0200)]
libweston: Introduce input-timestamps support

Introduce code to support the implementation of the
input_timestamps_unstable_v1 protocol in libweston. This commit does not
implement the actual timestamp subscriptions, but sets up the
zwp_input_timestamps_manager_v1 object and introduces dummy request
handling functions for it, laying the foundation for timestamp
subscriptions for keyboard/pointer/touch to be added cleanly in upcoming
commits.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agotests: Introduce input timestamps helper
Alexandros Frantzis [Fri, 16 Feb 2018 16:44:15 +0000 (18:44 +0200)]
tests: Introduce input timestamps helper

Introduce helper test code to implement the client side of the
input_timestamps_unstable_v1 protocol. This helper will be used in
upcoming commits to test the server side implementation of the protocol
in libweston.

The input_timestamps_unstable_v1 protocol was introduced in version 1.13
of wayland-protocols, so this commit updates the version dependency in
configure.ac accordingly.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoshared: Add timespec_eq helper function
Alexandros Frantzis [Fri, 16 Feb 2018 16:44:14 +0000 (18:44 +0200)]
shared: Add timespec_eq helper function

Add a helper function to check if two struct timespec values are equal.
This helper function will be used in upcoming commits that implement the
input_timestamps_unstable_v1 protocol.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agogl-renderer: make use of linux_dmabuf_buffer_get_user_data()
Emil Velikov [Thu, 15 Feb 2018 18:51:50 +0000 (18:51 +0000)]
gl-renderer: make use of linux_dmabuf_buffer_get_user_data()

... to get the user_data. Like everywhere else through weston.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agotests: Add test for seat destruction and creation
Alexandros Frantzis [Thu, 8 Feb 2018 13:37:58 +0000 (15:37 +0200)]
tests: Add test for seat destruction and creation

Add a test to check that we can destroy and create the test seat. Since
after test seat destruction the test client releases any associated
input resources, this test also checks that libweston properly handles
release requests for inert input resources.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agotests: Run devices tests using the test desktop shell
Alexandros Frantzis [Thu, 8 Feb 2018 13:37:57 +0000 (15:37 +0200)]
tests: Run devices tests using the test desktop shell

Use the weston-test-desktop-shell to run the devices tests, instead of
the currently used desktop-shell. The test desktop shell doesn't
interact with temporary globals (e.g. wl_seat), thus avoiding an
inherent race in the current wayland protocol when removing globals.
This will allow us to safely add tests which add/remove such globals in
upcoming commits.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agotests: Support setting the test client input dynamically
Alexandros Frantzis [Thu, 8 Feb 2018 13:37:56 +0000 (15:37 +0200)]
tests: Support setting the test client input dynamically

The current test client code waits for all wl_seat globals to arrive
before checking them and deciding which one is the test seat global to
use for the input object. Test code that needs to add/remove test seats
would have to call the client_set_input() function for any seat changes
to take effect. Although we could allow this by making
client_set_input() public, we would be exposing unecessary
implementation details.

This commit applies any seat changes immediately upon arrival of the
seat name, freeing test code from needing to call extra functions like
client_set_input(). To achieve this the call to input_data_devices() is
moved from client_set_input() to the seat name event handler.

This commit also moves the check that all seats have names to an
explicit test. To support this test, inputs corresponding to non-test
seats are not destroyed (unless their seat global is removed), as
was previously the case.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agotests: Handle removal of seat global in test clients
Alexandros Frantzis [Thu, 8 Feb 2018 13:37:55 +0000 (15:37 +0200)]
tests: Handle removal of seat global in test clients

The current test client code completely ignores removal of globals.
This commit updates the code to properly handle removal of globals in
general, and of seat globals in particular. This ensures that the test
client objects are in sync with the server and any relevant resources
are released accordingly.

This update will be used by upcoming tests to check that seat removal
and re-addition is working properly.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agolibweston: Make weston_seat release safe
Alexandros Frantzis [Thu, 15 Feb 2018 11:07:09 +0000 (13:07 +0200)]
libweston: Make weston_seat release safe

Ensure the server can safely handle client requests for wl_seat resource
that have become inert due to weston_seat object release and subsequent
destruction.

The clean-up involves, among other things, unsetting the destroyed
weston_seat object from the user data of wl_seat resources, and handling
this NULL user data case where required.

The list of sites extracting and using weston_seat object from wl_seat
resources which were audited for this patch are:

Legend:
N/A = Not Applicable (not implemented by weston)
FIXED = Fixed in the commit
OK = Already works correctly

== keyboard_shortcuts_inhibit_unstable_v1 ==
[N/A] zwp_keyboard_shortcuts_inhibit_manager_v1.inhibit_shortcuts
== tablet_input_unstable_v{1,2} ==
[N/A] zwp_tablet_manager_v{1,2}.get_tablet_seat
== text_input_unstable_v1 ==
[FIXED] zwp_text_input_v1.activate
[FIXED] zwp_text_input_v1.deactivate
== wl_data_device ==
[FIXED] wl_data_device_manager.get_data_device
[OK] wl_data_device.start_drag
[FIXED] wl_data_device.set_selection
[OK] wl_data_device.release
== wl_shell ==
[FIXED] wl_shell_surface.move
[FIXED] wl_shell_surface.resize
[FIXED] wl_shell_surface.set_popup
== xdg_shell and xdg_shell_unstable_v6 ==
[FIXED] xdg_toplevel.show_window_menu
[FIXED] xdg_toplevel.move
[FIXED] xdg_toplevel.resize
[FIXED] xdg_popup.grab
== xdg_shell_unstable_v5 ==
[FIXED] xdg_shell.get_xdg_popup
[FIXED] xdg_surface.show_window_menu
[FIXED] xdg_surface.move
[FIXED] xdg_surface.resize

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
6 years agolibweston: Make weston_pointer destruction safe
Alexandros Frantzis [Thu, 8 Feb 2018 13:37:53 +0000 (15:37 +0200)]
libweston: Make weston_pointer destruction safe

Properly clean up all sub-objects (e.g., weston_pointer_client objects)
when a weston_pointer object is destroyed. The clean-up ensures that the
server is able to safely handle client requests to any associated
pointer resources, which, as a consenquence of a weston_pointer
destruction, have now become inert.

The clean-up involves, among other things, unsetting the destroyed
weston_pointer object from the user data of pointer resources, and
handling this NULL user data case where required. Note that in many
sites affected by this change the existing code already properly handles
NULL weston_pointer (e.g. in init_pointer_constraint), so there is no
need for additional updates there.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agolibweston: Support NULL weston_pointer in init_pointer_constraint
Alexandros Frantzis [Thu, 8 Feb 2018 13:37:52 +0000 (15:37 +0200)]
libweston: Support NULL weston_pointer in init_pointer_constraint

Fix init_pointer_constraint so that it creates a valid, but inert,
resource if a NULL weston_pointer value is passed in. In that case no
constraint object is associated with the resource, but this is not an
issue since affected code can already handle NULL constraint objects.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agotests: fix a race condition in ivi-shell tests
Emre Ucan [Wed, 14 Feb 2018 10:06:54 +0000 (11:06 +0100)]
tests: fix a race condition in ivi-shell tests

ivi-shell tests load their own controller plugin
for testing purposes. Tests also uses the generated
weston-ivi.in config file, which causes weston to
load hmi-controller and its helper client.
Existence of hmi-controller and its helper client
confuses test plugins. Because they are creating
surfaces and layers which are not expected by
test plugins.

We can start ivi-shell tests without config file
to solve this problem. Then, weston will not load
hmi-controller plugin.

Reported-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Acked-by: Daniel Stone <daniels@collabora.com>
6 years agolibweston-desktop/xdg-shell-v5: Drop xdg-shell v5 support
Alexandros Frantzis [Tue, 13 Feb 2018 14:20:56 +0000 (16:20 +0200)]
libweston-desktop/xdg-shell-v5: Drop xdg-shell v5 support

Drop support for the obsolete xdg-shell v5 protocol. This clears the
path to properly support xdg-shell stable, since xdg-shell stable and
xdg-shell v5 can't currently co-exist in the same compositor, as both
define structures with the same name (such as struct
xdg_surface_interface).

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Proposed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Acked-by: Jonas Ådahl <jadahl@gmail.com>
6 years agodesktop-shell: fix shell_output_destroy_move_layer unused variable
Pekka Paalanen [Tue, 13 Feb 2018 14:18:05 +0000 (16:18 +0200)]
desktop-shell: fix shell_output_destroy_move_layer unused variable

/home/pq/git/weston/desktop-shell/shell.c: In function ‘shell_output_destroy_move_layer’:
/home/pq/git/weston/desktop-shell/shell.c:4718:24: warning: unused variable ‘output’ [-Wunused-variable]
  struct weston_output *output = data;

Since the data pointer is not used for anything, decided to also set it
to NULL in the caller. This caused another variable to become unused.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Marius-Vlad <marius-cristian.vlad@nxp.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
6 years agocompositor-drm: unref udev monitor on exit
Pekka Paalanen [Thu, 7 Dec 2017 14:06:05 +0000 (16:06 +0200)]
compositor-drm: unref udev monitor on exit

Leaks 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: 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>