platform/upstream/weston.git
6 years agolibweston: introduce weston_output_from_resource()
Pekka Paalanen [Mon, 27 Mar 2017 12:14:32 +0000 (15:14 +0300)]
libweston: introduce weston_output_from_resource()

This is a simple wrapper for casting the user data of a wl_resource into
a struct weston_output pointer. Using the wrapper clearly marks all the
places where a wl_output protocol object is used.

Replace ALL wl_output related calls to wl_resource_get_user_data() with
a call to weston_output_from_resource().

v2: add type assert in weston_output_from_resource().

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Armin Krezović <krezovic.armin@gmail.com>
6 years agolibweston: make weston_output::connection_internal a bool
Pekka Paalanen [Fri, 24 Mar 2017 13:46:23 +0000 (15:46 +0200)]
libweston: make weston_output::connection_internal a bool

It really is a boolean.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Armin Krezović <krezovic.armin@gmail.com>
6 years agolibweston: extend output->region lifetime
Pekka Paalanen [Thu, 30 Mar 2017 13:04:58 +0000 (16:04 +0300)]
libweston: extend output->region lifetime

It's a little awkward to try to keep the weston_output::region and
weston_output::previous_damage allocate exactly only when the output is
enabled. There was also a leak: weston_output_move() was calling
weston_output_init_geometry() on an already allocated regions without
fini in between.

Fix both issues by allocating the regions in weston_output_init(),
always fini/init'ing them in weston_output_init_geometry(), and fini'ing
for good in weston_output_destroy().

This nicely gets rid of weston_output_enable_undo() so I do not need to
try to figure out what to do with it later.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Armin Krezović <krezovic.armin@gmail.com>
6 years agolibweston: move globals to weston_compositor_add_output()
Pekka Paalanen [Thu, 30 Mar 2017 12:48:06 +0000 (15:48 +0300)]
libweston: move globals to weston_compositor_add_output()

Move the wl_output global management into weston_compositor_add_output()
and weston_compositor_remove_output().

If weston_output_enable() fails, there is no need to clean up the global
and the clients will not see a wl_output come and go.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Armin Krezović <krezovic.armin@gmail.com>
6 years agolibweston: move output id into add/remove_output()
Pekka Paalanen [Thu, 30 Mar 2017 12:19:45 +0000 (15:19 +0300)]
libweston: move output id into add/remove_output()

Move the output id management into weston_compositor_add_output() and
weston_compositor_remove_output(). This is a more logical place, and
works towards assimilating weston_output_enable_undo().

The output id is no longer available to the backend enable() vfuncs, but
it was not used there to begin with.

v2: moved assert earlier in weston_compositor_add_output()

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Armin Krezović <krezovic.armin@gmail.com>
6 years agolibweston: prevent double weston_output_enable()
Pekka Paalanen [Thu, 30 Mar 2017 12:11:25 +0000 (15:11 +0300)]
libweston: prevent double weston_output_enable()

Enabling an already enabled output is an error, at least with the
current implementation.

However, disabling an output that has not been enabled is ok.

Cope with the first and document the second.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Armin Krezović <krezovic.armin@gmail.com>
6 years agolibweston: specify weston_output::enabled
Pekka Paalanen [Thu, 30 Mar 2017 11:56:22 +0000 (14:56 +0300)]
libweston: specify weston_output::enabled

It was ambiguous what this flag meant - it did not mean whether the
backend is considering this output to be enabled, because
weston_output_destroy() unsets it while deliberately not calling the
backend disable() vfunc.

Perhaps the most clear definition is with respect to the output's
assignment in the pending vs. enabled output lists. There is also a whole
bunch of variables that are allocated only when enabled is true.

Since the flag is related to the list membership, set and clear the flag
only when manipulating the lists.

Assert that weston_compositor_add_output() and
weston_compositor_remove_output() are not called in a wrong state.

v2:
- talk about "list of enabled outputs"
- clear 'enabled' in weston_compositor_remove_output() earlier

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Armin Krezović <krezovic.armin@gmail.com>
6 years agolibweston: move asserts to add_pending_output()
Pekka Paalanen [Wed, 29 Mar 2017 14:14:00 +0000 (17:14 +0300)]
libweston: move asserts to add_pending_output()

weston_compositor_add_pending_output() is the point through which all
backends must go when creating a new output. The enable and disable
vfuns are essential for anything to be done with the output, so it makes
sense to check them here, rather than when actually enabling or
disabling.

Particularly the disable vfunc is rarely called, so this gets the check
better excercised.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Armin Krezović <krezovic.armin@gmail.com>
6 years agolibweston: unexport weston_output_update_matrix()
Pekka Paalanen [Wed, 29 Mar 2017 14:01:41 +0000 (17:01 +0300)]
libweston: unexport weston_output_update_matrix()

Only used internally in core. Needs to happen automatically when
something changes, so there should no need to call it from outside.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Armin Krezović <krezovic.armin@gmail.com>
6 years agolibweston: unexport weston_compositor_add_output()
Pekka Paalanen [Wed, 29 Mar 2017 13:58:48 +0000 (16:58 +0300)]
libweston: unexport weston_compositor_add_output()

Only used by weston_output_enable().

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Armin Krezović <krezovic.armin@gmail.com>
6 years agolibweston: two more weston_output docs
Pekka Paalanen [Wed, 29 Mar 2017 13:53:50 +0000 (16:53 +0300)]
libweston: two more weston_output docs

Document two more functions of the weston_output API.

Exported functions marked internal are meant for backends only.
Exported functions not marked internal are meant for libweston users.

v2: talk about "list of enabled outputs".

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Armin Krezović <krezovic.armin@gmail.com>
6 years agolibweston: let add/remove_output handle the lists
Pekka Paalanen [Wed, 29 Mar 2017 13:20:19 +0000 (16:20 +0300)]
libweston: let add/remove_output handle the lists

A weston_output available to the compositor should always be either in
the list of pending outputs or the list of enabled outputs. Let
weston_compositor_add_output() and weston_compositor_remove_output()
handle the moves between the lists.

This way weston_output_enable() does not need to remove and
oops-it-failed-add-it-back. weston_output_disable() does not need to
manually re-add the output back to the pending list.

To make everything nicely symmetric and fix any unbalancing caused by
this:
- weston_output_destroy() explicitly wl_list_remove()s
- weston_compositor_add_pending_output() first removes then inserts, as
we have the assumption that the link is always valid, even if empty.

Update the documentations, too.

