Commit Graph

258 Commits

Author SHA1 Message Date
Giulio Camuffo
26f62d4247 Move part of screenshooter.c to weston-screenshooter.c
This patch splits screensooter.c so that the code implementing
the private screenshooter protocol and launching the client is
moved to a weston specific file, leaving only the code that can
be shared between compositors in screenshooter.c.
Two exported functions are added in screenshooter.c to start and
stop the recorder.

Signed-off-by: Giulio Camuffo <giuliocamuffo@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-06-03 13:16:39 +03:00
Emmanuel Gil Peyrot
28834b6472 desktop-shell: Don’t reconfigure an already fullscreen surface
When we receive an wl_shell_surface::set_fullscreen request for a
surface that was already fullscreen, don’t do anything if the
parameters are the same as the initial request.

This prevents bogus or malicious clients from being able to always stay
on front by flooding the compositor with set_fullscreen requests after
the user has put them in the background with a mod+tab.

Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2016-05-19 17:52:46 -07:00
Quentin Glidic
5c20195e7a compositor.h: Add shell_interface.get_output_work_area
This will allow plugins to be aware of e.g. panels, to avoid covering
them with other surfaces.

Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-05-03 15:45:24 +03:00
Yong Bakos
bbb783a957 desktop-shell: Use 'surface-local' to correct grammar
Correct the pluralization by simplifying with 'surface-local'.

See https://lists.freedesktop.org/archives/wayland-devel/2016-April/028249.html.

Signed-off-by: Yong Bakos <ybakos@humanoriented.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2016-04-29 16:33:01 -07:00
Jonas Ådahl
10257ee5d9 desktop-shell: Get rid of some unused fields
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Mike Blumenkrantz <zmike@osg.samsung.com>
2016-04-22 10:31:21 +08:00
Jonas Ådahl
d3a3ee980d desktop-shell: Unset the shell surface owner when it goes away
On client destruction, the shell object may be destroyed before the
shell surface objects. If this happens to two surfaces of the same
client, and one surface being destroyed results in the focus being
switched to the other, this would trigger a ping event.

The ping event sending function relies on having a valid owner, and if
the shell would be destoryed prior to the shell surface, we'd crash in
this function.

Solve this by unsetting the owner pointer when the shell client goes
away and early out in the ping event sending function if the owner is
gone.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Mike Blumenkrantz <zmike@osg.samsung.com>
2016-04-22 10:31:21 +08:00
Giulio Camuffo
90a6fc659f input: use doubles in the interfaces to notify of input events
This patch is a further step in the wl_fixed_t internal sanitization.
It changes the notify_* functions to take doubles instead of wl_fixed_t
but does not change how these are stored in the various input structs
yet, except for weston_pointer_axis_event.
However this already allows to remove all wl_fixed_t usage in places
like the libinput or the x11 backend.

Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-03-23 14:05:09 +02:00
Derek Foreman
bbde643ecd shell: Don't send extra configure events on click
The click_to_activate handler fires on every mouse click for a surface
so let's be a little quicker to early return if you're clicking on the
surface that already has activation.

This prevents (among other side effects) the sending of two xdg_configure
events for every mouse click.

This should also make having two seats with keyboards behave in the same
way as a single seat.  Previously the second seat could have a keyboard
focus on the surface and prevent some of the extra processing (including
the extra configure events) from taking place.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2016-02-16 21:55:46 -08:00
Bryce Harrington
22b1f93432 shell: Check more thoroughly for undefined surface resource
The surface can have an undefined resource in certain situations (such
as with xwayland).  So, since NULL is a valid state for this parameter,
and since the wl_resource_*, etc. calls require their parameters to be
non-NULL, make a practice of always checking the surface resource before
making wayland calls.

update v2:
  * Fix some c/p errors for pointer names
  * Drop null ptr check in add_popup_grab; probably redundant now

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2016-02-03 19:05:12 -08:00
Peter Hutterer
87743e9303 Support axis source, axis discrete, frame and axis stop events
[jonas: only send focus wl_pointer.frame if resource supports it]

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2016-01-19 12:33:26 +08:00
Peter Hutterer
89b6a4931e Add a weston_pointer_axis_event
Use an event struct to pass axis events around. This helps dealing with the
upcoming axis discrete changes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
2016-01-19 10:53:16 +08:00
Bob Ham
553d12488c desktop-shell: Allow binding-modifier weston.ini option to be none
Allow the binding-modifier option in weston.ini to take a value of
"none", meaning that none of the usual Super+Tab, Super+K, Super+Fn,
etc. key bindings will be enabled.

