Commit Graph

1020 Commits

Author SHA1 Message Date
Christian Hergert
ef67eb0b3c gdk: backport GdkProfiler
This is a backport of the GdkProfiler from master. It does not include
the pixel bandwidth numbers that come from gdkdrawcontext.c since there
does not seem to be an analog in 3.x.

Additionally, this implements the recent changes for SYsprof's D-Bus
profiler API which adds a Capabilities property and an options hash-table
to the D-Bus interface for forward portability.
2019-06-06 17:17:20 -07:00
Matthias Clasen
044383fe45 Add a gtk-overlay-scrolling setting
This is in preparation for letting user opt out of
overlay scrolling in the control-center.
2019-05-31 11:54:06 -04:00
Olivier Fourdan
034ed1756c wayland: Use scale from core wl_output protocol
The “xdg-output” protocol provides clients with the outputs size and
position in compositor coordinates, and does not provide the output
scale which is already provided by the core “wl_output” protocol.

So when receiving the wl_output scale event, we should update the scale
regardless of “xdg-output” support, otherwise the scale will remain to
its default value of 1 and the surface will be scaled up by the
compositor to match the actual output scale, which causes blurry fonts
and widgets.

Fixes: https://gitlab.gnome.org/GNOME/gtk/issues/1901
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
2019-05-22 12:34:11 +02:00
Olivier Fourdan
4ba8971404 Revert "Revert "wayland: Add support for xdg-output""
This reverts commit 8e20c1fac2.
2019-05-22 12:34:11 +02:00
Matthias Clasen
8e20c1fac2 Revert "wayland: Add support for xdg-output"
This reverts commit 1f64689c31.

This was leading to blurry output, and needs more work.

See https://gitlab.gnome.org/GNOME/gtk/issues/1901
2019-05-21 13:25:38 -04:00
Matthias Clasen
fbf88d285e Merge branch 'xdg-output-3-24' into 'gtk-3-24'
[3.24] wayland: Add support for xdg-output

See merge request GNOME/gtk!750
2019-05-01 03:35:19 +00:00
Carlos Garnacho
e9757b9afc gdk/wayland: Listen to wl_surface events on tablet cursors
And update the surface accordingly (eg. scale on hidpi). The mechanism
that did that for wl_pointer has been made generic so it can be shared
with tablets too.

Closes: https://gitlab.gnome.org/GNOME/gtk/issues/1675
2019-04-18 18:05:19 +02:00
Matthias Clasen
ac739b2a72 wayland: Avoid using uninitialized memory
_gdk_wayland_cursor_get_buffer was not initializing
its out variables in the 'not found' case. This
was showing up in protocol traces as garbage hotspots
being sent to the compositor.

Closes: https://gitlab.gnome.org/GNOME/gtk/issues/1328
2019-04-18 10:40:09 -04:00
Olivier Fourdan
1f64689c31 wayland: Add support for xdg-output
Previously, the GDK backend for Wayland would deduce the logical size
of the monitors from the wl_output size and scale.

With the addition of fractional scaling which advertises a larger scale
value and then scale down the client surface, the computed logical size
of the monitors in GDK would be wrong and confuse applications which
insist on using the monitor size and position (like Firefox).

The xdg-output protocol aims at describing outputs in a way which is more
in line with the concept of an output on desktop oriented systems by
presenting the outputs using their logical size and position appropriately
transformed.

Add support for the optional xdg-output protocol so that the size and
position of the monitors as reported by GDK is correct even when using
fractional scaling.

Fixes: https://gitlab.gnome.org/GNOME/gtk/issues/1828
2019-04-16 16:14:24 +02:00
Robert Mader
df6ea75a04 gdk/wayland: Use event window to calculate coordinatess for show_window_menu()
The previously used window always was the xdg_toplevel window.
2019-04-14 12:26:45 +02:00
Christoph Reiter
d52dad2042 autotools: dist all meson related build files 2019-04-11 16:45:36 +02:00
Nirbheek Chauhan
a4fe15d9f0 meson: Sync build files with master and update to 3.24 2019-04-11 16:45:27 +02:00
Nirbheek Chauhan
8ec004cc08 Import meson build files from an 3.22
Specifically, from 6dd6660c68
2019-04-11 16:40:33 +02:00
Jan Alexander Steffens (heftig)
2d3936cbe6
Centralize DESKTOP_STARTUP/AUTOSTART_ID handling
Add private API to GDK to move these variables from the environment into
static scope. Also move the DESKTOP_STARTUP_ID validation here to reduce
code duplication.

Use constructors to read them as early as possible; however, do not
unset them until first requested. This avoids breaking gnome-shell and
gnome-settings-daemon, which want to use the DESKTOP_AUTOSTART_ID in
their own gnome-session clients.