v2:
- talk about "list of enabled outputs"
- keep wl_list_remove in weston_compositor_remove_output in its old
  place

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Armin Krezović <krezovic.armin@gmail.com>
6 years agolibweston: use helper var in weston_compositor_remove_output
Pekka Paalanen [Wed, 29 Mar 2017 13:16:04 +0000 (16:16 +0300)]
libweston: use helper var in weston_compositor_remove_output

To shorten lines.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Armin Krezović <krezovic.armin@gmail.com>
6 years agolibweston: untangle weston_compositor_remove_output doc
Pekka Paalanen [Wed, 29 Mar 2017 13:07:34 +0000 (16:07 +0300)]
libweston: untangle weston_compositor_remove_output doc

Trying to make it more readable. Things that happen in the same step are
kept in the same paragraph.

v2: talk about "list of enabled outputs"

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Armin Krezović <krezovic.armin@gmail.com>
6 years agoivi-shell: Fixed broken link to wiki page in ivi-layout header file
Michael Teyfel [Tue, 25 Jul 2017 09:34:33 +0000 (11:34 +0200)]
ivi-shell: Fixed broken link to wiki page in ivi-layout header file

Signed-off-by: Michael Teyfel <mteyfel@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoivi-shell: remove orientation calculation
Ucan, Emre (ADITG/SW1) [Fri, 3 Mar 2017 14:21:32 +0000 (14:21 +0000)]
ivi-shell: remove orientation calculation

Dead code as orientation cannot be changed anymore, see patches:
ivi-shell: remove layer_set_orientation API
ivi-shell: remove surface_set_orientation API

Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
[Pekka: added commit message]
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoivi-shell: remove layer_set_orientation API
Ucan, Emre (ADITG/SW1) [Fri, 3 Mar 2017 14:21:31 +0000 (14:21 +0000)]
ivi-shell: remove layer_set_orientation API

This API is used to rotate the contents of
application's buffer, which are in the render
order list of the layer. But this API is not
needed because an application can rotate
its buffers with set_buffer_transform request
of wl_surface interface

Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoivi-shell: remove surface_set_orientation API
Ucan, Emre (ADITG/SW1) [Fri, 3 Mar 2017 14:21:28 +0000 (14:21 +0000)]
ivi-shell: remove surface_set_orientation API

This API is used to rotate the contents of
application's buffer. But it is not needed
because an application can rotate its buffers
with set_buffer_transform request of
wl_surface interface.

Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
6 years agoivi-shell: add_screen_remove_layer API
Ucan, Emre (ADITG/SW1) [Thu, 2 Mar 2017 08:47:33 +0000 (08:47 +0000)]
ivi-shell: add_screen_remove_layer API

It is analagous to layer_remove_surface API.
The API removes a layer from the render order
of the screen.

v3:
add the new vfunc at the end of
the ivi_layout_interface struct.

Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Eugen Friedrich <friedrix@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
7 years agoxwm: update override-redirect surface's position upon configure_notify
Ilia Bozhinov [Tue, 27 Jun 2017 21:08:40 +0000 (00:08 +0300)]
xwm: update override-redirect surface's position upon configure_notify

When we receive configure_notify we should update the surface's
position by calling xwayland_api->set_xwayland(). Otherwise some surfaces
like dnd surfaces from xwayland views are "stuck" at one place. When
setting XWAYLAND state though we should always call view_set_position(),
not just the first time we set this state.

Signed-off-by: Ilia Bozhinov <ammen99@gmail.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
7 years agolibweston-desktop/xdg-shell: Properly handle ack_configure
Quentin Glidic [Tue, 18 Jul 2017 10:59:14 +0000 (12:59 +0200)]
libweston-desktop/xdg-shell: Properly handle ack_configure

Now we keep track of serial->state association and we discard the states
that the client ignored.

Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
7 years agolibweston-desktop/xdg-shell: Check surface size against acknowledged size
Quentin Glidic [Wed, 12 Jul 2017 07:45:43 +0000 (09:45 +0200)]
libweston-desktop/xdg-shell: Check surface size against acknowledged size

We were checking against the pending size, which lead some clients
(simple-egl) to crash because they sent a buffer before acknowledging
the latest configure event.

Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Tested-by: Emmanuel Gil Peyrot <emmanuel.peyrot@collabora.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
7 years agolibweston-desktop/xdg-shell: Add pending/next/current structs
Quentin Glidic [Wed, 12 Jul 2017 07:42:57 +0000 (09:42 +0200)]
libweston-desktop/xdg-shell: Add pending/next/current structs

Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Tested-by: Emmanuel Gil Peyrot <emmanuel.peyrot@collabora.com>
7 years agolibweston-desktop/xdg-shell: Rename requested_ to pending_
Quentin Glidic [Tue, 11 Jul 2017 11:31:36 +0000 (13:31 +0200)]
libweston-desktop/xdg-shell: Rename requested_ to pending_

Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Tested-by: Emmanuel Gil Peyrot <emmanuel.peyrot@collabora.com>
7 years agoconfigure.ac: bump to version 2.99.91 for the alpha release
Bryce Harrington [Wed, 12 Jul 2017 02:16:40 +0000 (19:16 -0700)]
configure.ac: bump to version 2.99.91 for the alpha release

7 years agoconfigure: Stop printing libxkbcommon in configure results
Derek Foreman [Mon, 3 Jul 2017 19:36:50 +0000 (14:36 -0500)]
configure: Stop printing libxkbcommon in configure results

Cosmetic leftovers I missed when removing the configure
option to --disable-xkbcommon

Reviewed-by: Daniel Stone <daniels@collabora.com>
7 years agodmabuf: Don't crash clients by sending version inappropriate events
Derek Foreman [Mon, 26 Jun 2017 20:55:44 +0000 (15:55 -0500)]
dmabuf: Don't crash clients by sending version inappropriate events

We need to make sure the client bound dmabuf with a high enough
version to receive modifier events before sending them or the
client will crash.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
7 years agolinux-dmabuf: Fix crash with no valid modifiers
Derek Foreman [Mon, 26 Jun 2017 19:44:54 +0000 (14:44 -0500)]
linux-dmabuf: Fix crash with no valid modifiers

We shouldn't free &modifier_invalid because it wasn't allocated
with malloc()

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
7 years agogl-renderer: Fix some missing newlines in log messages
Derek Foreman [Mon, 26 Jun 2017 19:42:44 +0000 (14:42 -0500)]
gl-renderer: Fix some missing newlines in log messages

Some log messages weren't terminated with a newline.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
7 years agoinput: Remove --disable-xkbcommon
Derek Foreman [Wed, 28 Jun 2017 16:17:23 +0000 (11:17 -0500)]
input: Remove --disable-xkbcommon

