1
0
Fork 0
Commit graph

901 commits

Author SHA1 Message Date
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
Marek Chalupa
49ea6486e2 wayland: bind wayland socket after xwayland is initialized
During xwayland initialization we run main loop and dispatch wayland
events, so that xwayland can initialize. If some client during this
phase connects and creates surface, mutter crashes because
it is not initialized yet. If we bind wayland socket after xwayland
is initialized and main loop is not running anymore, no client can
connect to mutter during initialization and that is what we want.

https://bugzilla.gnome.org/show_bug.cgi?id=751845
2015-12-15 15:49:13 +01:00
Jasper St. Pierre
91ac69382d wayland: Fix up touch coordinates on HiDPI 2015-12-14 14:52:23 -08:00
Jonas Ådahl
428c687b5a wayland: Clean up wl_pointer_send_enter/leave code
Be consistent and always use a helper, and fix the naming so
broadcast means to actually broadcast.

https://bugzilla.gnome.org/show_bug.cgi?id=755503
2015-12-03 16:11:37 +08:00
Jonas Ådahl
be5643cee7 wayland: Use xdg shell protocol from wayland-protocols
Use the xdg_shell XML file installed by wayland-protocols instead of
our own copy. This protocol has yet to go through any unstable naming,
but since we had an outdated (though wire compatible) version, some
minor changes were needed.

https://bugzilla.gnome.org/show_bug.cgi?id=758633
2015-11-26 16:55:35 +08:00
Jonas Ådahl
2ee1c5fa61 wayland: Use pointer gestures protocol from wayand-protocols
Remove our own copy of the pointer gestures protocol, and us the one
installed by wayland-protocols. This also means the new fixed unstable
naming conventions are used for the new version of the protocol, which
is reflected in the change. No functional changes were made, it is only
a rename.

https://bugzilla.gnome.org/show_bug.cgi?id=758633
2015-11-26 16:55:35 +08:00
Carlos Garnacho
3078f70f90 wayland: Fetch keyboard event codes from ClutterEvents
When running as a native compositor, we can just do that. However, the
previous code must stay for whenever it's run as a X11 client.

https://bugzilla.gnome.org/show_bug.cgi?id=758239
2015-11-25 18:00:36 +01:00
Carlos Garnacho
7309b20c25 wayland: Fetch pointer button event codes from the ClutterEvent
When running as a native compositor, we can just do that. However, the
previous code must stay for whenever it's run as a X11 client.

Additionally, the fallback switch{} that transforms clutter 1-indexed
buttons into input.h event codes had to be adapted to the change introduced
in clutter commit 83b738c0e, where the 4-7 button range is kept clear for
compatibility with the X11 backend.

https://bugzilla.gnome.org/show_bug.cgi?id=758239
2015-11-25 17:56:51 +01:00
Daniel Stone
c16a5ec1cf KMS/Wayland: Correct refresh rate units
On the wire, Wayland specifies the refresh rate in milliHz. Mutter sends
the refresh rate in Hz, which confuses clients, e.g. weston-info:
interface: 'wl_output', version: 2, name: 4
	mode:
		width: 2560 px, height: 1440 px, refresh: 0 Hz,
		flags: current preferred
interface: 'wl_output', version: 2, name: 5
	mode:
		width: 3200 px, height: 1800 px, refresh: 0 Hz,
		flags: current preferred

and xrandr:
XWAYLAND0 connected 2560x1440+3200+0 600mm x 340mm
   2560x1440@0.1Hz   0.05*+
XWAYLAND1 connected 3200x1800+0+0 290mm x 170mm
   3200x1800@0.1Hz   0.03*+

Export the refresh rate in the correct units. For improved precision,
perform the KMS intermediate calculations in milliHz as well, and
account for interlaced/doublescan modes.

This is also consistent with what GTK+ expects:
      timings->refresh_interval = 16667; /* default to 1/60th of a second */

      /* We pick a random output out of the outputs that the window touches
       * The rate here is in milli-hertz */
      int refresh_rate = _gdk_wayland_screen_get_output_refresh_rate (wayland_display->screen,
                                                                      impl->outputs->data);
      if (refresh_rate != 0)
        timings->refresh_interval = G_GINT64_CONSTANT(1000000000) / refresh_rate;

Where the 'refresh_rate' given is exactly what's come off the wire.
1000000000/60000 comes out as 16667, whereas divided by 60 is ...
substantially less.

https://bugzilla.gnome.org/show_bug.cgi?id=758653
2015-11-25 15:35:25 +01:00
Giovanni Campagna
a4f763ac3b wayland-surface: disconnect signals on destroy
Otherwise signal handlers will be called on garbage

