Commit Graph

632 Commits

Author SHA1 Message Date
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
Carlos Garnacho
c405f810cd wayland: Disallow setting the cursor on the touch master pointer
That "pointer" is not backed by anything in the windowing system, ignore
cursor updates there.
2015-11-19 23:26:48 +01:00
Carlos Garnacho
a72974252f wayland: Ensure we get the master pointer on GdkDeviceManager::get_client_pointer
Now that we have multiple master pointers, this call may pick the wrong one.
Instead, pick the GdkWaylandDeviceData from the first device, and pick the
master pointer from there.
2015-11-19 23:26:48 +01:00
Carlos Garnacho
04ecffa238 wayland: Separate touch pointer emulation into its own master pointer
The common GDK code accounts for "pointer emulating" touch sequences to be
synchronized with the pointer position by the windowing system.

However on Wayland pointer and touch are completely independent, the backend
attempts to implement pointer emulation, but doesn't account for the
possible crossing events happening when the user switches from pointer to
touch or the opposite.

In order to fix this, and to ensure we don't have to interact with the
master pointer (which backs the wl_pointer), separate the touch interface
to have its own master pointer, and ensure crossing events are emitted on
it, so the picture of an "emulated pointer" is complete above the backend.

Inspired in a former patch by Jonny Lamb <jonnylamb@gnome.org>

https://bugzilla.gnome.org/show_bug.cgi?id=750845
2015-11-19 23:26:48 +01:00
Matthias Clasen
12a692ea9d wayland: Avoid a crash
We can end up in situations where NULL gets passed to
get_transient_parent(). Embrace it instead of avoiding it.

https://bugzilla.gnome.org/show_bug.cgi?id=758327
2015-11-19 14:40:55 -05:00
Carlos Garnacho
4c49c0a297 wayland: Move additional pointer buttons after the old 4-7 scrolling ones
We were using that range for the extra buttons after left/right/middle,
while this is harmless for clients not handling extra buttons (we
used to translate those button events into scroll events in x11 anyway)
this will be unexpected for clients that do handle additional mouse
buttons themselves (eg. back/forward buttons present in some mice).

In order to remain compatible with X11, those need to be assigned from
button 8 onwards.

Also, include input.h, and stop using magic numbers here.

https://bugzilla.gnome.org/show_bug.cgi?id=758072
2015-11-17 22:41:22 +01:00
Rui Matos
bc6d2d65fb wayland: Translate virtual modifiers too
Wayland allows us to receive virtual modifiers too so we can just use
them directly if the compositor does send them.

https://bugzilla.gnome.org/show_bug.cgi?id=748904
2015-11-14 23:26:11 -05:00
Olivier Fourdan
3058c3e6a9 wayland: configure clients that resize themselves
Make sure the wayland backend sets a new geometry when the client
resizes itself, otherwise the compositor won't be notified and may
revert to the old size on state changes.

Thanks to Jasper St. Pierre <jstpierre@mecheye.net> who pointed out the
problem in gtk+.

bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=755051
2015-10-28 08:41:17 +01:00
Jonas Ådahl
db04c1eda7 wayland: Don't use GTK symbols from GDK
GTK_WINDOW_POPUP sets the GdkWindow type to GDK_WINDOW_TEMP, so use
that in GDK, not the GTK symbol which doesn't exist there.
2015-10-27 09:02:35 +08:00
Jonas Ådahl
bcb28adba3 wayland: Map UTILITY hinted popup windows as subsurfaces
Currently used by GtkTreeView to map windows without changing focus. We
can't map this as a popup, because popup implies focus change.

https://bugzilla.gnome.org/show_bug.cgi?id=756780
2015-10-27 08:41:02 +08:00
Jonas Ådahl
e25ea62f22 wayland: Don't try to use subsurfaces as popup parents
If a GtkMenu (or something else that is mapped as a xdg_popup) tries to
use a subsurface window as a parent, it will be terminated by the
compositor due to protocol violation. So to avoid this, if a parent
window is not a xdg_popup or xdg_surface, i.e. a wl_subsurface, then
traverse up the transient parents until we find the right popup parent.

https://bugzilla.gnome.org/show_bug.cgi?id=756780
2015-10-27 08:41:02 +08:00
Jonas Ådahl
49798754e6 wayland: Make window type conditions switches
In order to make it easier to add/remove in future commits.