It looks like there are some code paths where this has been forgotten, so
it likely doesn't work as is.  It's probable that nobody has actually
used this in a very long time, so it's not worth the maintenance burden
of keeping xkbcommon vs raw keyboard code anymore.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
7 years agolibweston-desktop/xdg-shell: Consolidate configure event sending
Quentin Glidic [Thu, 13 Apr 2017 18:25:27 +0000 (20:25 +0200)]
libweston-desktop/xdg-shell: Consolidate configure event sending

When switching a state twice in a row, we were overwriting the old value
without setting it back, sending a wrong state to the client.

Now we update our requested state, then check if we need to schedule a
configure event, if we have one scheduled already or even if we can
cancel it.

Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Daniel Stone <daniels@collabora.com>
7 years agolibweston-desktop/xdg_shell_v6: Send error on wrongly-sized buffer
Quentin Glidic [Fri, 10 Mar 2017 10:50:41 +0000 (11:50 +0100)]
libweston-desktop/xdg_shell_v6: Send error on wrongly-sized buffer

Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Daniel Stone <daniels@collabora.com>
7 years agoclients/simple-dmabuf-drm: import with dmabuf modifiers
Varad Gautam [Wed, 23 Nov 2016 08:33:21 +0000 (14:03 +0530)]
clients/simple-dmabuf-drm: import with dmabuf modifiers

mesa's freedreno driver supports importing dmabufs with format
DRM_FORMAT_NV12 and DRM_FORMAT_MOD_SAMSUNG_64_32_TILE modifier.
demonstrate weston modifier advertising and import path using this
combination when run with --import-format=NV12.

v2:
 - hard code format if platform doesn't implement
   EGL_EXT_image_dma_buf_import_modifiers and cannot advertise
   format/modifier support.
 - squash using valid frame data to fill dmabuf planes

Signed-off-by: Varad Gautam <varad.gautam@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
7 years agoclients/simple-dmabuf-drm: add freedreno support alongside intel
Varad Gautam [Wed, 26 Apr 2017 13:47:18 +0000 (19:17 +0530)]
clients/simple-dmabuf-drm: add freedreno support alongside intel

abstract drm specific bits to struct drm_device and support running on
freedreno. introduce 'modifier' event.

v2: rebase to master, deprecate 'format' event.

Signed-off-by: Varad Gautam <varad.gautam@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
7 years agoclients/simple-dmabuf-intel: rename to simple-dmabuf-drm
Varad Gautam [Thu, 17 Nov 2016 11:55:59 +0000 (17:25 +0530)]
clients/simple-dmabuf-intel: rename to simple-dmabuf-drm

this will allow adding other drm backends later.

Signed-off-by: Varad Gautam <varad.gautam@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
7 years agogl-renderer: allow importing fourth dmabuf plane
Varad Gautam [Wed, 23 Nov 2016 08:33:19 +0000 (14:03 +0530)]
gl-renderer: allow importing fourth dmabuf plane

EGL_EXT_image_dma_buf_import_modifiers supports importing upto four dmabuf
planes into an EGLImage.

v2: correct PLANE3_PITCH token (Daniel Stone)

Signed-off-by: Varad Gautam <varad.gautam@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
7 years agogl-renderer: allow importing dmabufs with format modifiers
Varad Gautam [Wed, 23 Nov 2016 08:33:18 +0000 (14:03 +0530)]
gl-renderer: allow importing dmabufs with format modifiers

pass over the modifier attributes to EGL.

v2: ensure same modifier is passed for all planes (Daniel Stone)

Signed-off-by: Varad Gautam <varad.gautam@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
7 years agolinux-dmabuf: advertise supported formats and modifiers
Varad Gautam [Wed, 26 Apr 2017 13:47:17 +0000 (19:17 +0530)]
linux-dmabuf: advertise supported formats and modifiers

implement 'modifier' event to communicate available formats and modifiers
to the client and support zwp_linux_dmabuf_v1 interface version 3.

v2: handle zero modifiers case, deprecate 'format' event.

Signed-off-by: Varad Gautam <varad.gautam@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
7 years agogl-renderer: support format and modifier queries
Varad Gautam [Wed, 23 Nov 2016 08:33:20 +0000 (14:03 +0530)]
gl-renderer: support format and modifier queries

EGL_EXT_image_dma_buf_import_modifiers allows querying the formats
and modifiers supported by the platform. expose these to the compositor.

v2:
 - change calloc args (Daniel Stone)
 - check for modifier support before querying formats (Daniel Stone)

Signed-off-by: Varad Gautam <varad.gautam@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
7 years agoclients/simple-dmabuf-intel: request no-roundtrip dmabuf import
Varad Gautam [Wed, 26 Apr 2017 13:46:00 +0000 (19:16 +0530)]
clients/simple-dmabuf-intel: request no-roundtrip dmabuf import

request immediate dmabuf import when run with "immed" arg.

Signed-off-by: Varad Gautam <varad.gautam@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
7 years agolinux-dmabuf: implement immediate dmabuf import
Varad Gautam [Wed, 26 Apr 2017 13:45:59 +0000 (19:15 +0530)]
linux-dmabuf: implement immediate dmabuf import

handle create_immed() dmabuf import requests and support
zwp_linux_dmabuf_v1_interface version 2.

v2: terminate client with INVALID_WL_BUFFER when reason
    for create_immed failure is unknown.

[daniels: Bump wayland-protocols dependency.]

Signed-off-by: Varad Gautam <varad.gautam@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
7 years agocompositor-fbdev: Instead of less than 1 Hz use default refresh rate
Oliver Smith [Mon, 17 Apr 2017 11:11:00 +0000 (11:11 +0000)]
compositor-fbdev: Instead of less than 1 Hz use default refresh rate

I ran Weston on a Nexus 4 mobile phone, with a native GNU/Linux userland,
and the latest Android kernel for that device from LineageOS [1].

calculate_refresh_rate() returned 1 (mHz), which gets rounded to 0 Hz later
and results in nothing being drawn to the screen.

This patch makes sure, that there is at least a refresh rate of 1 Hz, because
it returns the default refresh rate of 60 Hz otherwise.

[1]: https://github.com/LineageOS/lge-kernel-mako

Signed-off-by: Oliver Smith <ollieparanoid@bitmessage.ch>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
7 years agoweston: Add support for "--foo bar" style options
Lyude Paul [Mon, 8 May 2017 16:47:55 +0000 (12:47 -0400)]
weston: Add support for "--foo bar" style options

A little earlier today I ended up spending a lot of time trying to
figure out why weston wasn't managing to launch over SSH and telling me
that I did not have a --tty option specified, despite me passing the
option strings ["--tty", "3"]. Turns out weston just doesn't support
that.

