Commit Graph

351 Commits

Author SHA1 Message Date
Jonas Ådahl
d2a80cd235 wayland: Only update the window title if it actually updated
This makes the protocol log less spammy.

https://bugzilla.gnome.org/show_bug.cgi?id=769937
2016-08-25 12:31:40 +08:00
Jonas Ådahl
8270699119 wayland: Only sync surface regions once per commit
Only set input, opaque and window geometry regions once per commit.
They are double buffered anyway, so the last one would only take effect
either way; this way reading protocol logs are much more pleasent.

https://bugzilla.gnome.org/show_bug.cgi?id=769937
2016-08-25 12:31:40 +08:00
Jonas Ådahl
e53d381430 wayland: Get tiled state from gtk_shell instead of xdg_shell
Use our the 'tiled' entry from our new 'state' enum sent via
xdg_surface.configure.

https://bugzilla.gnome.org/show_bug.cgi?id=769937
2016-08-25 12:31:40 +08:00
Jonas Ådahl
80dd7566d5 wayland: Fix indentation
https://bugzilla.gnome.org/show_bug.cgi?id=769937
2016-08-25 12:31:40 +08:00
Jonas Ådahl
cc019de6a5 wayland: Postpone processing move_to_rect params until showing
At the time of move_to_rect() is called, not all state may have been set
up on the impl gdk window, causing the position to sometimes be
slightly offset due to drap shadow margins. For now, work around this
by postponing the processing of the move_to_rect() parameters until
showing, when its more likely that all state (such as shadow margin)
has been set correctly.

https://bugzilla.gnome.org/show_bug.cgi?id=769402
2016-08-18 04:52:03 -04:00
Jonas Ådahl
4e0ebd0cdf wayland: Don't traverse transient-ofs when faking root coordinate space
The position of each transient-of will be in fake-root coordinate
space; thus we should not accumulate all the positions making it an
offset; each window is already in fake root coordinate space.

https://bugzilla.gnome.org/show_bug.cgi?id=769402
2016-08-18 04:51:51 -04:00
Jonas Ådahl
1f7094a3e5 wayland: Use effective toplevel as popup parent
When using the set transient-for as a popup parent, fetch the effective
toplevel instead, otherwise we will position against the wrong
coordinate.

https://bugzilla.gnome.org/show_bug.cgi?id=769402
2016-08-18 04:51:46 -04:00
Simon McVittie
f65c116d2a Don't apply GDK_HINT_RESIZE_INC to GDK_WINDOW_STATE_TILED windows
This matches the behaviour of Mutter, Metacity and traditional X11
window managers on the window manager side, and is what we want
for at least gnome-terminal. I can't think of any reason why we'd
want incremental resize in any other tiled window.

Signed-off-by: Simon McVittie <smcv@debian.org>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=760944

https://bugzilla.gnome.org/show_bug.cgi?id=755947
2016-07-25 09:00:01 -04:00
Timm Bäder
d9a6517d5f wayland: Make sure window titles fit into a wl_buffer
A wl_buffer has a max size of 4096 bytes, of which 8 are needed for the
header and another 4 for the string argument length (in this case), so
make sure the we only save the first 4083 bytes that are still valid
UTF8.

https://bugzilla.gnome.org/show_bug.cgi?id=767241
2016-06-08 15:06:51 +02:00
Olivier Fourdan
85407180cf wayland: add extended state for tiled
xdg-shell allows desktop environments to extend the list of states
within a given range.

Use this possibility to add a new state for tiled so that gtk+ can
benefit from this.

https://bugzilla.gnome.org/show_bug.cgi?id=766860
2016-06-08 14:46:37 +02:00
Olivier Fourdan
0b58c96f06 wayland: Make gdk_wayland_window_get_wl_output() private
There is no need to make it a public API, move it to the private header
instead.