Fixes https://gitlab.gnome.org/GNOME/gtk/issues/1761
2019-04-02 09:14:35 +02:00
Robert Mader
35c4627fac gdk/wayland: Properly calculate coordinates for show_window_menu()
The event received in `gdk_wayland_window_show_window_menu()` can
come from widgets with a GdkWindow. In those cases the coordinates
are relative to the widget, not the root window.
This results in a misplaced window menu.

Properly calculate the coordinates by iterating to the toplevel
window as suggested by Carlos Garnacho.

https://gitlab.gnome.org/GNOME/gtk/merge_requests/684
2019-04-01 11:11:12 +02:00
Carlos Garnacho
ed9a6f755d gdk/wayland: Preserve stored startup id for gtk_surface1.request_focus
The use of the startup ID is now twofold, we reply back with it to end any
corresponding startup notification, but we also use it on
gtk_surface1.request_focus to acknowledge that the activation might raise
the corresponding window.

We should preserve the startup ID for the second to work properly, so avoid
clearing it here. It is inconsequential if the underlying
gtk_shell1.set_startup_id request happens multiple times on no longer existing
startup IDs, so don't bother preventing that from happening.

Closes: https://gitlab.gnome.org/GNOME/gtk/issues/1754
2019-03-18 12:28:57 +01:00
Matthias Clasen
3da6497d9f gdk: Stop using deprecated pango api 2019-01-31 14:07:28 -05:00
Carlos Garnacho
bff46d8696 gdk/wayland: Set a startup notification
And notify the shell about it. This is done through the
gtk_shell1.notify_launch request added in gtk-shell v3. All the plumbing
on the way to the activated application is already in place to transfer
the startup ID, so the other side just has to reply with
gtk_surface1.request_focus.

Closes: https://gitlab.gnome.org/GNOME/gtk/issues/624
2019-01-23 19:13:37 +01:00
Carlos Garnacho
ed9db5a173 gdk/wayland: Implement gdk_window_present()
This uses the gtk_surface1.request_focus request added in gtk-shell v3,
the given startup ID may be used by the compositor in order to determine
when was the request started, and whether user input happened in between.

Closes: https://gitlab.gnome.org/GNOME/gtk/issues/624
2019-01-23 19:13:37 +01:00
Carlos Garnacho
45d6c0091a wayland/protocol: Update gtk-shell protocol to v3
This version has 2 new requests:
- gtk_shell1.notify_launch notifies the compositor that the requesting
  client shall launch another application. The given ID is expected to
  be unique.
- gtk_surface1.request_focus notifies the compositor that a surface
  requests focus due to it being activated. The given ID is passed to
  this process through undetermined means, if it corresponds with a
  current startup ID and there was no user interaction in between the
  surface will be focused, otherwise it will demand attention.
2019-01-23 19:13:37 +01:00
Jonas Ådahl
66ee4dea40 wayland/window: Don't remap when handling xdg_popu.configure
If the size was constrained by the xdg_positioner mechanisms, we handle
the resize by resizing the popup window. What we shouldn't do is
hide/show the popup window so avoid that.
2019-01-17 16:17:32 +01:00
Jonas Ådahl
a907552df9 wayland/cursor: Make sure the cached cursor has the right size
The cache key is just the name of the cursor, so if a previously added
cursor had e.g. scale == 1, if we ask for a new cursor with scale == 2,
we might still fetch the scale == 1 cursor from the cache. Avoid this by
making sure the scale of the cached one is correct.

If it isn't, load the cursor as normal, and update the cache entry with
the new properly scaled cursor.

Fixes: https://gitlab.gnome.org/GNOME/gtk/issues/1183
2019-01-08 18:48:16 +01:00
Jonas Ådahl
d31107c4fe wayland/cursor: Rename GdkWaylandCursor variable
It was called "private" for some reason. Call it "wayland_cursor"
instead, as it's a GdkWaylandCursor, and also not private.
2019-01-08 18:48:16 +01:00
Matthias Clasen
3a1c5f7232 Wayland: Support key theme setting
GTK+ 3 has supported this all along, so we should support
it for Wayland as well, for feature parity.

Closes: #1553
2019-01-04 10:18:51 -05:00
Matthias Clasen
d21832719b wayland: Adapt to settings portal api change
ReadAll now accepts an array of patterns.
2018-11-12 14:10:13 -05:00
Matthias Clasen
8ef21cb32f wayland: Fix a thinko in settings portal support
When we decide to fall back because the settings portal
is not present, adhere to that decision elsewhere.
2018-11-05 18:34:57 -05:00
Matthias Clasen
41562ab2c6 wayland: Support the settings portal
Under Wayland, we are currently directly using GSettings
for desktop settings. But in a sandbox, we may not have
access to dconf, so this may fail. Use the new settings
portal instead.
2018-11-04 15:50:16 -05:00
Michael Catanzaro
b4464e1274 wayland: Avoid crashes inside wl_proxy_marshal()
Suggested by Garnacho. Hopefully fixes #1349.