So, add support for this kind of format in addition to "--foo=bar" to
save others from making the same mistake I did.

Changes since v1:
 - Add comment about unreachable boolean check in long_option_with_arg()
 - Convert boolean check in long_option_with_arg() to assert

Signed-off-by: Lyude <lyude@redhat.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
7 years agolibweston: Allow compositor-wayland to use wl_surface_damage_buffer
Derek Foreman [Fri, 19 May 2017 15:42:07 +0000 (10:42 -0500)]
libweston: Allow compositor-wayland to use wl_surface_damage_buffer

wl_surface_damage_buffer landed ages ago, but in order for GL to
use it the client must bind a wl_compositor version >= 4 (the
version where damage_buffer was introduced).

This patch updates the bind version and allows
eglSwapBuffersWithDamage to actually use the provided damage
rectangles instead of performing full surface damage.

Reviewed-by: Daniel Stone <daniels@collabora.com>
7 years agoclients: Allow simple-egl to use wl_surface_damage_buffer
Derek Foreman [Fri, 19 May 2017 14:39:06 +0000 (09:39 -0500)]
clients: Allow simple-egl to use wl_surface_damage_buffer

wl_surface_damage_buffer landed ages ago, but in order for GL to
use it the client must bind a wl_compositor version >= 4 (the
version where damage_buffer was introduced).

This patch updates the bind version and allows
eglSwapBuffersWithDamage to actually use the provided damage
rectangles instead of performing full surface damage.

This log is much longer than the patch.

Reviewed-by: Daniel Stone <daniels@collabora.com>
7 years agoxwm: Don't change focus on focus events from grabs
Olivier Fourdan [Mon, 15 May 2017 11:32:01 +0000 (13:32 +0200)]
xwm: Don't change focus on focus events from grabs

xwm would not let X clients change the focus behind the compositor's
back, reverting focus where it's supposed to be when this occurs.

However, X11 grab also issue focus in events, on which some clients
rely and reverting focus in this case braks the client logic (e.g.
combobox menu in gtk+ using the X11 backend).

Check if the focus event is actually coming from a grab or ungrab and
do not revert focus in this case, to avoid breaking clients logic.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Tested-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Acked-by: Daniel Stone <daniels@collabora.com>
Acked-by: Quentin Glidic <sardemff7+git@sardemff7.net>
7 years agoAccount for very large repaint window misses
Daniel Stone [Tue, 28 Feb 2017 21:53:51 +0000 (21:53 +0000)]
Account for very large repaint window misses

At the bottom of weston_output_finish_frame(), code exists to account
for flips which have missed the repaint window, by shifting them to lock
on to the next repaint window rather than repainting immediately.

This code only accounted for flips which missed their target by one
repaint window. If they miss by multiples of the repaint window, adjust
them until the next repaint timestamp is in the future. This will only
happen in fairly extreme situations, such as Weston being scheduled out
for a punitively long period of time. Nevertheless, try to help recovery
by still aiming for more predictable timings.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
7 years agodesktop-shell: Enable per-output fade animations
Bryce Harrington [Fri, 9 Sep 2016 20:16:02 +0000 (13:16 -0700)]
desktop-shell: Enable per-output fade animations

Instead of creating a single global fade surface across all outputs,
create a separate surface for each output.  This will permit
e.g. individual fades for each output (or blocking the fade-outs if
inhibiting idling as will come in a later patch.)

This also fixes a potential issue if on multihead layout spanning a
desktop wider than 8096 (or higher than 8096), the fade animation may
not completely cover all surfaces.

This assumes the output geometry doesn't change to become larger during
the course of the fade animation.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
7 years agocompositor-drm: Fix disabling cursor plane
Derek Foreman [Thu, 13 Apr 2017 18:48:48 +0000 (13:48 -0500)]
compositor-drm: Fix disabling cursor plane

commit a7cba1d4cd4c9013c3ac6cb074fcb7842fb39283 changed the way
the cursor plane is setup.  Previously it was pre-emptively set
disabled for the next frame, and that would be changed at next
frame time if the cursor plane was to be used.  It was changed
to be disabled at plane assignment time.

We disable the use of planes entirely by setting disable_planes to
a non-zero value, which bypasses all calls to assign_planes - so
if the plane was set-up in the previous frame it will retain its
state post-disable.

This leads to desktop zoom leaving the cursor plane in place when
it sets disable_planes.

This patch clears any stale cursor plane state from the redraw
handler if disable_planes is set so drm_output_set_cursor()
will do the right thing.

Reviewed-by: Daniel Stone <daniels@collabora.com>
Reported-by: Emmanuel Gil Peyrot <emmanuel.peyrot@collabora.com>
7 years agolibweston-desktop/xwayland: react to geometry changes
Pekka Paalanen [Wed, 18 Jan 2017 13:37:59 +0000 (15:37 +0200)]
libweston-desktop/xwayland: react to geometry changes

Fix up the window position whenever the geometry info changes.

If the window geometry changes, we want to keep the input-responding
content anchored to top-left. It is done by manipulating the dx,dy
arguments originating from a wl_surface.attach request.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Acked-by: Daniel Stone <daniels@collabora.com>
7 years agoxwm: use _XWAYLAND_ALLOW_COMMITS
Pekka Paalanen [Wed, 18 Jan 2017 13:37:58 +0000 (15:37 +0200)]
xwm: use _XWAYLAND_ALLOW_COMMITS

This patch uses the new feature proposed for Xwayland in the patch
series https://patchwork.freedesktop.org/series/16610/ .

When the frame window is created, immediately forbid Xwayland commits on
it. This prevents commits before the decorations have been drawn and the
initial pending state has been set. Commits are enabled right after
drawing and setting.

This ensures that the decorations are fully drawn when a window is
mapped. This also solves the initial commit/pending race, but the race
is on again after mapping.

If Xwayland does not implement the needed support, we are just setting a
window property with no effect.

This patch is the final piece for solving T7622, excluding the
_NET_WM_SYNC_REQUEST handling.

Task: https://phabricator.freedesktop.org/T7622
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Acked-by: Daniel Stone <daniels@collabora.com>
7 years agoxwm: do not draw decor twice on map
Pekka Paalanen [Wed, 18 Jan 2017 13:37:57 +0000 (15:37 +0200)]
xwm: do not draw decor twice on map

