platform/upstream/weston.git
8 years agoscreen-share: don't test keyboard/pointer pointers
Dawid Gajownik [Sat, 1 Aug 2015 02:46:46 +0000 (23:46 -0300)]
screen-share: don't test keyboard/pointer pointers

Keyboards and pointers aren't freed when devices are removed, so we
should really be testing keyboard_device_count and pointer_device_count
in most cases, not the actual pointers. Otherwise we end up with
different behaviour after removing a device than we had before it was
inserted.

This commit makes screen-share.c compile once again after changes in
commit 1281a36e3bcd27345bd4a107f282213ecca56f0e.

Signed-off-by: Dawid Gajownik <gajownik@gmail.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
8 years agodesktop-shell: drop shell_client from the head of the surface list on destroy
Derek Foreman [Fri, 29 May 2015 15:46:44 +0000 (10:46 -0500)]
desktop-shell: drop shell_client from the head of the surface list on destroy

This prevents a use after free when the surfaces are automatically cleaned
up later, as shell_client's freed node was still in the surface list.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
8 years agocompositor-rdp: free() can handle NULL pointers
Dawid Gajownik [Sat, 1 Aug 2015 14:02:54 +0000 (11:02 -0300)]
compositor-rdp: free() can handle NULL pointers

There's no need to check if a pointer exists before passing it to free().
free() can handle NULL pointers.

Signed-off-by: Dawid Gajownik <gajownik@gmail.com>
Reviewed-By: David FORT <contact@hardening-consulting.com>
8 years agomain: print backends in help message in alphabetical order
Dawid Gajownik [Fri, 31 Jul 2015 20:39:00 +0000 (17:39 -0300)]
main: print backends in help message in alphabetical order

For better readability of `weston --help' output, backends are now sorted
in alphabetical order.

Signed-off-by: Dawid Gajownik <gajownik@gmail.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years ago.gitignore: ignore doxygen generated files v2
Dawid Gajownik [Fri, 31 Jul 2015 21:28:59 +0000 (18:28 -0300)]
.gitignore: ignore doxygen generated files v2

Fixes incorrect commit d95637905861162c08251843acccc11e509b5d94

Signed-off-by: Dawid Gajownik <gajownik@gmail.com>
8 years agoinput: Don't test keyboard/pointer/touch pointers
Derek Foreman [Fri, 31 Jul 2015 21:55:32 +0000 (16:55 -0500)]
input: Don't test keyboard/pointer/touch pointers

Keyboards and pointers aren't freed when devices are removed, so we should
really be testing keyboard_device_count and pointer_device_count in most
cases, not the actual pointers. Otherwise we end up with different
behaviour after removing a device than we had before it was inserted.

This commit renames the touch/keyboard/pointer pointers and adds helper
functions to get them that hide this complexity and return NULL when
*_device_count is 0.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
8 years agofullscreen-shell: Test for device presence properly
Derek Foreman [Wed, 15 Jul 2015 18:00:47 +0000 (13:00 -0500)]
fullscreen-shell: Test for device presence properly

We should be testing device counts, not pointers.  The pointers are
persistent state that never gets freed, and are an inaccurate indicator
of device presence after the last release.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
8 years agodesktop-shell: Check for device presence properly
Derek Foreman [Wed, 15 Jul 2015 18:00:46 +0000 (13:00 -0500)]
desktop-shell: Check for device presence properly

We should be testing device counts, not pointers.  The pointers are
persistent state that never gets freed, and are an inaccurate indicator
of device presence after a release.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
8 years agodesktop-shell: Don't call wl_list_init() in the middle of a list
Derek Foreman [Wed, 15 Jul 2015 18:00:45 +0000 (13:00 -0500)]
desktop-shell: Don't call wl_list_init() in the middle of a list

seat->keyboard_focus_listener.link isn't a head, it's just sometimes a
member of the focus signal list.  Calling wl_list_init() on it puts
a loop in the list.

Instead, we remove the item then init it.  That way we can call remove on
it again later even if it hasn't been re-added to a list.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
8 years agoinput: Check device counts in bind_seat()
Derek Foreman [Wed, 15 Jul 2015 18:00:44 +0000 (13:00 -0500)]
input: Check device counts in bind_seat()

We shouldn't be using seat->pointer|keyboard|touch here, we should be
testing *_device_count to see if a device is currently present.

Testing the pointers directly will result in incorrectly advertising
capabilities after all devices of a type have been removed.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
8 years agoUpdate .gitignore
Dawid Gajownik [Wed, 29 Jul 2015 03:55:55 +0000 (00:55 -0300)]
Update .gitignore

Hi,

after running configure with "Enable developer documentation" set to
"yes" git status warns about two new untracked files:

        doc/doxygen/tooldev.doxygen
        doc/doxygen/tools.doxygen

Below is a small patch.

HTH,
  Dawid

8 years agomain: update RDP backend help message
Dawid Gajownik [Fri, 31 Jul 2015 17:49:57 +0000 (14:49 -0300)]
main: update RDP backend help message

`--env-socket' option is of type WESTON_OPTION_BOOLEAN, not
WESTON_OPTION_STRING. Socket should be defined in RDP_FD environment variable.

Signed-off-by: Dawid Gajownik <gajownik@gmail.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agogitignore: Ignore some dist generated files
Bryce Harrington [Fri, 31 Jul 2015 01:17:29 +0000 (18:17 -0700)]
gitignore: Ignore some dist generated files

8 years agozoom: Store the seat that initiated a zoom
Derek Foreman [Thu, 23 Jul 2015 19:55:15 +0000 (14:55 -0500)]
zoom: Store the seat that initiated a zoom

Track the seat that initiated a seat instead of picking the first one.

Previously, if there are multiple seats then any seat can adjust the zoom
level but the zoom tracks the first seat's pointer.

Now the zoom will follow the pointer of the seat that initiated the zoom.

Additionally, if there's no pointer in the first seat, starting a zoom
with the second seat will no longer crash weston.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
8 years agozoom: Call weston_output_activate_zoom() appropriately
Derek Foreman [Thu, 23 Jul 2015 19:55:13 +0000 (14:55 -0500)]
zoom: Call weston_output_activate_zoom() appropriately

No longer call weston_output_update_zoom() when trying to zoom out
on an unzoomed output.