https://bugzilla.gnome.org/show_bug.cgi?id=756548
2015-10-19 17:21:59 -07:00
Carlos Garnacho
a5d2555196 wayland: Make it possible to trigger popups through pointer/keyboard/touch
Right now we just check the pointer serial, so the popup will be
immediately dismissed if the client passes a serial corresponding to
another input device.

Abstract this a bit further and add a meta_wayland_seat_can_popup() call
that will check the serial all input devices. This makes it possible to
trigger menus through touch or keyboard devices.

https://bugzilla.gnome.org/show_bug.cgi?id=756296
2015-10-17 18:52:52 +02:00
Carlos Garnacho
dd5a4ecdf9 wayland: Store key press/release serials on MetaWaylandKeyboard
https://bugzilla.gnome.org/show_bug.cgi?id=756296
2015-10-17 18:52:15 +02:00
Jonas Ådahl
d6d377a447 wayland: Set the xdg_popup pointer even when not mapping
If we immediately dismiss the popup, we still need to set the
surface->xdg_popup pointer field in order for the destructor to
properly clean up the state. Not doing this may cause a crash if the
xdg_popup resource that was immediately dismissed is destoryed after
wl_surface during client destruction.

https://bugzilla.gnome.org/show_bug.cgi?id=756675
2015-10-16 11:31:51 +08:00
Jonas Ådahl
e84f694668 wayland: Don't scale XWayland pointer cursor sprites
We don't have any way of knowing what the intended size of a XWayland
cursor is supposed to be, so lets do what we do with regular XWayland
surfaces and don't scale them. The result is that cursor sprites of
HiDPI aware X11 clients will show correctly, but non-aware clients may
have tiny cursor sprites.

https://bugzilla.gnome.org/show_bug.cgi?id=755099
2015-10-04 14:17:14 +08:00
Carlos Garnacho
b18542f2b6 wayland: Avoid resending new data offers on intra-client focus changes
Each keyboard focus change ends up calling the MetaWaylandDataDevice
counterpart, we don't need though to notify the current selection
again. In order to fix this, keep track of the current client, and
only emit the relevant signals when the focus switches to another
client.

The situations where wl_data_device.selection were emitted during
focus changes between surfaces of the same client was inocuous most
of the times, although it's prone to inducing confusing behavior
on context menu clipboard actions, as the closing menu triggers a
focus change, which triggers a whole new wl_data_offer being created
and given on wl_data_device.selection, at a time where there's already
ongoing requests on the previous data offer.

https://bugzilla.gnome.org/show_bug.cgi?id=754357
2015-10-02 12:21:17 +02:00
Carlos Garnacho
da0aac665f xwayland: Protect against crash on x11->wayland transfer cancellation
If the transfer is cancelled, the X11SelectionData will be cleared from
the MetaSelectionBridge, although x11_data_write_cb() was invariably
expecting it to be non-NULL.

If the write was cancelled, all the actions done in x11_data_write_cb()
are moot, so just return early. If there's other errors happening
(eg. "connection closed" if the target client happens to crash), we
should still attempt at clearing the data anyway.

https://bugzilla.gnome.org/show_bug.cgi?id=754357
2015-10-02 12:21:17 +02:00
Jonas Ådahl
8b0b0cf028 MetaWaylandSurface: Don't assume a toplevel always have a MetaWindow
When committing a toplevel surface we might no longer have a MetaWindow
associated with it. The reason may vary but some are: a popup was
dismissed, the client attached and committed a NULL buffer to a
wl_surface with the wl_shell_surface role, the client committed a
buffer to a wl_surface which previously had an toplevel window role
which extension object was destroyed.

https://bugzilla.gnome.org/show_bug.cgi?id=755490
2015-09-29 09:09:57 +08:00
Carlos Garnacho
6f64d6b0aa wayland: Check the drag focus before processing XDND dest-side messages
If the drag dest surface suddenly disappears, we may find ourselves
processing an XdndPosition message that was sent before the X11 drag
source had an opportunity to find out.