Signed-off-by: Bob Ham <bob.ham@collabora.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
2016-01-12 09:25:28 -06:00
Bob Ham
744e65317d desktop-shell: Make zapping configurable
Add a new boolean weston.ini option, "allow-zap" to enable or disable
the Ctrl-Alt-Backspace key combination.

Signed-off-by: Bob Ham <bob.ham@collabora.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
2016-01-12 09:24:05 -06:00
Giulio Camuffo
f05d18f3ee xwm: let the shells decide the position of X windows
The xwm used to automatically send to Xwayland the position of X windows
when that changed, using the x,y of the primary view of the surface.
This works fine for the desktop shell but less so for others.
This patch adds a 'send_position' vfunc to the weston_shell_client that
the shell will call when it wants to let Xwayland know what the position
of a window is.
The logic used by the desktop-shell for that is exactly the same the xwm
used to have.
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: David Fort <contact@hardening-consulting.com>
2015-12-18 11:48:25 -06:00
Jonas Ådahl
2cbf293b05 input: Keep per client pointer resources in their own structs
Keep all per client wl_pointer resources in a new struct called
'weston_pointer_client'. When focus changes, instead of moving a list
of resources between different lists, just change the focused pointer
client.

The intention with this is to make it easier to add wl_pointer
extensions that share the same focus as the corresponding wl_pointer.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-11-20 11:52:19 +08:00
Jonas Ådahl
d2510105a6 input: Make pointer grab motion callbacks take an event struct
Instead of only passing absolute pointer coordinates, effectively
loosing motion event data, pass a struct that can potentially contain
different types of motion events, currently being absolute and relative.

A helper function to get resulting absolute coordinates was added for
when previous callbacks simply used the (x, y) coordinates.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
2015-11-20 11:44:56 +08:00
Jonas Ådahl
5b0b770c2d Remove workspaces protocol
It doesn't fill a useful function and is not intended to be continued.
If there is need for workspace manipulation from clients a protocol
based on those future needs need to be properly designed.
workspaces.xml is probably not very relevant since it did the bare
minimum.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Mariusz Ceier <mceier+wayland@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2015-11-19 15:11:08 +02:00
Jonas Ådahl
6d6fb61a32 desktop-shell: Rename protocol weston_desktop_shell
In the effort of going away from generic names of protocols only
relevant for weston, rename the weston desktop shell
weston_desktop_shell.

This also resets the version to 1, as there will be no prior versions
to weston_desktop_shell.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Mariusz Ceier <mceier+wayland@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2015-11-19 14:58:58 +02:00
Jonas Ådahl
2a229338a5 Use xdg_shell protocol from wayland-protocols
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Mariusz Ceier <mceier+wayland@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Acked-by: Jasper St. Pierre <jstpierre@mecheye.net>
2015-11-19 14:49:52 +02:00
Jonas Ådahl
b57f472c84 Use input method protocol from wayland-protocols
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Mariusz Ceier <mceier+wayland@gmail.com>
Reviewed-by: Jan Arne Petersen <janarne@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2015-11-19 13:17:59 +02:00
Peter Hutterer
1118952e14 desktop-shell: use weston_pointer_send_axis
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
2015-11-16 12:09:07 +08:00
Jonas Ådahl
0336ca0cc5 input: Pass axis events through pointer grab interfaces
Don't only send motions and buttons but also axis events through the
pointer grab interface.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
2015-11-02 14:30:16 +08:00
Jonas Ådahl
22faea11c8 desktop-shell: Add surface_keyboard_focus_lost helper
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
2015-11-02 14:10:01 +08:00
Jonas Ådahl
cd0f1acff4 desktop-shell: Make activate_binding take a view instead of surface
In preparation for further refactoring. This patch also removes a
redundant NULL check. Since we pass views, and views will always have an
associated surface, there is no point of checking if it has.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-10-23 17:03:54 -07:00
Marek Chalupa
6ce78992a0 shell: fix maximizing windows on a secondary output
commit f814c5dc9 changed get_output_work_area behaviour
which broke the code for positioning maximized window.
The x position was set to 2*output->x instead of to output->x

