Commit Graph

1020 Commits

Author SHA1 Message Date
Caolán McNamara
2b74662b2b gtk#767 add a way to change the application_id of a toplevel wayland GdkSurface
so LibreOffice can reuse toplevels and get the right task icons

references;
 https://gitlab.gnome.org/GNOME/gtk/-/issues/767
 https://lists.freedesktop.org/archives/wayland-devel/2019-July/040704.html
 e0d6ad1d5e
 https://bugs.documentfoundation.org/show_bug.cgi?id=125934
 https://bugzilla.redhat.com/show_bug.cgi?id=1334915
 https://bugreports.qt.io/browse/QTBUG-77182
2020-07-07 21:14:21 +01:00
Sebastian Keller
7998c53396 wayland: Remove unused fribidi include
The included fribidi header is not used in gdkkeys-wayland.c and already
included in gdk.c which causes linker issues due to the header defining
a global variable.
2020-06-04 21:08:20 +02:00
Carlos Garnacho
948782b7e5 gdk/wayland: Handle disorderly tablet/pad disconnects
If the tablet gets removed/freed while there are pad events in flight,
we leave a dangling pointer from the pad to the tablet, which may
lead to invalid reads/writes when handling the pad event(s).

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2748
2020-05-15 18:47:14 +02:00
Alberto Fanjul
1e2d72144a Prevent crashes on gdk wayland implementation using offscreen windows 2020-04-28 15:14:53 +02:00
Jonas Ådahl
cf060b4c7d wayland: Move warning about transient-less temporaries to map()
We shouldn't warn in a funtion that seemingly only checks how something
eventually should be mapped.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2589
2020-04-08 11:43:49 +02:00
Jonas Ådahl
c5d9c8be2b wayland: Always store unconfigured size
This means it'll always be as up to date GdkWindow::width/height. We
still skip the resize for non-configured windows though, to avoid
mapping with the wrong size.

The commit f06ee688fe also accidentally
removed the unconfigured size setting completely, so this essentially
adds it back, but always sets it.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2582
2020-04-07 09:00:26 +02:00
Jonas Ådahl
f06ee688fe wayland: Don't inhibit premature resize for popups
So now we essentially only inhibit the premature resize for toplevel
windows, where it is most crucial. For popups, this didn't work for two
reasons: we relied on the owner of the popup (application) to resize
according to the configured size. For custom popup operators like
Epiphany and LibreOffice, this didn't work out well, since they simply
didn't.

Making gdk do it for them in case they didn't themself did make the
popups show up properly, but there were still some weirdness in
LibreOffice where tooltips didn't still didn't get the right size. So,
even though the size set by application may be different from the one
later configured by the display server, let the applications have their
way and see their resize result immediately. It's fairly likely to be
what they eventually get anyway.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2583
2020-04-06 22:02:02 +02:00
Jonas Ådahl
92aa63c203 wayland: Set unconfigured size on impl construction
Who knows who might use this for something, so lets make the
unconfigured size slightly more predictable. This doesn't fix anything
known to be broken though.
2020-04-06 22:01:12 +02:00
Simon McVittie
46165b52e5 wayland: Guard against nonsense sizes being configured
With the fixes from !1638, it shouldn't be possible for this to happen
any more. However, non-positive sizes make no sense regardless, so if
this does somehow happen, let's make sure *something* reasonable happens.

The practical result of this assertion being hit is that we emit a
critical warning and then behave the same as if !1634 had been merged,
which is known to solve the issue for the submitter.

Signed-off-by: Simon McVittie <smcv@debian.org>
2020-04-06 13:33:09 +01:00
Jonas Ådahl
814d1e7f06 wayland: Store unconfigured size without margin
We get the unconfigured size request either with or without the shadow
margin already configured, so to get some consistency with the 'saved
size', cut away any potential shadow margin from the size before
storing.

Then when using, add it back, so we always create a configure event with
the correct size.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2576
2020-04-06 12:13:01 +02:00
Jonas Ådahl
2e5f344e3c wayland: Always update unconfigured size
If the window size didn't change, we should still update the
unconfigured size as the window size might not be up to date.
2020-04-06 12:05:58 +02:00
Jonas Ådahl
a4984cfd40 wayland: Use helpers to add/remove margins from sizes 2020-04-06 12:05:13 +02:00
William Wold
5a52af20cb Do not require an initial configure for DnD windows
Fixes #2075
2020-04-05 07:11:45 -04:00
William Wold
12fc9a45ef Do not require an initial configure for custom Wayland surfaces
There is no way for custom Wayland surfaces to get configure events, so an
initial configure event should not be required to resize a custom surface.