In that case mutter does know, so double check before processing the
messages.
2015-09-28 16:22:54 +02:00
Carlos Garnacho
ebeca983c7 wayland: Improve transformation of the UTF8_STRING atom to mimetype
We try to translate the atom with its corresponding mimetype both back
and forth, which actually breaks if the X11 client chose to announce the
mimetype atom. To do the translation properly, keep track on whether the
source announced the UTF8_STRING atom, and reply back with this only if
that happened.
2015-09-28 16:22:43 +02:00
Carlos Garnacho
cf88675807 wayland: Fix weak ref tracking on data sources
We may get a NULL one here, and we're wrongly attempting to remove
the old weak ref from the new data source object.
2015-09-28 16:22:32 +02:00
Carlos Garnacho
405f1ce3d0 wayland: Avoid use of struct data after destruction
data_device_end_drag_grab() will destroy the MetaWaylandDragGrab struct,
so we definitely must not use it after destruction.
2015-09-28 16:22:18 +02:00
Rui Matos
69c267b142 xwayland: Fix windows disappearing on reparenting
If the wayland surface isn't available yet when we process the
WL_SURFACE_ID ClientMessage, we schedule a later function to try the
association again after we get a chance to process wayland requests.

This works fine except on cases where the MetaWindow already had a
previous surface attached (i.e. when the xwindow is reparented) since
we only break the existing association on the later function which
means that when processing the old surface's destruction we destroy
the MetaWindow and cancel the pending later function leaving us
without a MetaWindow and an invisible surface.

Fix this by detaching the old surface as soon as possible so that the
MetaWindow survives.

https://bugzilla.gnome.org/show_bug.cgi?id=743339
2015-09-25 19:09:48 +02:00
Jonas Ådahl
a9df4bb81a wayland: Scale saved rect changing monitor scale
The saved rect is used to restore a saved window size. We need to
update this when the window is moved to a monitor with different scale,
so that if we unmaximize a window which was moved to a different
monitor while maximized (for example when unplugged) will restore to
the correct size.

https://bugzilla.gnome.org/show_bug.cgi?id=755097
2015-09-24 11:39:37 +08:00
Jonas Ådahl
bc9e63d3db wayland: Scale unconstrained rect changing monitor scale
When a window is moved across monitors with different scales, its
rectangle is scaled accordingly. We also need to scale the
unconstrained_rect rectangle, so that moving a window via
meta_window_move_resize() which uses the unconstrained_rect.

https://bugzilla.gnome.org/show_bug.cgi?id=755097
2015-09-24 11:39:37 +08:00
Florian Müllner
5b5ceede2b wayland: Fix variable declaration
Storage class always goes first.
2015-09-24 03:08:23 +02:00
Florian Müllner
bc00f118f3 Avoid shadowing existing variables 2015-09-24 03:08:22 +02:00
Florian Müllner
5801b5518f Annotate functions to improve compiler diagnostics 2015-09-24 03:01:51 +02:00
Florian Müllner
27b37407d0 Don't duplicate declarations from G_DEFINE_TYPE 2015-09-24 03:01:51 +02:00
Jonas Ådahl
e23e697043 wayland: Fix output destroyed callback vfunc type
It is not a callback on a parameter signal, and get no GParamSpec passed
to it. This fixes a crash when a surface is on a destroyed output.

https://bugzilla.gnome.org/show_bug.cgi?id=755096
2015-09-24 08:08:41 +08:00
Jonas Ådahl
5d837a5c85 wayland: Support sending wl_surface.enter/leave to cursor surfaces
Support notifying clients about what outputs their cursor surfaces are
on so that they can attach appropriately scaled buffers to them.

https://bugzilla.gnome.org/show_bug.cgi?id=744932
2015-09-13 21:26:22 +08:00
Jonas Ådahl
79c86ae890 Support scaling of cursor sprites given what output they are on
This commits refactors cursor handling code and plugs in logic so that
cursor sprites changes appearance as it moves across the screen.
Renderers are adapted to handle the necessary functionality.

The logic for changing the cursor sprite appearance is done outside of
MetaCursorSprite, and actually where depends on what type of cursor it
is. In mutter we now have two types of cursors that may have their
appearance changed:

 - Themed cursors (aka root cursors)
 - wl_surface cursors

Themed cursors are created by MetaScreen and when created, when
applicable(*), it will extend the cursor via connecting to a signal
which is emitted everytime the cursor is moved. The signal handler will
calculate the expected scale given the monitor it is on and reload the
theme in a correct size when needed.

wl_surface cursors are created when a wl_surface is assigned the
"cursor" role, i.e. when a client calls wl_pointer.set_cursor. A
cursor role object is created which is connected to the cursor object
by the position signal, and will set a correct texture scale given what
monitor the cursor is on and what scale the wl_surface's active buffer
is in. It will also push new buffers to the same to the cursor object
when new ones are committed to the surface.

This commit also makes texture loading lazy, since the renderer doesn't
calculate a rectangle when the cursor position changes.

The native backend is refactored to be triple-buffered; see the comment
in meta-cursor-renderer-native.c for further explanations.

* when we are running as a Wayland compositor

