1
0
Fork 0
Commit graph

842 commits

Author SHA1 Message Date
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