Add an assert() to make sure update_zoom is never called without an
active zoom.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
8 years agozoom: Rename zoom_area_center_from_pointer to zoom_area_center_from_point
Derek Foreman [Thu, 23 Jul 2015 19:55:14 +0000 (14:55 -0500)]
zoom: Rename zoom_area_center_from_pointer to zoom_area_center_from_point

It doesn't do anything with a pointer, and zoom can be initiated by the
keyboard, so the name was a little confusing.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agozoom: Change zoom->active to a bool
Derek Foreman [Thu, 23 Jul 2015 19:55:12 +0000 (14:55 -0500)]
zoom: Change zoom->active to a bool

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agoFix crash when using RDP4 security
FORT David [Mon, 20 Jul 2015 12:39:21 +0000 (14:39 +0200)]
Fix crash when using RDP4 security

The initialization of the freerdp_peer was done too early.
This fixes https://bugs.freedesktop.org/show_bug.cgi?id=91390.

Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
8 years agoremove a warning during compilation
FORT David [Mon, 20 Jul 2015 12:39:20 +0000 (14:39 +0200)]
remove a warning during compilation

backend_init now returns an int not a pointer.

Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
8 years agobuild: mkdir target weston.ini directories before writing
Ross Burton [Fri, 17 Jul 2015 11:33:45 +0000 (12:33 +0100)]
build: mkdir target weston.ini directories before writing

In parallel out-of-tree builds it is possible for e.g. ivi-shell/weston.ini to
be written before ivi-shell/ exists.  Solve this by creating the target
directory first.

Signed-off-by: Ross Burton <ross.burton@intel.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
8 years agocms-helper/static: Add "identity" builtin cms profile (v3)
Mario Kleiner [Sat, 18 Jul 2015 06:10:58 +0000 (08:10 +0200)]
cms-helper/static: Add "identity" builtin cms profile (v3)

Allows to force loading an identity gamma table if
option icc_profile= is given in weston.ini for
an output, ie., icc_profile= is specified to an
empty assignment.

Some special display output devices, e.g., for
neuro-science applications, and special display
testing hardware need a guaranteed perfect pixel
passthrough from framebuffer to output. This is
an easy way to set this up for cms-static.

v2: Remove confusing/redundant weston_log debug output.
v3: Don't use the "identity" keyword to trigger this, but
    instead assignment of an empty string will trigger
    loading of an identity LUT. Suggested by Derek Foreman.

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Cc: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
8 years agocms-colord: Fix crash at compositor shutdown. (v2)
Mario Kleiner [Sat, 18 Jul 2015 06:07:11 +0000 (08:07 +0200)]
cms-colord: Fix crash at compositor shutdown. (v2)

cms-colord used the weston_compositor destroy signal to
trigger its final colord_module_destroy cleanup, and the
wl_output destroy signal to trigger per output cleanup.

The problem is that the compositor destroy signal gets
emitted before the output destroy signals at compositor
shutdown, colord_module_destroy would free all its
shared data structures and then later on the output
destroy callback would try to access those shared
data structures when handling output destruction
-> Use after free -> Crash, usually with VT switching
dead and thereby an unuseable system requiring a reboot.

Solve this by moving the output destruction handling into
the colord_cms_output_destroy() cleanup function for
colord-cms own hash dictionary of all active outputs.

The output destroy callback just removes the corresponding
output from the dictionary and triggers proper cleanup if
an output is unplugged during runtime. During compositor
shutdown, the dictionary as a whole is released before
releasing all other shared data structures, thereby
triggering cleanup of all remaining outputs.

Tested to fix crashes on x11 and drm backends.

v2: Formatting: Wrap lines to < 80 characters, as suggested
    by Derek. Thanks.

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
8 years agodesktop-shell: Put monitor to sleep when idle timer expires
Derek Foreman [Mon, 20 Jul 2015 21:28:13 +0000 (16:28 -0500)]
desktop-shell: Put monitor to sleep when idle timer expires

Removing the screensaver had the accidental side effect of disabling
DPMS display shut down.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
9 years agocompositor: Respect WESTON_BUILD_DIR env var in weston_load_module
Derek Foreman [Mon, 8 Jun 2015 16:46:54 +0000 (11:46 -0500)]
compositor: Respect WESTON_BUILD_DIR env var in weston_load_module

We were loading modules out of the system dirs unconditionally, so
tests that loaded modules would use the system ones, or fail if
they weren't installed.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-By: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Jon A. Cruz <jonc@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
9 years agoexposay: Fix use after free when a view is destroyed during animation
Derek Foreman [Tue, 26 May 2015 21:21:05 +0000 (16:21 -0500)]
exposay: Fix use after free when a view is destroyed during animation

Moving the destroy listener setup allows the animation completion handler
to be called before we free any structures it needs.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
9 years agoexposay: Fix logic inversion when ending keyboard grabs
Derek Foreman [Sat, 18 Jul 2015 01:58:02 +0000 (20:58 -0500)]
exposay: Fix logic inversion when ending keyboard grabs

I flipped a ! in cee82d62865ab5b239935f102c2e1f7868e0fa65
and the exposay keyboard grab became permanent.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
9 years agoinput: make a function for device removal
Derek Foreman [Tue, 5 May 2015 20:01:52 +0000 (15:01 -0500)]
input: make a function for device removal

Break device_removed() out into its own function like device_added().

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
9 years agowindow: Use wl_cursor_frame_and_duration() for mouse cursor updates
Derek Foreman [Wed, 22 Apr 2015 22:23:35 +0000 (17:23 -0500)]
window: Use wl_cursor_frame_and_duration() for mouse cursor updates

Some animated cursor sets use very long delays, but until now we'd use the
frame callback and update the cursor at the display framerate anyway.

Now we use a timerfd to drive cursor animation if the delay is longer
than 100ms, or the old method for short delays.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
9 years agodesktop-shell: use work area instead of panel size to constrain moves
Derek Foreman [Wed, 15 Apr 2015 17:23:56 +0000 (12:23 -0500)]
desktop-shell: use work area instead of panel size to constrain moves

This fixes the case where an output isn't at y = 0, where the panel height
isn't correct for constraints.

It also kills a bug - moving a window with a mod-drag off the top of the
screen clamped earlier than it should.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
9 years agodesktop-shell: use output position in get_output_panel_size()
Derek Foreman [Wed, 15 Apr 2015 17:23:55 +0000 (12:23 -0500)]
desktop-shell: use output position in get_output_panel_size()