Normal windows enter the MapRequest handler, which schedules drawing the
decorations. Then Xwayland realizes the window, which ends with a call
to xserver_map_shell_surface(). The decorations are already drawn, no
need to draw them a second time. However, MapRequest handler could not
set the pending state because the weston_surface did not exist at the
time, because it gets created only when Xwayland realizes the window,
which happens after XWM has forwarded the MapWindow in MapRequest
handler. Therefore set the pending state explicitly at the end.
Scheduling had it done much later anyway.

Now that the pending state is set much earlier, it seems to be more
likely that it gets set before Xwayland's first commit is handled. This
means that -geometry command line option of X11 apps already takes the
geometry (decorations) into account. I do not think it is reliable yet,
though.

There is still the race between Xwayland committing and XWM setting the
pending state assuming the very next commit latches it in appropriately.
The race exists not because of Wayland, but because WL_SURFACE_ID comes
via X11, and could be processed after wl_compositor.create_surface and
wl_surface.commit. That commit/pending race is solved by a following patch.

For override-redirect windows weston_wm_window_schedule_repaint()
reduced into a call to weston_wm_window_set_pending_state_OR(), so we
can just call that directly. It should not matter that the call is moved
to the end of the function.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Acked-by: Daniel Stone <daniels@collabora.com>
7 years agolibweston: fix pixel-format helpers compilation on non-X11 EGL platforms
Philipp Zabel [Wed, 12 Apr 2017 13:32:09 +0000 (15:32 +0200)]
libweston: fix pixel-format helpers compilation on non-X11 EGL platforms

Since building libweston includes EGL/egl.h from pixel-formats.c,
EGL_CFLAGS must be added to libweston_CFLAGS, as on some platforms that
contains -DMESA_EGL_NO_X11_HEADERS, and fails to compile without it:

  CC       libweston/libweston_3_la-pixel-formats.lo
In file included from [...]/usr/include/EGL/egl.h:39:0,
                 from libweston/pixel-formats.c:39:
[...]/usr/include/EGL/eglplatform.h:119:22:
fatal error: X11/Xlib.h: No such file or directory

Fixes: 903721a6215f ("libweston: Add pixel-format helpers")
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Daniel Stone <daniels@collabora.com>
7 years agolibweston: improve weston_output_disable() comments
Pekka Paalanen [Wed, 29 Mar 2017 12:45:46 +0000 (15:45 +0300)]
libweston: improve weston_output_disable() comments

Reorder some paragraphs to be more logically ordered. Rewrite the
description of the backend-specific disable function to explain the
semantics instead of the mechanics. Remove the paragraph about
pending_output_list as unnecessary details.

Add a big fat comment on why we call output->disable() always instead of
only for actually enabled outputs.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Armin Krezović <krezovic.armin@gmail.com>
7 years agocompositor-drm: Rename drm_sprite to drm_plane
Daniel Stone [Tue, 4 Apr 2017 16:54:34 +0000 (17:54 +0100)]
compositor-drm: Rename drm_sprite to drm_plane

We make the differentiation where planes are an abstract framebuffer
with a position within a CRTC/output, and sprites are special cases of
planes that are neither the primary (base/framebuffer) nor cursor plane.

drm_sprite, OTOH, contains nothing that's actually specific to sprites,
and we end up duplicating a lot of code to deal with them, especially
when we come to use an entirely plane-based interface with atomic
modesetting.

Rename drm_sprite to drm_plane, to reflect that it's actually generic.

No functional changes.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
[Pekka: dropped the removal of an unrelated comment]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
7 years agocompositor-drm: Clean up page_flip_pending path
Daniel Stone [Tue, 4 Apr 2017 16:54:33 +0000 (17:54 +0100)]
compositor-drm: Clean up page_flip_pending path

page_flip_pending is only be set when do a pageflip to a newly-rendered
buffer; if the flag is not set, we have landed in the start_repaint_loop
path where the vblank query fails, and thus we must pageflip to the same
buffer.

This test was not sufficient for what it was supposed to guard:
releasing framebuffers back. When using client-supplied framebuffers, it
is possible to reuse the same buffer multiple times, and we would send a
framebuffer-release event too early.

However, since we have a properly reference-counted drm_fb now, we can
just drop this test, and rely on the reference counting to prevent
too-early release of client framebuffers.

page_flip_pending now becomes exactly what the name suggests: a flag
which indicates whether or not we are expecting a pageflip event. Add
asserts here to verify that we never receive a pageflip event we weren't
expecting.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
7 years agocompositor-drm: Turn vblank_pending from bool to refcount
Daniel Stone [Tue, 4 Apr 2017 16:54:32 +0000 (17:54 +0100)]
compositor-drm: Turn vblank_pending from bool to refcount

vblank_pending is currently a bool, which is reset on every vblank
requests (i.e. sprite pageflip). This can occur more than once per
frame, so turn it into a callback, so we only fire frame-done when we've
collected all the events.

This fixes unexpected behaviour when multiple views per output have been
promoted to DRM planes.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
7 years agocompositor-drm: Introduce fb_last member
Daniel Stone [Tue, 4 Apr 2017 16:54:31 +0000 (17:54 +0100)]
compositor-drm: Introduce fb_last member

Previously, framebuffers were stored as fb_current and fb_pending.
In this scheme, current was the last buffer that the kernel/hardware had
acknowledged displaying: a framebuffer would be created, set as
fb_pending, and Weston would request the kernel display it. When the
kernel signals that the request was completed and the hardware had made
the buffer current (i.e. page_flip_handler / vblank_handler), we would
unreference the old fb_current, and promote fb_pending to fb_current.

In other words, the view is 'which buffer has turned to light?'.

This patch changes them to a tristate of fb_last, fb_current and
fb_pending, based around the kernel's view of the current state.
fb_pending is used purely as a staging area for request construction;
when the kernel acknowledges a request (e.g. drmModePageFlip returns 0),
the previous buffer is moved to fb_last, and this new buffer to
fb_current. When the kernel signals that the request has completed and
the hardware has made the buffer current, we simply unreference and
clear fb_last, without touching fb_current/fb_pending.

The view here is now 'which state is current in the kernel?'.

As all state changes are incremental on the last state submitted to the
kernel, even if the hardware has not yet been able to make it current,
this simplifies state tracking: all state submissions will always be
relative to fb_current, rather than the previous
(fb_pending) ? fb_pending : fb_current.

The use of fb_pending is strictly bounded between a repaint cycle
(including a grouped set of repaints) beginning, and those repaints
being flushed to the kernel.

fb_current will always be valid between an output's first repaint
flush, and when a disable/destroy request has been processed. For a
plane, it will be valid when a repaint cycle enabling that plane has
been flushed, and when a repaint cycle disabling that plane has been
flushed.

fb_last is only present when a repaint request for the output/plane has
been submitted, but not yet completed by the hardware.

