Commit Graph

676 Commits

Author SHA1 Message Date
Matthias Clasen
eb2ef63211 wayland: Don't hardcode /tmp
As pointed out in https://bugzilla.gnome.org/show_bug.cgi?id=760964,
we should use the GLib facilities for determining the preferred
location for temporary files.
2016-01-21 22:57:39 -05:00
Ray Strode
5150849a67 wayland: don't pass in width and height to create_shm_pool
create_shm_pool doesn't need the width or height, it just needs
the total size.  By passing it in, we're requiring it to redo
stride calculation unnecessarily.

This commit drops the width and height parameters and makes the
function just take the total size directly.

https://bugzilla.gnome.org/show_bug.cgi?id=760897
2016-01-20 14:29:15 -05:00
Ray Strode
1e001eaa78 wayland: clean up stride calculation when creating shm surface
Right now, we assume the stride for the image surface needs to
be 4 byte aligned.  This is, in fact, true, but it's better to
ask cairo for the alignment requirement directly rather than
assume we know the alignment rules.

This commit changes the code to use cairo_format_stride_for_width
to calculate a suitable rowstride for pixman.

https://bugzilla.gnome.org/show_bug.cgi?id=760897
2016-01-20 14:29:15 -05:00
Ray Strode
c8deaeabdd wayland: unlink shm file earlier in create function
create_shm_pool unlinks the temporary file a little,
too late. It should be unlinked before ftruncate()
is called for two reasons:

1) if ftruncate fails, the file is currently not
getting cleaned up at all
2) in theory, if the file is public some other process
could muck with it

This commit just moves the unlink call a little higher
up.

https://bugzilla.gnome.org/show_bug.cgi?id=760897
2016-01-20 14:29:15 -05:00
Carlos Garnacho
4f6ea16c2e wayland: Protect against NULL offers on gdk_drag_status() implementation
If we're called untimely, we might end up crashing here when poking the
NULL wl_data_offer.
2016-01-20 18:55:51 +01:00
Carlos Garnacho
5b1d96234d wayland: Set weak reference on the current grab window
If the grab window is destroyed the grab will be implicitly removed,
although we won't get GdkSeat:ungrab called in order to clear our
internal window<->seat relation entirely. Setting a weak ref will
nullify the pointer we keep on the seat to the window, avoiding the
expected crashes.
2016-01-19 14:17:36 +01:00
Carlos Garnacho
be3f0dad82 wayland: Unset button modifiers on pointer enter
Due to implicit grabs, we basically can guarantee that the pointer
won't have any buttons pressed at the time of wl_pointer.enter.
Seems like a good place to unset any button modifiers that might
have been left stale by compositor grabs.
2016-01-19 14:17:36 +01:00
Carlos Garnacho
1045dda035 wayland: Implement DnD actions as per wl_data_device v3
Implement as a managed GdkDragContext, which actually fits nicely
with the drag-and-drop model in wayland.
2016-01-19 14:17:36 +01:00
Carlos Garnacho
0747a60129 wayland: Add internal gdk_wayland_seat_set_global_cursor()
This can be used for cases (like DnD) where there isn't necessarily
a grab, but we want a global pointer cursor.
2016-01-19 14:17:36 +01:00
Peter Hutterer
48aa1bb08f wayland: add gdk_event_is_scroll_stop_event()
And use it to handle kinetic scrolling in the GtkScrolledWindow.

However, dropping the delta check causes the X11-based kinetic
scroll to break since we don't have the stop event here. Correct handling of
xf86-input-libinput-based scroll events is still being discussed.

https://bugzilla.gnome.org/show_bug.cgi?id=756729
2016-01-18 21:36:23 +01:00
Peter Hutterer
3fca36169a wayland: add support for wl_pointer frame/axis_source/axis_discrete/axis_stop
This adds support for the new wl_pointer events available in v5.

The wl_pointer.axis_source events can be ignored for the purposes here, the
main reason they exist is so that the combination of axis_source=finger and
axis_stop triggers kinetic scrolling. We don't need to care about the source,
axis_stop is enough for us to tell us when we're scrolling.

The wl_pointer.frame events group events together and is intended as a
mechanism to coalesce events together. This for example allows us to now
send a single GTK scroll event for a diagonal scroll. Previously, the two
wl_pointer.axis events had to be handled separately.

The wl_pointer.axis_discrete event sends mouse wheel clicks where
appropriate, and is translated into up/down/left/right scroll events.