https://bugzilla.gnome.org/show_bug.cgi?id=766566
2016-05-19 09:48:46 +02:00
Olivier Fourdan
ca77de055b wayland: Add API to retrieve the Wayland output
In Wayland, surfaces get an enter/leave notification each time they
enter or leave an output.

Add an API to GdkWaylandWindow to retrieve the output the window has
last entered.

https://bugzilla.gnome.org/show_bug.cgi?id=766566
2016-05-18 19:07:27 +02:00
Christian Hergert
ebb894cd64 wayland: use g_signal_handler_disconnect()
Use of g_signal_handlers_disconnect_by_func() needs to do more work than
necessary to find all the matching handlers. Instead, just hold on to the
signal identifier and remove it directly so we hit the fast path.

Not terribly ground breaking in terms of performance gains, but its done
enough to be worthwhile.

https://bugzilla.gnome.org/show_bug.cgi?id=766049
2016-05-06 11:33:12 +03:00
Jonas Ådahl
145b626c2f wayland: Track orphaned dialogs per display
Don't track all orphaned dialogs globally, as mixing them up with each
other would in most cases trigger errors when we try to pass bogus
values to Wayland requests.

https://bugzilla.gnome.org/show_bug.cgi?id=765474
2016-04-26 08:38:18 -04:00
Jonas Ådahl
cb73becfb4 wayland: Clean up naming of GdkWaylandDisplay pointers
The naming of pointers to GdkWaylandDisplay's were inconsistent.
Running the following commands in gtk+/gdk/wayland illustrate the
inconsistency:

$ grep -r '\<display_wayland\>' *.[ch] | wc -l
195
$ grep -r '\<wayland_display\>' *.[ch] | wc -l
81

This patch renames all occurrences of "wayland_display" to
"display_wayland". This is also consistent with naming in the X11
backend. A couple of whitespace changes were done as well in places
where the rename was already done, that added line breaks to long lines
that stood out.

https://bugzilla.gnome.org/show_bug.cgi?id=765474
2016-04-26 08:38:18 -04:00
Olivier Fourdan
be6784c7ea wayland: Do not resize with the same size
gnome-control-center is calling gtk_window_resize() on configure-event
signals which leads to a busy loop.

Avoids such a busy loop by not re-configuring a window with the same
size, unless this is coming from and xdg-shell configure.

bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=764374
2016-04-05 18:22:40 +02:00
Christian Hergert
c48bc48dda wayland: avoid dropping surfaces when possible
If the configure-event gives us the same size as we had before,
which is common for animation resizes, then try to keep the
existing buffer around. This saves us a memfd_create() syscall
on every frame.

https://bugzilla.gnome.org/show_bug.cgi?id=763350
2016-03-21 22:03:20 -04:00
Jonas Ådahl
8fb7f50028 wayland: Add request focus support via gtk_shell
A gtk_surface.present request was added to gtk_surface which takes
timestamp from some input event, and uses that timestamp to figure out
whether the window can be presented or not. If we don't have a
timestamp, we should just give up instead of making up our own,
otherwise we might steal someones focus.

https://bugzilla.gnome.org/show_bug.cgi?id=763037
2016-03-10 12:31:15 +08:00
Jonas Ådahl
ed430dc00a wayland: Add system bell support via gtk_shell
Invoke the system bell by calling the request added to the gtk_shell
protocol.

https://bugzilla.gnome.org/show_bug.cgi?id=763001
2016-03-10 12:31:15 +08:00
Jonas Ådahl
f68cf698fc 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=763001
2016-03-10 12:31:15 +08:00
Matthias Clasen
aadbabf998 wayland: Don't crash with offscreen windows
Use gdk_window_get_effective_toplevel when looking for
a suitable transient parent, to skip over offscreen windows
that we might encounter in the window tree. This fixes
a crash in glade.

https://bugzilla.gnome.org/show_bug.cgi?id=763110
2016-03-04 20:04:43 -05:00
Olivier Fourdan
de383809f6 wayland: Check actual impl type in transient loop
If the parent of a transient is not a native Wayland window (e.g.
offscreen window), the transient loop check will crash.