https://bugzilla.gnome.org/show_bug.cgi?id=744932
2015-09-13 21:26:22 +08:00
Jonas Ådahl
7c7cf91c32 wayland: Move cursor surface role to meta-wayland-pointer.c
The wl_pointer assigns a role to a wl_surface, so it makes sense to put
the related logic there.

https://bugzilla.gnome.org/show_bug.cgi?id=744932
2015-09-13 21:26:22 +08:00
Jonas Ådahl
83c17134f1 wayland: GObject:ify surface roles
Make a surface roles into objects with vfuncs for things where there
before was a big switch statement. The declaration and definition
boilerplate is hidden behind C macros.

https://bugzilla.gnome.org/show_bug.cgi?id=744932
2015-09-13 21:24:58 +08:00
Jonas Ådahl
8e5fb03611 MetaWaylandSurface: Don't respond to frame callback when role unassigned
If a surface doesn't have a role, the compositor will not know how, if
or when it will be painted. By adding it to the compositor frame
callback list, the compositor will respond to the client that the
surface has been drawn already which might not be true.

Instead, queue the frame callback in a list that is then processed when
the surface gets a role assigned. The compositor may then, given the
role the surface got, queue the frame callback accordingly.

https://bugzilla.gnome.org/show_bug.cgi?id=744932
2015-09-13 21:24:58 +08:00
Jonas Ådahl
dece49b53d wayland: Introduce XWayland surface role
Being a "XWayland window" should be considered equivalent to a role,
even though it is not part of any protocol anywhere. The commit doesn't
have any functional difference, but just makes it clear that an
wl_surface managed by XWayland have the same type of special casing as
surface roles as defined by the Wayland protocol.

As the semantics are more explicit given the role is defined, a comment
explaining why the semantics need to be how they are was added.

https://bugzilla.gnome.org/show_bug.cgi?id=744932
2015-09-13 21:24:58 +08:00
Javier Jardón
6ea7fa9973 xwayland: Add missing include
https://bugzilla.gnome.org/show_bug.cgi?id=754621
2015-09-07 14:13:48 +01:00
Jonas Ådahl
94513726de wayland: Clean up surface role assignment
Use a better name, use GNOME conventions for error handling, open code the
client error reporting and send the error to the correct resource.
wl_subcompositor doesn't have a role error yet, so continue use some
other error. The only effect of this is error received in the client will
be a bit confusing, it will still be disconnected.

https://bugzilla.gnome.org/show_bug.cgi?id=754215
2015-09-07 17:41:14 +08:00
Owen W. Taylor
e3db4ab16a Avoid declaring variables in for loop to avoid upsetting older GCC
Older GCC only allows "for (int i" in explicit c99 mode - there's probably
no reason that we can't enable that, but avoiding the construct for
a fast fix.
2015-09-03 16:13:50 -04:00
Owen W. Taylor
614d6bd0f8 Nested X11: use KeymapNotify events to fix key state on FocusIn
If the user Alt-Tabs out of the window, we will be left thinking
the Alt key is still pressed since we don't see a release for it.

Solve this and other related issues for the nested X11 compositor
by selecting for KeymapStateMask which causes a KeymapNotify event
to be sent after each FocusIn, and when we get these events, update
the internal XKB state and send any necessary modifiers events to
clients.

https://bugzilla.gnome.org/show_bug.cgi?id=753948
2015-09-03 16:02:25 -04:00
Jonas Ådahl
68279e8a08 MetaWaylandPointer: Don't keep our own MetaCursorTracker pointer
There is no reason to, we can just retrieve it every time we need it.

https://bugzilla.gnome.org/show_bug.cgi?id=744932
2015-08-28 09:52:30 +08:00
Jonas Ådahl
cd1ce2cb0a MetaWaylandSurface: Make it a GObject
This way we can add signals and weak references without relying on
wl_signal, wl_listener etc.

https://bugzilla.gnome.org/show_bug.cgi?id=744932
2015-08-28 09:52:30 +08:00
Jonas Ådahl
b01f95cfdd Make MetaCursorSprite a GObject
To easier track lifetime and utilize other GObject features, make
MetaCursorSprite a GObject.

https://bugzilla.gnome.org/show_bug.cgi?id=744932
2015-08-28 09:52:30 +08:00
Jonas Ådahl
4b667d1e09 Rename MetaCursorReference to MetaCursorSprite
It isn't really a reference to a MetaCursor enum, but a reference
counted cursor sprite, and enum value.

https://bugzilla.gnome.org/show_bug.cgi?id=744932
2015-08-28 09:52:30 +08:00
Jonas Ådahl
e76c3ecb00 wayland/pointer-gestures: Send error on protocol version mismatch
When a client binds an incompatible version, we should terminate it.
This check should only be there for the unstable version, as once it is
declared stable and renamed, future versions will be backward compatible.