Note: I'm riskily committing this via web UI not because I'm lazy
(though I am :) but because I'm seeing a weird host key when I try to
push or pull from GitLab.
2018-09-24 20:19:26 +00:00
Matthias Clasen
677627346d Merge branch 'wip/tooltip-move-to-rect' into 'gtk-3-24'
Make tooltips use gdk_window_move_to_rect()

See merge request GNOME/gtk!293
2018-08-15 22:01:20 +00:00
Carlos Garnacho
935bb5db32 gdk/wayland: Avoid idempotent wl_subsurface.set_position calls
These may not result on wl_surface.frame callbacks, yet we do trigger
a frame clock tick that would get stuck on the lack of such callback.

https://bugzilla.gnome.org/show_bug.cgi?id=784314
https://gitlab.gnome.org/GNOME/gtk/issues/844

Closes: #844
2018-08-14 18:52:07 +02:00
Jonas Ådahl
595f3902c8 gdk/wayland: Always map windows 'moved-to-rect' as popups
Only popups can make use of the move-to-rect semantics so it makes no
sense to try anything other surface type.
2018-08-10 18:32:54 +02:00
Jonas Ådahl
1ed53199c5 gdk/wayland: Don't remap non-subsurface as subsurface
Let's just use the fact that a window was mapped as a subsurface to
remap it above another transient parent instead of relying on the more
complicated 'should-map-as-subsurface' helper function.
2018-08-10 18:32:54 +02:00
Jonas Ådahl
927004178f Merge branch 'fix_wayland_csd_announce' into 'gtk-3-24'
Fix gdk_wayland_window_announce_csd

See merge request GNOME/gtk!221
2018-07-03 10:14:57 +00:00
David Edmundson
d49335c59a wayland: Use correct enums in server_decoration_request_mode
The enum is duplicated in the spec for the manager and the decoration
object. We should be using the right ones. In practice they have the
same value, so this bug didn't cause any issues.
2018-06-28 18:51:12 +01:00
David Edmundson
f62c92783a wayland: Respond to server_decoration.mode events 2018-06-28 18:51:12 +01:00
David Edmundson
f3f4d40b89 wayland: Fix memory leak in server decoration object
The server decoration object becomes invaid when the wl_surface is
deleted. We should tidy it up then.
2018-06-28 18:51:12 +01:00
David Edmundson
b0bfe606aa wayland: Reset server decoration interface on window mapping
The wl_surface is destroyed and recreated when the window is
mapped/unmapped. As we have a new wl_surface we need to create a new
server_decoration object for that surface.
2018-06-28 18:50:50 +01:00
David Edmundson
32ae97f13a wayland: Explicitly request mode for both CSD and SSD modes
According to the spec compositors were to assume surfaces are CSD until
told otherwise. This means we need to send
org_kde_kwin_server_decoration_request_mode in both cases.

This fixes libreoffice under kwin, which would remove it's own headers
as per the manager's request but not inform kwin leaving it in the even
more broken state of having none.
2018-06-28 18:50:50 +01:00
Jonas Ådahl
3354d91090 wayland: Update cursor surface scale when output scale changes
Cursor surfaces didn't listen for output scale changes, meaning they
didn't adapt their scale when an output changed scale, which could
happen for example when changing the monitor scale via Settings.
2018-06-28 12:01:48 +02:00
myfreeweb
055c1b2faa wayland: Use shm_open(SHM_ANON) on FreeBSD
This functionality is similar to Linux's memfd. It creates anonymous shared memory without touching the filesystem, which allows it to work in Capsicum capability mode (sandbox).
2018-06-19 14:49:18 +00:00
Martin Blanchard
cbc8d39887 wayland: Implement'gtk-fontconfig-timestamp' & 'gtk-modules'
The 'gtk-fontconfig-timestamp' and 'gtk-modules' settings are
currently not available at all on Wayland. On X11, they are
implemented through xsettings maintained up-to-date by
gnome-settings-daemon.

This patch implements both GtkSettings for Wayland using a
new dbus interface also provided by gnome-settings-daemon.

Closes #886
2018-05-30 19:26:24 +01:00
Olivier Fourdan
cc4dd0d343 wayland: check native window for crossing events
gdk_wayland_*_grab()/ungrab() would emit crossing events which translate
as focus_in/focus_out events for keyboard.

However, the ungrab() functions compare the native toplevel as this is
what gets the Wayland pointer enter/leave events with the grab window,
so if the grab is issued on a child gdk window, those won't match and we
would emit more focus_out events than focus_in events.