Check for the actual type in the transient loop check and do not assume
the parent is necessarily Wayland native.

bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=761156

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
2016-03-01 22:18:32 -05:00
Olivier Fourdan
3607b9aa2e wayland: Restore size when configure size is 0x0
According to xdg_shell, an xdg_surface.configure with size 0x0 should
be interpreted as that it is up to the client to set a size.

When transitioning from maximize or fullscreen state, this means the
client should configure its size back to what it was before being
maximize or fullscreen.

This problem currently only occurs on weston because weston sends a
configure with size 0x0 when transitioning back from maximize or
fullscreen.

bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=762713
2016-03-01 13:15:02 +01:00
Ray Strode
316fe1dbbd wayland: deal with staging buffer getting allocated prematurely
The staging buffer gets allocated any time begin_paint is called
on the window. This can happen even with an empty paint region,
so we should cope with that situation. At the moment we crash
trying to post a runtime warning.

https://bugzilla.gnome.org/show_bug.cgi?id=762755
2016-02-29 10:52:00 -05:00
Carlos Garnacho
f9f5586714 wayland: Make the function to get the last serial a seat one
This will be useful for primary selection.

https://bugzilla.gnome.org/show_bug.cgi?id=762561
2016-02-26 19:59:17 +01:00
Jonas Ådahl
38b1f15f12 wayland: Only attach the buffer if there was damage
There is no point in attaching and then committing the same buffer if
there was no damage. This will also make us do less unnecessary backfill
read backs, for the cases where we paint with an empty paint region.

https://bugzilla.gnome.org/show_bug.cgi?id=762120
2016-02-16 16:22:51 -05:00
Jonas Ådahl
64c9ec14fe wayland: Handle after-paint invocations when nothing was painted
If a after-paint was scheduled but nothing was painted, for example when
the it was scheduled by a subsurface wanting to update its position,
we'd still try to read back from the backfill cairo surface and update
the committed cairo surface reference even though no buffer was
attached.

Fix this by adding a new state, 'pending_buffer_attached', which is only
true if a buffer was attached during frame. Only when this is true will
the backfill be read back and the committed cairo surface reference be
updated.

https://bugzilla.gnome.org/show_bug.cgi?id=762120
2016-02-16 16:22:51 -05:00
Ray Strode
c80dd54924 wayland: stage uncommitted changes to dedicated buffer
Right now we use one buffer for both staged changes (freshly painted
changes waiting for the frame clock to send to the compositor) and
committed changes (changes actively being read by the compositor
process). This creates a problem in the event we need to stage updates
at the same time the compositor is processing committed updates: we
can't change what the compositor is actively processing.

The current solution for handling this contention is to allocate a
temporary buffer on the spot at the time the updates are staged, and to
copy that buffer back to the shared buffer later.  The problem, though,
is that the copy to the shared buffer currently happens as soon as
the updates are finished being staged, not when the shared buffer is
done being processed by the compositor.

In order to address that problem, this commit changes the code to always
stage changes to a dedicated staging buffer.  The staging buffer is
used exclusively by the client until the client is done with it, and then
once that staging buffer is committed, the client never writes to that
buffer again.  If the client needs to stage new updates, it allocates a
brand new staging buffer, draws to it, and back fills the undrawn parts
of the buffer from a copy of the contents of the committed buffer.

As an optimization, the compositor has the option of releasing the
committed buffer back to the client.  If it does so before the client
needs to stage new updates, then the client will reuse the buffer
for staging future updates.  This optimization prevents having to allocate
a new staging buffer and the associated cost of back filling
that new buffer with a readback of the committed buffer.

https://bugzilla.gnome.org/show_bug.cgi?id=761312
2016-02-06 08:02:57 -05:00
Ray Strode
40e91195ad wayland: don't handle buffer release centrally
Right now we handle buffer releases coming from the
compositor in a central place. We add a listener when
first creating the shared buffers.