https://bugzilla.gnome.org/show_bug.cgi?id=756729
2016-01-18 21:36:23 +01:00
Rui Matos
303556ac2a wayland: Fix an endless loop 2016-01-15 18:40:43 +01:00
Timm Bäder
8cb515e2f3 Remove stray semicolon
Gets rid of a mixed code/declaration warning.
2016-01-12 09:35:04 +01:00
Matthias Clasen
771149e19a wayland: Ensure we have a dnd-ask cursor
We use this for DND, so make sure that we fall back to some other
cursor if this one isn't present.
2016-01-08 18:11:07 -05:00
Carlos Garnacho
ad0fc8ae7e wayland: Force the grab cursor while a grab is active
When a cursor is specified in gdk_seat_grab(), the cursor is reverted as
soon as the pointer enters or leaves another window.

To avoid this issue, store the grab cursor separately, so we force-apply
it in ::set_window_cursor(). Also, unset early the seat info from the
window on gdk_seat_ungrab(), so the next time switch_to_pointer_grab()
happens we end up picking the cursor set for the window underneath the
pointer window.

Based on a patch by Olivier Fourdan <ofourdan@redhat.com>.

https://bugzilla.gnome.org/show_bug.cgi?id=760213
2016-01-08 22:01:25 +01:00
Matthias Clasen
f9e504d70e wayland: Keep the drag window alive longer
We destroy the widget that is wrapped around the drag window
when the object data on the drag context gets cleared. Destroying
the window before that happens leads to unpleasantries. E.g. we may
try to access the frame clock, which doesn't exist anymore, and
things go downhill from there. So, keep the window alive for
a little longer.
2016-01-08 11:22:47 -05:00
Olivier Fourdan
120088b15f wayland: Update parent of dialogs without transient
X11 has the notions of "transient for group", and while it's an ICCCM
violation, it's commonly used and documented that a window manager
would treat a window with transient_for set to None to transient for all
windows of its group.

gtk uses this when an application sets a dialog type window but does not
specify an explicit transient.

While this works on X11, there is no such thing as groups in Wayland and
the closest equivalent which is set_parent() in xdg-shell takes only one
parent. This is what is used for modal dialogs.

To get something similar in behavior to what is available on X11, a
solution is to update the parent() of the dialogs without transient when
the active surface changes.

Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=759161
2016-01-08 11:55:41 +01:00
Olivier Fourdan
28f011eb05 wayland: prefer subsurface when possible
Quite a few applications use GTK_WINDOW_POPUP to create various
temporary windows and place then on screen. That works fine on X11 but
on Wayland there is no global coordinate system for regular surfaces.

If the application is using a gdk temp window and set a parent with
gtk_window_transient_for(), the gdk wayland backend has all it needs to
create a subsurface that can be placed at will by the application.

Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=759738
2016-01-08 10:33:26 +01:00
Matthias Clasen
10cc35405e wayland: Only do cursor name fallback for standard names
Always returning a left_ptr if we can't find anything better
broke firefox application-specific fallback for missing cursors.
Keep that working by only doing the fallback for the CSS cursor
names, not for things like hashes.

https://bugzilla.gnome.org/show_bug.cgi?id=760141
2016-01-06 14:57:42 -05:00
Carlos Garnacho
fc2879108d wayland: Don't trigger grab on missing capabilities
Those might not be currently there in the first place.
2015-12-21 19:14:21 +01:00
Carlos Garnacho
1fbf2fe4d7 wayland: Avoid GdkDeviceManager APIs
In most places, we can do with the pointer/keyboard of the default seat
instead of the client pointer. We can also remove some code from
gdk_input_init() because we know for sure there's no floating devices to
care about here.
2015-12-16 19:47:06 +01:00
Olivier Fourdan
b456db8cf4 wayland: Check transient loop
Gdk Wayland backend walks up the transient windows tree, but does not
check for cycles when doing so.

As a result, if two or more windows are transient to each other, the
Wayland gdk backend will enter an infinite loop.

While this is clearly a bug in the application, gtk+/gdk should be more
robust and handle such errors more gracefully.

To avoid looping infinitely at various point in the code, check for a
possible loop when setting the transient relationship and deny the
request to set a window transient for another if that would create a
loop.

Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=759299
2015-12-16 14:11:11 +01:00
Carlos Garnacho
a33aefc281 wayland: Improve creation of windowing surface roles
We no longer need a grabbed seat, instead we'll just use the default
seat if this happens, not without first warning and recommending
gdk_seat_grab() for the operation.

https://bugzilla.gnome.org/show_bug.cgi?id=759309
2015-12-15 00:40:21 +01:00
Carlos Garnacho
c7280e4a31 wayland: Replace deprecated functions
We can just gdk_seat_ungrab() here.