This means that a widget such as spice-gtk which issues a keyboard grab
whenever the pointer enters the window and releases the grab when it
leaves the window would get uneven numbers of focus_in/focus_out events.

Also, gdk_wayland_seat_ungrab() would not emit crossing events for
keyboard devices, whereas gdk_wayland_device_ungrab() does, which adds
even more potential discrepancies between focus_in/focus_out events.

To solve this problem, introduce two new helper functions which check
the relevant native windows to emit crossing events when needed that get
called evenly from both gdk_wayland_seat_grab()/ungrab() and gdk_Wayland
_device_grab()/ungrab() APIs.

Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=780422
Fixes: https://gitlab.gnome.org/GNOME/gtk/issues/792
2018-05-25 21:10:58 +01:00
Jonas Ådahl
7edd465f6d wayland: Fix restarting cursor animation
When an animated cursor was set and the previous cursor animation delay
happened to be the same, we wouldn't restart the animation timeout and
just return G_SOURCE_CONTINUE assuming the timer would continue. This
assumption is however only valid if the function was called from the
timeout, which is not the case.

Instead also arm the timer also if there is no previous timer active.
2018-05-09 22:13:10 +02:00
Ting-Wei Lan
a9f0704ae1 wayland: Use dev/evdev/input.h on FreeBSD
The header linux/input.h used by GDK is specific to Linux. It is
possible to get a few Linux headers on FreeBSD by installing v4l_compat,
but it is usually better to use the one shipped with FreeBSD.

We prefer dev/evdev/input.h to linux/input.h here, so it will always use
dev/evdev/input.h on FreeBSD regardless of v4l_compat.

https://svnweb.freebsd.org/changeset/ports/465644
2018-05-01 22:00:31 +08:00
Emmanuele Bassi
88b08c05c0 wayland: Allow a NULL inhibitors hash table
The shortcuts inhibitors hash table is created when we create a
GdkWaylandWindow implementation for a GdkWindow, and it's destroyed once
we finalize the instance. The fake "root" window we create for the
Wayland display does not have a backing native window, so the shortcuts
inhibitors hash table is set to NULL; this causes a critical error
message when calling g_hash_table_destroy() on it. The finalization of
the root window happens when we close a display connection.

We should use g_clear_pointer(), instead, as it's NULL safe.

Without this change, the displayclose test fails, as all warnings are
considered fatal.
2018-04-23 10:02:43 +01:00
Jan Alexander Steffens (heftig)
8e74e515c7
wayland: Fix setting geometry hints
The stable xdg_shell port (5c8bb51a) introduced an error in
gdk_wayland_window_set_geometry_hints which would set the minimum size
to the maximum size, if provided.

This resulted in various wxWidgets apps (FileZilla, Audacity, Veracrypt)
crashing because they attempted to allocate a ginormous surface.

Fixes #157.
2018-04-04 14:38:45 +02:00
Matthias Clasen
a09df57a5f Merge branch 'gtk-3-22-bz773274' into 'gtk-3-22'
wayland: Don't paint if the window is unmapped

See merge request GNOME/gtk!31
2018-03-25 20:47:02 +00:00
Olivier Fourdan
3bd7b379c8 wayland: Drop cairo surfaces when withdrawing
If a window is unmapped by the client while gdk is processing updates,
(for example Firefox un-mapping its window on Expose events), the
windowing backend resources might be lost (for example with Wayland)
which can cause a crash in end_paint().

Make sure we drop the cairo surfaces as well when hiding the surface,
that will avoid the crash in gdk_window_impl_wayland_end_paint() when
trying to attach the staging cairo surface to a released wl_surface,
these will be recreated when needed when the surface becomes visible
again and there is no need to keep such buffers around for a surface
which is not visible anyway.

https://bugzilla.gnome.org/show_bug.cgi?id=793062
2018-03-16 16:01:21 +01:00
Jonas Ådahl
0454a1cace wayland: Minor whitespace cleanups
Broke up a long line, added an empty one, and indented another one.

https://bugzilla.gnome.org/show_bug.cgi?id=791939
2018-03-16 17:44:48 +08:00
Jonas Ådahl
a46bc8b5a3 wayland: Add support for xdg-shell stable
This commit adds support the stable version of the xdg-shell protocol.
Support for the last version of the unstable series is left intact, but
will not receive new features.

The stable version is prioritized above the older version.

https://bugzilla.gnome.org/show_bug.cgi?id=791939
2018-03-16 17:44:48 +08:00
Carlos Garnacho
3146f29d3a gdk/wayland: Add GdkDisplay call to query available globals
The internal known_globals hashtable is used to carry accounting for
interfaces that depend on others (as ordering is not guaranteed), extend
its usage so it also keeps track of unimplemented interfaces (here at
least).