This is the same set of constructs which will be used for storing
plane/output state objects in future patches.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
7 years agocompositor-drm: correctly set the version of the drmEventContext
Emil Velikov [Tue, 4 Apr 2017 17:07:34 +0000 (18:07 +0100)]
compositor-drm: correctly set the version of the drmEventContext

We implement v2 so use that instead of the DRM_EVENT_CONTEXT_VERSION
macro.

The latter defines the version of the drmEventContext struct declared in
the header [used in the current build] and can be 2, 3 or even 1000.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
7 years agocompositor-drm: Return FB directly from render
Daniel Stone [Tue, 4 Apr 2017 16:54:30 +0000 (17:54 +0100)]
compositor-drm: Return FB directly from render

Instead of setting state members directly in the drm_output_render
functions (to paint using Pixman or GL), just return a drm_fb, and let
the core function place it in state.

This brings damage handling in line with repaint state, so we do not
clear damage if repaint fails.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
7 years agocompositor-drm: Reshuffle drm_output_render
Daniel Stone [Tue, 4 Apr 2017 16:54:29 +0000 (17:54 +0100)]
compositor-drm: Reshuffle drm_output_render

Call drm_output_render unconditionally, doing an early exit if we're
already rendering a client buffer on the primary plane.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
7 years agocompositor-drm: Rename current/next FB members
Daniel Stone [Tue, 4 Apr 2017 16:54:28 +0000 (17:54 +0100)]
compositor-drm: Rename current/next FB members

'next' is used as a framebuffer which has either been rendered but not
had a configuration request (pageflip or CRTC set) applied to it, or
when for a framebuffer that has had configuration requested but not
applied (delayed pageflip where the event has not been applied).

'current' is used as the last framebuffer for which we know
configuration has been fully applied, i.e. CRTC set executed or pageflip
requested and event received.

Rename these members to fb_current and fb_pending, doing some small
reordering of drm_output whilst in the vicinity.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
7 years agocompositor-drm: Use drm_fb for cursor buffers
Daniel Stone [Tue, 4 Apr 2017 16:54:27 +0000 (17:54 +0100)]
compositor-drm: Use drm_fb for cursor buffers

Now that we have better types in drm_fb, use it for cursor buffers as
well. This gives us easier refcounting for our cursors, as well as a
unified buffer-destruction path.

Currently this makes no difference, as the KMS legacy cursor update API
uses GEM names directly, and never touches DRM FBs. However, the cursor
plane becomes a regular KMS plane under atomic, at which point we
require DRM FBs.

Take the opportunity to move to drm_fb ahead of time.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
7 years agocompositor-drm: Refcount drm_fb
Daniel Stone [Tue, 4 Apr 2017 16:54:26 +0000 (17:54 +0100)]
compositor-drm: Refcount drm_fb

Sometimes we need to duplicate an existing drm_fb, e.g. when
pageflipping to the same buffer to kickstart the repaint loop. To handle
situations like these, and simplify resource management for dumb and
cursor buffers, refcount drm_fb.

drm_fb_get_from_bo has a path where it may reuse a drm_fb, if the BO has
been imported and not released yet. As drm_fb_unref now relies on actual
refcounting (backed up by asserts), we add a balancing drm_fb_ref() to
the path where we return a reused drm_fb.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
7 years agocompositor-drm: Drop output from release_fb
Daniel Stone [Tue, 4 Apr 2017 16:54:25 +0000 (17:54 +0100)]
compositor-drm: Drop output from release_fb

We only need it for the GBM surface the FB was originally created
against; a mismatch here is very bad indeed, so no reason to pass it in
explictly every time rather than store it.

Following patches change drm_fb to be explicitly reference counted; in
order to reduce churn, rename drm_output_release_fb to drm_fb_unref
whilst changing its call signature here, even though it does not yet
actually perform reference counting.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
7 years agocompositor-drm: Refactor destroy drm_fb function
Tomohito Esaki [Tue, 4 Apr 2017 16:54:24 +0000 (17:54 +0100)]
compositor-drm: Refactor destroy drm_fb function

The drm_fb destroy callback to mostly the same thing regardless of
whether the buffer is a dumb buffer or gbm buffer. This patch refactors
the common parts into a new function that can be called for both cases.

[daniels: Rebased on top of fb->fd changes, cosmetic changes.]

Signed-off-by: Tomohito Esaki <etom@igel.co.jp>
Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
7 years agocompositor-drm: Store format in drm_fb
Daniel Stone [Tue, 4 Apr 2017 16:54:23 +0000 (17:54 +0100)]
compositor-drm: Store format in drm_fb

This uses the new pixel-format helpers, so we can also replace depth/bpp
with these.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalaneN@collabora.co.uk>
7 years agocompositor-drm: Add explicit type member to drm_fb
Daniel Stone [Tue, 4 Apr 2017 16:54:22 +0000 (17:54 +0100)]
compositor-drm: Add explicit type member to drm_fb

Rather than magically trying to infer what the buffer is and what we
should do with it when we go to destroy it, add an explicit type
instead.