https://bugzilla.gnome.org/show_bug.cgi?id=759309
2015-12-15 00:40:21 +01:00
Carlos Garnacho
3009eac85e wayland: Emit cancelled on touchpoint used on window dragging/moving
This allows GDK to unset the grab itself. Also, make sure we unset
the "pointer emulating" touch on the device if this is the
pointer emulating sequence.

https://bugzilla.gnome.org/show_bug.cgi?id=759309
2015-12-15 00:40:21 +01:00
Carlos Garnacho
77cf80f3a9 wayland: Unset "pointer emulating" touch on wl_touch.cancel
And emit the corresnponding leave event on its master pointer.

https://bugzilla.gnome.org/show_bug.cgi?id=759309
2015-12-15 00:40:21 +01:00
Carlos Garnacho
09947a63ed wayland: Make gdk_wayland_device_get_focus() work on touch
So we can figure out the focus for the master device.

https://bugzilla.gnome.org/show_bug.cgi?id=759309
2015-12-15 00:40:21 +01:00
Carlos Garnacho
17525ef7a6 wayland: Add GdkSeat implementation
GdkWaylandDeviceData conceptually gathers the data that belongs to
a seat, so it's been renamed (although the old typedef stays, plenty
of refactoring is due here...).

The methods in GdkSeatClass have also been implemented, the most
remarkable is ::grab, which ensures the grab is performed on all
the relevant "master" devices.

https://bugzilla.gnome.org/show_bug.cgi?id=759309
2015-12-15 00:40:21 +01:00
Lucas Baudin
306ee6d9a5 wayland: recursively search for the settings schema.
On some systems, the gtk settings are not used properly for wayland.
Indeed, g_settings_schema_source_get_default is used, and as the docs says it,
"all lookups performed against the default source should probably be done
recursively.".

https://bugzilla.gnome.org/show_bug.cgi?id=759409
2015-12-14 08:20:04 -05:00
Matthias Clasen
268c7a3e44 gdk: Allow passing the start coordinates in drag_begin
Add a variant of gdk_drag_begin that takes the start position
in addition to the device. All backend implementation have been
updated to accept (and ignore) the new arguments.

Subsequent commits will make use of the data in some backends.
2015-12-13 10:39:43 -05:00
Jonas Ådahl
561833334b wayland: Implement DND icon hotspot API
In Wayland, the hotspot of a DND icon is set using the buffer offset in
wl_buffer.attach. To implement this, add a private API to cause the
next wl_surface.attach to offset the new buffer with a given offset.
Setting a DND icon hotspot sets this offset while also queuing a redraw
of the window to trigger the wl_surface.attach.

https://bugzilla.gnome.org/show_bug.cgi?id=759168
2015-12-11 09:16:46 -05:00
Matthias Clasen
28ae8a3608 Revert "wayland: Implement DND icon hotspot API"
This reverts commit 3ab9d96623.

Pushed prematurely.
2015-12-08 13:04:17 -05:00
Jonas Ådahl
3ab9d96623 wayland: Implement DND icon hotspot API
In Wayland, the hotspot of a DND icon is set using the buffer offset in
wl_buffer.attach. To implement this, add a private API to cause the
next wl_surface.attach to offset the new buffer with a given offset.
Setting a DND icon hotspot sets this offset while also queuing a redraw
of the window to trigger the wl_surface.attach.

https://bugzilla.gnome.org/show_bug.cgi?id=759168
2015-12-08 11:47:07 -05:00
Matthias Clasen
3b4bfba37d wayland: Add a dummy implementation of gdk_drag_context_set_hotspot
This just records the hotspot coordinates. Still to do:
apply the hotspot when updating the drag window.
2015-12-07 21:53:38 -05:00
Matthias Clasen
9fd6db87d2 Drop gdk_wayland_drag_context_get_dnd_window
This backend-specific and libgtk-only API is now unused,
so drop it.
2015-12-02 00:47:53 -05:00
Matthias Clasen
fff8297a50 Add gdk_drag_context_get_drag_window
This makes gdk_wayland_drag_context_get_dnd_window
backend-independent API and adds an implementation
for X11.
2015-12-01 23:47:56 -05:00
Benjamin Otte
9a1913dfb0 wayland: Remove unused variable
Poor gcc was unhappy.
2015-12-02 00:29:29 +01:00
Olivier Fourdan
f37aa415cd wayland: re-configure surface even if size matches
gdk-wayland backend would not re-configure a surface when its size and
scale match the known size and scale.