This is problematic because a buffer can only have
one listener on it at once so users of the buffer
can't get notified when it's released.

This commit moves the buffer listener code from the
centrally managed display code to the cursor and window
code.

https://bugzilla.gnome.org/show_bug.cgi?id=761312
2016-02-06 08:02:57 -05:00
Ray Strode
2c300081c4 wayland: always return FALSE from begin_paint
The client and compositor share access to the window
pixel buffers. After the client hands off (commits)
the buffer to the compositor it's not supposed to write
to it again until it's released by the compositor.

The code tries to deal with this contention by allocating
a temporary buffer and using that in the mean time. This
temporary buffer is allocated by a higher layer of the code
when begin_paint returns TRUE. Unfortunately, that layer of
the code has no idea when the buffer is released, so it ends
up blitting the temporary buffer back to the shared buffer
prematurely.

This commit changes begin_paint to always return FALSE.

A future commit will address the contention problem in
a different way.

https://bugzilla.gnome.org/show_bug.cgi?id=761312
2016-02-06 08:02:57 -05:00
Ray Strode
1cfa2f4134 wayland: use g_clear_pointer when destroying cairo surfaces
There are a few places where we destroy a cairo surface and
then nullify it. This commit changes those to use
g_clear_pointer instead.

It also drops a cairo_surface_finish call that is unnecessary

https://bugzilla.gnome.org/show_bug.cgi?id=761312
2016-02-06 08:00:35 -05:00
Ray Strode
3ac78ea0be wayland: move server proxy objects to substructure
This commit moves the server proxy objects to a substructure
for clarity.

https://bugzilla.gnome.org/show_bug.cgi?id=761312
2016-02-06 07:59:09 -05:00
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
Jonas Ådahl
f13157f4bb wayland: Don't allocate a full size SHM buffer when drawing using OpenGL
Before this patch, we'd always allocate a full size SHM buffer via
the wl_shm_pool, even though it would never be used. Instead allocate a
logical 1x1 cairo image surface.

https://bugzilla.gnome.org/show_bug.cgi?id=745076
2015-02-24 20:22:03 -05:00
Jonas Ådahl
aa81262f11 wayland: Scale up wl_egl_window according to window scale
In order to support window scales for EGL windows, resize the
wl_egl_window to the window dimension multiplied with the window scale,
just as with SHM window buffers.

https://bugzilla.gnome.org/show_bug.cgi?id=745076
2015-02-24 20:22:03 -05:00
Jonas Ådahl
56c9eac16e wayland: Properly support changing of surface scale
When the preferred surface scale changes, for example when entering a
wl_output with a higher scale than any previous entered output, recreate
the shm surface and redraw the window content with the new window scale.

Before this patch, the internal scale would be changed, but the shm
surface would not be recreated given the new scale, i.e. we'd attach a
buffer for a different scale than wl_surface.set_scale specified.

https://bugzilla.gnome.org/show_bug.cgi?id=745076
2015-02-24 20:22:02 -05:00
Jonas Ådahl
a70b478a5c wayland: Don't ever try to set surface buffer scale when not supported
If the compositor is too old for handling surface buffer scales, never
tyr to set change it. This will effectively always leave it to its
initial state, i.e. 1.

https://bugzilla.gnome.org/show_bug.cgi?id=745076
2015-02-24 20:22:02 -05:00
Jonas Ådahl
5889905d1d wayland: Update to xdg-shell unstable v5
Only trivial changes needed.

https://bugzilla.gnome.org/show_bug.cgi?id=744455
2015-02-14 20:54:47 -05:00
Armin K
6886f479fe wayland: Implement minimize support
Use the existing xdg_surface API for minimization.