The panel size calculation needs to take the output position into account
or it's only correct when the output is at 0, 0.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
9 years agodesktop-shell: add output co-ordinates to get_output_work_area()
Derek Foreman [Wed, 15 Apr 2015 17:23:54 +0000 (12:23 -0500)]
desktop-shell: add output co-ordinates to get_output_work_area()

get_output_work_area() now returns the absolute work area including the
output's offset.

This will make math a little simpler later when we use it to constrain
window moves.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
9 years agologind-util: Use %u for unsigned int in snprintf
Bryce Harrington [Sat, 11 Jul 2015 02:51:52 +0000 (19:51 -0700)]
logind-util: Use %u for unsigned int in snprintf

Addresses this warning found by Denis Denisov:

  [src/logind-util.c:702]: (warning) %d in format string (no. 1)
  requires 'int' but the argument type is 'unsigned int'.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
9 years agocompositor: destroy modifier_binding_list
Ryo Munakata [Fri, 17 Jul 2015 04:07:42 +0000 (13:07 +0900)]
compositor: destroy modifier_binding_list

Signed-off-by: Ryo Munakata <ryomnktml@gmail.com>
Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
9 years agoAdding doxygen setup and info for the testing framework.
Jon A. Cruz [Thu, 16 Jul 2015 02:22:43 +0000 (19:22 -0700)]
Adding doxygen setup and info for the testing framework.

Signed-off-by: Jon A. Cruz <jonc@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agoConverted the config parser test to the new framework.
Jon A. Cruz [Thu, 16 Jul 2015 02:22:42 +0000 (19:22 -0700)]
Converted the config parser test to the new framework.

Signed-off-by: Jon A. Cruz <jonc@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agoEnables output in the JUnit XML format.
Jon A. Cruz [Thu, 16 Jul 2015 02:22:41 +0000 (19:22 -0700)]
Enables output in the JUnit XML format.

Adds basic support for optionally outputting in the XML format
commonly used by JUnit compatible tools.

This format is supported by default by many tools, including
the Jenkins build system. It also is more detailed and
captures more information than the more simplistic TAP
format.

Signed-off-by: Jon A. Cruz <jonc@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agobuild: don't duplicate rule for weston.desktop
Ross Burton [Thu, 16 Jul 2015 19:56:32 +0000 (20:56 +0100)]
build: don't duplicate rule for weston.desktop

dist_wayland_session_DATA will distribute and install src/weston.desktop, so the
definition of wayland_session_DATA which also installs src/weston.desktop will
result in the file being installed twice and (rarely) cause install to fail.

Spotted and fix by Roy Li <rongqing.li@windriver.com>.
Signed-off-by: Ross Burton <ross.burton@intel.com>
Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
9 years agoshell: Switch middle and right mouse bindings
Derek Foreman [Thu, 25 Jun 2015 21:03:30 +0000 (16:03 -0500)]
shell: Switch middle and right mouse bindings

Currently rotate is on the right mouse button and resize is on the middle.

As fantastic as rotating windows is, it's probably nicer to have resize on
the right button, especially for anyone with only 2 buttons.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
9 years agolog: Open log file CLOEXEC so child processes don't get the fd
Derek Foreman [Mon, 8 Jun 2015 16:37:31 +0000 (11:37 -0500)]
log: Open log file CLOEXEC so child processes don't get the fd

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
9 years agoinput: Also pass appropriate pointer type when libva unavailable
Bryce Harrington [Fri, 17 Jul 2015 02:12:26 +0000 (19:12 -0700)]
input: Also pass appropriate pointer type when libva unavailable

9 years agobindings: Make run binding functions take apropriate device instead of a seat
Derek Foreman [Wed, 15 Jul 2015 18:00:43 +0000 (13:00 -0500)]
bindings: Make run binding functions take apropriate device instead of a seat

Going from seat to input device requires that we test the device
before relying on the pointer.  In all of these binding functions
we can trust exactly one input device type directly.  If we pass
that in instead of a seat it's more obvious that we can trust
the one pointer we have.

When a seat is required, we can access through the device we have
and use that to get to other device types for the seat, provided
we validate them appropriately.

Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
9 years agobindings: make install_binding_grab take a keyboard instead of a seat
Derek Foreman [Wed, 15 Jul 2015 18:00:42 +0000 (13:00 -0500)]
bindings: make install_binding_grab take a keyboard instead of a seat

It doesn't need the seat pointer, and the caller should already have
tested that the keyboard pointer is valid.

Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
9 years agodesktop-shell: Use the grabbed pointer in popup_grab_button
Derek Foreman [Wed, 15 Jul 2015 18:00:41 +0000 (13:00 -0500)]
desktop-shell: Use the grabbed pointer in popup_grab_button

This should be identical to the pointer in shset->seat.

A later patch prevents direct access to seat->pointer, using the
known valid pointer in the grab will be nicer than using the
getter functions that patch introduces.

Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
9 years agodesktop-shell: Make surface_resize take a pointer instead of a seat
Derek Foreman [Wed, 15 Jul 2015 18:00:40 +0000 (13:00 -0500)]
desktop-shell: Make surface_resize take a pointer instead of a seat

It doesn't actually need the seat and we have to validate that the seat
has a pointer before making the call, so it's safer just to pass
the validated pointer.

Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
9 years agodesktop-shell: Make surface_rotate take a pointer instead of a seat
Derek Foreman [Wed, 15 Jul 2015 18:00:39 +0000 (13:00 -0500)]
desktop-shell: Make surface_rotate take a pointer instead of a seat

It doesn't actually need the seat and we have to validate that the seat
has a pointer before making the call, so it's safer just to pass
the validated pointer.

Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
9 years agodesktop-shell: Make surface_move take a pointer instead of a seat
Derek Foreman [Wed, 15 Jul 2015 18:00:38 +0000 (13:00 -0500)]
desktop-shell: Make surface_move take a pointer instead of a seat

It doesn't actually need the seat and we have to validate that the seat
has a pointer before making the call, so it's safer just to pass
the validated pointer.

Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
9 years agodesktop-shell: Make surface_touch_move take a touch instead of a seat
Derek Foreman [Wed, 15 Jul 2015 18:00:37 +0000 (13:00 -0500)]
desktop-shell: Make surface_touch_move take a touch instead of a seat