But there might be a pending xdg_surface_configure() that would revert
this change so we should re-configure even if the currently known
size/scale match, otherwise we may end up with a wrong size after the
xdg_surface_configure() is received.

Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=758901
2015-12-01 16:17:39 +01:00
Carlos Garnacho
1a394bd5ec wayland: Invert drop_finished/button release call order
If we "release" the button first, the drag will be eventually cancelled,
we must first signal GDK_DROP_FINISHED, and then release the button so
the success status prevails.
2015-12-01 15:49:13 +01:00
Carlos Garnacho
0ad927adca wayland: Store requested target on GdkWaylandSelection
It doesn't make a lot of sense to have this stored as data offer data,
rather together with the source_targets array, which is what we're
poking here in the end.

https://bugzilla.gnome.org/show_bug.cgi?id=758713
2015-12-01 15:49:13 +01:00
Carlos Garnacho
4f9d0c06ef wayland: Refactor selection ownership
Dissociate ownership from our maintenance of wl_data_source objects.
The only place where ownership must be updated together is
data_source.cancelled, for the other places GDK should take care of
setting up the right ownership, even if at a different order than
we'd expect here.

This fixes GTK+ apps on wayland being locally confused about the
current selection ownership. Because gtk_selection_add_targets()
results in a wl_data_source being created, and ownership being
updated right away, early callers of this will change the ownership
even if the widget it's being called on didn't explicitly request
the selection ownership yet.

https://bugzilla.gnome.org/show_bug.cgi?id=758660
2015-11-30 20:37:25 +01:00
Jonas Ådahl
1e11b55606 wayland: Use xdg shell protocol from wayland-protocols
Drop our own copy of the xdg shell XML file, and use the one installed
by wayland-protocols.

https://bugzilla.gnome.org/show_bug.cgi?id=758634
2015-11-26 16:54:32 +08:00
Jonas Ådahl
912e79dbe2 wayland: Use pointer gestures protocol from wayland-protocols
Instead of having our own copy of the pointer gestures XML file, use
the one installed by wayland-protocols.

Since pointer gestures is an unstable protocol, it went through the
unstable protocol naming convention changes, which is reflected in this
commit.

https://bugzilla.gnome.org/show_bug.cgi?id=758634
2015-11-26 16:54:32 +08:00
Carlos Garnacho
de7e27bc97 wayland: remove embarrassing g_print()s 2015-11-24 20:57:03 +01:00
Carlos Garnacho
5f59d7de1e wayland: Do not store the grab cursor separately
After the grab is finished, we would expect an enter event, and
GDK updating internally the cursor for that window and device.
This means there is no need at all to store it separately in the
backend.

As a side effect, animated cursors are now also possible on grab
icons.

https://bugzilla.gnome.org/show_bug.cgi?id=735847
2015-11-24 20:52:12 +01:00
Carlos Garnacho
d62febcf97 wayland: Plug surface leak
Other backends take care of the cairo surface destruction in
GdkWindow::destroy. We must do the same here, or the cairo_surface
and its corresponding wl_buffer are left dangling.

https://bugzilla.gnome.org/show_bug.cgi?id=747295
2015-11-24 20:52:12 +01:00
Jonas Ådahl
dc65abc44c wayland: Set a null cursor surface when cursor buffer is null
If the buffer of a cursor is NULL, for example if its an empty cursor,
just set the cursor surface to NULL as well. Not doing this we'll use
uninitialized hotspot coordinates, dimensions and scales.

https://bugzilla.gnome.org/show_bug.cgi?id=758025
2015-11-20 11:59:46 -05:00
Carlos Garnacho
c4f5fd111c wayland: Ensure we have a drop-side GdkDragContext without pointer
This GdkDragContext should be created even if we don't have pointer
capabilities. Make it created on add_seat(), and only set the device
on wl_seat.capabilities, so it can be set to either master pointer.

https://bugzilla.gnome.org/show_bug.cgi?id=741066
2015-11-20 00:11:33 +01:00
Carlos Garnacho
ec65c6d1ce wayland: Fix toplevel lookup before starting DnD
We use the high-level gdk_device_get_window_at_position() to figure
out the window, although this one actually tries to find out the
current window under the device coordinates, which might well fall
outside the window, so NULL is returned in those cases.

Fix this by using the lower level _gdk_device_window_at_position()
that will return the toplevel without further lookups, so is more
desirable here.

https://bugzilla.gnome.org/show_bug.cgi?id=758250
2015-11-19 23:27:26 +01:00
Carlos Garnacho
d221119d14 wayland: Implement GdkDevice::window_at_position for touch
This goes through its own master pointer, so look up the pointer
emulating touch focus window and coordinates.
2015-11-19 23:26:48 +01:00