Commit Graph

269 Commits

Author SHA1 Message Date
Ray Strode
f90db30b9e wayland: rename window->surface to window->wl_surface
The name surface is really overloaded when dealing
with wayland windows.

To alleviate ambiguity, this commit changes the name
of the "surface" and "subsurface" members to have
a wl_ prefix.

https://bugzilla.gnome.org/show_bug.cgi?id=761312
2016-02-06 07:58:56 -05:00
Matthias Clasen
f42cd18779 wayland: Reduce warning level for parentless temporaries
Temp windows without parent are used frequently in our testsuite;
using g_warning on them causes the tests to fail, which is not
useful. Reduce the warning to a g_message.
2016-01-30 20:56:17 -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
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
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
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
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
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
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
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
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
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
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
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
Olivier Fourdan
c806f9b709 ignore size inc when maximized/fullscreen
Under Wayland, fullscreen/maximized windows may not cover the entire
area when a size increment is specified.

Ignore size increments for fullscreen/maximized windows just like most
window managers do under X11 so that windows with size increments can
still be fullscreen or fully maximized under Wayland as well.

https://bugzilla.gnome.org/show_bug.cgi?id=751368
2015-07-03 16:21:13 +02:00
Jonas Ådahl
0dab37c78f wayland: Always request transient commit when mapping subsurface
A subsurface positioning operation only takes effect when the parent
surfaces state is applied. If a subsurface is mapped and positioned, but
the parent surface state is not immediately committed, the relative
position of the subsurface is undefined and may be placed incorrectly.

To avoid this undefined state, always request that the parent surface
should be committed after mapping a subsurface so that the position
operation will take effect.

https://bugzilla.gnome.org/show_bug.cgi?id=751098
2015-06-17 17:41:31 +08:00
Matthias Clasen
5a446284b7 Ensure a variable is initialized
clang complained about transient_for being used uninitialized.
2015-06-13 21:10:25 -04:00
Jonas Ådahl
85635457bc wayland: Improve guessing of popup placement for detached popup menus
If a menu was not attached to any widget, we try to calculate its
position given where the grabbed pointer is and what window has its
focus. Previously we failed to do so if a "transfer window" was used
for the grab, and this patch adds a code path that, if the menu window
itself didn't have the grab, look for the transfer window and get the
grab device from there.

https://bugzilla.gnome.org/show_bug.cgi?id=748951
2015-06-10 11:28:32 +08:00
Jonas Ådahl
9e464252c0 wayland: Don't try to guess the popup menu placement when it was set
If a position was already explicitly set, don't try to guess the
position of popup menus by looking at the pointer position, just use
the set coordinates.

https://bugzilla.gnome.org/show_bug.cgi?id=748951
2015-06-10 11:28:32 +08:00
Jonas Ådahl
0f47d1bac4 wayland: Position popups 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 an xdg_surface, we'd position it relative to top left corner of the
window geometry of that xdg_surface.

https://bugzilla.gnome.org/show_bug.cgi?id=749717
2015-06-10 10:50:12 +08:00
Matthias Clasen
62b858cf0f Avoid a critical under weston
The ordering of globals in connection setup under weston
is different from mutter, and we end up creating a the
dnd window before any outputs are present. Don't cause
a critical warning in that case.
2015-05-11 22:13:07 -04:00
Jonas Ådahl
3da7394b58 wayland: Add support for gtk_window_set_modal
Add two new requests to the gtk_surface interface: set_modal and
unset_modal. The server will currently not do anything special with
input focus, and its up to the client to ignore events on the parent
surface.

This commit bumps the gtk_shell interface version to 2. By connecting to
a Wayland server with another gtk_shell interface version any features
depending on the gtk_shell protocol will not be available.

https://bugzilla.gnome.org/show_bug.cgi?id=745721
2015-04-23 16:09:15 +08:00
Jonas Ådahl
71256a0f94 wayland: Set a more correct xdg_surface application id
The "app_id" of a xdg_surface should be the ID that can potentially be
used to get the DBUS name or the .desktop file.

For GtkApplication programs this is often the ID passed when creating the
GtkApplication object, so when available lets use that.

As fallbacks, first try g_get_prgname as it often corresponds to the
basename part of the .dektop file for non-GtkApplication programs.
Otherwise use gdk_get_program_class, even though that string usually
doesn't conform to the expectations of xdg_surface.set_application_id.

https://bugzilla.gnome.org/show_bug.cgi?id=746435
2015-03-31 12:37:50 +08:00
Jonas Ådahl
225c10bc5a wayland: Don't set the wl_surface user_data twice
wl_surface_add_listener already sets the user data pointer, so no need
to do it separately before.

https://bugzilla.gnome.org/show_bug.cgi?id=746141
2015-03-16 19:53:37 +08:00
Jonas Ådahl
7b2cdabc2e wayland: Put interface version defines in a common place
So far only one, but put it somewhere all files can see it.

https://bugzilla.gnome.org/show_bug.cgi?id=746141
2015-03-16 19:53:37 +08:00
Carlos Garnacho
eaebc2cb4b wayland: Delay wl_subsurface interface creation until the window is shown
It isn't really necessary anytime before, so just make sure it's there only
when the window is visible.

https://bugzilla.gnome.org/show_bug.cgi?id=743427
2015-03-02 12:11:59 +01:00
Carlos Garnacho
c55fcd35fe wayland: Thaw the clock if we hide a GdkWindow mid-frame
When a window is hidden, its surface and all its roles are destroyed,
if this happens when we already issued a wl_surface_commit and are
awaiting for a frame callback, the clock will remain frozen for the
next time the window is shown.

To avoid this, keep track of the wl_surface_frame() calls issued,
and ensure the clock is thawed after hiding. If we happen to receive
the frame callback, it is just ignored.

https://bugzilla.gnome.org/show_bug.cgi?id=743427
2015-03-02 12:11:59 +01:00
Matthias Clasen
af86bc58b9 wayland: Add debug spew 2015-02-28 00:58:05 -05:00
Matthias Clasen
94c5d691df wayland: Formatting fixes 2015-02-28 00:02:30 -05:00
Matthias Clasen
a0eb0e2346 wayland: Apply maximized and fullscreen state
We were just throwing the request away if the app asks to
fullscreen or maximize a window before it has been mapped.
This is something the GdkWindow API explicitly supports,
so make it work by saving the state until the surface exists.

This fixes things under weston. There are bugs in mutter
that keep this from working correctly with gnome-shell.

https://bugzilla.gnome.org/show_bug.cgi?id=745303
2015-02-27 19:09:03 -05:00
Matthias Clasen
3d205a2037 wayland: Drop some pointless lines
No need for these parameter checks, really.
2015-02-27 19:09:03 -05:00