1
0
Fork 0
Commit graph

887 commits

Author SHA1 Message Date
Carlos Garnacho
c17d85e16b wayland: Let MetaWaylandTabletManager process tablet events
meta_wayland_tablet_manager_update()/handle_event() are called before
the MetaWaylandSeat counterparts. If the event comes from a device
managed by MetaWaylandTabletManager, the event will be exclusively handled
by it.
2016-05-03 18:17:01 +02:00
Carlos Garnacho
ec53b5562d wayland: Implement wl_tablet_tool.set_cursor
Each tool has its own MetaCursorRenderer instance, which is created/destroyed
upon proximity, and possibly updated through focus and set_cursor calls in
between.
2016-05-03 18:17:01 +02:00
Carlos Garnacho
521e934cb9 wayland: Implement wl_tablet_tool device event emission
This takes care of the emission of motion/down/up/button, in addition
to the extra distance/pressure/tilt axes.
2016-05-03 18:17:01 +02:00
Carlos Garnacho
edfb8fe19b wayland: Add focus management to MetaWaylandTabletTool
Tools can now switch between surfaces, which implies the emission
of wl_tablet_tool.proximity_in/out events.
2016-05-03 18:17:01 +02:00
Carlos Garnacho
745cb67988 wayland: Initialize the MetaWaylandTabletManager 2016-05-03 18:17:01 +02:00
Carlos Garnacho
d990f873c1 wayland: Add MetaWaylandTabletManager
This struct keeps the server side information for the wl_tablet_manager
global resource. It keeps the clients requesting this interface, and
does keep track of the plugged tablet devices, so
wl_tablet_manager.device_added is emitted on the expected clients.
2016-05-03 18:17:01 +02:00
Carlos Garnacho
0deb069f87 wayland: Add MetaWaylandTabletSeat
This object groups all the tablets/tools pertaining to a given seat.
2016-05-03 13:05:06 +02:00
Carlos Garnacho
ee394a6cd3 wayland: Add MetaWaylandTabletTool
This struct holds the server-side information of a wl_tablet_tool, which
represents an specific tool of an specific tablet, and is unique as such.
2016-05-03 13:05:06 +02:00
Carlos Garnacho
5478accbf2 wayland: Add MetaWaylandTablet
This (very basic at the moment) struct keeps server-side information
for wl_tablet resources.
2016-05-03 13:05:06 +02:00
Carlos Garnacho
5849275b76 wayland: Refactor MetaWaylandSurfaceRoleCursor
Move into a standalone meta-wayland-surface-role-cursor.[ch], and
make generic enough to work for pointe and additional (eg. tablet)
cursors.

Most notably, the sprite is now kept completely internal to the
cursor role, and updates are routed through the given
MetaCursorRenderer (which may be the default one for the pointer,
or something else).