It never actually needs the seat, and we always verify the touch pointer
before calling it, so let's just pass a touch pointer instead of having
an assumption that the seat's touch pointer has been verified.

Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
9 years agoinput: Pass the appropriate pointer type to bindings instead of a seat
Derek Foreman [Wed, 15 Jul 2015 18:00:36 +0000 (13:00 -0500)]
input: Pass the appropriate pointer type to bindings instead of a seat

Normally we need to check if a seat's [device_type]_count is > 0 before
we can use the associated pointer.  However, in a binding you're
guaranteed that the seat has a device of that type.  If we pass in
that type instead of the seat, it's obvious we don't have to test it.

The bindings can still get the seat pointer via whatever->seat if they
need it.

This is preparation for a follow up patch that prevents direct access
to seat->device_type pointers, and this will save us a few tests at
that point.

Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
9 years agocompositor-drm: Simplify logic in setup_output_seat_constraint
Derek Foreman [Wed, 15 Jul 2015 18:00:35 +0000 (13:00 -0500)]
compositor-drm: Simplify logic in setup_output_seat_constraint

Use early return for a slight simplification.

Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
9 years agobindings: Stop exporting internal functions
Derek Foreman [Wed, 15 Jul 2015 18:00:34 +0000 (13:00 -0500)]
bindings: Stop exporting internal functions

These functions should never be called outside of the core.

Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
9 years agoexposay: Test keyboard presence before using keyboard pointer
Derek Foreman [Wed, 15 Jul 2015 18:00:33 +0000 (13:00 -0500)]
exposay: Test keyboard presence before using keyboard pointer

We shouldn't actually use the keyboard pointer unless we check that
a keyboard is present.

Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
9 years agotext-backend: Replace focus_listener_initialized with a bool
Derek Foreman [Wed, 15 Jul 2015 18:00:32 +0000 (13:00 -0500)]
text-backend: Replace focus_listener_initialized with a bool

Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
9 years agocompositor-drm: Refactor code into cursor_bo_update()
Pekka Paalanen [Mon, 16 Jun 2014 09:05:40 +0000 (12:05 +0300)]
compositor-drm: Refactor code into cursor_bo_update()

Cut a chunk of code out from drm_output_set_cursor() and form a new
function for writing a cursor bo data from a weston_view with a wl_shm
buffer.

Add more asserts to verify the assumptions in there.

v2: Use drm_compositor::cursor_{width,height} instead of hard-coded 64.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
9 years agocompositor-drm: Fix cursor view size check
Daniel Stone [Tue, 16 Jun 2015 17:42:23 +0000 (18:42 +0100)]
compositor-drm: Fix cursor view size check

Instead of testing against a hardcoded 64x64 pixel size to see if a view
is suitable for promotion to a cursor plane, use our cursor_width and
cursor_height variables.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
9 years agocompositor-drm: Record current DPMS level
Daniel Stone [Thu, 18 Jun 2015 06:49:02 +0000 (07:49 +0100)]
compositor-drm: Record current DPMS level

Track the current DPMS level for any given output, and track failure (or
otherwise) of the DPMS-setting property call.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
9 years agocompositor-drm: Refactor getting current mode into a new function
Pekka Paalanen [Wed, 4 Jun 2014 13:43:06 +0000 (16:43 +0300)]
compositor-drm: Refactor getting current mode into a new function

Makes create_output_for_connector() slightly easier to read.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
9 years agocompositor-drm: Refactor connector name into new function
Pekka Paalanen [Wed, 4 Jun 2014 13:29:49 +0000 (16:29 +0300)]
compositor-drm: Refactor connector name into new function

Refactor the code constructing the connector name into a new function.
This makes create_output_for_connector() slightly easier to read.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
9 years agocompositor-drm: Refactor initial mode out of create_output
Pekka Paalanen [Wed, 4 Jun 2014 11:00:53 +0000 (14:00 +0300)]
compositor-drm: Refactor initial mode out of create_output

Refactor the code for choosing the initial mode for an output from
create_output_for_connector() to drm_output_choose_initial_mode().

This makes create_output_for_connector() slightly easier to read.

v2: Document everything.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
9 years agocompositor: Respect repaint-window when restarting repaint loop.
Mario Kleiner [Sun, 21 Jun 2015 19:25:15 +0000 (21:25 +0200)]
compositor: Respect repaint-window when restarting repaint loop.

If a stopped repaint loop gets restarted due to posting of new
damage, and this restart of the repaint loop happens late in the
video refresh cycle, ie. already inside the repaint-window and
thereby after the composition deadline for the current frame,
then defer the actual output repaint to the composition deadline
of the next video refresh cycle by setting the repaint timer
accordingly.

This tries to make sure that:

a) Client(s) posting damage timely before the composition deadline
   (video refresh duration - "repaint-window" duration) of the
   current refresh cycle will trigger a repaint within the current
   refresh cycle, thereby avoiding one extra frame of compositor
   lag due to the needed restart of the repaint loop if the loop
   was stopped. This allows them to benefit from the earlier
   "instant repaint restart" commit to keep latency low.

b) Late clients which post damage close to the end of a refresh
   cycle can't race other clients if the repaint loop is restarted.
   Instead they will get deferred to the next compositor cycle,
   just as if the repaint loop would have been already running -
   the semantic of the "repaint-window" parameter is preserved.

   This is especially important to prevent a very late client
   from triggering a repaint very close to the vblank, which
   would cause the compositor to certainly miss the vblank and
   skip one frame and then cause a delay of another frame for
   other clients which posted their damage in time for the
   following frame. Iow. this provides clients with a more
   predictable compositor timing and makes it easier for them
   to latch onto the compositors repaint cycle.

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agocompositor-drm: Allow instant start of repaint loop. (v4)
Mario Kleiner [Sun, 21 Jun 2015 19:25:14 +0000 (21:25 +0200)]
compositor-drm: Allow instant start of repaint loop. (v4)

drm_output_start_repaint_loop() incurred a delay of
one refresh cycle by using a no-op page-flip to get
an accurate vblank timestamp as reference. This causes
unwanted lag whenever Weston exited its repaint loop, e.g.,
whenever an application wants to repaint with less than
full video refresh rate but still minimum lag.

Try to use the drmWaitVblank ioctl to get a proper
timestamp instantaneously without lag. If that does
not work, fall back to the old method of idle page-flip.