https://bugzilla.gnome.org/show_bug.cgi?id=756780
2015-10-27 08:41:02 +08:00
Jonas Ådahl
f838743bc0 wayland: Map windows with tooltip hint as subsurfaces
Tooltips tend to be placed on top of a parent surface with a given
relative coordinate, and without any input focus. So lets map them as
subsurfaces.

https://bugzilla.gnome.org/show_bug.cgi?id=756496
2015-10-18 21:32:22 +08:00
Jonas Ådahl
9fe40f9a46 wayland: Clean up code determining how to map a window
Restructure the mapping procedure so that its known up front what the
expected way mapping is to be done (subsurface, popup or stand alone),
and warn if it fails to actually map in such a way (for example a popup
without a parent or device grab, a tooltip without a parent).

https://bugzilla.gnome.org/show_bug.cgi?id=756496
2015-10-18 21:32:22 +08:00
Carlos Garnacho
7ab250c10c wayland: Set a more believable crossing detail on pointer enter/leave
GDK_NOTIFY_ANCESTOR would happen when the pointer crosses across a direct
parent/child. However nonlinear events are more likely, specially when
the pointer moves across toplevels (either different apps, or menus being
popped up over the pointer position).

This makes popping up comboboxes and other menus that fall over the pointer
position possible. With the previous detail the GtkMenu code misinterpreted
the crossing event, making it think the button release coming right after
should dismiss the popup, which made menus just flash on the screen unless
you kept the button pressed.
2015-10-13 02:07:23 +02:00
Emmanuele Bassi
f10c0da36c wayland: Allow falling back to compatibility EGL contexts
If the shared context is in legacy mode, or if the creation of a core
profile context failed, we fall back to an EGL context in compatibility
mode.

Since we're relying on a fairly new EGL implementation for Wayland, we
don't fall back to the older EGL API, and instead we always require the
EGL_KHR_create_context extension.

https://bugzilla.gnome.org/show_bug.cgi?id=756142
2015-10-07 16:21:57 +01:00
Jonas Ådahl
dad1931b5f wayland: Don't ignore wl_keyboard.leave if surface is gone
keyboard_handle_leave() might be called with a NULL surface resource
(for example if the surface was destroyed after the event was sent). If
so, we should still deal with the keyboard focus lost event, otherwise
we will both leak (the keyboard_focus GdkWindow reference) and miss
stopping the key repeat timer.

https://bugzilla.gnome.org/show_bug.cgi?id=755927
2015-10-07 12:28:39 +08:00
Carlos Garnacho
603ea3b3e7 wayland: Avoid running stale cursor animation timeouts
gdk_wayland_device_update_window_cursor() is inconsistently returning
TRUE/FALSE, despite the timeout being always replaced for new cursor
frames. This could end up in these timeouts being "leaked" and running
as long as the window has an animated cursor.

Fix this by making it really sure we return G_SOURCE_REMOVE, although
now we keep track of animation delays, so the timeout will be reused
for constant time animations.
2015-09-16 19:19:49 +02:00
Jonas Ådahl
7c4c8b90f0 wayland: Make subsurface desynchronized after first parent surface frame
Initially the subsurface will be in synchronized mode and we will leave
it like this until the first time the parent surface has been committed.
The reason for this is because the subsurface position will be applied
as part of the parent surface state, and we need to synchronize the
initial position with the initial frame, so that we don't accidentally
draw the subsurface at the default position (0, 0) which would happen in
desynchronized mode if the subsurface content is committed before the
next parent surface commit.

https://bugzilla.gnome.org/show_bug.cgi?id=754839
2015-09-15 08:11:47 +08:00
Matthias Clasen
b64a0b9233 wayland: Avoid a crash with GtkGLArea
We must not call gdk_wayland_window_attach_image when
using GL for drawing, this leads to a crash.

https://bugzilla.gnome.org/show_bug.cgi?id=754770
2015-09-13 15:56:30 -04:00
Matthias Clasen
27e3059a32 wayland: Remove an overeager assert
If we are using gl for drawing, we don't have a shm surface,
so don't assert that we do. Instead, only call shm-specific
apis when they make sense.

This fixes a crash when showing popovers over a GtkGLArea,
as seen in gdkgears.