https://bugzilla.gnome.org/show_bug.cgi?id=753855
2015-08-22 00:04:33 +08:00
Carlos Garnacho
b64b159109 wayland: Avoid warning when switching out into another vt
meta_wayland_pointer_get_client_pointer() may be called when the
MetaWaylandPointer as been already shut down, so the hash table will be
NULL at that moment.
2015-08-14 14:48:43 +02:00
Carlos Garnacho
804ab7894f wayland: Use wl_resource_for_each_safe() on pointer client destruction
We must use this by definition since we're removing all elements from the
resource lists.
2015-08-14 14:46:27 +02:00
Carlos Garnacho
55692b4019 wayland: Implement wl_pointer_gestures
The global wl_pointer_gestures object is now created, effectively
bridging pinch/swipe gestures with clients, so they're now
accessible to clients implementing the protocol.
2015-08-10 17:30:12 +02:00
Carlos Garnacho
2fafa24305 wayland: Implement the wl_pointer_gesture_pinch interface
The pinch gesture resources are part of the MetaWaylandPointerClient, which
will be used during the propagation of CLUTTER_TOUCHPAD_PINCH events.
2015-08-10 17:23:23 +02:00
Carlos Garnacho
51a2f28723 wayland: Implement the wl_pointer_gesture_swipe interface
The swipe gesture resources are part of the MetaWaylandPointerClient, which
will be used during the emission of CLUTTER_TOUCHPAD_SWIPE events.
2015-08-10 17:23:23 +02:00
Carlos Garnacho
e11feb229b wayland: Add gestures protocol XML 2015-08-10 17:23:23 +02:00
Jonas Ådahl
1ee387bb31 MetaWaylandPointer: Put client resources in its own struct
Instead of moving around all the bound pointer resources for a client
when changing focus, keep all the resources bound by a client in a per
client struct, and track the focus by having a pointer to the current
active pointer client struct instance.

This will simplify having wl_pointer extensinos sharing the pointer
focus of the wl_pointer by only having to add them to the pointer
client.

https://bugzilla.gnome.org/show_bug.cgi?id=744104
2015-08-10 17:23:23 +02:00
Adel Gadllah
4dc5882777 wayland: Add frame callbacks to the actor based on the role
Checking for the presense of the actor is wrong because we always
create one.

https://bugzilla.gnome.org/show_bug.cgi?id=739163
2015-08-09 19:25:46 +02:00
Adel Gadllah
070cd27786 wayland: Only call frame callbacks when a surface gets drawn on screen
The spec says:
"A server should avoid signalling the frame callbacks if the surface is not
visible in any way, e.g. the surface is off-screen, or completely obscured
by other opaque surfaces."

We actually do have the information to do that but we are always calling
the frame callbacks in after_stage_paint. So fix that to only call when
when the surface gets drawn on screen.

https://bugzilla.gnome.org/show_bug.cgi?id=739163
2015-08-09 10:40:40 +02:00
Rui Matos
9c745105f8 wayland-surface: Send out an error for a popup with an invalid parent
Instead of silently failing without the client noticing.

https://bugzilla.gnome.org/show_bug.cgi?id=753237
2015-08-05 13:50:09 +02:00
Rui Matos
ab9dabe725 wayland-surface: Don't crash if clients commit to a done popup
If we can't put up a popup because grabbing the pointer fails we
immediately dismiss the popup but the client might have made requests
already, in particular it might have commited the surface and in that
case we should ignore it.

https://bugzilla.gnome.org/show_bug.cgi?id=753237
2015-08-05 13:50:09 +02:00
Jonas Ådahl
ac79988939 wayland: Handle unsetting of input and opaque surface region
When a client sets an input region or a opaque region to NULL, it
should still be considered a change to the corresponding region on the
actor. This patch makes sure this state is properly forwarded.

https://bugzilla.gnome.org/show_bug.cgi?id=753222
2015-08-05 10:22:49 +08:00
Jonas Ådahl
f01247d815 wayland: Fix calculation of window geometry when scaled
Take the surface actor scale into account when calculating the window
geometry.

https://bugzilla.gnome.org/show_bug.cgi?id=744934
2015-07-16 11:54:14 +08:00
Jonas Ådahl
db6caa2c49 wayland: Take scale into account when placing windows relatively
When placing a popup and the legacy transient wl_shell_surface surfaces,
take the current scale of the window into account. This commit doesn't
fix relative positioning in case a window scale would change, but since
the use case for relative positioning is mostly popups, which would be
dismissed before the parent window would be moved, it should not be that
much of a problem.