This optimization will work on any drm/kms driver
which supports high precision vblank timestamping.
As of Linux 4.0 these would be intel, radeon and
nouveau on all their supported gpu's.

On kms drivers without instant high precision timestamping
support, the kernel is supposed to return a timestamp
of zero when calling drmWaitVblank() to query the current
vblank count and time iff vblank irqs are currently
disabled, because the only way to get a valid timestamp
on such kms drivers is to enable vblank interrupts and
then wait a bit for the next vblank irq to take a new valid
timestamp. The caller is supposed to poll until at next
vblank irq it gets a valid non-zero timestamp if it needs
a timestamp.

This zero-timestamp signalling works up to Linux 3.17, but
got broken due to a regression in Linux 3.18 and later. On
Linux 3.18+ with kms drivers that don't have high precision
timestamping, the kernel erroneously returns a stale timestamp
from an earlier vblank, ie. the vblank count and timestamp are
mismatched. A patch is under way to fix this, but to deal with
broken kernels, we also check non-zero timestamps if they are
more than one refresh duration in the past, as this indicates
a stale/invalid timestamp, so we need to take the page-flip
fallback for restarting the repaint loop.

v2: Implement review suggestions by Pekka Paalanen, especially
    extend the commit message to describe when and why the
    instant restart won't work due to missing Linux kernel
    functionality or a Linux kernel regression.

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
v3: Fix timespec_to_nsec() which was computing picoseconds,
    use the new timespec-util.h helpers.

v4: Rebased to master, split long lines.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agocompositor,shared: add millihz_to_nsec()
Pekka Paalanen [Fri, 3 Jul 2015 12:08:53 +0000 (15:08 +0300)]
compositor,shared: add millihz_to_nsec()

A helper to improbe readability.

Cc: Daniel Stone <daniels@collabora.com>
Cc: Mario Kleiner <mario.kleiner.de@gmail.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agoshared: introduce timespec-util.h
Pekka Paalanen [Fri, 3 Jul 2015 12:44:50 +0000 (15:44 +0300)]
shared: introduce timespec-util.h

Copyright is set according to the moved code from compositor.c.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agopresentation-shm: Allow setting of delay before surface.commit
Mario Kleiner [Sun, 21 Jun 2015 19:25:16 +0000 (21:25 +0200)]
presentation-shm: Allow setting of delay before surface.commit

A new optional parameter "-d msecs" allows to specify a
delay before the surface attach/damage/commit to shift
the point in time when a surface update is committed.

This allows to test how different client timings interact
with the compositors repaint timing.

Suggested by Pekka Paalanen.

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
v2: Clarify the intent, doing a delay in window_create_feedback()
    is a bit surprising. Use nanosleep() instead of clock_nanosleep(),
    which may not support the chosen presentation clock.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agoREADME: introduce libweston
Pekka Paalanen [Tue, 14 Jul 2015 10:05:34 +0000 (13:05 +0300)]
README: introduce libweston

What is libweston and where do we intend to go with it.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Acked-by: Giulio Camuffo <giuliocamuffo@gmail.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Acked-by: Jon A. Cruz <jonc@osg.samsung.com>
9 years agoivi-shell: transform refactoring to improve it to more readable code
Nobuhiko Tanibata [Wed, 15 Jul 2015 05:05:32 +0000 (14:05 +0900)]
ivi-shell: transform refactoring to improve it to more readable code

Transform matrix for transforming a surface to global_matrix is
calculated from
* ivi_layout_surface_properties
* ivi_layout_layer_properties

This patch pareares sub-method like following,
1/ calc_surface_to_global_matrix()
 calc_transformation_matrix() is called twice with
 ivi_layout_surface/layer_properties respectively.

2/ calc_transformation_matrix()
 This calcurates matrix from orientation, source rectangle and
 destination rectangle.
 2-1/ To calculate rotation, fit centor of source rectangle to (0,0)
      temporarily. This is moved back in 2-4.
 2-2/ Apply rotation variant
 2-3/ Apply scale variant
 2-4/ Apply positioning variant, taking account into 2-1 temporary
      positioning.

Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agoivi-shell: transform refactoring, remove transform part of ivi_layout_surface and...
Nobuhiko Tanibata [Wed, 15 Jul 2015 05:05:10 +0000 (14:05 +0900)]
ivi-shell: transform refactoring, remove transform part of ivi_layout_surface and ivi_layout_layer once

To refactor transform of ivi_layout_surface and ivi_layout_surface to be
more readable logical flow.

Remove following parts once,
* definition of weston_transform in ivi_layout_surface
* update_layer_orientation
* update_layer_position
* update_surface_position
* update_surface_orientation
* update_scale

Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agoivi-shell: remove one indent level from update_prop()
Nobuhiko Tanibata [Wed, 15 Jul 2015 04:55:50 +0000 (13:55 +0900)]
ivi-shell: remove one indent level from update_prop()

There is no logic update.

Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agoPartially revert "xwayland: Always free reply from xcb_get_property_reply()"
Emmanuel Gil Peyrot [Wed, 15 Jul 2015 20:19:04 +0000 (22:19 +0200)]
Partially revert "xwayland: Always free reply from xcb_get_property_reply()"

This reverts commit d3553c721c0fed07f85b70fea418ca65ed974fbb.

weston_wm_write_property() takes the ownership of the reply it gets as
a parameter, and will eventually free it later in writable_callback.

This change introduced a double-free when Xwayland programs triggered a
copy to the clipboard, leading to a Weston crash.

Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
9 years agoDocumentation for the prepare_lock_surface event description, is incorrect
Christopher Michael [Tue, 14 Jul 2015 08:21:40 +0000 (01:21 -0700)]
Documentation for the prepare_lock_surface event description, is incorrect

Documentation for the prepare_lock_surface event description is
incorrect. The summary says "Tell the client..." however the full-text
description says "tell the shell..."

Signed-off-by: Chris Michael <cp.michael@samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
[This time include the actual changes.]