fix https://bugs.freedesktop.org/show_bug.cgi?id=92357

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
2015-10-09 15:24:04 -05:00
Nicolas Guyomard
4845354cfa input-panel: Fix show_input_panel_surface crash when no surface has focus
Signed-off-by: Nicolas Guyomard <nicolas.guyomard@open.eurogiciel.org>
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-10-07 17:13:17 -07:00
Derek Foreman
bdc8c721e4 cosmetic: Remove a few double semicolons
Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
2015-10-07 11:22:03 -07:00
Jonas Ådahl
bc5d849c9d desktop-shell: NULL check whether a popup parent is a shell surface
get_shell_surface(parent) may return NULL if the client passed a
unassigned wl_surface or a wl_surface with a non-shell surface role
(such as cursor role).

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

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Tested-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
2015-10-07 11:43:59 -05:00
Ben Hummon
445e44cfb2 clients: Moving and rotating transient surfaces
Transient surfaces use child/parent surfaces for stacking order. This
change resloves an issue in which attempting to move or rotate a
toplevel transient surface can move or rotate its ancestor.
2015-10-06 15:24:28 -05:00
Derek Foreman
45a7c27f2b clients: If available, prefer top level surfaces for move or rotate
This stops us from rotating or moving pop-up menus by instead rotating
their parents.

This is easiest to see using a multi-seat configuration.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-09-15 06:51:15 -07:00
Derek Foreman
c0c1497f99 shell: Make sure we actually have a resource in end_busy_cursor
It's actually possible to get here after the surface has been destroyed,
especially when running client apps under valgrind.

That probably shouldn't be able to segfault the compositor.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2015-09-14 11:33:31 -07:00
Derek Foreman
f9318d1452 input: add a weston_pointer_clear_focus() helper function
Valgrind has shown that in at least one place (default_grab_pointer_focus)
we're testing uninitialized values coming out of weston_compositor_pick_view.

This is happening when default_grab_pointer_focus is called when there is
nothing on the view list, and during the first repaint when only the black
surface with no input region exists.

This patch adds a function to clear pointer focus and also set the sx,sy
co-ordinates to a sentinel value we shouldn't compute with.

Assertions are added to make sure any time pointer focus is set to NULL
these values are used.

weston_compositor_pick_view() now returns these values too.

Now the values are always initialized, even when no view exists, and
they're initialized in such a way that actually doing computation
with them should fail in an obvious way, but we can compare them
safely for equality.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2015-08-06 16:28:30 +01:00
Giulio Camuffo
61ed7b6bf0 input: pass the global touch coordinates to the touch grab
This makes it consistent with the pointer grab, which also gets
global coordinates and not surface relative ones, and allows to
easily filter out gestures based on compositor global hotspots.

Reviewed-by: Daniel Stone <daniels@collabora.com>
2015-08-06 16:21:01 +01:00
Derek Foreman
e4d6c83986 desktop-shell: Make resize and move functions take a pointer instead of a seat
An earlier patch made surface_resize() and surface_move() take pointers
instead of seats, this updates the weston_shell_interface resize and move to
match.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2015-08-06 16:16:14 +01:00
Derek Foreman
e42d754843 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>
2015-08-06 16:04:15 +01:00
Derek Foreman
1281a36e3b 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>
2015-07-31 15:16:09 -07:00
Derek Foreman
006cf67c77 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>
2015-07-31 15:16:03 -07:00
Derek Foreman
60d97311be 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>
2015-07-31 15:15:59 -07:00
Derek Foreman
22276a596a 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>
2015-07-29 19:54:17 -07:00
Derek Foreman
25bd8a71fc 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>
2015-07-29 19:47:31 -07:00
Derek Foreman
004b4a1dc1 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>
2015-07-23 10:54:47 -07:00
Derek Foreman
d8156e22f6 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>
2015-07-17 19:02:28 -07:00
Derek Foreman
daf846e4ea exposay: Fix logic inversion when ending keyboard grabs
I flipped a ! in cee82d6286
and the exposay keyboard grab became permanent.

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
2015-07-17 18:59:35 -07:00
Derek Foreman
6feb0f9f55 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>
2015-07-17 17:46:58 -07:00
Derek Foreman
612341f1a6 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>
2015-07-17 17:46:54 -07:00
Derek Foreman
f814c5dc9d 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>
2015-07-17 17:46:49 -07:00
Derek Foreman
2217f3f738 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>
2015-07-16 19:35:19 -07:00
Derek Foreman
f7b2f8b0a6 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>
2015-07-16 19:04:19 -07:00
Derek Foreman
8fbebbd985 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>
2015-07-16 19:04:17 -07:00
Derek Foreman
74de4693b7 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>
2015-07-16 19:04:07 -07:00