https://bugzilla.gnome.org/show_bug.cgi?id=744934
2015-07-16 11:54:14 +08:00
Jonas Ådahl
fbd237bc66 MetaWaylandSurface: Return top most toplevel window for popups
Make meta_wayland_surface_get_toplevel_window return the top most window
in case its a chain of popups. This is to make all popups in a chain
including the top most surface have the same scale.

The reason for this is that popups are mostly integrated part of the
user interface of its parent (such as menus). Having them in a different
scale would look awkward.

Note that this doesn't affect non-popup windows with parent-child
relationship, because such windows are typically not an integral part of
the user interface (settings window, dialogs, ..) and can typically be
moved independently. It would probably make sense to make attached modal
dialogs have the same scale as their parent windows, but modal dialogs
are currently not supported for Wayland clients.

https://bugzilla.gnome.org/show_bug.cgi?id=744934
2015-07-16 11:54:14 +08:00
Jonas Ådahl
f6c9261bf6 wayland: Scale window geometry rects given the main output
Since we scale surface actors given what main output their toplevel
window is on, also scale the window geometry coordinates and sizes
(window->rect size and window->custom_frame_extents.top/left) in order
to make the window geometry represent what is being rendered on the
stage.

https://bugzilla.gnome.org/show_bug.cgi?id=744934
2015-07-16 11:54:14 +08:00
Jonas Ådahl
441efd17ce MetaMonitorInfo: Provide scale information
Tracking back from the monitor to the output every time we need to
figure out the scale of a window on a monitor is inconvenient, so
propagate the scale from the output to the monitor it is associated
with.

https://bugzilla.gnome.org/show_bug.cgi?id=744934
2015-07-16 11:53:40 +08:00
Jonas Ådahl
208da2316d wayland: Fix subsurface place_above/below type cast error
A MetaWaylandSurface was casted into a ClutterActor, but it should have
been the MetaSurfaceActor.

Move out parent_actor and surface_actor out of the loop while at it
since they won't change when iterating.

https://bugzilla.gnome.org/show_bug.cgi?id=745655
2015-07-16 11:43:19 +08:00
Jonas Ådahl
3b993131e8 wayland: Fix subsurface positioning on HiDPI
Keep the active position state in its original coordinate space, and
synchronize the surface actor with it when it changes and when
synchronizing the rest of the surface state, in case the surface scale
had changed.

https://bugzilla.gnome.org/show_bug.cgi?id=745655
2015-07-16 11:43:19 +08:00
Jonas Ådahl
117f57f74c wayland: Factor out some parts of meta_surface_actor_wayland_get_scale
Put a toplevel window getter in meta-wayland-surface.h and a main
monitor scale getter in window-wayland.h.

https://bugzilla.gnome.org/show_bug.cgi?id=745655
2015-07-16 11:43:19 +08:00
Jonas Ådahl
f295349e26 wayland: Don't crash if wl_output resource is destroyed after being removed
Previously a MetaWaylandOutput could be removed from the current outputs
table (by being unplugged for example). This would result in the global
object being removed and the MetaWaylandOutput instance freed, but the
wl_resource destructor would still try to remove itself from the list of
resources. Trying to do this, it'd try to access its user data pointer
which would point to the freed MetaWaylandOutput instance, and as a
result crash when trying to manipulate the freed data.

https://bugzilla.gnome.org/show_bug.cgi?id=744453
2015-07-15 14:55:55 +08:00
Jonas Ådahl
eb023ff2c9 wayland: Send wl_surface.enter and wl_surface.leave
Whenever a MetaSurfaceActor is painted, update the list of what outputs
the surface is being drawed upon. Since we do this on paint, we
effectively avoids this whenever the surface is not drawn, for example
being minimized, on a non-active workspace, or simply outside of the
damage region of a frame.

DND icons and cursors are not affected by this patch, since they are not
drawn as MetaSurfaceActors. If a MetaSurfaceActor or a parent is cloned,
then we'll check the position of the original actor again when the clone is
drawn, which is slightly expensive, but harmless. If the MetaShapedTexture
instead is cloned, as GNOME Shell does in many cases, then these clones
will not cause duplicate position checks.

https://bugzilla.gnome.org/show_bug.cgi?id=744453
2015-07-15 14:55:55 +08:00
Jonas Ådahl
ba7c524a18 MetaSurfaceActorWayland: Unset the MetaWaylandSurface pointer when it goes away
We may access it during painting even if it has been freed. For now,
manually unset it during the MetaWaylandSurface cleanup; in the future
make MetaWaylandSurface a GObject and make the surface pointer a weak
reference.