9 years agozunitc: Fix minor typo
Bryce Harrington [Mon, 13 Jul 2015 19:23:01 +0000 (12:23 -0700)]
zunitc: Fix minor typo

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agozunitc: Fix some minor grammatical errors in dox
Bryce Harrington [Mon, 13 Jul 2015 19:23:00 +0000 (12:23 -0700)]
zunitc: Fix some minor grammatical errors in dox

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agozunitc: wrap dox to 80 columns
Bryce Harrington [Mon, 13 Jul 2015 19:22:59 +0000 (12:22 -0700)]
zunitc: wrap dox to 80 columns

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agoDocumentation for the prepare_lock_surface event description, is incorrect
Christopher Michael [Mon, 13 Jul 2015 19:57:41 +0000 (12:57 -0700)]
Documentation for the prepare_lock_surface event description, is incorrect

Documentation for the prepare_lock_surface event description is
incorrect. The summary says "Tell the client..." however the full-text
description says "tell the shell..."

Signed-off-by: Chris Michael <cp.michael@samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agoscreen-share: Use the correct list pointer when freeing shm buffers
Bryce Harrington [Sat, 11 Jul 2015 01:52:56 +0000 (18:52 -0700)]
screen-share: Use the correct list pointer when freeing shm buffers

The wl_list_for_each operation on the free_buffers list should use
free_link not link, which is a different list.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
9 years agocompositor: make sure to reset views' pointers to destroyed output
Giulio Camuffo [Sun, 12 Jul 2015 07:52:32 +0000 (10:52 +0300)]
compositor: make sure to reset views' pointers to destroyed output

When an output is being destroyed reassign the output of the views
that were in it, to be sure not to keep a dangling pointer which could
be used later on by calling weston_surface_assign_output() on the
view's surface.
Also make sure we send wl_surface.leave events to the surfaces that
were in that output.

Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
9 years agocompositor-wayland: Use the correct list pointer when freeing shm buffers
Derek Foreman [Fri, 29 May 2015 21:32:52 +0000 (16:32 -0500)]
compositor-wayland: Use the correct list pointer when freeing shm buffers

The wl_list_for_each operation on the free_buffers list should use
free_link not link, which is a different list.

This fixes a crash when entering fullscreen mode when using the pixman
renderer on the wayland back-end.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
9 years agoxwayland: Allow dump_property when selection fails
Bryce Harrington [Sat, 11 Jul 2015 01:13:48 +0000 (18:13 -0700)]
xwayland: Allow dump_property when selection fails

dump_property allows reply to be NULL.  Calling it unconditionally will
ensure user knows where the selection failed.

Also refactor code a bit.

Suggested by Marek Chalupa

9 years agoxwayland: Check return of xcb_get_property_reply() before deref
Bryce Harrington [Fri, 10 Jul 2015 04:30:16 +0000 (21:30 -0700)]
xwayland: Check return of xcb_get_property_reply() before deref

The man pages indicate this routine can return NULL on certain error
conditions.

Suggested by Marek Chalupa

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Marek Chalupa <mchqwerty@gmail.com>
9 years agodesktop-shell: make client_initiated a bool
Derek Foreman [Wed, 3 Jun 2015 20:53:22 +0000 (15:53 -0500)]
desktop-shell: make client_initiated a bool

Make it a bool in both surface_move() and struct weston_move_grab

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
9 years agocompositor: move the main() to a new main.c file
Giulio Camuffo [Sat, 11 Oct 2014 21:24:25 +0000 (00:24 +0300)]
compositor: move the main() to a new main.c file

This commits starts to separate the libweston code from the weston
specific code. As such, the main() is moved, together with signals
handling and configuration handling.

The definition of DEFAULT_REPAINT_WINDOW is left in compositor.c, so the
config loading of repaint_msec is slightly modified to account that.

Acked-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agocompositor: add API to manage compositor instances
Giulio Camuffo [Sat, 11 Oct 2014 20:56:24 +0000 (23:56 +0300)]
compositor: add API to manage compositor instances

This commit adds three new exported functions:
- weston_compositor_create() returns a new weston_compositor instance,
initializing it as the now removed weston_compositor_init() did.
- weston_compositor_exit(compositor) asks the compositor to tear
down by calling the compositor's exit vfunc which is set by the
libweston application.
- weston_compositor_destroy(compositor) is called by the libweston
application when tearing down the compositor. The compositor is destroyed
and the memory freed.

Reviewed-by: Jon A. Cruz <jonc@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agoxwayland: Always free reply from xcb_get_property_reply()
Bryce Harrington [Wed, 1 Jul 2015 04:35:43 +0000 (21:35 -0700)]
xwayland: Always free reply from xcb_get_property_reply()

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Marek Chalupa <mchqwerty@gmail.com>
9 years agoclients: Simplify memory allocation with xzalloc()
Bryce Harrington [Fri, 19 Jun 2015 23:12:22 +0000 (16:12 -0700)]
clients: Simplify memory allocation with xzalloc()

It is redundant to check x*alloc's return value for null pointers, since
they are guaranteed to either return non-NULL or terminate the program.

In cases where we memset the malloc'd memory to 0, we can more
efficiently use the xzalloc() routine.  zalloc looks for opportunities
to return memory chunks that have already been zero'd out, so it can
provide better performance.

This patch addresses this warning, reported by Denis Denisov:

  [clients/window.c:1164] -> [clients/window.c:1166]: (warning) Possible
  null pointer dereference: surface - otherwise it is redundant to check
  it against null.

  [clients/window.c:4513] -> [clients/window.c:4514]: (warning) Possible
  null pointer dereference: surface - otherwise it is redundant to check
  it against null.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Marek Chalupa <mchqwerty@gmail.com>
9 years agoweston-launch: Drop redundant exit()
Bryce Harrington [Fri, 19 Jun 2015 22:47:40 +0000 (15:47 -0700)]
weston-launch: Drop redundant exit()

error(1, ...) already will exit, per man page: "If status has a nonzero
value, then error() calls exit(3) to terminate the program using the
given value as the exit status."  So exit(EXIT_FAILURE) is never
reached.

The EXIT_FAILURE macro is guaranteed to be non-zero.  Typically it's
just 1, but on some systems (e.g. OpenVMS apparently) exit(1) means
success so EXIT_FAILURE there is defined to some other non-zero value.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Marek Chalupa <mchqwerty@gmail.com>
9 years agocompositor: introduce struct weston_backend
Giulio Camuffo [Sat, 11 Oct 2014 15:27:30 +0000 (18:27 +0300)]
compositor: introduce struct weston_backend