In doing so, the test for dumb images (destroying them, but only if
they're not the 'live' ones) is removed. This was dead code, as the only
path which could cause us to shuffle images is drm_output_switch_mode.
This calls drm_output_release_fb before the images are reallocated in
drm_output_fini_pixman / drm_output_init_pixman, with the reallocation
unconditionally destroying the images, so can never be hit.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
7 years agocompositor-drm: Calculate more cursor state up front
Daniel Stone [Tue, 4 Apr 2017 16:54:21 +0000 (17:54 +0100)]
compositor-drm: Calculate more cursor state up front

Make drm_output_set_cursor more deterministic, by calculating more state
and performing more plane manipulation, inside
drm_output_prepare_cursor_view.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
7 years agolibweston: Add pixel-format helpers
Daniel Stone [Tue, 4 Apr 2017 16:54:20 +0000 (17:54 +0100)]
libweston: Add pixel-format helpers

Rather than duplicating knowledge of pixel formats across several
components, create a custom central repository.

Signed-off-by: Daniel Stone <daniels@collabora.com>
[Pekka: fix include paths and two copy-pastas]
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
7 years agobuild: make libdrm a hard build-time dependency
Pekka Paalanen [Thu, 6 Apr 2017 11:06:20 +0000 (14:06 +0300)]
build: make libdrm a hard build-time dependency

Libdrm provides headers that are useful even without libdrm.so itself,
particularly drm_fourcc.h. Therefore promote libdrm as a hard build-time
dependency of libweston core so that we can always rely on libdrm
headers.

This does not affect any runtime dependencies. Specifically, no runtime
dependency to libdrm.so is added in any build configuration.

Currently only gl-renderer is using drm_fourcc.h. Now we can drop the
GL_RENDERER check from configure.ac and just use LIBDRM_CFLAGS.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
[Pekka, from Quentin: just drop have_libdrm var completely]
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
7 years agobuild: do not link libdrm without DRM backend
Pekka Paalanen [Thu, 6 Apr 2017 10:57:57 +0000 (13:57 +0300)]
build: do not link libdrm without DRM backend

The pkg-config test for LIBDRM is independent of whether the DRM backend
is enabled or not. Therefore it is possible to have libdrm available and
found, even though it is not needed.

Do not link libdrm.so into the launchers unless it is really needed,
that is, DRM compositor is built. Otherwise you end up with
fbdev-backend.so and weston-launch depending on libdrm.so.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
7 years agoconfigure: replace HAVE_LIBDRM with BUILD_DRM_COMPOSITOR
Pekka Paalanen [Thu, 6 Apr 2017 10:18:59 +0000 (13:18 +0300)]
configure: replace HAVE_LIBDRM with BUILD_DRM_COMPOSITOR

HAVE_LIBDRM was used as a condition for the launcher infrastructure to
call libdrm.so functions. It was set by an independent test for libdrm,
which would silently continue if libdrm was not found. It was assumed
that if you enabled a feature that used libdrm at runtime, the test for
that feature would imply that HAVE_LIBDRM is also set. This was quite
subtle.

The only feature that actually uses libdrm.so at runtime is the DRM
backend. No other backend needs the libdrm calls in the launcher
infrastructure.

Therefore to simplify things, stop using HAVE_LIBDRM and use
BUILD_DRM_COMPOSITOR instead. If you enable the DRM compositor, you
automatically also get libdrm support in the launchers.

There are still things depending on LIBDRM_CFLAGS and LIBDRM_LIBS, so
the test cannot be removed completely.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
7 years agodesktop-shell: Position maximized surfaces on the correct output.
Emmanuel Gil Peyrot [Tue, 4 Apr 2017 17:49:33 +0000 (18:49 +0100)]
desktop-shell: Position maximized surfaces on the correct output.

During a maximize event, a surface was previously always put back to
the primary output after one frame on the correct output, while keeping
its size.  This was caused by the shell surface’s last_{width,height}
not being reset when it was either fullscreen or maximized, leading to
the unmaximize/maximize dance being done at each commit.

This was introduced in 8f9d90a84bb2888b074fea93c4a28778bc6439c6.

Changes since v1:
- Fix the actual issue instead of a symptom.

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.peyrot@collabora.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
7 years agowcap: Prevent fd leak in wcap_decoder_create() fail path
Sergi Granell [Wed, 29 Mar 2017 20:41:02 +0000 (22:41 +0200)]
wcap: Prevent fd leak in wcap_decoder_create() fail path

Signed-off-by: Sergi Granell <xerpi.g.12@gmail.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
7 years agocompositor-wayland: Properly dealloc mmap data using munmap
Raúl Peñacoba [Wed, 29 Mar 2017 20:23:07 +0000 (22:23 +0200)]
compositor-wayland: Properly dealloc mmap data using munmap

Signed-off-by: Raúl Peñacoba <raul.mikaop.zelda@gmail.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
7 years agoeditor: Add missing free() and display_destroy() in main
Raúl Peñacoba [Wed, 29 Mar 2017 16:16:46 +0000 (18:16 +0200)]
editor: Add missing free() and display_destroy() in main

Signed-off-by: Raúl Peñacoba <raul.mikaop.zelda@gmail.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
7 years agoivi-layout: Add missing free() in ivi_view_create
Raúl Peñacoba [Wed, 29 Mar 2017 16:13:36 +0000 (18:13 +0200)]
ivi-layout: Add missing free() in ivi_view_create

Signed-off-by: Raúl Peñacoba <raul.mikaop.zelda@gmail.com>
Reviewed-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
7 years agogl-renderer: Change 'data' type to 'uint8_t *', since 'void *' arithmetic is undefined
Raúl Peñacoba [Tue, 28 Mar 2017 16:17:56 +0000 (18:17 +0200)]
gl-renderer: Change 'data' type to 'uint8_t *', since 'void *' arithmetic is undefined

Signed-off-by: Raúl Peñacoba <raul.mikaop.zelda@gmail.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
7 years agocompositor-drm: Add missing drmModeFreeResources in drm_device_is_kms
Sergi Granell [Tue, 28 Mar 2017 10:44:04 +0000 (12:44 +0200)]
compositor-drm: Add missing drmModeFreeResources in drm_device_is_kms

Signed-off-by: Sergi Granell <xerpi.g.12@gmail.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
7 years agocompositor-wayland: Call weston_compositor_exit when receiving an xdg toplevel close...
Sergi Granell [Sat, 25 Mar 2017 16:19:36 +0000 (17:19 +0100)]
compositor-wayland: Call weston_compositor_exit when receiving an xdg toplevel close event

Signed-off-by: Sergi Granell <xerpi.g.12@gmail.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
7 years agodesktop-shell: Remove unused variable in panel_create
Raúl Peñacoba [Sat, 25 Mar 2017 15:42:38 +0000 (16:42 +0100)]
desktop-shell: Remove unused variable in panel_create

Signed-off-by: Raúl Peñacoba <raul.mikaop.zelda@gmail.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
7 years agocompositor-wayland: Call set_window_geometry when using zxdg_shell_v6
Sergi Granell [Fri, 24 Mar 2017 22:45:13 +0000 (23:45 +0100)]
compositor-wayland: Call set_window_geometry when using zxdg_shell_v6

This way Wayland compositors will be aware of Weston's
"visible bounds" (and ignore its shadows).

Signed-off-by: Sergi Granell <xerpi.g.12@gmail.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
7 years agoweston-terminal: Fix race at startup
Derek Foreman [Fri, 24 Mar 2017 21:29:31 +0000 (16:29 -0500)]
weston-terminal: Fix race at startup

If anything is printed for the terminal window to display before the
window has been initially sized we end up with a segfault.

This defers the exec() of the shell child process until after the
window is sized so this can't happen anymore.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
7 years agodesktop-shell: launch clients in their own process group.
Derek Foreman [Fri, 24 Mar 2017 14:41:13 +0000 (09:41 -0500)]
desktop-shell: launch clients in their own process group.

Client applications shouldn't be in the same process group as
the display server.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
7 years agoweston: Set CLOEXEC on stdin
Derek Foreman [Fri, 24 Mar 2017 14:41:12 +0000 (09:41 -0500)]
weston: Set CLOEXEC on stdin

We don't want to leak this into apps launched from the panel.

stdout and stderr are left for now because some things launched
by weston - such as weston-keyboard - share weston's log by
printing to those fds.

I'm singling out stdin because it's never needed by a child process
and because it's value is 0, which makes it easy to accidentally
do bad things to (commit 5c611d933f60f720db98331c9c1c6ed4420f9782)

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
7 years agoos: Check for EINTR on ftruncate()
Derek Foreman [Thu, 23 Mar 2017 16:59:23 +0000 (11:59 -0500)]
os: Check for EINTR on ftruncate()

The man page indicates that ftruncate() can set errno to EINTR, so test
for this.

I have not actually been able to provoke an EINTR error from ftruncate()
in testing though.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
7 years agoos: Check for EINTR on posix_fallocate()
Derek Foreman [Thu, 23 Mar 2017 16:59:22 +0000 (11:59 -0500)]
os: Check for EINTR on posix_fallocate()

posix_fallocate() can return EINTR and need to be restarted - I've hit
this when running weston-terminal under gdb.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
7 years agocompositor-wayland: Check the return value of wayland_output_create_common
Sergi Granell [Fri, 24 Mar 2017 19:48:02 +0000 (20:48 +0100)]
compositor-wayland: Check the return value of wayland_output_create_common

If wayland_output_create_common returns NULL, it means that
the output creation failed.

Signed-off-by: Sergi Granell <xerpi.g.12@gmail.com>
Reviewed-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
7 years agocompositor-wayland: Refactor struct wayland_output::name usage
Sergi Granell [Fri, 24 Mar 2017 19:48:01 +0000 (20:48 +0100)]
compositor-wayland: Refactor struct wayland_output::name usage

struct wayland_output::name was used but never initialized.
Also zxdg_toplevel_v6_set_title was only called for windowed outputs,
and some compositors let you see the client's name even when it is
fullscreen (GNOME Shell's Activities menu for example).

So rename struct wayland_output::name to struct wayland_output::title and
precompute it on wayland_output_create_common(), so it can be later used
on xdg's set_title and frame_create.

v2: Move zxdg_toplevel_v6_set_title() before the wl_surface_commit()
as per Quentin Glidic's suggestion.

Signed-off-by: Sergi Granell <xerpi.g.12@gmail.com>
Reviewed-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
7 years agoFix uninitialized msec_to_next in output_repaint_timer_arm
Sergi Granell [Sat, 18 Mar 2017 12:01:15 +0000 (13:01 +0100)]
Fix uninitialized msec_to_next in output_repaint_timer_arm

Signed-off-by: Sergi Granell <xerpi.g.12@gmail.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
7 years agoman: move pageflip-timeout later
Pekka Paalanen [Mon, 13 Mar 2017 13:25:42 +0000 (15:25 +0200)]
man: move pageflip-timeout later

The paragraph about pageflip-timeout was added in between the two
paragraphs of idle-time, causing the paragraphs to be associated wrong.

Move the pageflip-timeout paragraph to the end.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=100163

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
7 years agoweston-terminal: Add a --maximized command line parameter
Derek Foreman [Wed, 8 Mar 2017 17:58:20 +0000 (11:58 -0600)]
weston-terminal: Add a --maximized command line parameter

This is useful for testing compositor response to a client that
requests a maximized initial surface.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
7 years agoweston-launch: Add sysmacros.h include for major()
Daniel Stone [Tue, 14 Mar 2017 17:25:30 +0000 (17:25 +0000)]
weston-launch: Add sysmacros.h include for major()

Same as with c4d7f66c, but I hadn't done a full-tree rebuild so didn't
see this one go by.

Signed-off-by: Daniel Stone <daniels@collabora.com>
7 years agolibinput: Suppress unhandled-case warning
Daniel Stone [Tue, 14 Mar 2017 17:24:04 +0000 (17:24 +0000)]
libinput: Suppress unhandled-case warning

When the wheel tilt source is present, gcc complains that we don't
handle all possible enumeration values. We already ensure this cannot
happen in its only caller (handle_pointer_axis), but gcc doesn't
recognise this. Give it a default value to quiet the warning.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
7 years agosimple-dmabuf-v4l: Remove incorrect assert
Derek Foreman [Fri, 10 Mar 2017 20:21:32 +0000 (14:21 -0600)]
simple-dmabuf-v4l: Remove incorrect assert

According to v4l2 documentation, DQBUF always clears FLAG_DONE, so
this assert can be expected to fire 100% of the time.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
7 years agoconfigure: bump libweston to 3.0.0
Pekka Paalanen [Tue, 14 Mar 2017 10:14:51 +0000 (12:14 +0200)]
configure: bump libweston to 3.0.0

Bump the future release to 3.0.0 due to breaking ABI in libweston.

We have merged a few patches already that change libweston/compositor.h.
While most of the changes arguably change only things libweston users
should not be touching, some change the size of e.g. struct
weston_output and struct weston_compositor, possibly moving member
offsets. We also haven't separated public and private parts from
compositor.h yet. To be on the safe side, bump the major now. I'm sure
there will be more changes that make the bump obviously necessary.

Cc: Bryce Harrington <bryce@osg.samsung.com>
Cc: Daniel Stone <daniels@collabora.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
7 years agoAllow backends to group repaint flushes
Daniel Stone [Wed, 1 Mar 2017 11:34:10 +0000 (11:34 +0000)]
Allow backends to group repaint flushes

Implement new repaint_begin and repaint_flush hooks inside
weston_backend, allowing backends to gang together repaints which
trigger at the same time.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
7 years agoSwitch to global output repaint timer
Daniel Stone [Wed, 1 Mar 2017 11:34:08 +0000 (11:34 +0000)]
Switch to global output repaint timer

In preparation for grouping output repaint together where possible,
switch the per-output repaint timer, to a global timer which iterates
across all outputs.

This is implemented by storing the absolute time for the next repaint
for each output locally, and maintaining a global timer which iterates
all of them, scheduling the repaint for the first available time.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Cc: Mario Kleiner <mario.kleiner.de@gmail.com>
Cc: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
[Pekka: The comment about 1 ms delay.]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
7 years agolauncher: Add sysmacros.h include for major()
Daniel Stone [Mon, 13 Mar 2017 16:32:18 +0000 (16:32 +0000)]
launcher: Add sysmacros.h include for major()

glibc 2.25 produces a warning when sysmacros.h is not directly included
but major() is used, as it is intended to be moved to sysmacros.h and
only there. Include it to keep the build happy.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>