https://bugzilla.gnome.org/show_bug.cgi?id=744453
2015-07-15 14:55:55 +08:00
Jonas Ådahl
dc99af40f3 wayland: Make MetaWaylandOutput a GObject
This way we can later add signals to it.

https://bugzilla.gnome.org/show_bug.cgi?id=744453
2015-07-15 14:55:55 +08:00
Jonas Ådahl
1576b7d5a6 wayland: Put MetaWaylandOutput struct in header file
We need this in MetaWaylandSurface to be able to send
wl_surface.enter/leave.

https://bugzilla.gnome.org/show_bug.cgi?id=744453
2015-07-15 14:55:55 +08:00
Jonas Ådahl
6ec7fa2cbd wayland: Use surface role when special casing surface commits
Lets use the role when doing role specific commit actions. The
conditions effectively do that anyway, and this way we will get a
compiler warning here whenever we add a new role, as well as we avoid
having different variants of role-determination checks in different
places.

https://bugzilla.gnome.org/show_bug.cgi?id=744453
2015-07-15 14:55:55 +08:00
Jonas Ådahl
5547c98f97 wayland: Make MetaWaylandDataSource ownership protocol specific
Firstly, this patch makes MetawaylandDataSource a GObject. This is in
order to easier track its lifetime without adding destroy signals etc. It
also makes the vfunc table GObject class functions instead while at it,
as well as moves protocol specific part of the source into their own
implementations.

An important part of this patch is the change of ownership. Prior to this
patch, MetaWaylandDataDevice would kind of own the source, but for
Wayland sources it would remove it if the corresponding wl_resource was
destroyed. For XWayland clients it would own it completely, and only
remove it if the source was replaced.

This patch changes so that the protocol implementation owns the source.
For Wayland sources, the wl_resource owns the source, and the
MetaWaylandDataDevice sets a weak reference (so in other words, no
semantical changes really). For XWayland sources, the source is owned by
the selection bridge, and not removed until replaced or if the client
goes away.

Given the changes in ownership, data offers may now properly track the
lifetime of a source it represents. Prior to this patch, if an offer with
an XWayland source would loose its source, it wouldn't get notified and
have an invalid pointer it would potentally crash on. For Wayland
sources, an offer would have a weak reference and clean itself up if the
source went away. This patch changes so the behavior is consistent,
meaning a weak reference is added to the source GObject so that the offer
can behave correctly both for Wayland sources and XWayland sources.

https://bugzilla.gnome.org/show_bug.cgi?id=750680
2015-06-30 11:23:40 +08:00
Carlos Garnacho
ea4979e182 data-device: Protect against destroyed dnd-focus clients
When a possible drag dest client crashes during DnD, it may happen
we receive first the destroy notification for the data_device, and
later the notification for the focus surface. When this happens we
unset the drag_focus_data_device first, and later on
meta_wayland_drag_grab_set_focus(grab, NULL) we assume it still
exists when sending the leave event, leading to mutter crashing
right after.

So, as we don't receive any ordering guarantees about resource
destruction, just prepare the meta_wayland_drag_grab_set_focus()
paths for this.
2015-06-29 18:38:50 +02:00
Jonas Ådahl
bb4dcd62ec MetaWaylandDataDevice: Propagate the unsetting of a selection
If a client unsets a selection (calls set_selection with the offer
NULL), this should cause the compositor not to continue sending the
previously set offer.

https://bugzilla.gnome.org/show_bug.cgi?id=750007
2015-06-18 11:15:18 +08:00
Carlos Garnacho
cdac4d0e92 wayland: Ensure we queue a "calc showing" operation after we get a buffer
This will ensure the window is made visible, now that we're going to ignore
all previous petitions until we get a buffer.

https://bugzilla.gnome.org/show_bug.cgi?id=750552
2015-06-16 20:35:00 +02:00
Olivier Fourdan
d593a61b39 wayland: do not generate motion events
Mutter generates a motion event for every button and scroll events,
which confuses Xwayland apps that rely on XMotionEvents for various
purposes, e.g. it fools rxvt jumpy mouse detection code.

Remove the call to notify_motion() from the button and scroll event
handlers to avoid these spurious motion events.

https://bugzilla.gnome.org/show_bug.cgi?id=748705
2015-06-12 11:14:21 -04:00
Jonas Ådahl
daa15d94fd xdg-shell: Popups should be placed relative to the parent surface
According to the xdg-shell protocol specification the (x, y) coordinates
passed when creating a popup surface is relative to top left corner of
the parent surface, but prior to this patch, if the parent surface was
a xdg_surface, it'd position it relative to top left corner of the
window geometry of that xdg_surface.