This is a preliminary change for libweston, with no functional modifications.
Separate the backends and the core weston_compositor struct, by creating
the weston_compositor in the main(), and having the various backends extend
the weston_backend struct, an instance of which is returned by the backend
entry point.
This enable us to logically separate the compositor core from the backend,
allowing the core to be extended without messing with the backends.

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agoAdded simple unit/integration test framework and corresponding test program.
Jon A. Cruz [Fri, 3 Jul 2015 06:36:44 +0000 (23:36 -0700)]
Added simple unit/integration test framework and corresponding test program.

Added a simple C-based test framework and an example program
that uses it to run through some simple unit tests.

This is new code inspired primarily by the approaches of Google
Test, Boost Test, JUnit and TestNG. Factors of others were also
considered during design and implementation.

Signed-off-by: Jon A. Cruz <jonc@osg.samsung.com>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agodesktop-shell: Allow fullscreen windows to mode-switch their output.
Mario Kleiner [Sun, 21 Jun 2015 19:25:12 +0000 (21:25 +0200)]
desktop-shell: Allow fullscreen windows to mode-switch their output.

Fix desktop-shell's activate() method to only restore the output
mode on the single output on which a shell surface gets activated.

This way toplevel fullscreen surfaces can mode-switch their output
via method WL_SHELL_SURFACE_FULLSCREEN_METHOD_DRIVER and that
temporary mode properly persists until the surface loses its
fullscreen status, but effects like window switching and exposay
still work in the expected way.

v2: Split into a separate patch from original patch
    "Allow restore_output_mode() to work properly.",
    as suggested by Derek Foreman.

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Cc: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agocompositor-drm: fix drm_waitvblank_pipe() decl style
Pekka Paalanen [Thu, 2 Jul 2015 12:06:08 +0000 (15:06 +0300)]
compositor-drm: fix drm_waitvblank_pipe() decl style

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agocompositor-drm: Add comment for newly added drm_waitvblank_pipe()
Bryce Harrington [Tue, 30 Jun 2015 20:25:46 +0000 (13:25 -0700)]
compositor-drm: Add comment for newly added drm_waitvblank_pipe()

9 years agocompositor-drm: Handle more than two output crtcs per card
Mario Kleiner [Sun, 21 Jun 2015 19:25:13 +0000 (21:25 +0200)]
compositor-drm: Handle more than two output crtcs per card

Allow proper handling of output->pipe > 1 to support
triple-head graphics cards etc. by using the "high-crtc"
support introduced in Linux 2.6.39 and libdrm 2.4.25
around May 2011.

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
9 years agocompositor-drm: Allow weston_output_mode_switch_to_native() to work.
Mario Kleiner [Sun, 21 Jun 2015 19:25:11 +0000 (21:25 +0200)]
compositor-drm: Allow weston_output_mode_switch_to_native() to work.

Initialize output->native_mode with the initially chosen
mode for an output, so weston_output_mode_switch_to_native()
has something to work with and can switch back from temporary
selected modes to the outputs native mode. Before, this was a
no-op.

This allows an output to switch back to its default mode if
a former toplevel fullscreen shell surface created via method
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DRIVER gets destroyed, or
it gets demoted to non-fullscreen, or if modesetting on the
output failed for some reason.

v2: Modified and split into a separate patch from original
    patch "Allow restore_output_mode() to work properly.",
    as suggested by Derek Foreman.

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Cc: Derek Foreman <derekf@osg.samsung.com>
Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
9 years agocompositor-drm: Fix refresh rate selection in drm_output_switch_mode
Mario Kleiner [Sun, 21 Jun 2015 19:25:09 +0000 (21:25 +0200)]
compositor-drm: Fix refresh rate selection in drm_output_switch_mode

The matching logic in choose_mode() compared refresh rate
of a drm_mode candidate mode expressed in Hz against the
requested refresh rate of the target weston_mode expressed
in milliHz, so the match always failed and the logic always
ended up the mode with the highest refresh rate for a given
resolution, instead of the one matching the requested rate.

Match proper fields to fix this.

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
9 years agodesktop-shell: Allow multiple active fullscreen windows on multi-display setup.
Mario Kleiner [Sun, 21 Jun 2015 19:25:08 +0000 (21:25 +0200)]
desktop-shell: Allow multiple active fullscreen windows on multi-display setup.

Desktop shell demoted all fullscreen shell surfaces on all active
outputs of a multi-display setup whenever any shell surface was
activated anywhere. This made it impossible to have multiple
fullscreen windows on separate outputs active at the same
time, as creating or activating any shell surface would disable
fullscreen status for all existing fullscreen surfaces.

Make lower_fullscreen_layer() more selective, so on request it
only demotes fullscreen surfaces on a specified weston_output.

The activate() method for a specific surface will now only request
demotion of fullscreen surfaces on the target output of the activated
surface, but leave fullscreen surfaces on unrelated outputs alone.

Desktop wide acting functions like the window switcher or exposay
will still demote all fullscreen surfaces on all outputs to
implement their effect as before.

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
9 years agoxdg-shell: Further clarify xdg_surface.resize semantics
Jonas Ådahl [Thu, 2 Apr 2015 07:13:51 +0000 (15:13 +0800)]
xdg-shell: Further clarify xdg_surface.resize semantics

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agoxdg-shell: Further clarify xdg_surface.move semantics
Jonas Ådahl [Wed, 18 Mar 2015 12:29:10 +0000 (20:29 +0800)]
xdg-shell: Further clarify xdg_surface.move semantics

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
9 years agotext_backend: make destructor call explicit
Pekka Paalanen [Wed, 24 Jun 2015 13:09:17 +0000 (16:09 +0300)]
text_backend: make destructor call explicit

We used to rely on the order in which the
weston_compositor::destroy_signal callbacks happened, to not access
freed memory. Don't know when, but this broke at least with ivi-shell,
which caused crashes in random places on compositor shutdown.