The API call will then use this to allow querying the globals offered by
the compositor, it will be useful to determine whether we can use
text-input protocols or should fallback to other IMs.
2018-02-14 14:58:06 +01:00
Emmanuele Bassi
80e5f28ca0 Remove stray format character
We are not using any string in the debug message.
2018-02-11 23:28:50 +00:00
Carlos Garnacho
08f60dbcf6 wayland: Improve EOF detection when reading selections
g_input_stream_read_bytes() roughly provides the same guarantees
than g_input_stream_read() wrt the number of bytes being possibly
read (i.e. it being a best effort, but no real guarantees).

Instead, rely on the 0-len read that we'd get at the end of the
transfer.

Fixes clipboard/DnD transfers possibly being cut short, resulting
on "Broken pipe" errors on the other side.

https://gitlab.gnome.org/GNOME/gtk/issues/1

Closes: #1
2018-02-08 16:29:18 +01:00
Jason Gerecke
c94993e29b wayland: Add support for BTN_STYLUS3
BTN_STYLUS3 is defined by the Linux 4.15 kernel and is sent when the
third button on a stylus is pressed. At the moment, only Wacom's "Pro
Pen 3D" has three stylus buttons. Pressing this button triggers a button
8 event to be sent under X11, so we use the same mapping here.

https://bugzilla.gnome.org/show_bug.cgi?id=790033
2018-01-30 21:32:24 +01:00
Ting-Wei Lan
b68e55ecce wayland: Use portable sed syntax in gdk/wayland/Makefile.am
Replace non-portable \<, \>, \+ with \(, \), \{, \} to avoid build
failure on systems not using GNU sed.

https://bugzilla.gnome.org/show_bug.cgi?id=792279
2018-01-10 00:45:07 +08:00
Matthias Clasen
a41e0ce4a4 wayland: Handle scale 3 for cursors
This is just a bandaid solution to make scale 3 work.
If people seriously want to go for scales larger than
that, we need a better solution.
2017-12-17 17:17:12 -05:00
Jonas Ådahl
25dc32c1a1 wayland: Destroy the xdg_imported after the wl_surface
This way the window manager can handle destruction while having the
transient-for relationship still valid.

https://bugzilla.gnome.org/show_bug.cgi?id=791062
2017-12-07 22:13:40 -05:00
Jonas Ådahl
dee5142c91 wayland: Maybe postpone xdg-foreign state setup until mapping
In order to map a window with the correct initial parent-child
relationship when a modal dialog is set up to be a child of an imported
foreign window, the relationship must be set up before the window is
mapped.

In order to do this, if a window is not yet mapped, postpone the
relationship setup until when the window is eventually mapped.

https://bugzilla.gnome.org/show_bug.cgi?id=791062
2017-12-07 22:13:39 -05:00
Carlos Garnacho
e7e047fc3f gdk/wayland: Restrict shortcut inhibition to keyboard grabs on toplevels
It is unlikely that popup windows will contain anything that requires this
(popup menus being more interested in redirecting keyboard focus to
themselves). OTOH popup implementations that just grab the keyboard are
commonplace enough, it makes sense not to trigger inhibition for these.

https://bugzilla.gnome.org/show_bug.cgi?id=789268
2017-11-30 18:54:47 +01:00
Christophe Fergeau
7d18f2fd3c wayland: Fix indentation of previous commit 2017-11-29 12:15:48 +01:00
Christophe Fergeau
8af29e3756 wayland: emit GDK_SELECTION_CLEAR on owner changes
The wayland backend currently never emits GDK_SELECTION_CLEAR events.
GtkClipboard uses this signal in order to clear the clipboard owner when
the selection is set to something outside the application.
This commit ensures the wayland backend emits GDK_SELECTION_CLEAR before
setting the clipboard owner to NULL, as this means we lost the
selection.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>

https://bugzilla.gnome.org/show_bug.cgi?id=790031
2017-11-29 11:21:32 +01:00
Christophe Fergeau
beb2caacb9 wayland: Remove unused data structure
Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>

https://bugzilla.gnome.org/show_bug.cgi?id=790031
2017-11-29 11:21:32 +01:00
Alex Ivanov
2b6f3f7867 wayland: Don't provide gsetting if dconf is not available
This makes gtk+ fall back to reading ~/.config/gtk-3.0/settings.ini
on systems with Wayland, but without dconf (do those exist?).

https://bugzilla.gnome.org/show_bug.cgi?id=790201
2017-11-26 19:32:52 -05:00
Simon McVittie
72a45366e2 wayland: Distribute protocol/server-decoration.xml in tarballs
Otherwise, builds that include the Wayland backend fail.

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=789630
Signed-off-by: Simon McVittie <smcv@debian.org>
Reviewed-by: Emmanuele Bassi <ebassi@gnome.org>
2017-10-30 02:16:21 +00:00
Olivier Fourdan
8ef20c0e2f wayland: scale down reported monitor geometry
According to the documentation, gdk_monitor_get_geometry() reports the
monitor geometry in ”application pixels”, not in ”device pixels”,
meaning that the actual device resolution needs to be scaled down by the
scale factor of the output.

