Commit graph

245 commits

Author SHA1 Message Date
Jonas Ådahl 1fa6dedb82 desktop-shell: Make activate() take a view instead of surface
In preparation for further refactorings.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-07-26 17:21:15 +08:00
Jonas Ådahl 90c90b205f desktop-shell: Change switcher to track views
Preparation for future refactorings.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-07-26 17:21:15 +08:00
Jonas Ådahl 7bfb113dbe desktop-shell: Track the black surface by its view
In preparation for further refactoring.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Signed-off-by: Arnaud Vrac <avrac@freebox.fr>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
2016-07-26 17:21:15 +08:00
Jonas Ådahl ef8e1c31e3 input: Activate view no matter the keyboard focus
Activate a view even though it effectively may already be active.
Without this, in later patches, it won't be possibe to track what view
was activated by clicking last, as a view which surface already had
keyboard focus, won't be activated.

To keep avoiding sending xdg_surface.configure events, only change the
keyboard focus if the focus actually changed.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
2016-07-26 17:21:15 +08:00
Armin Krezović 4663aca2e2 desktop-shell: update for manual surface/view mapping
This is a follow up for desktop-shell to manually
set mapped status for views/surfaces it controls

v2:

- Add manual mapping to shell_fade_create_surface()
  and shell_ensure_fullscreen_black_view()

Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-07-01 15:29:26 +03:00
Bryce Harrington 260c2ffd97 input: Rename weston_surface_activate to weston_seat_set_keyboard_focus
The name suggests that it activates surfaces, but the code says it
rather just assigns keyboard focus.  Rename it for clarity, and so the
original function name could be used for something more appropriate
later.  Switch order of parameters since keyboard focus is a property of
the seat.  Update all callers as appropriate.

Change was asked for by pq, May 26, 2016:

 "This should be called weston_seat_set_keyboard_focus(seat, surface).
 Keyboard focus is a property of the seat."

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-06-30 13:15:33 +03:00
Armin Krezović c77f258b4a desktop-shell: Avoid NULL pointer dereference
When there are no outputs present, an output pointer
can be NULL. Dereferencing such pointer will result
in a crash.

Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-06-27 13:17:05 +03:00
Armin Krezović 10b0618c07 desktop-shell: Return NULL when no outputs are present
Currently, get_default_output returns a first member
of the linked list, which can never be NULL.

This is problematic, as the function would return a
dangling pointer and NULL pointer checks wouldn't
work where needed and some of the invalid members
would get accessed that way, resulting in a crash.

Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-06-27 13:17:05 +03:00
Pekka Paalanen 58f98c99f5 Move weston source to compositor/
This is the start of separating weston-the-compositor source files from
libweston source files.

This is moving all the files related to the 'weston' binary. Also the
CMS and systemd plugins are moved.

xwayland plugin is not moved, because it will be turned into a
libweston feature.

To avoid breaking the build, #includes for weston.h are fixed to use
compositor/weston.h. This serves as a reminder that such files may need
further attention: moving to the right directory, or maybe using the
proper -I flags instead.

v2: Move also screen-share.c, and add a note about weston-launch.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Tested-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Tested-by: Benoit Gschwind <gschwind@gnu-log.net>
Acked-by: Benoit Gschwind <gschwind@gnu-log.net>
[Pekka: rebased]
2016-06-23 17:44:54 +03:00
David Fort 50d962fc07 desktop-shell: resize background and panel surfaces on output resize v4
When an output is resized (permanent mode switch), we should also notify the
shell client so that the panel and background fits to the new screen dimensions.

Signed-off-by: David Fort <contact@hardening-consulting.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-06-10 11:52:01 +03:00
Giulio Camuffo d52f3b775b compositor: remove the weston_config field in weston_compositor
The config can now be retrieved with a new function defined in weston.h,
wet_get_config(weston_compositor*).

Signed-off-by: Giulio Camuffo <giuliocamuffo@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
2016-06-03 13:16:39 +03:00
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
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
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