https://bugzilla.gnome.org/show_bug.cgi?id=754143
2015-09-04 23:29:31 -04:00
Jonas Ådahl
d682aed550 wayland: Don't broadcast selection owner changes
When receiving a selection or when a drag icon enter a window, it was
targeted at a specific window. Lets emit the GDK_OWNER_CHANGE event
only for this window, instead of broadcasting.

Broadcasting has some nasty side effects. For example, if there was n
GdkWindows, and one would for every "owner-change" signal handler
receive n signals about the owner being changed.

An example of where this went a bit out of hand was gnome-terminal,
which added one listener per terminal window. This meant that if
one had m number of terminal windows, each time any one would loose or
gain keyboard focus, O(m^2) owner-change events would be emitted.

https://bugzilla.gnome.org/show_bug.cgi?id=754158
2015-09-02 11:28:27 +08:00
Matthias Clasen
b7ad7ea918 Fix the build 2015-08-31 11:31:24 -04:00
Matthias Clasen
690a11b5b8 wayland: Stop key repeat on focus out
This should address the occasional 'key repeat gone wild' issue
that some people have been seeing in gnome-terminal under Wayland.

http://bugzilla.gnome.org/show_bug.cgi?id=747684
2015-08-31 11:07:00 -04:00
Matthias Clasen
77b506e22a wayland: Stop key repeat when a seat goes away
Seems unlikely, but it is the right thing to do.
2015-08-31 11:07:00 -04:00
Matthias Clasen
cfeed32c4e wayland: Trivial refactor
Break out a stop_key_repeat function instead of open-coding this
in several places.
2015-08-31 11:07:00 -04:00
Matthias Clasen
ea66300cf9 wayland: Make display closing work
The code in _gdk_wayland_window_dispose was not safe against
being called twice - it would call g_hash_table_destroy twice
on the known_globals hash table, the second time operating on
freed memory. It was also leaking the list of async_roundtrips.

After fixing both of these issues, the displayclose testcase
now works on Wayland.
2015-08-28 16:15:26 -04:00
Matthias Clasen
0dc6726f02 wayland: Be more careful when destroying windows
We call gdk_wayland_window_hide_surface when the window gets
destroyed, and in this case, the frame clock might not exist
anymore.

This was showing up in the displayclose testcase.
2015-08-28 16:15:26 -04:00
Matthias Clasen
de684dac1b Trivial formatting fix 2015-08-28 16:15:26 -04:00
Matthias Clasen
578ba0f974 wayland: Don't assert non-recursing in gdk_window_destroy
While we do not have subwindows in Wayland, we do create an
artificial root window. When the display is closed, the root
window gets destroyed, causing recursing to be true for the
toplevel windows.
2015-08-28 16:15:26 -04:00
Jonas Ådahl
32cd1a7447 wayland: Only bind supported unstable pointer gestures global
As the protocol is still considered unstable (meaning not backward
compatible), we should, as stated in the protocol, only bind the version
advertised is the version we implement.

https://bugzilla.gnome.org/show_bug.cgi?id=753856
2015-08-21 10:04:02 +08:00
Jonas Ådahl
e1fd87728d wayland: Use g_get_prgname() to get the xdg_surface.set_app_id string
Prior to this patch, the ID of the GtkApplication was always used for
clients which were GtkApplications. This would only be guaranteed to be
correct for D-Bus activatable programs. As a result, all
non-D-Bus-activatable applications would set the wrong ID making the
shell unable to find the corresponding .desktop file.

This change makes it so that the GDK backend always uses the name
passed to g_set_prgname, or the default value if not explicitly set, as
this more often corresponds to the .desktop file.

This means that in order to make D-Bus activatable applications set the
correct application ID, they must, for now, manually call
g_set_prgname() with their application ID (basename of the .desktop
file).

If g_get_prgname() returns NULL, fallback to gdk_get_program_class()
even though it will most likely never be correct according to the
xdg_surface.set_app_id specification.

https://bugzilla.gnome.org/show_bug.cgi?id=746435
2015-08-18 08:45:12 +08:00
Carlos Garnacho
02f3fe0671 wayland: calculate screen physical size
A simple calculation is done so far (assuming monitor areas never overlap)
so gdk_screen_get_width/height_mm return meaningful values.

https://bugzilla.gnome.org/show_bug.cgi?id=753621
2015-08-15 22:11:10 -04:00
Ray Strode
83c25169e8 Revert "wayland: require WAYLAND_DISPLAY be set to open wayland display"
This reverts commit 35489f5d31.