x11 backend does that downscaling, whereas Wayland backend did not,
causing a discrepancy depending on the backend used.

https://bugzilla.gnome.org/show_bug.cgi?id=783995
2017-10-27 16:11:03 -04:00
Simon McVittie
465ef50554 Set GDK_WINDOW_STATE_TILED if any edge is tiled
This state flag is used in several places in GTK+, for example to
ignore RESIZE_INC hints if tiled. Setting it is also necessary for
backwards compatibility with applications that changed their behaviour
when tiled, such as GNOME Terminal and its MATE fork.

Signed-off-by: Simon McVittie <smcv@debian.org>

https://bugzilla.gnome.org/show_bug.cgi?id=789357
2017-10-27 10:58:35 -02:00
Drew DeVault
f2adaba237 Wayland: Implement KDE's SSD protocol
If the compositor prefers server-side decorations and the client doesn't
customize the title bar, we disable client-side decorations and let the
compositor know. Otherwise, we continue to use client-side decorations.

Signed-off-by: Drew DeVault <sir@cmpwn.com>

https://bugzilla.gnome.org/show_bug.cgi?id=781909
2017-10-26 16:34:42 -04:00
Olivier Fourdan
30e7215406 wayland: Do not constrain saved window size
Under Wayland, an xdg_surface.configure with size 0x0 means it's up to
the client to set its size.

When transitioning from maximized state to un-maximized, the Wayland
compositor will send such an 0x0 configure so that the client can
restore its original size.

However, the original size was already constrained, so re-applying
size constrains can lead to a smaller size when using size increments.

Avoid this caveat by not applying size constrains when we are restoring
the original size.

https://bugzilla.gnome.org/show_bug.cgi?id=777072
2017-10-26 15:51:01 -04:00
Matthias Clasen
fc741adbbb wayland: Don't spew warnings for blank cursors
We were unnecessarily spewing warnings when blank cursors
were getting a new scale set. Standardize on "none" as the
name for blank cursors, and avoid the warning.

https://bugzilla.gnome.org/show_bug.cgi?id=775217
2017-10-26 00:32:07 -04:00
Michael Catanzaro
26ff667901 Revert "gdk/wayland: Avoid idempotent wl_subsurface.set_position calls"
This reverts commit 8aa6d59b7a.

This caused a regression in totem that still needs to be investigated.

https://bugzilla.gnome.org/show_bug.cgi?id=784314
2017-10-19 19:51:43 -05:00
Carlos Garnacho
8aa6d59b7a gdk/wayland: Avoid idempotent wl_subsurface.set_position calls
These may not result on wl_surface.frame callbacks, yet we do trigger
a frame clock tick that would get stuck on the lack of such callback.

https://bugzilla.gnome.org/show_bug.cgi?id=784314
2017-10-16 11:27:47 +02:00
Matthias Clasen
223a709403 wayland: Fix a typo
We were not setting the right tiling hint in some cases.

Patch by Jan Steffens.
2017-10-04 07:35:45 -04:00
Georges Basile Stavracas Neto
3bae80dfc1 wayland: consider edge constraints in surface configuration
Now that GTK windows have the ability to properly handle
per-edge tiling constraints, this patch extends GTK's
internal Wayland protocol to have a proper enum with the
relevant edge data.

Once this approach is validated, we can think of upstreaming
this work as an official Wayland protocol extension.

https://bugzilla.gnome.org/show_bug.cgi?id=783669
2017-10-03 20:06:46 -03:00
Daniel Elstner
a57630b30c gdk-wayland: Do not leak dummy 1x1 surface on every draw
When using EGL, neither leak nor re-create the dummy 1x1 Cairo
surface every time gdk_wayland_window_ensure_cairo_surface()
is called.

https://bugzilla.gnome.org/show_bug.cgi?id=775126
2017-09-26 21:15:21 +02:00
Lionel Landwerlin
12d10f239b gdk: wayland: always set buffer scale on size update
We're only updating this when we have an EGL window. This means we
have the wrong scaling factor when using Vulkan.

https://bugzilla.gnome.org/show_bug.cgi?id=786492
2017-08-23 10:44:20 -04:00
Olivier Fourdan
1c23bce350 wayland: add shortcut inhibitor support
This adds support for the shortcut inhibitor protocol in gdk/wayland
backend.

A shortcut inhibitor request is issued from the gdk wayland backend for
both the older, deprecated API gdk_device_grab() and the new gdk seat
API gdk_seat_grab(), but only if the requested capability is for the
keyboard only.