https://bugzilla.gnome.org/show_bug.cgi?id=695945
2015-02-11 22:01:38 -05:00
Carlos Garnacho
44c412ecc7 wayland: Pass shadow width to the compositor
Use xdg_surface_set_window_geometry() to tell the compositor about the
shadow widths, this makes some gnome-shell/mutter features (edge resistance,
frames around windows in the overview, side maximization, ...) work alright
with GTK+.

In order to add this, some other places in gdkwindow-wayland had to gain
some knowledge about margins:

- xdg_surface_configure() now syncs the shadow after applying the state,
  and gdk_wayland_window_set_shadow_width() possibly reconfigures the
  window in order to preserve window geometry. This is necessary to keep
  shadows in sync with state/geometry changes, as this does not happen
  all at once.
- xdg_popups relative to an xdg_surface are shown relative to buffer
  coordinates, so the left/top margins must be added there.

https://bugzilla.gnome.org/show_bug.cgi?id=736742
2014-11-23 13:11:08 +01:00
Jasper St. Pierre
8976e84ded gdkwindow: Don't pass the region to the impl when beginning a paint
It's unused. At the same time, rename "begin_paint_region" to
"begin_paint". This will help us clean up how GDK painting works
in the future to allow more creative use of double-buffering.
2014-11-22 08:08:34 -08:00
Javier Jardón
710f332082 configure.ac: Depend on cairo 1.14.0
This is needed for cairo_set_device_scale()
2014-11-10 15:12:17 +00:00
Carlos Garnacho
af6eab850e wayland: Schedule a clock tick instead of wl_surface_commit()ting directly
Instead of possibly calling wl_surface_commit() out of
GdkFrameClock::after-paint, tick the transient parent clock so ::after-paint
can be eventually run.

This ensures that the subsurface coordinates (considered part of the state
of the parent) aren't committed untimely, and guaranteed to be orderly with
the wl_subsurface-relative state.

This is a gtk-side fix for https://bugzilla.gnome.org/show_bug.cgi?id=738887
2014-11-07 17:24:10 +01:00
Carlos Garnacho
964abf7423 wayland: Don't translate a NULL region into an empty one
cairo_region_copy(NULL) will effectively return an empty region, as this
function is always meant to return valid memory. This however inverts the
meaning of the NULL region and results in entirely non-clickable windows.
2014-11-07 17:23:54 +01:00
Bastien Nocera
4af0379aae wayland: Don't try to create a subsurface again
We already did that inside gdk_wayland_window_create_surface() that's
called 2 lines above.

https://bugzilla.gnome.org/show_bug.cgi?id=738912
2014-10-21 12:18:01 +02:00
Alexander Larsson
3d43a9b084 Fix warning 2014-10-13 10:43:32 -04:00
Alexander Larsson
236d08c3c5 gl: Make all user GdkGLContexts not attached to any window
We make user facing gl contexts not attached to a surface if possible,
or attached to dummy surfaces. This means nothing can accidentally
read/write to the toplevel back buffer.
2014-10-13 10:43:31 -04:00
Alexander Larsson
7eae4985e8 wayland: Add OpenGL support
This uses EGL to implement GdkGLContext for wayland.
2014-10-13 10:43:31 -04:00
Benjamin Otte
5e4672092a gdk: Deprecate static gravities
... and remove all implementations. The API allows to not work "if the
server doesn't support it. So from now on, no server does!
2014-10-06 02:38:40 +02:00
Matthias Clasen
52578945bd Wayland: Fix various compiler warnings
Mostly missing declarations, missing statics and unused functions.
2014-09-05 20:41:06 -04:00
Carlos Garnacho
7fbac57712 wayland: Unset window_impl->commit_pending when hiding the surface
A surface may be hidden when a frame is already scheduled, which may cause
crashes on on_frame_clock_after_paint() when calling commit() on a NULL
surface. To fix this, ensure commit_pending is also set to FALSE when the
surface is gone.

https://bugzilla.gnome.org/show_bug.cgi?id=735226
2014-09-01 22:44:08 +02:00