It snuck in when i was trying to push

commit f4d2022d46
2015-08-14 11:24:44 -04:00
Ray Strode
f4d2022d46 wayland: change wl_log level to G_LOG_LEVEL_DEBUG
wl_log() currently logs using G_LOG_LEVEL_ERROR
(which is fatal). The wayland client library doesn't
expect this behavior. It uses wl_log to log recoverable
errors.

This commit changes the log level to G_LOG_LEVEL_DEBUG
instead.

https://bugzilla.gnome.org/show_bug.cgi?id=753635
2015-08-14 11:06:48 -04:00
Ray Strode
35489f5d31 wayland: require WAYLAND_DISPLAY be set to open wayland display
The wayland client libraries now require WAYLAND_DISPLAY be set
to use them.

See:

http://cgit.freedesktop.org/wayland/wayland/commit/?id=fb7e13021730d0a5516ecbd3712ea4235e05d24d

This commit makes _gdk_wayland_display_open bail early if
WAYLAND_DISPLAY is unset, just as it does for XDG_RUNTIME_DIR.
2015-08-14 10:28:31 -04:00
Carlos Garnacho
45d15b302e wayland: Implement touchpad gesture events
On wayland, the gestures protocol defines a wl_pointer_gestures global
object, that will match in number with wl_seats, swipe and pinch
interfaces can be obtained from it, which events are translated into
GdkEventTouchpadSwipe/Pinch events.
2015-08-12 23:20:25 +02:00
Carlos Garnacho
b037d4d628 wayland: Add touchpad gestures protocol 2015-08-12 23:20:25 +02:00
Jonas Ådahl
27763743b1 wayland: Don't assume drag context has a source window when finalizing
Only a drag context which was created with 'drag_begin' will be
guaranteed to have a source window at all times. Thus, in finalize we
cannot assume we can retrieve a GdkDisplay from the source_window
pointer since it may be NULL. Though, the display is only needed for
contexts created via 'drag_begin' thus we can retrieve it after
checking that is the case.

https://bugzilla.gnome.org/show_bug.cgi?id=749339
2015-08-05 10:31:55 +08:00
Rui Matos
bd3b496586 wayland: Ensure modal hint gets set on map
We need to be mapped to have a gtk_surface and thus be able to do
requests on it so we need to save the modal hint and apply it when we
get mapped so that code that sets the hint before showing a window
doesn't get ignored.

https://bugzilla.gnome.org/show_bug.cgi?id=753138
2015-08-03 14:24:38 +02:00
Rui Matos
36263076b2 wayland: Invalidate our gtk_surface when we're unmapped
Otherwise if we get mapped again we'll try to use an invalid
gtk_surface and the compositor will disconnect us.

https://bugzilla.gnome.org/show_bug.cgi?id=753138
2015-08-03 14:24:36 +02:00
Matthias Clasen
7d87eebfe7 wayland: Return a display name
Make gdk_screen_make_display_name() return a likely correct
name for the Wayland socket we are using.
2015-07-28 00:43:54 -04:00
Giovanni Campagna
83b7a0f0e5 wayland: Fix initial fullscreen monitor support
-1 means that we have no specific preference for an initial
fullscreen monitor, and -1 is less than the number of monitors,
so we would end up accessing invalid memory. Prevent that.

https://bugzilla.gnome.org/show_bug.cgi?id=752875
2015-07-26 01:55:56 -04:00
Jeremy Whiting
f9d903995d Added api to set a window to fullscreen on a given monitor.
https://bugzilla.gnome.org/show_bug.cgi?id=752677
2015-07-25 07:08:59 -06:00
Jonas Ådahl
2943bfef46 wayland: Always apply scaling factor to cursor hotspot and dimension
Prior to this patch, the hotspot would be passed in buffer coordinate
space. Where this were ever tested, i.e. in a patched mutter, the
server interpreted them incorrectly, which meant it went undiscovered.
In the updated mutter patches the incorrect behavior in GTK+ was
discovered due to the behavior in mutter was corrected.

In the themed cursor case, the dimensions were not correctly scaled
either, but this had no negative visible effect because the dimension is
only used for reporting damage tracking, and passing a bigger damage
region than surface has no negative visible effects.

https://bugzilla.gnome.org/show_bug.cgi?id=752616
2015-07-20 17:36:38 +08:00