https://bugzilla.gnome.org/show_bug.cgi?id=783343
2017-08-02 12:38:52 +02:00
Carlos Garnacho
b53a6fb092 wayland: Clear tablet tool cursor on proximity out
This ensures that the tablet tool will get the cursor updated even if it
happens to fall within the same window again on the next proximity in.

https://bugzilla.gnome.org/show_bug.cgi?id=785375
2017-07-25 18:36:12 +02:00
Carlos Garnacho
3f09833253 wayland: Observe GDK_SEAT_CAPABILITY_TABLET_STYLUS on gdk_seat_get_slaves()
This flag wasn't being honored so far...
2017-07-25 15:35:41 +02:00
Jason Gerecke
32919a4a02 wayland: Implement support for tablet wheel scrolling
Adds support for creating scroll events from Wayland tablet wheel events.
Even though no Wacom tablet puck has a smooth-scrolling wheel, both event
types need to be generated to make the upper layers happy.

https://bugzilla.gnome.org/show_bug.cgi?id=783716
2017-07-20 14:11:26 +02:00
Carlos Garnacho
e6863da8fc wayland: Make function to create scroll event more generic
Add GdkWaylandPointerData and GdkDevice arguments so it can be
used across master devices.

https://bugzilla.gnome.org/show_bug.cgi?id=783716
2017-07-20 14:11:26 +02:00
Jason Gerecke
3a83de295d wayland: Get implicit grab serial information from tablet devices
If a tablet device is used to perform actions like window moving or resizing,
GTK must provide the correct implicit grab serial number over Wayland to Mutter
in order for the action to succeed. This commit adds tablet support to the
implicit serial getters.

https://bugzilla.gnome.org/show_bug.cgi?id=777333
2017-07-20 12:23:15 +02:00
Jonas Ådahl
376ff1ae60 wayland: Throttle system bell requests
If a bad behaving application tries to make the window/display beep too
often, throttle the beep requests so that we don't end up filling the
Wayland socket queue.

The throttle is set to 50 beeps per second, which far more beeps than
will ever make any sense from a user experience point of view, but will
avoid terminating due to an excessive amount of requests.

https://bugzilla.gnome.org/show_bug.cgi?id=778188
2017-07-20 10:03:51 +08:00
Jonas Ådahl
f78585b7c3 wayland: Make beep requests go through the GdkDisplay
This way we can add things like throttling.

https://bugzilla.gnome.org/show_bug.cgi?id=778188
2017-07-20 10:03:43 +08:00
Mart Raudsepp
bb13421fd3 GdkWaylandWindow: Fix version numbers in export_handle() docs
This change appeared first in 3.22.16 release, not 3.22.13.

https://bugzilla.gnome.org/show_bug.cgi?id=782325
2017-06-22 05:39:25 +03:00
Carlos Garnacho
9e740bd435 gdk: Set vid/pid on wayland tablets
This was missed so far... Use %.4x format, in order to behave just
the same than X11.
2017-06-16 19:30:10 +02:00
Dan Torop
d9a9530f28 wayland: selectively cancel key repeat on key release
Under Wayland, when multiple keys are pressed and the user releases a
key, key repeat should continue unless the key released is the one
currently repeating.

In the case of:

- key1 press
- key1 repeat
- key2 press -> key1 repeat stopped
- key2 repeat
- key2 release

The behavior should be to cancel keyboard repeat, though key1 is still
held down. This is consistent with prior X11/XWayland behavior.

The following also must work:

- key1 press
- key2 press
- key2 release
- key2 press
- key1 release
- key2 should continue to repeat

The fix for bug #778019 should continue to work:

- key1 press
- key1 repeat
- key2 press -> key1 repeat stopped
- key1 release
- key2 should repeat

The choice to change the counter nkeys to the flag repeat_active
helps to solve the second test case.

https://bugzilla.gnome.org/show_bug.cgi?id=781285
2017-06-02 19:18:05 +02:00
Olivier Fourdan
2d41d772d7 wayland: fix xdg_surface test in move/resize drag
begin_resize_drag() and begin_move_drag() check for xdg_surface being
not null, but those apply on xdg_toplevel so they should check for
xdg_toplevel being non-null instead.

https://bugzilla.gnome.org/show_bug.cgi?id=781945
2017-06-02 15:54:50 +02:00
Olivier Fourdan
c94f40b893 wayland: check parent surface for subsurface
When an event is received while a tooltip is showing, the GtkTooltip's
event handling code can end up calling gdk_window_set_transient_for()
from gtk_tooltip_set_last_window().

The Wayland GDK backend will try to automatically create a subsurface
in gdk_wayland_window_set_transient_for() but if the parent surface is
gone meanwhile, this will will cause a crash when trying to create a
subsurface from a parent with a null surface.