The way cursor updates after cursor surface destruction has also
been reworked, the pointer will just keep track of the last cursor
surface, so older surfaces being destroyed don't trigger pointer
rechecks/updates.
2016-05-03 13:05:06 +02:00
Carlos Garnacho
1acfcbda6c wayland: Add MetaWaylandSurface::destroy signal
There's places where it would be convenient to add listeners to this,
so add the signal. The signal is only emitted once during destruction,
it is convenient for the places where we want notifications at a time
the object is still alive, as opposed to weak refs which notify after
the fact.
2016-05-03 13:05:06 +02:00
Jonas Ådahl
a4ba72b0bf wayland/xdg-shell: Restructure file layout a bit
Separate "xdg_surface", "xdg_popup" and "xdg_shell" related functions
into three sections. Prior to this, the "xdg_shell" part was a bit all
over the place.

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
f318ec9df5 wayland: Move shell surface role fields to the role structs
Don't keep all the role specific fields in MetaWaylandSurface and have
the roles manage the needed fields themself.

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
a89aa1d8cc wayland/wl_shell: Dismiss popup when parent is destroyed
Dismiss the popup when the parent is destroyed, and do this in the
destructor of the parent object. This makes the parent destory listener
unnecessary, since we already handle the parent child unlinking
explicitly in the object destructor.

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
61c717abb3 wayland: Let the popup surface explicitly dismiss the popup
Instead of relying on destroy signals attached to the corresponding
role object, let the roles explicitly dismiss the popup when it should
be dismissed.

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
229a143eac wayland: Add 'MetaWaylandPopupSurface' bridge between popup and surface
Add a bridge between the MetaWaylandPopup object and the corresponding
popup surface role. This bridge replaces communicating dismissed and
unmapped popup events.

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
d9b98bced9 wayland/xdg-shell: Send popup_done if failed to start grab
https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
e68b5f6655 wayland: Simplify popup grabbing API
meta_wayland_popup_grab_create() creates and begins the grab and
meta_wayland_popup_grab_destroy() both ends and destroys the grab.

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
19f7e310d9 MetaSurfaceActorWayland: Use weak pointer instead of destroy hook
MetaWaylandSurface is a GObject now, so lets utilize that.

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
bca041b68e MetaWindow: Make buffer_rect and rect share coordinate space
Before this commit, on Wayland, the buffer rect would have the size of
the attached Wayland buffer, no matter the scale. The scale would then
be applied ad-hoc by callers when a sane rectangle was needed. This
commit changes buffer_rect to rather represent the surface rect (i.e.
what is drawn on the stage, including client side shadow). The users of
buffer_rect will no longer need to scale the buffer_rect themself to
get a usable rectangle.

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
ca44770f1a wayland: Sync surface actor state in actor role commit handler
This'll also make the actor state already synchronized when shell
surfaces handlers apply their state.

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
9028e30b39 wayland: Move out window state application into the roles
A large part of meta_wayland_surface_apply_window_state() was only
relevant for xdg_surface. Make this more obvious by splitting it up,
moving the relevant parts to the relevant roles.

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
e66f176c29 wayland: Add get_toplevel() vfunc to the role class
How to find the toplevel surface of a surface depends on the surface
role, so let the roles implement it themself.

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
5e54f322ab wayland: Rename subsurface commit role function
This is to make it obvious it is an implementation of a role class
vfunc.

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
23b1b5f57e wayland: Make wl_shell surface role name shorter
MetaWaylandSurfaceRoleWlShellSurface -> MetaWaylandWlShellSurface

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
87555359f5 wayland: Make xdg_shell surface role names shorter
MetaWaylandSurfaceRoleXdgSurface -> MetaWaylandXdgSurface
MetaWaylandSurfaceRoleXdgPopup -> MetaWaylandXdgPopup

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
1088bf476d wayland: Set window type of wl_shell_surface popups to 'dropdown menu'
The wl_shell_surface popups are mostly used in the same way as
xdg_popup, so set the same window type.

https://bugzilla.gnome.org/show_bug.cgi?id=757623

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
f8878ac907 wayland: Let the roles handle their windows being managed
Move xdg_shell specific code from generic Wayland code into the xdg
shell code unit by letting the roles handle the corresponding
MetaWindow being managed.

https://bugzilla.gnome.org/show_bug.cgi?id=757623

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
c2643ba5ac wayland: Keep wl_shell_surface state during loss of window
It has been common practice (in QT5 for example) to set
wl_shell_surface state at situations where mutter will have destroyed
the MetaWindow. This commit keeps track of the relevant state
separately from MetaWindow, and synchronizes when needed.

https://bugzilla.gnome.org/show_bug.cgi?id=757623

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
b3ba8e897e wayland: Clean up wl_shell_surface popup management
The wl_surface_shell protocol allows changing the popup parent, so lets
deal with the possibility that it may happen.

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Jonas Ådahl
7fd585fe98 wayland: Split out shell surface code from meta-wayland-surface.c
Move xdg_shell related functionality to a new meta-wayland-xdg-shell.c
and wl_shell related functionality to a new meta-wayland-wl-shell.c,
and adapt role object tree.

Common functionality related to the surface being drawn as a
MetaSurfaceActor was moved to a MetaWaylandSurfaceRoleActorSurface role.

The subsurface role GObject is made to inherit the actor surface GObject.

Shell surface hooks (configure, ping, close, popup done) were added to
a MetaWaylandSurfaceRoleShellSurface GObject which inherits the
surface actor role GObject.

The shell surface roles (xdg_surface, xdg_popup, wl_shell_surface) are
made to inherit the shell surface GObject and implement the relevant
API.

https://bugzilla.gnome.org/show_bug.cgi?id=757623

https://bugzilla.gnome.org/show_bug.cgi?id=763431
2016-05-01 21:11:27 +08:00
Carlos Garnacho
a6cc35e595 wayland: remove pressed button checks from meta_wayland_pointer_can_grab_surface()
Leave these checks up to the callers, the only uses of this function
(indirect, through meta_wayland_seat_get_grab_info) are
[wl_shell|xdg]_surface.move/resize/show_window_menu.

In move/resize it makes sense to check for a button being pressed, because
we must expect a button release event. However for xdg_surface.show_window_menu
we 1) don't strictly need further events and 2) we must account for press+release
event pairs being processed at once in the compositor before the client sees
the former.

That is eg. the case of touchpad 2nd/3rd button tap emulation, multifinger
taps will emit the event pair at once, so when the client manages to request
xdg_surface.show_window_menu, it'll be too late in the compositor side, so the
request is ignored.