Valgrind found the following:

 Invalid write of size 8
    at 0xC2EDC69: unbind_input_panel (input-panel-ivi.c:340)
    by 0x4E3B6BB: destroy_resource (wayland-server.c:537)
    by 0x4E3E085: for_each_helper.isra.0 (wayland-util.c:359)
    by 0x4E3E60D: wl_map_for_each (wayland-util.c:365)
    by 0x4E3BEC7: wl_client_destroy (wayland-server.c:675)
    by 0x4182F2: text_backend_notifier_destroy (text-backend.c:1047)
    by 0x4084FB: wl_signal_emit (wayland-server-core.h:264)
    by 0x4084FB: main (compositor.c:5465)
  Address 0x67ea360 is 208 bytes inside a block of size 232 free'd
    at 0x4C2A6BC: free (vg_replace_malloc.c:473)
    by 0x4084FB: wl_signal_emit (wayland-server-core.h:264)
    by 0x4084FB: main (compositor.c:5465)

 Invalid write of size 8
    at 0x4E3E0D7: wl_list_remove (wayland-util.c:57)
    by 0xC2EDEE9: destroy_input_panel_surface (input-panel-ivi.c:191)
    by 0x4E3B6BB: destroy_resource (wayland-server.c:537)
    by 0x4E3BC7B: wl_resource_destroy (wayland-server.c:550)
    by 0x40DB8B: wl_signal_emit (wayland-server-core.h:264)
    by 0x40DB8B: weston_surface_destroy (compositor.c:1883)
    by 0x40DB8B: weston_surface_destroy (compositor.c:1873)
    by 0x4E3B6BB: destroy_resource (wayland-server.c:537)
    by 0x4E3E085: for_each_helper.isra.0 (wayland-util.c:359)
    by 0x4E3E60D: wl_map_for_each (wayland-util.c:365)
    by 0x4E3BEC7: wl_client_destroy (wayland-server.c:675)
    by 0x4182F2: text_backend_notifier_destroy (text-backend.c:1047)
    by 0x4084FB: wl_signal_emit (wayland-server-core.h:264)
    by 0x4084FB: main (compositor.c:5465)
  Address 0x67ea370 is 224 bytes inside a block of size 232 free'd
    at 0x4C2A6BC: free (vg_replace_malloc.c:473)
    by 0x4084FB: wl_signal_emit (wayland-server-core.h:264)
    by 0x4084FB: main (compositor.c:5465)

 Invalid write of size 8
    at 0x4E3E0E7: wl_list_remove (wayland-util.c:58)
    by 0xC2EDEE9: destroy_input_panel_surface (input-panel-ivi.c:191)
    by 0x4E3B6BB: destroy_resource (wayland-server.c:537)
    by 0x4E3BC7B: wl_resource_destroy (wayland-server.c:550)
    by 0x40DB8B: wl_signal_emit (wayland-server-core.h:264)
    by 0x40DB8B: weston_surface_destroy (compositor.c:1883)
    by 0x40DB8B: weston_surface_destroy (compositor.c:1873)
    by 0x4E3B6BB: destroy_resource (wayland-server.c:537)
    by 0x4E3E085: for_each_helper.isra.0 (wayland-util.c:359)
    by 0x4E3E60D: wl_map_for_each (wayland-util.c:365)
    by 0x4E3BEC7: wl_client_destroy (wayland-server.c:675)
    by 0x4182F2: text_backend_notifier_destroy (text-backend.c:1047)
    by 0x4084FB: wl_signal_emit (wayland-server-core.h:264)
    by 0x4084FB: main (compositor.c:5465)
  Address 0x67ea368 is 216 bytes inside a block of size 232 free'd
    at 0x4C2A6BC: free (vg_replace_malloc.c:473)
    by 0x4084FB: wl_signal_emit (wayland-server-core.h:264)
    by 0x4084FB: main (compositor.c:5465)

Looking at the first of these, unbind_input_panel() gets called when the
text-backend destroys its helper client which has bound to input_panel
interface. This happens after the shell's destroy_signal callback has
been called, so the shell has already been freed.

The other two errors come from
  wl_list_remove(&input_panel_surface->link);
which has gone stale when the shell was destroyed
(shell->input_panel.surfaces list).

Rather than creating even more destroy listeners and hooking them up in
spaghetti, modify text-backend to not hook up to the compositor destroy
signal. Instead, make it the text_backend_init() callers' responsibility
to also call text_backend_destroy() appropriately, before the shell goes
away.

This fixed all the above Valgrind errors, and avoid a crash with
ivi-shell when exiting Weston.

Also using desktop-shell exhibited similar Valgrind errors which are
fixed by this patch, but those didn't happen to cause any crashes AFAIK.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
9 years agotests: test set for ivi-shell notification with bad condition in server side
Nobuhiko Tanibata [Mon, 22 Jun 2015 06:37:41 +0000 (15:37 +0900)]
tests: test set for ivi-shell notification with bad condition in server side

These tests are implemented on test suite framework, which provides
internal method validation,
Following features are tested,
- add notification of ivi-layer with bad parameter
- add notification of ivi-surface configure with bad parameter
- add notification of creating ivi-layer with bad parameter
- add notification of creating ivi-surface with bad parameter
- add notification of removing ivi-layer with bad parameter
- add notification of removing ivi-surface with bad parameter

Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Jon A. Cruz <jonc@osg.samsung.com>
9 years agotests: test set for ivi-shell notification in bad condition with helper client
Nobuhiko Tanibata [Mon, 22 Jun 2015 06:36:21 +0000 (15:36 +0900)]
tests: test set for ivi-shell notification in bad condition with helper client

These tests are implemented on test suite framework, which provides
helper client.
Following features are tested,
- add notfication of ivi-surface with bad condition

Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Jon A. Cruz <jonc@osg.samsung.com>
9 years agotests: test set for ivi-shell notification normal use case in server side
Nobuhiko Tanibata [Mon, 22 Jun 2015 06:36:11 +0000 (15:36 +0900)]
tests: test set for ivi-shell notification normal use case in server side

These tests are implemented on test suite framework, which provides
internal method validation.
Following features are tested,
- notification of adding ivi-layer
- notification of creating ivi-layer
- notification of removing ivi-layer

Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Jon A. Cruz <jonc@osg.samsung.com>
9 years agotests: test set for ivi-shell notification normal use case with helper client
Nobuhiko Tanibata [Mon, 22 Jun 2015 06:35:58 +0000 (15:35 +0900)]
tests: test set for ivi-shell notification normal use case with helper client

These tests are implemented on test suite framework, which provides
helper client.
Following features are tested,
  - notification of adding ivi-surface
  - notification of ivi-surface configure
  - notification of creating ivi-surface
  - notification of removing ivi-surface

Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Jon A. Cruz <jonc@osg.samsung.com>