Fixes #2578.
2020-04-05 05:28:55 -04:00
Jonas Ådahl
749d940887 wayland: Don't postpone resizes for subsurfaces
Subsurfaces won't ever receive a configure event.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2570
2020-04-03 18:04:44 +02:00
Jan Alexander Steffens (heftig)
c27cb675b7
gdk/wayland: Clear modifiers when we lose keyboard focus
When we `Alt+Tab` away from a GTK application, it loses keyboard focus.
If we don't clear the modifiers, events from other devices that we
receive while unfocused will assume `Alt` is still pressed. This results
in e.g. Firefox navigating through the history instead of scrolling the
page when using the mouse wheel on it.

We don't get any information about modifiers while we are missing
keyboard focus, so assuming no modifiers are active is the best we can
do.

The shell sends us a modifier update immediately before we regain
keyboard focus, so the state shouldn't get out of sync.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/2112
2020-04-02 20:45:55 +02:00
Jonas Ådahl
3b91c20eac wayland: Add margin to saved size when restoring size
We're normally going from a fixed size to a floating state when we're
using the saved size, meaning we're practically always going towards a
state where the shadow margin will non-empty. However, if we don't
include any margin when creating a new configure request, we'll end up
resizing to a slightly smaller size as gtk will cut off the margin from
the configure request when changing the window widget size.

This wasn't visible when e.g. going from maximized to floating, as we'd
add the shadow margin at a later point, which would effectively "grow"
the widnow size, but when we're going from tiled to floating, we both
start and end with a non-empty shadow margin, meaning we'd shrink ever
so slightly every time going between tiled and floating.
2020-04-02 18:10:03 +02:00
Jonas Ådahl
50aa947e51 wayland: Treat being tiled as maximized when saving size
We should never save a size when we're tiled, just as we shouldn't when
we're maximized. This fixes returning to the correct floating size after
having been tiled or maximized.
2020-04-02 18:10:03 +02:00
Jonas Ådahl
04b7853a38 wayland: Respect fixed size when resizing
If a window is configured with a fixed size (it's tiled, maximized, or
fullscreen), ignore any resize call that doesn't respect this. The set
size will instead be saved, when appropriate, so that the new size is
used when e.g. unmaximizing.

This makes it possible to call 'gtk_window_resize()' while the window is
maximized, without the window actually changing size until it's
unmaximized. Changing size to a non-maximized size is a violation of the
xdg-shell protocol.
2020-04-02 18:10:03 +02:00
Jonas Ådahl
7f12dc2b66 wayland: Postpone window resize requests until configured
An application may want to set a fallback size of a window while still
mapping maximized. This is done by calling gtk_window_resize() before
gtk_window_maximize() and before gtk_window_show(). When the window is
mapped, it should have a maximized size, and if it eventually is
unmaximized, it should fall back to the size from the earlier
gtk_window_resize() call.

What happens before this commit is that the initial window size ends up
respecting the first gtk_window_resize() dimensions, and not the window
dimension configured by the Wayland display server (i.e. maximized
dimensions).