https://bugzilla.gnome.org/show_bug.cgi?id=764519
2016-04-25 14:23:01 +02:00
Jonas Ådahl
08ac192b9d wayland: Handle wl_data_device being destroyed while focused
A wl_data_device object may be created while it is being focused,
either because the client destroyed it or because the client was
destroyed. Handle this by early out in focus handler vfuncs the case
where it was destroyed, so that we don't corrupt memory and/or cause
segmentation fault.

https://bugzilla.gnome.org/show_bug.cgi?id=765062
2016-04-25 20:17:24 +08:00
Rui Matos
e284370013 wayland-keyboard: Notify clients of pending modifier state changes
If we get a key event but still have pending modifier state changes we
need to send a modifiers event right away so that the key event can be
interpreted by clients correctly modified.

This case could happen when mutter/gnome-shell itself consumes the
modifier key press event such as with the overview key which by
default is triggered on super press.

https://bugzilla.gnome.org/show_bug.cgi?id=748526
2016-04-19 18:02:25 +02:00
Rui Matos
0fa9751b31 wayland-keyboard: Include virtual modifiers along with real modifiers
The wayland protocol has enough space to send both virtual and real
modifiers on modifiers events which saves clients the work of
resolving virtual modifiers themselves.

https://bugzilla.gnome.org/show_bug.cgi?id=748526
2016-04-19 18:02:25 +02:00
Florian Müllner
8842bdfb11 Do not skip CoglError parameters
While CoglError is a define to GError, it doesn't follow the convention
of ignoring errors when NULL is passed, but rather treats the error as
fatal :-(
That's clearly unwanted for a compositor, so make sure to always pass
an error parameter where a runtime error is possible (i.e. any CoglError
that is not a malformed blend string).

https://bugzilla.gnome.org/show_bug.cgi?id=765058
2016-04-15 17:22:24 +02:00
Rui Matos
e017148208 wayland: Make wayland move/resizes be constrained the same as X11
Just like we do for _NET_WM_MOVERESIZE messages on X11, consider
wayland client move/resizes as "frame actions" so that the same
constraints are applied to them, in particular the titlebar visibility
constraint.

https://bugzilla.gnome.org/show_bug.cgi?id=748819
2016-04-06 17:58:18 +02:00
Jonas Ådahl
7173937a7d wayland/cursor: Keep a private use count and reference to active buffer
In order for the native cursor renderer to be able to create a hw
cursor in response to wl_pointer.set_cursor(), keep a private use-count
and reference to the active buffer, stopping it from being released
until it is consumed, replaced, or the surface is destroyed.

https://bugzilla.gnome.org/show_bug.cgi?id=762828
2016-03-29 18:26:10 +08:00
Jonas Ådahl
f44238a72f MetaWaylandSurface: Keep an extra buffer use count for role-less surfaces
Whether a surface needs to keep the committed wl_buffer un-released
depends on what role the surface gets assigned to. For example a cursor
role may need an unreleased shm buffer in order to create a hw cursor from
it.

In order to support this, keep a separate reference and use count to
the buffer on behalf of the in the future assigned role, and release
those references after the surface was assigned a role. A role that
needs its own references and use counts, must in its assign function
make sure to add those.

https://bugzilla.gnome.org/show_bug.cgi?id=762828
2016-03-29 18:26:10 +08:00
Jonas Ådahl
10a0114856 wayland: Move buffer use count to MetaWaylandSurface
Each wl_surface.commit with a newly attached buffer should result in
one wl_buffer.release for the attached buffer. For example attaching
the same buffer to two different surfaces must always result in two
wl_buffer.release events being emitted by the server. The client is
responsible for counting the wl_buffer.release events and be sure to
have received as many release events as it has attached and committed
the buffer, before reusing it.

https://bugzilla.gnome.org/show_bug.cgi?id=762828
2016-03-29 18:26:10 +08:00
Jonas Ådahl
aa7bc501d5 wayland: Replace buffer destroy wl_signal with a GObject signal
Don't use the libwayland-* utilities when we have our own that do the
same thing.

https://bugzilla.gnome.org/show_bug.cgi?id=762828
2016-03-29 18:02:31 +08:00
Carlos Garnacho
3d67bfda14 wayland: Implement support for the x-rootwindow-drop target
This target is set whenever DnD moves towards an area between surfaces.
Although no offer is set and data is actually not read, drag sources
offering this mimetype will be able to behave just like they used to
do in X11.

https://bugzilla.gnome.org/show_bug.cgi?id=762104
2016-03-11 14:47:02 +01:00
Carlos Garnacho
51e4491a9f wayland: Force an initial focus in meta_wayland_drag_grab_set_focus()
We want some initial processing, even if the current focus didn't change.
This could be for example the case of starting DnD too close to the window
edge and out of it. At the point start_drag() is called, the current
pointer focus is already NULL, so set_focus() would simply bail out here.

https://bugzilla.gnome.org/show_bug.cgi?id=762104
2016-03-11 14:47:02 +01:00
Carlos Garnacho
82153ff23f wayland: Always send focus() when starting a pointer grab
Even if the focus is NULL, we may want the current grab focus code
to be run.

https://bugzilla.gnome.org/show_bug.cgi?id=762104
2016-03-11 14:47:01 +01:00
Rui Matos
8b801aac77 Handle meta_screen_get_monitor_for_point() returning NULL
On the X11 backend we don't track the pointer position in
priv->current_x/y which remain set to zero. That means we never set
the clutter stage cursor if point 0,0 isn't covered by any monitor
since we return early.

Commit 4bebc5e5fa introduced this to
avoid crashing on the prepare-at handlers when the cursor position
doesn't fall inside any monitor area but we can handle that higher up
in the stack. In that case, the sprite's scale doesn't matter since
the cursor won't be shown anyway so we can skip setting it.

https://bugzilla.gnome.org/show_bug.cgi?id=763159
2016-03-10 16:01:54 +01:00
Rui Matos
c380f2e03f wayland-pointer: Drop a phony signal disconnect
cursor_sprite_prepare_at() is never connected to a MetaCursorTracker
signal.

https://bugzilla.gnome.org/show_bug.cgi?id=763159
2016-03-10 15:58:46 +01:00
Jonas Ådahl
f6ba3bdfc2 wayland: Add gtk_surface.present to gtk-shell
This commits adds a gtk_surface.present request and its implementation.
The timestamp is assumed to be from some input event that the client
responded to. The timestamps we deal with when managing windows will
usually come from two different clocks: CLOCK_MONOTONIC if they come
from libinput/evdev, or CLOCK_MONOTONIC_COARSE if they come from the
X server.

Luckily these are quite similar, the difference beeing that the X server
timestamps having lower resolution, so we can just pass the timestamps
no matter where they came from and it'll most likely work fine, except
for the race condition described in bug 756272 which might happen here
too until it is properly fixed.

https://bugzilla.gnome.org/show_bug.cgi?id=763295
2016-03-10 12:34:56 +08:00
Jonas Ådahl
4af908a970 wayland: Add system bell support via gtk_shell
Add a system_bell request to gtk_shell. A client can use this to invoke
the system bell, be it aural, visual or none at all. Currently per
window visual bell support is not implemented.

https://bugzilla.gnome.org/show_bug.cgi?id=763284
2016-03-10 12:34:56 +08:00
Jonas Ådahl
9f1d1151b7 wayland: Namespace gtk_shell request handlers
https://bugzilla.gnome.org/show_bug.cgi?id=763284
2016-03-10 12:34:56 +08:00
Jonas Ådahl
fea1ddcd29 wayland: Don't invent our own unstable protocol semantics
The gtk_shell protocol used some half baked unstable protocol semantics
that worked by only allowing binding the exact version of the
interface. This hack is a bit too confusing and it makes it impossible
to do any compatible changes without breaking things.

So, instead rename it to include a number in the interface names. This
way we can add requests and events without causing compatibility issues,
and we can later remove requests and events by bumping the number in
the interface names.

https://bugzilla.gnome.org/show_bug.cgi?id=763284
2016-03-10 12:29:43 +08:00
Carlos Garnacho
3b023ea994 wayland: Start drags from the press position
Using the current position to set the origin x/y of the DnD icon
is wrong, it should still be used in order to move the icon besides
the current pointer position though.

Fixes possible drag-start-x/y property constraint warnings when
starting a drag too close to the window edge, and towards outside
of it.
2016-03-09 18:31:50 +01:00
Carlos Garnacho
f8c70491b9 wayland: Small code cleanup in meta_wayland_drag_grab_set_focus()
There's enough instances of drag_grab->drag_data_source to make it
nicer getting a "source" variable first.
2016-03-09 18:19:23 +01:00
Jonas Ådahl
d4b0c21d06 MetaWaylandPointerConstraint: Maybe enable on window 'raise'
If a MetaWindow's 'appears-focused' state changed to true, but the
window did not have pointer focus, the constraint did not enable. Thus,
make it possible for the user to also click the window to enable it.

https://bugzilla.gnome.org/show_bug.cgi?id=762661
2016-03-09 14:29:22 +08:00
Jonas Ådahl
517078d142 MetaWaylandPointerConstraint: Disable if 'appears-focused' is false
Disable a constraint if the associated MetaWindow's 'appears-focused'
state changed to false.

https://bugzilla.gnome.org/show_bug.cgi?id=762661
2016-03-09 14:27:43 +08:00
Jonas Ådahl
1c94d0e598 MetaWaylandPointerConstraint: Require 'appears-focused' to enable
Instead of relying on the keyboard focus surface, use the
'appears-focused' state of the corresponding MetaWindow to determine if
a constraint should enable or not.

https://bugzilla.gnome.org/show_bug.cgi?id=762661
2016-03-09 14:26:53 +08:00
Jonas Ådahl
b04747b174 MetaWaylandPointerConstraint: Unset is_enabled state when disabling
If we don't set the is_disabled state to FALSE when disabling,
re-enabling will fail.

https://bugzilla.gnome.org/show_bug.cgi?id=762661
2016-03-09 14:26:53 +08:00
Jonas Ådahl
6396974eae MetaWaylandPointerConstraint: Use own 'appears-focused' signal handler
Instead of having MetaWindowWayland having hooks into pointer
constraints subsystem, have the pointer constraints subsystem listen
for the signal itself and enable/disable itself.

https://bugzilla.gnome.org/show_bug.cgi?id=762661
2016-03-09 14:26:53 +08:00
Jonas Ådahl
20908b9c2c MetaWaylandPointerConstraint: Make per surface state a quark
Make the per surface pointer constraint related state (list of
constraints on given surface) a quark managed from the pointer
constraints unit.

https://bugzilla.gnome.org/show_bug.cgi?id=762661
2016-03-09 14:24:28 +08:00
Jonas Ådahl
4abfb299e2 MetaWaylandPointerConstraint: Use NULL for infinite region
Instead of having a very large region represent an infinitely large
region, use NULL, and use the calculated input region from the
MetaWaylandSurface if the constraint region was not set.

https://bugzilla.gnome.org/show_bug.cgi?id=762661
2016-03-09 14:24:28 +08:00
Jonas Ådahl
62ac9df43d MetaWaylandPointerConstraint: Fix effective region calculation
The when surface->input_region is NULL, it should be interpreted as the
whole surface region. If not, the effective input region is the
intersection of the buffer region and the input region set by
wl_surface.set_input_region. Add
meta_wayland_surface_calculate_input_region() that does this
calculation.

https://bugzilla.gnome.org/show_bug.cgi?id=762661
2016-03-09 14:24:28 +08:00
Carlos Garnacho
a94e640b3f xwayland: Fix possible cancellation of wayland data sources
If we receive multiple SelectionRequest events, we'll end up replacing the
former WaylandSelectionData at a time when an async read has been issued.
This will cause the cancellation of the previous operation.

But the wayland_data_read() callback will attempt to just remove the
current wayland data again on error, which will not be the one we're
cancelling, so the new operation will just be cancelled too.

Also, cancellation is no longer warned about. As the wayland selection
has been replaced at this time, we can just return here.

https://bugzilla.gnome.org/show_bug.cgi?id=760745
2016-03-04 00:50:43 +01:00
Carlos Garnacho
da28d7a012 wayland: Emit signal on primary selection data source destruction
This is necessary for the X11 side to catch up, and unset the primary
selection ownership on our window that represents the wayland side in
X11 selection.

https://bugzilla.gnome.org/show_bug.cgi?id=760745
2016-03-04 00:50:43 +01:00
Carlos Garnacho
169f0e7324 wayland: Emit signal on selection data source destruction
This is necessary for the X11 side to catch up, and unset the selection
ownership on our window that represents the wayland side in X11 selection.

https://bugzilla.gnome.org/show_bug.cgi?id=760745
2016-03-04 00:50:43 +01:00
Jonas Ådahl
96927b3415 wayland: Don't access the cursor wl_buffer when updating the sprite
We may have released the wl_buffer already when doing this, which means
we should not try to access the wl_buffer content.

Regarding the cursor texture this is not an issue since we can just use
the texture created in apply_pending_state().

The hw cursor however will only be realized if the surface is already
using the the buffer (surface->using_buffer == true). This will, at the
moment, effectively disable hardware cursors for SHM buffers.

https://bugzilla.gnome.org/show_bug.cgi?id=762828
2016-03-03 23:26:02 +08:00
Carlos Garnacho
1a3653765c wayland: Close primary selection fd after gtk_primary_selection_source.send
We leak the fd otherwise.
2016-03-01 21:07:56 +01:00
Jonas Ådahl
d340c3a6dd wayland: Don't unset surface->buffer when wl_buffer destroyed
Don't unset the surface->buffer if the associated wl_buffer object is
destroyed. The MetaWaylandBuffer doesn't really only represent a
wl_buffer object, but also the data (texture) created from the given
wl_buffer. Thus, for example destroying a released SHM wl_buffer should
not destroy the MetaWaylandBuffer instance, because the texture may
still be used.

This commit also fixes a race where calc_showing would hide a window
because, at the time of calculation whether it should be showing, the
surface's buffer had been destroyed as described above.

https://bugzilla.gnome.org/show_bug.cgi?id=762716
2016-03-01 13:33:13 +08:00
Carlos Garnacho
43bd057754 wayland: Ensure harder we're dealing with DnD offers/sources
In destroy_data_offer() there is code to ensure compatibility when
dragging from a v3 wl_data_device to a v2 one, it's however not checking
correctly that this is the DnD drag source. The other path should be
used otherwise.

https://bugzilla.gnome.org/show_bug.cgi?id=762878
2016-02-29 19:55:55 +01:00
Carlos Garnacho
66be0387ee wayland: Use separate destructor for the gtk_primary_selection_offer
Things don't mix well if we use the same destructor than wl_data_offer,
Use a separate destructor with no DnD paths whatsoever.

https://bugzilla.gnome.org/show_bug.cgi?id=762878
2016-02-29 19:55:55 +01:00
Carlos Garnacho
7c114360d0 wayland: Implement the (so far internal) primary selection protocol
Add an additional MetaWaylandDataSource implementation for primary selection
sources, and methods to set primary selection offers. Primary selection
sets altogether a different channel than the clipboard selection, those don't
cross in any way.

Also, the bridge for the X11 PRIMARY selection atom has been added, which
adds all the necessary handling to translate primary selection both ways
with wayland and X11 applications.

https://bugzilla.gnome.org/show_bug.cgi?id=762560
2016-02-26 19:51:32 +01:00
Carlos Garnacho
c6aad6e735 wayland: Add gtk-primary-selection protocol
This protocol is an internal mirror of the primary selection drafts
being proposed for wayland-protocols. No changes besides prefix/suffix
changes.

https://bugzilla.gnome.org/show_bug.cgi?id=762560
2016-02-26 19:51:32 +01:00
Jonas Ådahl
ad7e654a8b MetaWaylandPointerConstraint: Don't expose internal function
It was exposed via meta-wayland-pointer-constraints.h for no apparent
reason.
2016-02-25 11:47:17 +08:00
Jonas Ådahl
b01926dbfa MetaWaylandPointerConstraint: Ignore requests on defunct resource
The constraint may be destroyed before the client destroyes the
protocol object, for example if a oneshot constraint was disabled by
alt-tab. Therefore we need to NULL check the constraint in request
handlers and ignore any requests to defunct objects.
2016-02-25 11:32:20 +08:00
Jonas Ådahl
5001aa76d7 MetaWaylandPointerConstraint: Remove redundant typedef 2016-02-25 11:32:20 +08:00
Jonas Ådahl
f1730e488d MetaWaylandPointerConstraint: Remove unused function 2016-02-25 11:32:20 +08:00
Carlos Garnacho
3f60a2e48a wayland: Implement gtk-shell v3
Implement the gtk_shell.set_startup_id request, so that the ID is
removed from the sequences list, and feedback updated accordingly.

https://bugzilla.gnome.org/show_bug.cgi?id=762268
2016-02-19 17:41:03 +01:00
Carlos Garnacho
3729e592a6 wayland: Update gtk-shell protocol file to v3
Add a gtk_shell.set_startup_id request, so the application can communicate
to the compositor the startup id that it received through the
DESKTOP_STARTUP_ID envvar, or other means.

https://bugzilla.gnome.org/show_bug.cgi?id=762268
2016-02-19 17:41:03 +01:00
Ray Strode
bed82427c6 wayland: change accessible boolean to use_count counter
Since a buffer can be used by multiple surfaces at once,
we need to release the buffer only after all surfaces
are finished with it.  Currently we track whether or
not to release the buffer based on the accessible boolean.
This commit changes it to a counter to accomodate multiple
users.

Also, each surface needs to know whether not it is done with
the buffer, so this commit adds a buffer_used boolean to the
surface state.

https://bugzilla.gnome.org/show_bug.cgi?id=761613
2016-02-19 08:57:56 -05:00
Ray Strode
e097bc8353 wayland: get rid of buffer->copied_data boolean
We currently track whether or not a buffer can be released early
by looking at the copied_data boolean on the buffer.  This boolean
is, practically speaking, always set to TRUE for shm buffers and is
always false otherwise.

We can just as easily check if the buffer is a shm buffer to decide
whether or not to do an early release.  That's better from a
theoretical point of view since copied_data assumes a 1-to-1
relationship between surface and buffer, which may not actually hold.

This commit drops copied_data and changes the check to instead see
if the buffer is shm.

https://bugzilla.gnome.org/show_bug.cgi?id=761613
2016-02-19 08:57:56 -05:00
Ray Strode
acd50508dc wayland: return from toplevel commit early if no new buffer
meta_wayland_surface_toplevel_commit has a lot of logic to handle
a new buffer getting attached as part of the commit.  None of
that code needs to run if there is no new buffer attached.

This commit short-circuits that case.

https://bugzilla.gnome.org/show_bug.cgi?id=761613
2016-02-17 16:16:07 -05:00
Jonas Ådahl
a70a2c3744 MetaPointerConfinementWayland: Support non-rectangular confinement regions
This patch adds support for confinement regions that are more complex
than a single rectangle. It relies on details about cairo regions not
explicitly in the API in order to generate the outer border of the
region.

https://bugzilla.gnome.org/show_bug.cgi?id=744104
2016-02-16 19:02:48 +08:00
Jonas Ådahl
bc47b19c3f wayland: Use the event coordinates when sending pointer motion events
The x/y coordinates of the ClutterInputDevice were not the ones which was
the result of this event but whatever event was queued the last. The
correct coordinates can, however, be found in the event itself, so lets
use those.

https://bugzilla.gnome.org/show_bug.cgi?id=744104
2016-02-16 19:02:48 +08:00
Jonas Ådahl
495c89401a Implement support for the wp_pointer_constraints protocol
The wp_pointer_constraints protocol is a protocol which enables clients
to manipulate the behavior of the pointer cursor associated with a seat.

Currently available constraints are locking the pointer to a static
position, and confining the pointer to a given region.

Currently locking is fully implemented, and confining is implemented for
rectangular confinement regions.

What else is lacking is less troublesome semantics for enabling the lock
or confinement; currently the only requirement implemented is that the
window that appears focused is the one that may aquire the lock.

This means that a pointer could be 'stolen' by creating a new window that
receives active focus, or when using focus-follows-mouse, a pointer
passes a window that has requested a lock. This semantics can be changed
and the protocol itself allows any semantics as seems fit.

https://bugzilla.gnome.org/show_bug.cgi?id=744104
2016-02-16 19:02:48 +08:00
Jonas Ådahl
e2efc85b08 wayland: Make the pending surface state a GObject
Making the pending state an GObject makes it easier to extend it with
additional optional state without putting everything inside one big
struct.

https://bugzilla.gnome.org/show_bug.cgi?id=744104
2016-02-16 19:02:48 +08:00
Jonas Ådahl
020ae58fe4 wayland: Add "painting" signal to surface actor
Make MetaWaylandSurface a listener and move output state updating to
the handler function.

https://bugzilla.gnome.org/show_bug.cgi?id=744104
2016-02-16 19:02:48 +08:00
Jonas Ådahl
bc8ec2d90d wayland: Add global to surface coordinate helper
https://bugzilla.gnome.org/show_bug.cgi?id=744104
2016-02-16 19:02:47 +08:00
Jonas Ådahl
5b0eabec51 wayland: Implement support for wp_relative_pointer
Add support for sending relative pointer motion deltas to clients who
request such events by creating wp_relative_pointer objects via
wp_relative_pointer_manager.

This currently implements the unstable version 1 from wayland-protocols.

https://bugzilla.gnome.org/show_bug.cgi?id=744104
2016-02-16 19:02:47 +08:00
Ray Strode
50099c4c10 wayland: use glib function for fetching timestamp
The code currently implements a function, get_time, that
fetches a timestamp.  That duplicates code already in glib,
and the glib implementation is better, anyway, since it doesn't
skew backward when the system clock is changed.

This commit changes the code to use g_get_monotonic_time and
drop the get_time function.

https://bugzilla.gnome.org/show_bug.cgi?id=761613
2016-02-08 17:01:58 -05:00
Ray Strode
7adbb58736 wayland: don't prematurely release EGL buffers
commit 0165cb6974 changed
mutter to release committed shm buffers as soon as they were
uploaded to the GPU.

It also inadvertently changed mutter to prematurely
release EGL buffers (which never get copied, but get used
directly).

This commit corrects that mistake.

https://bugzilla.gnome.org/show_bug.cgi?id=761312
2016-02-02 11:15:43 -05:00
Ray Strode
0165cb6974 wayland: release buffer after processing commit
When a client is ready for the compositor to read a surface's
shared memory buffer, it tells the compositor via
wl_surface_commit.

From that point forward, the baton is given to the compositor:
it knows it can read the buffer without worring about the client
making changes out from under it.

After the compositor has uploaded the pixel contents to the video
card it is supposed to release the buffer back to the client so that
the client can reuse it for future use.

At the moment, mutter only releases the buffer when a new buffer
is attached.  This is problematic, since it means the client has
to have a second buffer prepared before the compositor gives the
first one back.  Preparing the second buffer potentially involves
copying megabytes of pixel data, so that's suboptimal, and there's
no reason mutter couldn't release the buffer earlier.

This commit changes mutter to release a surface's buffer as soon
as it's done processing the commit request.

https://bugzilla.gnome.org/show_bug.cgi?id=761312
2016-02-01 14:16:17 -05:00
Florian Müllner
72d6efc0d5 Shut up some compiler warnings 2016-01-21 23:04:22 +01:00
Jonas Ådahl
bcdda506e1 MetaWaylandDataDevice: Don't set surface offset as anchor offset
Since we are using the surface actor to draw the DND icon, the offset
is already accounted for by MetaSurfaceActorWayland, and passing the
surface position offset would effectively double the actual offset,
causing the icon to be misplaced.

This patch always sets the anchor offset to (0, 0) when the icon is a
Wayland surface, and lets the surface actor deal with the offsetting.

https://bugzilla.gnome.org/show_bug.cgi?id=759222
2016-01-19 14:32:34 +01:00
Carlos Garnacho
9b26694bbc wayland: Implement DnD actions as per wl_data_device v3 changes
We now additionally send:
  - wl_data_offer.source_actions
  - wl_data_source.action
  - wl_data_offer.action
  - wl_data_source.dnd_drop_performed
  - wl_data_source.dnd_finished

The protocol changes allow for compositors to implement different policies
when chosing the action, mutter uses this to reimplement the same behavior
that GTK+ traditionally had:

  - Alt/Control/Shift modifiers change the chosen action to
    ask/copy/move respectively
  - Drags with middle button start out as "ask" by default

As mutter now also grabs the keyboard and unsets the window focus for these
purposes, the window focus is restored after the drag operation has
finished.

The Xdnd bridge code is also modified to cope with actions, so mixed
wayland-x11 scenarios are able to convey that information.

https://bugzilla.gnome.org/show_bug.cgi?id=760805
2016-01-19 13:55:33 +01:00
Carlos Garnacho
f053c09083 data-device: Refactor data source management by the drag grab
Move to a separate meta_wayland_drag_grab_set_source() so we keep
the weak pointer management in a single place.

https://bugzilla.gnome.org/show_bug.cgi?id=760805
2016-01-19 13:45:56 +01:00
Carlos Garnacho
ec9abaf1ef wayland: Add MetaWaylandKeyboardGrab and keyboard grab API
This will be useful during DnD, where mutter is expected to consume
keyboard events for either allowing changes in the selected DnD action,
or misc a11y features like keyboard-driven DnD.

Currently, the vtable contains 2 functions, key() will be used on every
key event we get from Clutter, modifiers() will notify of changes in the
keyboard modifiers (mouse buttons will never be set in the modifier mask)

https://bugzilla.gnome.org/show_bug.cgi?id=760805
2016-01-19 13:45:56 +01:00
Carlos Garnacho
6b88420465 wayland: Add "update" vfunc to MetaWaylandDragDestFuncs
This will be useful when an update is due but no motion event is to be
sent/received (eg. modifier changes during DnD).

https://bugzilla.gnome.org/show_bug.cgi?id=760805
2016-01-19 13:45:56 +01:00
Carlos Garnacho
fc0a834abb wayland: Emit wl_pointer.frame after .enter in pointer resource creation
This place was missing concordance with wl_pointer v5.
2016-01-19 11:51:36 +01:00
Carlos Garnacho
e30010b9f0 wayland: Rename meta_wayland_pointer_send_frame() to broadcast_frame
It's closer to what we mean here. And we can have a send_frame() helper
that does this for a single wl_resource.
2016-01-19 11:50:27 +01:00
Carlos Garnacho
935d76ba04 wayland: Implement wl_pointer.axis_source/axis_stop/axis_frame emission
As per the spec:
- wl_pointer.axis_source determines the current source of
  scroll events.
- wl_pointer.axis_stop determines when there's no further
  scroll events on the given axis.
- wl_pointer.axis_discrete is emitted on "wheel"
  scroll sources, measured in ticks.
- wl_pointer.frame is meant to coalesce events that logically belong
  together, e.g. axis events in this case.

Co-Authored-By: Peter Hutterer <peter.hutterer@who-t.net>

https://bugzilla.gnome.org/show_bug.cgi?id=760637
2016-01-14 19:27:48 +01:00
Florian Müllner
3aea8d8ce6 Revert "Add "size states" which save window size information"
This reverts commit 2c7ef2269f.
2016-01-10 15:16:09 +01:00
Jasper St. Pierre
2c7ef2269f Add "size states" which save window size information
https://bugzilla.gnome.org/show_bug.cgi?id=751857
2016-01-09 18:08:35 -08:00