https://bugzilla.gnome.org/show_bug.cgi?id=749716
2015-06-10 11:08:12 +08:00
Jonas Ådahl
64cf87cfe1 MetaWaylandSurface: Create the window when creating wl_shell_surface
Some clients will do things like set_toplevel before committing the
buffer, so we need to have a window to manipulate before that.

https://bugzilla.gnome.org/show_bug.cgi?id=750256
2015-06-02 10:28:09 +08:00
Dave Airlie
e2d6028924 wayland: use monitors info for outputs instead of kms outputs
Wayland shouldn't use KMS outputs, it should use the monitor
infos to show its outputs, this will make tiled monitors work
with wayland.
2015-06-01 09:38:13 -07:00
Carlos Garnacho
4a968c3b4e xwayland: Implement X11-to-wayland DnD
When DnD is started from an X11 client, mutter now sets up an special
grab that 1) Ensures the drag source keeps receiving events, and 2)
Moves an internal X Window over wayland clients as soon as the pointer
enters over these.

That window will act as the X-side peer for the currently focused
wayland client, and will transform XdndEnter/Position/Leave/Drop
messages into wayland actions. If DnD happens between X11 clients,
the window will be moved away and unmapped, to let these operate as
usual.

https://bugzilla.gnome.org/show_bug.cgi?id=738312
2015-05-29 11:27:53 +02:00
Carlos Garnacho
ccb7833e99 xwayland: Implement wayland-to-X11 DnD
X11 client windows now hook a X11-specific MetaWaylandDragDestFuncs
that converts these into Xdnd* messages, and an additional selection
bridge has been added to take care of XdndSelection, and the data
transfers done through it.

https://bugzilla.gnome.org/show_bug.cgi?id=738312
2015-05-29 11:27:53 +02:00
Carlos Garnacho
b449ba942a xwayland: Refactor XFixesSelectionNotifyEvent handler
Prepare it for more selection atoms (i.e. XdndSelection) to come.

https://bugzilla.gnome.org/show_bug.cgi?id=738312
2015-05-29 11:27:53 +02:00
Carlos Garnacho
f53eea2c1c wayland: Refactor DnD target functions into MetaWaylandDragDestFuncs
This will be useful in order to interact with drag dest surfaces in
its windowing-specific ways, although everything defaults to the
wayland vfuncs.

https://bugzilla.gnome.org/show_bug.cgi?id=738312
2015-05-29 11:27:52 +02:00
Carlos Garnacho
0b0ce4193f xwayland: Ensure we've got an owner when setting the X selection owner
Otherwise we may end up claiming the X selection when there's no wayland
selection owner.
2015-05-18 20:59:07 +02:00
Carlos Garnacho
719d8bd0c7 xwayland: remove unused struct field 2015-05-18 20:58:57 +02:00
Carlos Garnacho
4fc1811c15 wayland: Add X11/wayland selection interoperation
This piece of code hooks in both wl_data_device and the relevant X
selection events, an X11 Window is set up so it can act as the clipboard
owner when any wayland client owns the selection, reacting to
SelectionRequest events, and returning the data from the wayland client
FD to any X11 requestor through X properties.

In the opposite direction, SelectionNotify messages are received,
which results in the property contents being converted then written
into the wayland requestor's FD.

This code also takes care of the handling incremental transfers through
the INCR property type, reading/writing data chunk by chunk.

https://bugzilla.gnome.org/show_bug.cgi?id=738312
2015-05-15 17:43:53 +02:00
Carlos Garnacho
4b5f5abb4f wayland: refactor MetaWaylandDataSource
Expose it partly (in internal headers anyway), and pass a vtable for the
data source functions, the wayland vfuncs just delegate operations on the
wl_data_source resource. The resource has been also made optional, although
it'll be present on all data sources from wayland clients.

The ownership/lifetime of the DnD data source has also changed a bit,
belonging now to the MetaWaylandDataDevice like the selection one does, as
we can't guarantee how long it will be needed after the grab is finished,
it will be left inert and replaced the next time DnD is started at worst.

This allows the creation of custom/proxy data sources, which will turn out
useful for X11 selection interoperation.

https://bugzilla.gnome.org/show_bug.cgi?id=738312
2015-05-15 17:43:46 +02:00
Carlos Garnacho
d6a7559750 wayland: Fix c&p typo in wl_listener notify callback
The corresponding wl_notify field for destroy_data_device_icon()
is drag_grab->drag_icon_listener, otherwise we're fetching a pointer
that's slightly off where we want.
2015-05-01 18:50:06 +02:00