Fix this by postponing any configure events until we received our
configuration from the display server. If we got one with a fixed size
(e.g. we're maximized, tiled etc), we use that, otherwise we look at the
one that was previously configured by gtk which corresponds to the
"preferred" size when not being maximized.

This fixes Firefox being started in a maximized state when using the
Wayland backend.

Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2538
2020-04-02 18:09:56 +02:00
Alberto Fanjul
842599e0f9 gdk/wayland: Control translate from parent geometry
offscreen windows return NULL for its parent
2020-03-25 23:23:23 +01:00
Matthias Clasen
58eb628571 wayland: Support scales up to 400% for cursors
Suggested in https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/1503
2020-03-25 11:21:50 -04:00
Emmanuele Bassi
c08908b488 Fix build when G_ENABLE_DEBUG is undefined 2020-03-13 15:51:57 +00:00
Carlos Garnacho
a097ca0906 gdk/wayland: Harden against NULL selection content
If NULL is returned, probably the client shouldn't advertise the
mimetype. Make it sure we forget entirely about the attempt to
cache this mimetype, as it'll be mistaken as pending otherwise.

Dropping this cached selection will in consequence close the fd
of all pending readers, which seems appropriate for NULL content.

https://gitlab.gnome.org/GNOME/gtk/issues/2456
2020-02-20 14:09:00 +01:00
Carlos Garnacho
6893118510 gdk/wayland: Avoid invalid memory access on cancellation
The only way to have G_IO_ERROR_CANCELLED in the write callback
goes through having the array of pending writers already cleared.
It should not access the invalid AsyncWriteData and StoredSelection
in that case.
2020-02-20 14:09:00 +01:00
Matthias Clasen
56ee5f03c7 Merge branch 'wip/carlosg/simultaneous-clipboard-access-3.24' into 'gtk-3-24'
gdk/wayland: Handle simultaneous selection requests

See merge request GNOME/gtk!1438
2020-02-14 23:32:07 +00:00
Carlos Garnacho
2ba067e3bc gdk/wayland: Handle simultaneous selection requests
Cache separately the selection contents for each given window/selection/atom
combination, and keep the requestors separate for each of those.

This allows us to incrementally request multiple mimetypes, and dispatch
the requestors as soon as the data is up. This stored selection content is
cached until the selection owner changes, at which point all pending readers
could get their transfers cancelled, and the stored content for the selection
forgotten.
2020-02-14 21:06:59 +01:00
Emmanuele Bassi
418b80e6c8 Merge branch 'private-code' into 'gtk-3-24'
Use `wayland-scanner private-code` in autotools build

See merge request GNOME/gtk!1295
2020-02-11 16:35:30 +00:00
Olivier Fourdan
c9601f1567 gdk/wayland: Fix gdk_window_impl_wayland_finalize() warnings
On Wayland, opening and closing a `GdkDisplay` generates a coupe of
warnings at runtime:

```
  GLib-GObject-WARNING **:
    invalid cast from 'GdkWindowImplWayland' to 'GdkWindow'
  GLib-GObject-WARNING **:
    invalid cast from 'GdkWaylandWindow' to 'GdkWindowImplWayland'
```

This is from `gdk_window_impl_wayland_finalize()` which tries to cast
the given GObject to a `GdkWindow` while it's a `GdkWindowImplWayland`.

Use the correct type casting of objects to avoid the warnings.
2020-01-23 17:34:47 +01:00
Michael Forney
fb98242e18 Use wayland-scanner private-code in autotools build
The sed -i flag is non-standard, and may not be available in all
implementations.

The meson build already requires wayland >= 1.14.91 and uses
private-code, so just do that in the autotools build as well.
2020-01-09 19:15:46 -08:00
Carlos Garnacho
ff41436b59 gdk: Do not change the windowing selection when cancelling source
We are interested in changing the owner window, so the upper bits know
that it is not this client who owns the selection. We are still not
interested in unsetting the selection desktop-wide though, so only avoid
emitting the relevant events then.

The same reasonings than in commit 7a891eeb6d apply otherwise.
2019-10-22 18:43:04 +02:00
Carlos Garnacho
ba0a0ce0a0 Revert "gdk: Do not call gdk_selection_owner_set() internally to the backend"
This reverts commit 7a891eeb6d.
2019-10-22 18:36:44 +02:00
Carlos Garnacho
7a891eeb6d gdk: Do not call gdk_selection_owner_set() internally to the backend
This should just be called by the upper layers (and result in
wl_data_device.set_selection, etc). We should not trigger this within
the backend otherwise.

Related: https://gitlab.gnome.org/GNOME/mutter/issues/878
2019-10-21 20:41:14 +02:00
Carlos Garnacho
299902b008 gdk: Shuffle the situations where a selection is unset
This should only be explicitly unset (face to the windowing) on
gdk_selection_owner_set() with a NULL window. Other circumstances
(eg. selection being taken over by another client) should just
trigger the SelectionClear event in GDK internally.

Related: https://gitlab.gnome.org/GNOME/mutter/issues/878
2019-10-21 20:41:09 +02:00
Carlos Garnacho
bcd384711a gdk: Avoid poking possibly freed memory
The event may end up freed after delivery, ensure to keep the data we need
in order to emit the matching emulated crossed event matching a proximity
event.

Closes: https://gitlab.gnome.org/GNOME/gtk/issues/2157
2019-10-08 17:59:43 +02:00
Carlos Garnacho
d70f85d6b9 gdk: Fix wl_output accounting on tablet devices
The code managing this accounting mixed seat and tablet output lists,
can't bode well. Fixes invalid reads on list elements, as there are
dangling pointers.

Closes: https://gitlab.gnome.org/GNOME/gtk/issues/2157
2019-10-08 17:59:37 +02:00
Matthias Clasen
340c62ecd6 Merge branch 'issue1044' into 'gtk-3-24'
Fix resize requests being forgotten when maximizing a hidden window

See merge request GNOME/gtk!367
2019-09-03 15:43:07 +00:00
Jonas Ådahl
e9fdb35687 Revert "gdk/wayland: go through monitor to compute scale factor"
This reverts commit 6d545b6d03.

Reverting as this broke multi DPI systems, where a client is expected to
render at scale = 1 if it is only visible on a scale = 1 monitor.

Fixes: https://gitlab.gnome.org/GNOME/gtk/issues/2129
2019-09-03 17:13:17 +02:00
Olivier Fourdan
a1becccd3f wayland: Fix xdg-output v3 support
The xdg_output.done event is deprecated in xdg-output v3, so clients
need to rely on the wl_output.done event instead.

However, applying the changes on the fist wl_output.event when using
xdg-output v3 may lead to an incomplete change, as following xdg-output
updates may follow.

Make sure we apply xdg-output events on wl_output.done events with
xdg-output v3.

https://gitlab.gnome.org/GNOME/gtk/issues/2128
2019-09-03 16:10:33 +02:00
Matthias Clasen
64fe119643 Merge branch 'wip/carlosg/ensure-selection-notify' into 'gtk-3-24'
Ensure to emit GDK_SELECTION_NOTIFY on all circumstances

See merge request GNOME/gtk!1057
2019-08-25 11:54:46 +00:00
Carlos Garnacho
022d0044cc Merge branch 'fix-2070' into 'gtk-3-24'
Fixes incorrect crossing emulation of proximity events in Wayland

See merge request GNOME/gtk!1044
2019-08-21 22:23:10 +00:00
Julius Lehmann
94960b828f Add slave device option for emulated crossing events under Wayland
This fixes an issue where stylus proximity in/out events emulate enter/leave events.
The emulated events didn't contain the correct slave device and therefore the
resulting device class was set incorrectly. Crossing event emulation now also
works with slave devices.

Closes #2070
Fixes #2070
Closes: https://gitlab.gnome.org/GNOME/gtk/issues/2070
2019-08-21 16:23:45 +02:00
Carlos Garnacho
6841c73808 gdk/wayland: Unset clipboard/primary if giving up selection ownership
If gdk_selection_owner_set() is called with a NULL window, we should unset
the related data source for the current selection.
2019-08-20 23:51:04 +02:00
Carlos Garnacho
f43f6900c9 gdk/wayland: Emit GDK_SELECTION_NOTIFY on all failure/unset paths
Either on failure, or when replacing a selection buffer due to a new
wl_offer. We should emit one event for each pending requestor then.
2019-08-20 23:51:04 +02:00
Lionel Landwerlin
6d545b6d03 gdk/wayland: go through monitor to compute scale factor
The current code only goes through the output associated to the
window's wayland surface enter/leave events. That means that to update
the scale factor the window only looks at the outputs on which it
received enter/leave events. That doesn't include a new monitor
connected to the system on which the window might be display next.

The spirit of the existing logic seems to be to go through all the
scale factor available on the current monitors of the system and pick
the highest. So fix the current behavior by looking at the monitor on
the display.

Fixes #1144.

Signed-off-by: Lionel Landwerlin <llandwerlin@gmail.com>
2019-08-03 22:36:48 +03:00
Lionel Landwerlin
27b4032680 gdk/wayland: remove unused variable
Signed-off-by: Lionel Landwerlin <llandwerlin@gmail.com>
2019-08-03 22:30:59 +03:00
Olivier Fourdan
ab1e86a3b1 wayland: Add xdg-output v3 support
xdg-output v3 marks xdg-output.done as deprecated and compositors are
not required to send that event anymore.

So if the xdg-output version is 3 or higher, simply set the initial
value `xdg_output_done` to TRUE so we don't wait/expect that event
from the compositor.

https://gitlab.gnome.org/GNOME/gtk/issues/2053
2019-07-26 17:26:05 +02:00
Olivier Fourdan
a393e2ef33 wayland: Update saved size when maximized/fullscreen
If a client issues a `move_resize()` request while the window is
maximized or fullscreen, update the saved size for when it will be
unmaximized/unfullscreened

Related: https://gitlab.gnome.org/GNOME/gtk/issues/1044
2019-07-26 15:51:47 +02:00
Emmanuele Bassi
8e08721278 Relay the xdg_output.name to GdkMonitor
The xdg_output interface has a `name` property that reflects the output
name coming from the compositor.

This is the closest thing we can get to a connector name.

Fixes: #1961
2019-06-20 22:51:47 +01:00
Matthias Clasen
0872338cf2 wayland: Explicitly require RGBA8888
Its the format we expect to have. If we want to
support 10-bit visuals at some point, that should
be an explicit decision.
2019-06-17 13:04:35 -04:00