Checking for the parent is not sufficient, we ought to check for the
parent surface as well to avoid the crash.

https://bugzilla.gnome.org/show_bug.cgi?id=782283
2017-06-02 15:43:34 +02:00
Olivier Fourdan
63e05158ea wayland: Do not map toplevel utility as popup
Applications can specify the type hint as utility even on toplevel
windows.

When that toplevel is also marked as a transient for another window,
GDK Wayland backend would translate that as an xdg_popup which is not
appropriate.

While utility temp windows should remain mapped as subsurfaces (such as
the ones used by treeviews), regular windows should not translate as
neither a subsurface nor an xdg_popup.

https://bugzilla.gnome.org/show_bug.cgi?id=781945
2017-06-02 15:16:13 +02:00
Debarshi Ray
bebd5020ec wayland: Don't warn if the display is lost, skip exit handlers
There is no need to have every application log a warning when the
Wayland display server goes away, and we are using _exit instead of
exit elsewhere.

This is also what the X11 backend does (see gdk_x_io_error).

https://bugzilla.gnome.org/show_bug.cgi?id=745289
2017-05-30 09:16:45 +02:00
Debarshi Ray
425e4df100 wayland: Don't abort when preparing the source if connection is lost
Aborting the application makes it look like an application bug, when
it is the expected thing to do when the Wayland display server goes
way. eg., when the user logs out. The log level is also demoted to
avoid a storm of warnings in the log from all applications whenever
this happens.

This is also what the X11 backend does (see gdk_x_io_error).

https://bugzilla.gnome.org/show_bug.cgi?id=783047
2017-05-25 11:53:15 +02:00
Jonas Ådahl
dba57db1f3 GdkWaylandWindow: Allow calling export() multiple time
Allow getting the same export handle multiple times by calling
gdk_wayland_window_export_handle() multiple times. For each time
export() is called, a unexport() must be called to unexport.

When the window is already exported, the exported callback is called
via a idle handler. If there are multiple export() calls, they are
invoked in order either when the handle is received by the display
server, or when the idle callback is invoked.

Calling unexport() will not affect future invokations of the exported
callback, unless all export() calls have their unexport() call count
matched.

https://bugzilla.gnome.org/show_bug.cgi?id=782325
2017-05-23 09:39:29 +08:00
Jonas Ådahl
31c72bd7df GdkWaylandWindow: Unexport when finalizing
The application might not have exported, and it'll be too late for it
at this point anyway, so lets be helpful and not leak it.

https://bugzilla.gnome.org/show_bug.cgi?id=782109
2017-05-09 10:16:32 +08:00
Jonas Ådahl
64312d79f7 wayland: Remove self assignment
Don't assign the value of a variable to itself. It was added just for
clarity, but it makes coverity complain, so remove it.

https://bugzilla.gnome.org/show_bug.cgi?id=780301
2017-05-08 17:51:41 -04:00
Jonas Ådahl
6f326a71d4 wayland: Use correct enum type and values
Use the gravity enum values when converting to gravity. It doesn't fix
anything, since the enum values were identical, but it makes a coverity
warning go away.

https://bugzilla.gnome.org/show_bug.cgi?id=780301
2017-05-08 17:51:30 -04:00
Matthias Clasen
7c66c68f48 Revert "GdkWaylandWindow: Unexport when finalizing"
This reverts commit ab4e4bd3ae.
2017-05-08 16:00:49 -04:00
Jonas Ådahl
ab4e4bd3ae GdkWaylandWindow: Unexport when finalizing
The application might not have exported, and it'll be too late for it
at this point anyway, so lets be helpful and not leak it.

https://bugzilla.gnome.org/show_bug.cgi?id=782109
2017-05-08 15:47:12 -04:00
Jonas Ådahl
e016d9a5db GdkWaylandWindow: Clear export user data when used
It was only cleared when unexported, but we could just as well clear it
when its used too.

https://bugzilla.gnome.org/show_bug.cgi?id=782109
2017-05-08 15:47:12 -04:00
Olivier Fourdan
c770b5cbbc wayland: make key event log more explicit
With Wayland, GDK_DEBUG=events would log key events but not explicitly
state whether the event is a key press or release, or if it's
originating from a key repeat.

Add some more verbosity to make sure these informations are logged on
key delivery when GDK_DEBUG is set.

https://bugzilla.gnome.org/show_bug.cgi?id=781767
2017-04-28 13:08:37 +02:00
Florian Müllner
a866937d08 gdk: Relicense translate_wm_button_layout_to_gtk()
It is generally a good idea to license individual files under the
same terms as the project license (in particular when the mismatch
boils down to having copied the wrong license header), so relicense
the code under the LGPL.

https://bugzilla.gnome.org/show_bug.cgi?id=781422
2017-04-27 21:06:15 +02:00