Commit Graph

1661 Commits

Author SHA1 Message Date
Matthias Clasen
1d40f29776 wayland: Make gdk_wayland_device_pad_set_feedback private
It is not a generally useful api, and awkwardly named.
2020-10-15 12:00:00 -04:00
Jonas Ådahl
7dfb25f124 wayland/surface: Clear has_uncommitted_ack_configure when hiding
The 'has_uncommitted_ack_configure' state was added to make sure we're
responding to 'xdg_surface.configure' events with
'xdg_surface.ack_configure' requests, as is necessary according to spec.
What we didn't do was to clear this state when hiding, meaning that if
we hid the surface after a configure event, but before the frame
finished and we processed the 'has_uncommitted_ack_configure', we'd try
to acknowledge the surface configuration after having destroyed the
surface.

Closes: #3262
2020-10-15 14:56:06 +02:00
Emmanuele Bassi
9377192102 Correctly annotate gdk_wayland_seat_get_wl_seat()
We expect a `GdkWaylandSeat` as the instance parameter.
2020-10-14 11:57:06 +01:00
Emmanuele Bassi
da007ac97b Add a public header for GdkWaylandSeat
We have public API requiring it as a type.
2020-10-14 11:55:34 +01:00
Emmanuele Bassi
13aa053f6b Rename libgtk_only symbol in GdkWaylandToplevel
All public non-exported symbols in GDK can be used by GTK.
2020-10-12 16:49:10 +01:00
Emmanuele Bassi
38304fc138 Hide gdk_wayland_display_prefers_ssd()
The function is not exported, so it should not be in a public header.
2020-10-12 16:44:05 +01:00
Emmanuele Bassi
da6c0f3ecb Move private GdkSurface Wayland API into its own header
This allows us to hide private API from installed headers,
documentation, and introspection.
2020-10-12 16:40:19 +01:00
Emmanuele Bassi
f83ee2ab6a Add type annotations for GdkWayland API
The GdkWayland API takes generic GDK types and performs a run time
check, which means we need to properly annotate the actual expected
type in order to have methods recognised as such.
2020-10-12 14:07:26 +01:00
Emmanuele Bassi
33e84edf0c Skip GdkWayland symbols that use wayland-client types
The wayland-client API does not have introspection annotations, so we
can't use these types anyway.
2020-10-12 14:07:26 +01:00
Matthias Clasen
e602d67e59 wayland: Stop using gdk_surface_new_temp
No need to roundtrip through the frontend to create
one of our own surfaces.
2020-10-07 21:02:22 -04:00
Matthias Clasen
082edd957e wayland: Don't forget to reapply margins
When using the saved size because the compositor
told us to, we were forgetting to readd the margins.

The visible symptom of this was the window getting
smaller every time we went to tiled state and back.
2020-10-05 20:17:50 -04:00
Matthias Clasen
e5cd2568c8 wayland: Don't save size when tiled
Don't remember the surface size when we are in tiled
state either. This matches the 'fixed_size' condition
in gdk_wayland_surface_configure_toplevel.

This change fixes an issue where moving a window first
to tiled, then to maximized state and back would lead
to the unmaximized window having the tiled dimensions.
2020-10-05 20:15:33 -04:00
Matthias Clasen
d51608a2c9 wayland: Don't emit premature configure events
We should not emit configure events before we are realized - size
changes at this point are not relevant.

This gets rid of a mysterious emission of GdkSurface::size-changed
with a size of 52x52, that is happening when GtkWindow sets the
shadow_width before the window is mapped.
2020-10-05 17:18:14 -04:00
Matthias Clasen
165768b6ad wayland: Match header and doc arguments
gtk-doc doesn't take this lightly.
2020-09-29 07:04:07 -04:00
Robert Mader
9ea0469ab0 gdk/wayland: Replace gtk-primary-selection with primary-selection-unstable-v1
The later is the public upstream version, while identical implementation wise.

https://gitlab.gnome.org/GNOME/gtk/-/issues/2591
2020-09-27 16:23:42 +02:00
Matthias Clasen
bb402a1f1d wayland: Fix grabbing popup
A typo snuck into commit 3023a61e1d that
caused us to fail all grabbing popups with
"grab failed: not viewable". Fix that.
2020-09-20 10:02:53 -04:00
Matthias Clasen
93cfa3855c Merge branch 'wayland-backend-api-cleanup' into 'master'
wayland: Change backend api to use GdkToplevel

See merge request GNOME/gtk!2598
2020-09-19 18:19:18 +00:00
Matthias Clasen
dd0da0f3cc passwordentry: Add an ::activate signal
GtkSearchEntry has one, no reason why GtkPasswordEntry
should not as well.

Fixes: #3174
2020-09-19 13:25:03 -04:00
Matthias Clasen
3023a61e1d wayland: Change backend api to use GdkToplevel
Most of the surface api we have in the Wayland backend
only makes sense for toplevels, so reshuffle things to
take a GdkToplevel instead of a GdkSurface.

Update all callers and the docs.
2020-09-19 13:07:11 -04:00
Jonas Ådahl
4200936f21 wayland/surface: Make sure to commit ack_configure
We must wl_surface.commit after xdg_surface.ack_configure to make it
have an effect. We failed to do so when a configure event didn't result
in new updates, so make sure we fall back on an simple
wl_surface.commit if there was no new actual frame painted.

Closes: #2910
2020-09-17 18:20:08 +02:00
Jonas Ådahl
1abcd6f304 wayland: Commit surface from cairo context
In order to make the cairo renderer/context behave more similar to how
the OpenGL and Vulkan renderer/context behaves, request a frame callback
and commit in the end frame vfunc.

This means the end frame vfunc in cairo does

 * attach buffer
 * request frame callback
 * sync surface state
 * commit

Where as e.g. the OpenGL version of the same flow does

 * attach buffer
 * request frame callback
 * sync surface state
 * eglSwapBuffers()

where eglSwapBuffers() indirectly calls wl_surface_commit().
2020-09-17 17:35:35 +02:00
Jonas Ådahl
f87de393b5 wayland/surface: Remove 'committed' signal
It wasn't used by anything anymore, lets remove it.
2020-09-17 16:01:08 +02:00
Matthias Clasen
929a56e53c Clean up lots of GTK+ -> GTK
Replace most remaining uses of GTK+ in the docs and
user-visible strings by GTK. Also remove some leftover
"Was added in 3.x" sentences from the docs.
2020-09-12 12:01:04 -04:00
Matthias Clasen
93078e52c0 gdk: Rename GdkSurfaceState to GdkToplevelState
That is what it is.

Fixes: #2790
2020-09-10 00:39:03 -04:00
Matthias Clasen
ccb447da02 Merge branch 'wip/baedert/for-master' into 'master'
Wip/baedert/for master

Closes #2777

See merge request GNOME/gtk!2503
2020-08-31 16:30:21 +00:00
Julien Ropé
665955b81e Fix resource leak in gdk_display_close() under Wayland
When using the gdk_display_close(), the handle to the Wayland compositor was not released. This could cause the consumption of all available handles, preventing other processes from accessing the display.

Fixing this by calling wl_display_disconnect() when releasing the GdkWaylandDisplay object.

Signed-off-by: Julien Ropé <jrope@redhat.com>
2020-08-31 17:46:18 +02:00
Timm Bäder
b0d89b1882 wayland: Fix a GSettingsSchema leak 2020-08-29 16:46:28 +02:00
Matthias Clasen
81e113d8aa Merge branch 'wip/carlosg/shuffle-font-mouse-settings' into 'master'
Look up font and mouse settings in gsettings-desktop-schemas

See merge request GNOME/gtk!2489
2020-08-27 00:08:45 +00:00
Alexander Mikhaylenko
0a59429dc8 wayland: Fix dnd hotspot movement
_gdk_wayland_surface_offset_next_wl_buffer() moves the surface relatively
to its current position, pass it a delta instead of new position.
2020-08-27 04:04:48 +05:00
Carlos Garnacho
6421355065 gdk/wayland: Use double-click/drag-threshold settings from g-d-s
Handle both these settings, and the older settings-daemon ones for
backwards compatibility. The keys are already checked for existence
in the schema, so it will just use the existing ones.
2020-08-27 00:27:50 +02:00
Carlos Garnacho
536966e848 gdk/wayland: Look for font settings in gsettings-desktop-schemas
Prefer this location, but also look for the old location in
settings-daemon for backwards compatibility. This applies to both
direct settings lookups and via the settings portal.
2020-08-27 00:18:09 +02:00
Matthias Clasen
0d82fcf76f wayland: Drop unused argument from query_state
Now that this is backend-only api, we can just
drop unused arguments.
2020-08-26 17:56:41 -04:00
Matthias Clasen
0091de63b4 wayland: Fix return value of get_device_state
We need to look a the position, not the child surface.
2020-08-26 17:56:41 -04:00
Matthias Clasen
8c9e1e7444 wayland: Stop using the query_state vfunc
Just call the backend implementation directly.
2020-08-26 17:56:41 -04:00
Matthias Clasen
125ed52ccb Merge branch 'new-sysprof' into 'master'
Port profiling to sysprof-collector api

See merge request GNOME/gtk!2457
2020-08-21 23:58:09 +00:00
Matthias Clasen
d4e069a629 Port tracing to the sysprof collector api
Use the new sysprof collector api to do tracing.
2020-08-21 10:55:01 -04:00
Björn Daase
6315cd977c *: Fix spelling mistakes found by codespell 2020-08-21 15:29:34 +02:00
Matthias Clasen
3d7343144f wayland: Drop unused surface type hint field
This wasn't used at all.
2020-08-13 22:24:06 -04:00
Matthias Clasen
a85fc0008c wayland: Don't send invalid anchor rectangles
When we send an anchor rectangle with a width or
height of 0, mutter reponds with "Invalid anchor
rectangle size". So, don't do that.

This was seen as sudden disappearance of gtk4-demo
when you click the fishbowl benchmark all the way
through to the menubuttons.

Fixes: #3027
2020-08-09 16:02:25 -04:00
Jonas Ådahl
6724d4250f wayland/toplevel: Don't leak wl_callback used during present() 2020-08-07 14:01:16 +02:00
Jonas Ådahl
c27f811462 wayland/surface: Destroy toplevel present callback if ignored
We might break the loop early, e.g. if we're unmapped before the round
trip finishes, and to avoid the callback to write to invalid stack
memory, destroy the callback so it won't be invoked.

Fixes: #3026
2020-08-07 09:06:21 +02:00
Jonas Ådahl
3590923c8b wayland/surface: Fix toplevel present roundtrip condition
We should round trip until we both have received callback and have
ensured we received the initial configuration.
2020-08-07 09:06:21 +02:00
Matthias Clasen
12450cfcef wayland: Don't leak content formats
We were not unreffing the formats here.
2020-08-06 20:02:33 -04:00
Matthias Clasen
1d7b273669 docs: Clean up dangling links in gdk docs
Clean up references to no-longer-existing APIs.
2020-08-05 15:45:43 -04:00
Jonas Ådahl
2ff74eb667 gdk/toplevel: Negotiate surface size via a compute-size signal
GTK will not up front know how to correctly calculate a size, since it
will not be able to reliably predict the constraints that may exist
where it will be mapped.

Thus, to handle this, calculate the size of the toplevel by having GDK
emitting a signal called 'compute-size' that will contain information
needed for computing a toplevel window size.

This signal may be emitted at any time, e.g. during
gdk_toplevel_present(), or spontaneously if constraints change.

This also drops the max size from the toplevel layout, while moving the
min size from the toplevel layout struct to the struct passed via the
signal,

This needs changes to a test case where we make sure we process
GDK_CONFIGURE etc, which means we also needs to show the window and
process all pending events in the test-focus-chain test case.
2020-08-05 15:49:00 +02:00
Carlos Garnacho
96452a2e46 gdk: Rename gdk_seat_get_physical_devices() to gdk_seat_get_devices()
We don't want to tell what they are, and the distinction is now less
clear. Remove the adjective from the function name.
2020-07-30 18:44:40 +02:00
Carlos Garnacho
46eb054337 gdk: Drop gdk_device_get_device_type()
There is no longer a hierarchy of devices, or none that is seen
on the outside.
2020-07-30 18:44:40 +02:00
Benjamin Otte
4dc2ab61c9 Merge branch 'wip/otte/geometry' into 'master'
Some GdkGeometry cleanups

See merge request GNOME/gtk!2322
2020-07-30 15:31:27 +00:00
Benjamin Otte
b12b06e917 gdk: Remove base_size and increment from GdkGeometry
It's unused.
2020-07-30 16:55:45 +02:00
Matthias Clasen
7df070d681 gdk: Move default group api to the X11 backend
This is the only place where it is implemented.
2020-07-29 22:58:37 -04:00
Carlos Garnacho
cab1dcb696 gdk: Conflate GDK devices
Make GdkEvents hold a single GdkDevice. This device is closer to
the logical device conceptually, although it must be sufficient for
device checks (i.e. GdkInputSource), which makes it similar to the
physical devices.

Make the logical devices have a more accurate GdkInputSource where
needed, and conflate the event devices altogether.
2020-07-29 01:27:51 +02:00
Carlos Garnacho
25ea17a6fc gdk: Drop source_device argument from _gdk_display_device_grab_update()
It's just passed around and used nowhere.
2020-07-29 01:27:51 +02:00
Carlos Garnacho
4a2bbed157 gdk: Make events hold an axis array matching GdkAxisUse
Instead of doing device-specific translations of array positions,
use GdkAxisUse as an array index right away.
2020-07-29 01:27:51 +02:00
Carlos Garnacho
b52ad33031 gdk: Add gdk_seat_get_tools() API call
There's GdkSeat::tool-added and ::tool-removed, but there's no
API to query the known tools. Add this call.
2020-07-29 00:11:34 +02:00
Carlos Garnacho
a2876b5cb4 gdkdevice: Remove gdk_device_get_state()
This is not needed nor recommended anymore, all reasons to maybe
need this were all kept within gdk.
2020-07-28 17:36:18 +02:00
Benjamin Otte
3078b180fe Replace "gdouble" with "double" 2020-07-25 00:47:36 +02:00
Benjamin Otte
d375dce9f5 Replace "gchar" with "char" 2020-07-25 00:47:36 +02:00
Benjamin Otte
d7266b25ba Replace "gint" with "int" 2020-07-25 00:47:36 +02:00
Emmanuel Gil Peyrot
74a4432688 gdk/wayland: Add an API to inhibit and uninhibit idle
This uses the idle-inhibit protocol from wayland-protocols, to attach an
inhibitor to the GdkSurface.  The inhibit function can be called as many
times as the user wants, but the uninhibit function MUST be called as
many times to unset the idle inhibition.

This has been tested on Sway.
2020-07-14 21:47:22 +02:00
Caolán McNamara
7e97c2513f 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 15:56:12 +01:00
Matthias Clasen
d46b04631e wayland: Respect GDK_DEBUG=default-settings
You can get this in other ways for Wayland (by
setting GSETTINGS_BACKEND=memory), but it is better
to be consistent across backends.
2020-06-28 13:42:02 -04:00
Carlos Garnacho
7be6afe84d gdk: Depend less on gdk_event_get_device()
For the most part, we are interested in seats here.
2020-06-23 23:42:53 +02:00
Carlos Garnacho
6d2860efb7 gdk: Drop gdk_seat_get_logical_pointers()
Events come from hardware devices and are handled by controllers,
there's no need to use logical pointers, nor to peek them. Drop this
unused API.
2020-06-23 23:42:53 +02:00
Carlos Garnacho
5f29b8fcec gdk: Drop GdkGrabOwnership
We no longer expose such low level tweaks, this is essentially
unused.
2020-06-23 23:42:53 +02:00
Carlos Garnacho
c1d90273ca gdk: Drop GDK_SOURCE_ERASER
All tools come from devices with GDK_SOURCE_PEN.
2020-06-23 23:42:53 +02:00
Emmanuele Bassi
1c856a208f Rename master and slave device
We already use the "logical/virtual" and "physical" names in the
documentation, there's no reason to use loaded terms just because X11
uses them.
2020-06-18 19:22:20 +01:00
Matthias Clasen
2c82151d65 gdk: Drop axis labels
This was only ever implemented on X11, and the labels
here were atom names, so unlikely to be useful for
anything interesting.
2020-06-10 07:36:30 -04:00
Matthias Clasen
876560924f wayland: Drop a pointless vfunc
A vfunc that just returns FALSE is not useful.
2020-06-08 18:24:20 -04:00
Sebastian Keller
2bd938952d 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 20:44:55 +02:00
Benjamin Otte
3c1cca13b7 wayland: Remove function declaration for nonexisting function 2020-05-30 10:46:49 -04:00
Yuri Chornoivan
01bd4cc4e1 Fix minor typos 2020-05-28 11:00:03 +03:00
Matthias Clasen
ec39ddee63 Help static analysis with an assertion
It is hard for clang to see that layouts will
always be smaller than num_layouts, so just assert
that.
2020-05-25 20:56:09 -04:00
Timm Bäder
ae711d8301 gdkdisplay-wayland: only remove one monitor
Ids here are unique, so break out of the loop once we found the monitor
with the given ID.
2020-05-20 15:51:11 +02:00
Christian Hergert
fa08d848ca device: remove get_toplevel from surface_at_position vfunc
This is not used anymore now that surfaces are always toplevel in the
semantics of GdkWindow where child windows were available. We can drop
that and simplify the vfunc just a bit more.

Fixes #2765
2020-05-19 13:07:38 -07:00
Matthias Clasen
d6818475d7 gdk: Simplify gdk_display_supports_input_shapes
Make this a display property, and do away with
the vfunc in favor of a private setter, to match
how we handle other display characteristics.
2020-05-17 22:05:24 -04:00
Matthias Clasen
287c40276a gdk: Drop gdk_display_supports_shapes
The apis to set shapes on surfaces are gone,
so there is no point in providing this information
on GdkDisplay.
2020-05-17 21:52:15 -04:00
Matthias Clasen
71bad81aff gdk: Make gdk_drag_begin take doubles
This is a better fit to the way we treat coordinates
everywhere else.
2020-05-17 17:51:03 -04:00
Matthias Clasen
c0faf0c6b6 Merge branch 'toplevel-move-resize' into 'master'
Toplevel move resize

See merge request GNOME/gtk!1923
2020-05-17 19:15:46 +00:00
Matthias Clasen
1e8a58e367 gdk: Move the begin_move/resize_drag vfuncs around
Move these from GdkSurface to GdkToplevel, where they
belong. Update all backends.
2020-05-17 14:15:06 -04:00
Benjamin Otte
b353221185 Merge branch 'wip/otte/monitors' into 'master'
various GDK cleanups

See merge request GNOME/gtk!1920
2020-05-17 16:57:52 +00:00
Benjamin Otte
4c7914dc49 display: Remove unneeded getters
Applications can use the listmodel instead.
2020-05-17 07:32:37 +02:00
Benjamin Otte
9a30019268 display: Remove the monitor signals
Applications can listen to GdkDisplay:monitors::items-changed if they
want to track monitor changes.
2020-05-17 07:10:34 +02:00
Benjamin Otte
e81a1db48c monitor: Add gdk_monitor_set_geometry()
Make it replace gdk_monitor_set_size() and gdk_monitor_set_position()
which used to be called in pairs anyway.
2020-05-17 07:10:34 +02:00
Benjamin Otte
0c6266fd1a surface: Remove gdk_surface_is_viewable()
It returns the same value as gdk_surface_get_mapped(), so use that
instead.
2020-05-17 00:41:44 +02:00
Carlos Garnacho
000487c36c 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).
2020-05-15 23:40:18 +02:00
Matthias Clasen
8912a6eb75 gtk: Handle seatless displays
If you run weston with the headless backend, you get a Wayland
display with no seat, which is just fine by the protocol.

gdk_display_get_default_seat() returns NULL in this case. Various
widgets assume that we always have a seat with a keyboard and a
pointer, since that is what X guarantees. Make things survive
without that, so we can run the testsuite under a headless
Wayland compositor.
2020-05-15 14:11:53 -04:00
Benjamin Otte
dd7d76f389 gdk: Add gdk_display_get_monitors()
Returns a GListModel of GDK_TYPE_MONITOR.

This will replace the current andling of monitors in GdkDisplay.
2020-05-13 07:00:35 +02:00
Benjamin Otte
3536bdd7a6 wayland: Use a GListStore for the monitors
Guess where this is going...
2020-05-13 04:51:52 +02:00
Carlos Garnacho
e33af5895f gdk/wayland: Drop explicit ungrab after surface move/resize
We now break grabs properly if receiving a .leave event with
active buttons. This is not necessary anymore.
2020-05-12 14:14:39 +02:00
Carlos Garnacho
f7d2985f89 gdk/wayland: Ensure .leave events with active buttons breaks grabs
Instead of silently ending up the grab, make it sure that we emit
a GDK_GRAB_BROKEN event if needed.
2020-05-12 14:14:39 +02:00
Timm Bäder
85237c8665 gdkdisplay-wayland: Fix a possibly uninitialized out value 2020-05-05 08:20:09 +02:00
Matthias Clasen
99c3928cec keymap: Cache key info
We currently calling gdk_display_map_keyval up to
once per key event per shortcut trigger, and that function
does an expensive loop over the entire keymap and
allocates an array. Avoid this by caching the entries
in a single array, and have a lookup table for finding
the entries for a keyval.

To do this, change the GdkKeymap.get_entries_for_keyval
signature, and change the ::keys-changed signal to be
RUN_FIRST, since we want to clear the cache in the class
handler before running signal handlers. These changes are
possible now, since keymaps are no longer public API.
2020-04-30 13:05:52 -04:00
Matthias Clasen
e1b25eaf5a wayland: Fall back to an unthemed default cursor
In the absence of icon themes (such as in a freshly
created toolbox container), we should not just fall back
to "no cursor", since that makes it hard even to close
the application. Fall back to an included default cursor
of last resort.
2020-04-26 14:42:45 -04:00
Carlos Garnacho
41b7f03d55 gdk/wayland: Ensure to clean up stale touchpoint data on surface destroy
If the wl_surface receiving touch events is destroyed, we will get no
wl_touch.up event to remove the touchpoint from our internal accounting.
Check for this, and drop touchpoints happening in surfaces that do
disappear during operation.
2020-04-24 23:11:00 +02:00
Jonas Ådahl
ab59459f7a wayland: Don't continue showing if xdg_popup creation failed
We don't create a grabbing popup if it's not the top most one, as that
is a protocol violation, and complain if anything attempts to do it.
What we didn't do is handle this gracefully in the code that tries to
create said popup.

Fix this by dropping the attempt to show the popup on the floor, instead
of setting various state making it look like it succeeded. This won't
actually fix anything, but it'll result in a bit more accurate warnings
logged, as the state more correctly corresponds to the reality.
2020-04-18 22:57:25 +02:00
Emmanuele Bassi
f28aa1ba02 Restructure the GdkEvent type hierarchy
GdkEvent has been a "I-can't-believe-this-is-not-OOP" type for ages,
using a union of sub-types. This has always been problematic when it
comes to implementing accessor functions: either you get generic API
that takes a GdkEvent and uses a massive switch() to determine which
event types have the data you're looking for; or you create namespaced
accessors, but break language bindings horribly, as boxed types cannot
have derived types.

The recent conversion of GskRenderNode (which had similar issues) to
GTypeInstance, and the fact that GdkEvent is now a completely opaque
type, provide us with the chance of moving GdkEvent to GTypeInstance,
and have sub-types for GdkEvent.

The change from boxed type to GTypeInstance is pretty small, all things
considered, but ends up cascading to a larger commit, as we still have
backends and code in GTK trying to access GdkEvent structures directly.
Additionally, the naming of the public getter functions requires
renaming all the data structures to conform to the namespace/type-name
pattern.
2020-04-16 19:54:02 +01:00
Matthias Clasen
209398d736 wayland: emit ::enter/leave-monitor
These signals directly mirror the surface_enter/leave events
of the Wayland protocol, so this is very staightforward.
2020-04-13 07:54:31 -04:00
Matthias Clasen
754d6d1a04 wayland: Avoid criticals when unsetting transient parents
Must not check the display when parent is NULL.
2020-04-12 12:10:18 -04:00
Jonas Ådahl
458b8a6554 wayland: Move transient-for field to GdkWaylandToplevel
A toplevel will only ever be transient-for to another toplevel, and only
a toplevel will ever be transient-for, so move the field into the
GdkWaylandToplevel, and make it a pointer to another GdkWaylandToplevel.
2020-04-08 23:32:47 +02:00
Jonas Ådahl
307cc69adb wayland: Add surface to toplevel list only if toplevel
It was using another check (has parent) to do this, but now we have a
much more obvious way of creating surfaces, so we can use the type
directly.
2020-04-08 23:32:47 +02:00
Jonas Ådahl
ab6b5ae568 wayland: Remove own pointer to the popup parent
It's there already as the GdkSurface::parent, no need to duplicate.
2020-04-08 23:32:47 +02:00
Jonas Ådahl
0e601c0a70 wayland: Move toplevel/popup/drag surface definitions higher up
We them up there, so that code higher up compared to where they are
defined now can make use of them. Also add a few macros for type
checking and casting.
2020-04-08 23:32:47 +02:00
Jonas Ådahl
5425edff82 wayland: Move popups with xdg_popup.reposition
The third version of xdg-shell introduces support for explicit popup
repositioning. If available, make use of this to implement popup
repositioning.

Note that this does *NOT* include atomic parent-child state
synchronization. For that,
https://gitlab.freedesktop.org/wayland/wayland-protocols/issues/13 will
be needed.

This currently uses my own fork of wayland-protocols which adds meson
support, so that we can use it as a subproject. Eventually when
wayland-protocols' meson support lands upstream, we should change it to
point there.

Silence some meson warnings while at it to make CI happy.

This also bumps the glib requirement, since g_warning_once() is used.
2020-04-08 23:32:47 +02:00
Matthias Clasen
dce8d251c6 keymap: Remove virtual modifier mapping functions
These are not used anymore.

Drop the vfuncs and their implementations in the
broadway, x11, wayland and win32 backends as well.
2020-04-06 16:32:03 -04:00
Matthias Clasen
89ad7893ad gdk: Make GdkKeymap a private api
We have replacement apis in GdkDevice and GdkDisplay.
2020-04-06 16:32:03 -04:00
Matthias Clasen
0a96a483c6 gdk: Redo key events
Add all of the keyboard translation results in the key event,
so we can translate the keyboard state at the time the event
is created, and avoid doing state translation at match time.

We actually need to carry two sets of translation results,
since we ignore CapsLock when matching accelerators, in
gdk_event_matches().

At the same time, drop the scancode field - it is only ever
set on win32, and is basically unused in GTK.

Update all callers.
2020-04-06 15:13:54 -04:00
Matthias Clasen
7fa103717d wayland: Stop setting MOD2..MOD5
These are going away in the GdkModifierType cleanup.
2020-04-06 01:40:49 -04:00
Matthias Clasen
b02db72e17 Rename GDK_MOD1_MASK to GDK_ALT_MASK
We've hardcoded Mod1 = Alt for a long time, there is
no need to keep the confusing naming around anymore.
2020-04-06 01:40:49 -04:00
Matthias Clasen
e165267924 wayland: Notify new device properties 2020-04-06 01:40:49 -04:00
Matthias Clasen
cffa45d5ff wayland: Add a comment about keyboard state handling
Clarify a point that took me a few hours to fully track
down, so lets preserve what I found for the next poor
sould coming this way.
2020-04-02 17:43:14 -04:00
Jan Alexander Steffens (heftig)
7444b15d47 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 16:18:18 -04:00
Olivier Fourdan
36d986f33c wayland: Implement inhibit_system_shortcuts API
On Wayland, this is a direct mapping with the inhibit shortcut protocol
that GDK already supports.

Simply wire the new API to the existing entries.
2020-03-30 18:25:36 +02:00
Olivier Fourdan
5ac73be976 wayland: Use a GdkSeat as key for our internal hash table
With the current implementation, we use a `wl_seat` as the key for our
internal has table where we store the Wayland shortcuts inhibitors.

There is however no technical reason for this, and we could use a
GdkSeat instead, which will ease the implementation of the GdkToplevel
shortcut inhibition API.
2020-03-30 18:25:36 +02:00
Matthias Clasen
1576cced0f Drop GdkToplevel:accept-focus/:focus-on-map
These properties were only ever implemented in the
X11 backend. If you want to use them, just use the
X properties directly.
2020-03-14 19:28:00 -04:00
Matthias Clasen
32b9dd64db Drop GdkToplevel:keep-above/below
These properties were only ever implemented in the X11
backend. If you want to keep windows above or below
on X11, just use the X properties.
2020-03-14 15:46:55 -04:00
Matthias Clasen
60ea97187a Drop GdkToplevel:sticky
This was only ever implemented on X11. If you
want to use it there, just use the X properties
yourself.
2020-03-14 15:16:18 -04:00
Matthias Clasen
331069f378 wayland: Stop capping cursor scales
We don't load entire themes anymore, so we can
easily accomodate larger cursor scales now.
2020-03-13 11:13:02 -04:00
Matthias Clasen
3e06a9b1d2 Drop root coordinates from _gdk_device_query_state
Callers are not using them anyway. Update all callers.
2020-03-12 15:30:11 -04:00
Matthias Clasen
f020d77a23 Move fullscreen-mode to GdkToplevel 2020-03-12 15:30:11 -04:00
Matthias Clasen
81be6ff46b Move edge-constraints to GdkToplevel 2020-03-12 15:30:11 -04:00
Matthias Clasen
651b746747 wayland: Drop some unused vfuncs
show, withdraw, raise, lower, toplevel_resize,
present_popup,
are all unused in the frontend.
2020-03-12 15:30:10 -04:00
Matthias Clasen
7e15a13f48 wayland: Drop dead code 2020-03-12 15:30:10 -04:00
Matthias Clasen
a2dbc729f6 wayland: Stop using surface-type 2020-03-12 15:30:10 -04:00
Matthias Clasen
5a516f2a22 wayland: Stop using surface types 2020-03-12 15:30:10 -04:00
Matthias Clasen
cd773e7cb3 wayland: Implement GdkPopup, GdkToplevel and GdkDragSurface
Make subclasses of GdkWaylandSurface that implement these
interfaces.
2020-03-12 14:56:21 -04:00
Matthias Clasen
f7aec64e6f wayland: Stop using gdk_surface_set_title
Directly call the backend function for this, and for
gdk_surface_set_transient_for.
2020-03-12 14:56:20 -04:00
Matthias Clasen
6c44f7bf07 wayland: Stop tracking orphan dialogs
Wayland has no concept of transient-for-group. If we want to
support that, add proper proper protocol for it, don't hack it
in this like.
2020-03-11 19:35:56 -04:00
Matthias Clasen
b2ae6ce8ff surface: Rename gdk_surface_input_shape_combine_region
There is no shape combining going on anymore, so
call this just gdk_surface_set_input_region, and
remove the offset arguments too. All callers pass
0 anyway.

Update all callers and implementations.
2020-03-11 19:35:56 -04:00
Matthias Clasen
29606af03e wayland: Stop using gdk_surface_set_geometry_hints
Just use the backend function directly.
2020-03-11 19:35:56 -04:00
Matthias Clasen
5acbfce264 wayland: Stop abusing type hints
Instead of misusing window type hints, introduce
a private flag for drag surfaces.
2020-03-11 19:35:55 -04:00
Matthias Clasen
c2f25c0c2f wayland: Stop calling frontend surface api
This is an unnecessary vfunc roundtrip, and the
frontend api is going away shortly.
2020-03-11 19:35:55 -04:00
Benjamin Otte
e356d59a92 build: Add -Wnull-dereference
Sprinkle various g_assert() around the code where gcc cannot figure out
on its own that a variable is not NULL and too much refactoring would be
needed to make it do that.

Also fix usage of g_assert_nonnull(x) to use g_assert(x) because the
first is not marked as G_GNUC_NORETURN because of course GTester
supports not aborting on aborts.
2020-03-05 08:14:37 +01:00
Benjamin Otte
7cd728a0ea gdk: Make gdk_drop_status() take preferred action
This allows textview/text dnd to properly display a MOVE icon when in
the widget the drag started from but a COPY icon otherwise.
2020-03-02 04:43:56 +01:00
Matthias Clasen
7a39f2d49d Replace gdk_surface_is_visible by _get_mapped
The property  is called ::mapped, and we want to get
to standard getter naming.
2020-02-24 19:07:03 -05:00
Matthias Clasen
6be9e44786 gdk: Drop GdkDevice::input-mode and rename ::input-source
Drop the input-mode, since it only makes sense for
floating devices, which we don't have anymore. And renamt
::input-source to ::source, to match the getter.

Update all users.
2020-02-24 14:38:42 -05:00
Benjamin Otte
60307da5b1 wayland: Replace final mention of GdkAtom 2020-02-23 01:59:26 +01:00
Benjamin Otte
28dced597f gdk: Remove gdk_text_property_to_utf8_list_for_display()
A lot of files became empty now, so they have been removed, which makes
this commit seem larger than it is.
2020-02-23 01:59:26 +01:00
Benjamin Otte
6442ec2f8d gdk: Remove gdk_utf8_to_string_target()
Only keep the X11 version around in the backend.
2020-02-23 01:59:00 +01:00
Benjamin Otte
b0f6996892 gdk: Remove gdk_surface_register_dnd()
All surfaces are expected to be DND surfaces from creation.
2020-02-23 01:59:00 +01:00
Matthias Clasen
7edfcc37a3 Merge branch 'wip/wayland-fix-popup-grabs' into 'master'
Fix Wayland popup grabs

See merge request GNOME/gtk!1463
2020-02-22 20:51:32 +00:00
Jonas Ådahl
f0b0076a1c wayland/popup: Emit un-withdrawn event earlier
Otherwise grabbing the seat will appear to have failed.
2020-02-22 20:09:38 +01:00
Jonas Ådahl
71323a8b48 wayland/popup: Remove unnecessary checks when mapping popup
We only call this when we're not already mapped so don't check that. We
also only call this when we should be mapped so don't check that either.
2020-02-22 20:08:37 +01:00
Benjamin Otte
b002572824 Merge branch 'wip/otte/dnd' into 'master'
stuff

See merge request GNOME/gtk!1460
2020-02-22 14:53:13 +00:00
Matthias Clasen
76e115b910 Add a warning when a grab fails
This reveals that the grabs for popover menus
always fail now, causing the menus to not properly
hide.
2020-02-22 08:11:34 -05:00
Benjamin Otte
ce3ed45e81 surface: Inline function
Fixes compile error with -DG_DISBALE_CHECKS
2020-02-22 07:33:40 +01:00
Jonas Ådahl
2f13ac2e4d gdk/wayland: Avoid relayout with the same properties
When a popup is already showing, and gdk_surface_present_popup() is
called, if the layout didn't change, we're not really interested in
relayouting.

In the future, we'll be able to get notified if position of the popup
would change by some environmental changes, but until then, just don't
support it.
2020-02-21 21:55:16 +01:00
Benjamin Otte
808961564c gdk: Make DRAG_ENTER event take x/y coordinates
Make it mirror the behavior of ENTER/LEAVE events.
2020-02-21 18:19:16 +01:00
Matthias Clasen
4947b94a41 Stop exporting check_event_sanity 2020-02-21 00:51:03 -05:00
Matthias Clasen
de91e10a1b wayland: Fix a release build warning 2020-02-21 00:51:03 -05:00
Matthias Clasen
b1eaa502df events: reorganize getters
Restructure the getters for event fields to
be more targeted at particular event types.

Update all callers, and replace all direct
event struct access with getters.

As a side-effect, this drops some unused getters.
2020-02-21 00:51:03 -05:00
Matthias Clasen
31bf9da63a Strip const from GdkEvent
Events are refcounted structs, and we generally don't
pass these as const.
2020-02-21 00:51:02 -05:00
Matthias Clasen
c343031a0e Stop using g_object_ref/unref on events
Use gdk_event_ref/unref instead of g_object_ref/unref.
Events will stop being object soon.
2020-02-21 00:47:53 -05:00
Matthias Clasen
7f2564aabe wayland: Clean up coordinate handling
Get rid of the get_coordinates function and just
use the structs directly.
2020-02-21 00:39:12 -05:00
Matthias Clasen
07ffa9ad6b wayland: Use event constructors
Convert all of Waylands event handling to use the new
constructors.
2020-02-21 00:39:12 -05:00
Dominique Leuenberger
8b9ad1e963
build: gdk/wayland/cursor depends on wayland-client
On distros where wayland-client.h might not be directly in /usr/include
we fail to find the correct headers otherwise.
2020-02-20 17:07:02 +01:00
Benjamin Otte
9660ae5556 Merge branch 'wip/xdg-popup-async-relayout' into 'master'
Synchronous popup layout

See merge request GNOME/gtk!1241
2020-02-19 18:57:14 +00:00
Jonas Ådahl
ca71119a40 gdk/surface: Replace move_to_rect() with GdkPopupLayout based API
Replace the gdk_surface_move_to_rect() API with a new GdkSurface
method called gdk_surface_present_popup() taking a new GdkPopupLayout
object describing how they should be laid out on screen.

The layout properties provided are the same as the ones used with
gdk_surface_move_to_rect(), except they are now set up using
GdkPopupLayout.

Calling gdk_surface_present_popup() will either show the popup at the
position described using the popup layout object and a new unconstrained
size, or reposition it accordingly.

In some situations, such as when a popup is set to autohide, presenting
may immediately fail, in case the grab was not granted by the display
server.

After a successful present, the result of the layout can be queried
using the following methods:

 * gdk_surface_get_position() - to get the position relative to its
   parent
 * gdk_surface_get_width() - to get the current width
 * gdk_surface_get_height() - to get the current height
 * gdk_surface_get_rect_anchor() - to get the anchor point on the anchor
   rectangle the popup was effectively positioned against given
   constraints defined by the environment and the layout rules provided
   via GdkPopupLayout.
 * gdk_surface_get_surface_anchor() - the same as the one above but for
   the surface anchor.

A new signal replaces the old "moved-to-rect" one -
"popup-layout-changed". However, it is only intended to be emitted when
the layout changes implicitly by the windowing system, for example if
the monitor resolution changed, or the parent window moved.
2020-02-19 09:47:18 +01:00
Jonas Ådahl
46d40cd4bd wayland: Simplify logic deciding whether to use xdg_popup
From a handful of hueristics and guess-work, to a single
`surface->surface_type == GDK_SURFACE_POPUP`.
2020-02-19 09:47:18 +01:00
Jonas Ådahl
11dbc384ab wayland: Fix top-most-popup check
We can map a non-grabbing popup wherever, it's just the grabbing
popup-chain that needs to be ensured not to break any ordering rules.

Fix this by managing two lists; one of open popups, and another for
grabbing ones.
2020-02-19 09:47:18 +01:00
Jonas Ådahl
2bb0eddfb5 wayland: Simplify popup parent discovery
Now popups surfaces are always created with the parent set, so we don't
need to implement vorious guess work to try to find what the parent
might be. Remove that code and just use GdkSurface::parent which is
where the parent set during construction ends up at.
2020-02-19 09:47:18 +01:00
Jonas Ådahl
49fcbc27ca wayland: Remove old "gdk-attached-grab-surface" hackery
The corresponding code in gtk/ is long gone, so it's luckly unused these
days.
2020-02-19 09:47:18 +01:00
Jonas Ådahl
7fafa5133b wayland/surface: Add per surface configuration event queues
Add event queues specifically for surface configuration events
(xdg_surface.configure, xdg_toplevel.configure, xdg_popup.configure etc)
so that a configuration can be completed without having side effects on
other surfaces. This will be used to synchronously configure specific
GdkSurfaces, as is needed by the Gtk layout mechanisms.
2020-02-19 09:47:18 +01:00
Jonas Ådahl
0d086872ae gdk/wayland/surface: Use dedicated bool for frame callback freezing
The freezing is conditioned on various state, so lets make the thawing a
bit more robust. Without this there was a risk that we'd thaw too many
times if there was a frame callback requested while the conditions for
the freezing were not met.
2020-02-19 09:47:18 +01:00
Jonas Ådahl
f284e1d483 wayland: Remove position method split
Position can only be done via gdk_surface_queue_relayout(); the legacy
way is no longer possible, so remove the legacy positioning code.
2020-02-19 09:47:18 +01:00
Benjamin Otte
762c4602fb wayland: Destroy the offer on gdk_drop_finish()
Otherwise the compositor won't be aware the dnd failed and will in turn
not notify the drag source.
2020-02-16 20:10:30 +01:00
Benjamin Otte
46bbb397e1 wayland: Use a magic mime type for local DND
Otherwise the compositor gets all confused when it's trying to make
drag happen but we know it's not going to happen.

After all, we exchange data behind its back, we just need to keep it
informed.
2020-02-15 22:33:57 +01:00
Alexander Larsson
2890cd849f profiler: Add _end_mark() version of _add_mark()
These don't take a duration, instead they call g_get_monotonic_time() to
and subtract the start time for it.

Almost all our calls are like this, and this makes the callsites clearer
and avoids inlining the clock call into the call site.
2020-02-12 11:25:34 +01:00
Alexander Larsson
01d5ad2056 profiler: Make profiler-is-running a macro
When we use if (GDK_PROFILER_IS_RUNNING) this means we get an
inlined if (FALSE) when the compiler support is not compiled in, which
gets rid of all the related code completely.

We also expand to  G_UNLIKELY(gdk_profiler_is_running ()) in the supported
case which might cause somewhat better code generation.
2020-02-12 11:05:01 +01:00
Alexander Larsson
cc643df88b Convert all profiler times from nsec to usec
usec is the scale of the monotonic timer which is where we get almost
all the times from. The only actual source of nsec is the opengl
GPU time (but who knows what the actual resulution of that is).

Changing this to usec allows us to get rid of " * 1000" in a *lot* of
places all over the codebase, which are ugly and confusing.
2020-02-12 10:44:17 +01:00
Matthias Clasen
4e58541d52 Make wayland load cursors on demand
Copy just enough of libwayland-cursor to make our own
loading. This lets us drop the dependency on libwayland-cursor,
and changes the startup cost for cursor theme loading
from 25ms to 0.1ms.

At the same time, simplify the handling of scaled cursors -
instead of creating an array of theme objects, just make a
single theme object provide all scaled cursor sizes.
2020-01-24 17:27:45 -05:00
Matthias Clasen
527b67af3d wayland: Add a mark for cursor loading
This is much too slow.
2020-01-22 23:44:01 -05:00
Matthias Clasen
3c03d7970a More profiler reshuffling
Add more of the marks without requiring a debug build.
2020-01-22 23:44:01 -05:00
Matthias Clasen
dfea9bf0e8 wayland: Add profiler marks around surface handling
Add marks for when we do commits, swap buffer or
receive frame events. These are the low-level start
and end points of the frame cycle, and it is useful
to see them in the profiler.
2020-01-22 15:12:03 -05:00
Matthias Clasen
46bb1a9b6a wayland: Fix release build warnings 2020-01-18 11:49:16 -05:00
Robert Ancell
83867f9cbf Add missing (closure) GIR annotations 2020-01-13 14:26:50 +13:00
Matthias Clasen
2ee9752822 wayland: Remove debug spew 2020-01-06 08:19:01 -05:00
Matthias Clasen
759d53cfa0 wayland: Don't artificially prefer ASK
We were always adding ASK to the list of possible
actions, and preferring it. This was causing the
ask cursor to show up when both the source and
the target support ASK, even though it is only
meant to happen if you hold the Alt modifier.

Instead, use one of the supported actions as
preferred action.
2020-01-04 12:51:32 -05:00
Matthias Clasen
6cef520804 wayland: Minor cleanup
Stop storing selected_action, mainly since the name
is confusing. Instead, just pass the value directly
in the 2 places where it is used.
2020-01-04 12:48:39 -05:00
Matthias Clasen
8c77491150 wayland: Fix action handling more
When updating GdkDrop::actions from changes sent by
the compositor, we were inadvertently setting them to 0,
causing drops to appear impossible.
2020-01-04 09:38:31 -05:00
Matthias Clasen
709ebcedd4 wayland: Finish pending offer handling
When creating a new GdkDrop object on drag_enter, take pending
source_actions and action into account. The code to store the
pending actions was already there, they were just not passed
on to the drop object when we create it.
2020-01-04 09:38:01 -05:00
Matthias Clasen
47e6b88555 wayland: Clean up drags
We need to set the drag to NULL in gdk_wayland_drag_drop_done,
otherwise, all future drags will be considered local after the
first local one. Worse, they will also provide the wrong data.
2020-01-04 09:36:38 -05:00
Matthias Clasen
4b818495ca wayland: Fix dnd type negotiation
We need to call gdk_content_formats_union_serialize_mime_types
like GdkClipboard does, in order to get mime types that we can
sent out.
2020-01-01 12:51:19 -05:00
Matthias Clasen
15242d66e1 wayland: Pass root coordinates for dnd events
That is what the api currently requires, so provide it.

This fixes DND to work again, for the most part.
2019-12-30 12:00:53 -05:00
Jonas Ådahl
d6a6313493 wayland/glcontext: Fix damage region on HiDPI
The passed regions are in surface coordinates, but
eglSwapBuffersWithDamage() is in buffer coordinates.
2019-12-03 16:45:37 +01:00
Emmanuele Bassi
def700739d Use a single compilation symbol
We use a compilation symbol in our build to allow the inclusion of
specific headers while building GTK, to avoid the need to include only
the global header.

Each namespace has its own compilation symbol because we used to have
different libraries, and strict symbol visibility between libraries;
now that we have a single library, and we can use private symbols across
namespaces while building GTK, we should have a single compilation
symbol, and simplify the build rules.
2019-11-27 13:33:43 +00:00
Emmanuele Bassi
9a88d17ef2 Merge branch 'gdk-backend-imports' into 'master'
Correct Gdk backend import paths and related gtk-doc

See merge request GNOME/gtk!1197
2019-11-18 10:27:32 +00:00
Andy Holmes
907a86fd93 Correct Gdk backend import paths and related gtk-doc
Correct the paths in the include guard warnings and use the `@Include`
directive for the Gdk backends.
2019-11-18 00:31:38 -08:00
Emmanuele Bassi
1ec4cb7f17 Disable GdkSurface.minimize on Wayland
The existing xdg-shell protocols do not support minimization in a way
that allows us to implement the GdkSurface API; the only minimization
operation does not come with a state notification, nor it comes with
a way to undo itself.

Closes: #67
2019-11-16 20:25:01 +00:00
Emmanuele Bassi
b70e4f6de9 Rename "iconify" to "minimize"
The "iconified" state is mostly an X11-ism; every other platform calls
this state "minimized" because it may not involve turning a window into
an icon at all.
2019-11-16 20:07:37 +00:00
Matthias Clasen
cb81a06793 wayland: Drop the keyboard settings object
It is no longer used.
2019-10-29 22:20:57 -04:00
Matthias Clasen
4d9cc483c9 wayland: Rely on server key repeat info
Using gsettings for this information does not work
in sandboxed scenarios, where settings are per-app.
Since the Wayland protocol provides this information
nowadays, just drop the old code for reading
the gsettings.
2019-10-29 21:58:45 -04:00
Carlos Garnacho
075c77325b gdk: Avoid poking possibly freed memory
The event may end up freed after delivery, ensure to keep a ref in order
to emit the matching emulated crossed event matching a proximity event.

Closes: https://gitlab.gnome.org/GNOME/gtk/issues/2157
2019-10-09 10:35:50 +02:00
Carlos Garnacho
f354a7787a 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:57 +02:00
Georges Basile Stavracas Neto
a91d0ac156 wayland: Allow binding to wl_compositor v4
This is a requirement for using VK_KHR_incremental_present.
Vulkan Wayland drivers translate the VkPresentRegionsKHR to
wl_surface.damage_buffer(), which a v4-only request.
2019-10-05 12:13:22 -03:00
Georges Basile Stavracas Neto
0e55f7a52f wayland/surface: Fix crash when unexporting
This is the exact same problem of 655c9dd526.
2019-10-01 16:13:43 -03:00
Georges Basile Stavracas Neto
655c9dd526 wayland/surface: Only call destroy func when available
When calling gdk_wayland_surface_export_handle(), if we pass
some 'user_data' but no 'destroy_func', GTK4 crashes. That's
because in xdg_exported_handle() we are unconditionally calling
destroy_func -- even when it's NULL.

Fix that by checking if there's a destroy function before calling
it.

Fixes https://gitlab.gnome.org/GNOME/gtk/issues/2179
2019-10-01 11:54:28 -03:00
Olivier Fourdan
31393704de 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:13:24 +02:00
Olivier Fourdan
795899f9d5 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:32:17 +02:00
Jonas Ådahl
0885eb0a7b gdk: Remove gdk_surface_move_resize() API
Windows/surface's aren't supposed to be explicitly moved by any external
part, so don't provide API for doing so. Usage throughout Gdk is
replaced by the corresponding backend variants.
2019-07-25 10:35:43 +02:00
Jonas Ådahl
6314ebd435 gdk/surface: Add toplevel_resize vfunc
To separate how toplevels and popups are configured, a first step is to
introduce a resize-only vfunc for backends to implement. It's meant to
only configure toplevel windows, i.e. popups. Currently it's used for
both types, but introducing the resize-only API is a first step.
2019-07-25 10:24:50 +02:00
Jonas Ådahl
b062dea1aa wayland: Cleanup surface configuration
Configuration should happen in response to the xdg_surface.configure
event, not in the events that preceeds it. Do this by making all
configured state pending until the committing "configure" event. Also
split up toplevel vs popup configuration in a more clear way.
2019-07-24 22:42:37 +02:00
Jonas Ådahl
9b561581d5 wayland: Rename gdk_wayland_surface_configure to *_resize
It only issues a resize; configuring should imply more state is
configured, e.g. maximized, etc.
2019-07-24 22:42:37 +02:00
Jonas Ådahl
5db079b052 gdk/frameclock: Make surfaces inhibit freeze
To make a frame clock tick as long as any of the associated surfaces
expect to receive ticks, make the surfaces inhibit freezing the clock,
instead of directly tell the frame clock to freeze itself.

This makes it so that as long as any surface using a certain frame clock
is not frozen (e.g. just received a frame event from the display
server), the frame clock will not be frozen.

With this, the frame clock is initiated as frozen, and won't be thawed
until any surface inhibits freeze. It will be frozen again, when every
surface has that previously inhibited freeze uninhibited freeze.
2019-07-03 11:42:28 +02:00
Emmanuele Bassi
a5f22897f9 Relay the xdg_output.name to GdkMonitor
The xdg_output v2 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.
2019-06-24 15:38:36 +01:00
Matthias Clasen
bbea1cc841 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 12:41:01 -04:00
Matthias Clasen
ed9b874d2e wayland: Fix the popover race workaround
The Wayland backend has a hack to work around
a race with popover mapping: If the surface size
changes before the initial configure, we hide and
show the surface. Unfortunately, the code was doing
this in a way that is externally observable (by
listening for surface state changes), and popovers
were observing it and hiding themselves in response.

Avoid this by not going through the GDK frontend
code for this.
2019-06-12 21:50:16 -04:00
Matthias Clasen
1f70bc4bf3 gdk: Create a global shared GL context
Create a global GL context that connects all
GL contexts on a display and lets us share textures
between them.
2019-06-04 23:00:02 +00:00
Matthias Clasen
2ae6f1a741 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 14:07:15 +00:00
Matthias Clasen
987e7878a2 Drop gdk_surface_get_frame_extents
No longer used.
2019-05-29 18:04:08 +00:00
Matthias Clasen
2fa1a0a651 wayland: Disconnect the frame clock
The frame clock can survive the surface now,
so we need to disconnect.
2019-05-28 20:25:17 +00:00
Matthias Clasen
44be64278b surface: Make surface-type a property
Make surface-type a construct-only property,
so we can set it before the frame clock.
2019-05-28 20:25:16 +00:00
Matthias Clasen
db855e092d Add a GdkSurface::parent property 2019-05-28 20:25:15 +00:00
Matthias Clasen
ef353f24c6 gdk: Inherit the frame clock for popups
With separate clocks, the phases are not coordinated,
which messes with GTKs size allocation machinery treating
the entire widget tree as a whole, and causes us to
run into assertion where popups get drawn before they
are allocated.
2019-05-28 20:25:15 +00:00
Matthias Clasen
99783c7fb7 wayland: Use popup parents
Make the Wayland move-to-rect implementation
use popup parents.
2019-05-28 20:25:14 +00:00
Matthias Clasen
9af6d7f733 surface: Store popup parent
Store popup parents separately from transient-for
parents, since these are separate concepts with
different behaviors. And we need the parent in
the frontend, so we can use it in the fallback
move-to-rect implementation.
2019-05-28 20:25:14 +00:00
Matthias Clasen
712a5d4f25 Get rid of GdkSurfaceImpl
We don't need the complicated wrapper system anymore,
since client-side windows are gone. This commit moves
all the vfuncs to GtkSurfaceClass, and changes the
backends to just derive their surface implementation
from GdkSurface.
2019-05-28 20:25:14 +00:00
Matthias Clasen
d2951d3aac Rename surface constructors
We want to use a gdk_surface_new_popup for popups,
and align the constructor names with the surface
types, so rename

gdk_surface_new_popup -> gdk_surface_new_temp
gdk_surface_new_popup_full -> gdk_surface_new_popup

The temp surface type will disappear eventually.
2019-05-28 20:25:14 +00:00
Matthias Clasen
47fb092393 gdk: Drop GdkWindowAttr
All the information in it is already contained
in the surface object we pass along, and none
of the backend implementations were using the
attributes at all.
2019-05-28 20:25:14 +00:00
Matthias Clasen
6029875ed3 wayland: Remove a useless switch
We are setting the title unconditionally, now
2019-05-28 20:25:14 +00:00
Matthias Clasen
f692974e5a gdk: Remove remnants of client-side windows
Now that all surfaces are native, we don't need
to separately keep track of grab surfaces and
their native ancestor anymore.
2019-05-28 20:25:14 +00:00
Matthias Clasen
9b54f124e5 surface: Simplify destroy implementation
Without child surfaces, there is no need to recurse.
2019-05-28 20:25:14 +00:00
Matthias Clasen
7aae92656d wayland: Stop using surface->children
It is always NULL.
2019-05-28 20:25:13 +00:00
Matthias Clasen
bb1dd3f3ae wayland: Stop using surface->parent
It is always NULL.
2019-05-28 20:25:13 +00:00
Matthias Clasen
989792cbc0 Drop child surfaces
Drop gdk_surface_child_new and the child surface type,
since we no longer use them. Deprecate surface apis
that only make sense with child surfaces.
2019-05-28 20:25:13 +00:00
Matthias Clasen
f7e1146eda wayland: Stop using child surface apis
We no longer have child surfaces.
Drop code that only makes sense in their
presence.
2019-05-28 20:25:13 +00:00
Matthias Clasen
c50052e223 Revert "wayland: Keep some resources until destroy"
This reverts commit f2d598b9a1.
2019-05-25 18:08:43 +00:00
Olivier Fourdan
713fceb1bd 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:22:36 +02:00
Matthias Clasen
54530334f4 Revert "wayland: Make popups work more than once"
This reverts commit e74c655016.
2019-05-19 16:50:49 +00:00
Matthias Clasen
e74c655016 wayland: Make popups work more than once
The change to keep some server resources around
until destroy was causing us to not recreate
the right things when a surface is hidden and
then shown again. Make sure to recreate everything.
2019-05-19 04:43:16 +00:00
Matthias Clasen
f2d598b9a1 wayland: Keep some resources until destroy
The Wayland backend was dropping _all_ serverside
resources on hide, which is too early e.g. for
GtkGLArea which wants to use egl resources to
unload textures on unrealize.

Closes: https://gitlab.gnome.org/GNOME/gtk/issues/1485
2019-05-18 19:15:47 +00:00
Matthias Clasen
33ffd54d5f Redo frame profiling
We were adding incomplete frame timings to the
profile, which lead to occasional nonsense
numbers. Instead, only add timings to the profile
once we marked them as complete. This also
gives us an opportunity to add the presentation
time as a marker.
2019-05-16 19:08:34 +00:00
Benjamin Otte
7ae675b469 build: Install the backend headers in the backend directories
That's where they are in the sources and we include them from other
headers. So make sure the directories match.
2019-05-06 20:14:53 +02:00
Matthias Clasen
737400ddbc wayland: sanity check events at the source
Sanity check events before we throw them into
the event queue, as this makes it much easier
to track down the culprit.
2019-05-01 20:51:43 +00:00
Matthias Clasen
5b8f1aa2ee Merge branch 'xdg-output' into 'master'
[gtk4] wayland: Add support for xdg-output

Closes #1828

See merge request GNOME/gtk!751
2019-05-01 03:34:56 +00:00
Jonas Ådahl
5f8543fe81 wayland: Only check top-most for grabbing popups
Non-grabbing popups are not limited to a single
nesting stack, as per the spec, so we should not
prevent that on the client-side.
2019-04-29 16:00:53 +00:00
Matthias Clasen
aae7816557 wayland: Reshuffle some internals
Make find_grab_input_seat return a GdkWaylandSeat
instead of a struct wl_seat, so we can use it and
avoid calling gdk_display_get_default_seat when
we need to get a serial later.
2019-04-29 16:00:09 +00:00
Timm Bäder
1f5649e1ce GdkWaylandDevice: Don't recreate the default cursor every frame
Save the information whether the cursor in use is the default one, and
don't create a new cursor object in that case.
We previously created a new cursor object every frame just to compare it
to the current cursor in use and then throw it away.
2019-04-23 17:09:14 +02:00
Matthias Clasen
51b2759eb1 surface: Drop group api
This was only ever implemented on X11, and
GTK is not using it at all. Relegate it to
x11-specific api.
2019-04-20 02:28:46 +00:00
Matthias Clasen
fed2db1493 window: Drop some x11-specific apis
The skip-taskbar, skip-pager and urgency hints were
only ever implemented for X11, and are not very useful
with modern desktops. Relegate the functionality to
x11 backend api, and drop the GtkWindow api.
2019-04-20 02:28:46 +00:00
Matthias Clasen
37fee8c52f wayland: Improve debug output for events
We were missing surfaces in a few places.
2019-04-19 13:58:45 -04:00
Carlos Garnacho
50eb11a2a0 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 19:27:29 +02:00
Matthias Clasen
e8f898508a Merge branch 'handle-tool-scale-fix' into 'master'
gdkdevice-wayland: Update pointer scale on tablet tool proximity events

See merge request GNOME/gtk!582
2019-04-18 16:55:28 +00:00
Matthias Clasen
ecdad20827 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 14:27:00 +00:00
Olivier Fourdan
1f58e0ed6b 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:43 +02:00
Matthias Clasen
624c30ecd2 Drop gdk_wayland_surface_set_use_custom_surface
This is unused in GTK, and it does not seem useful
enough to keep around.

Closes: https://gitlab.gnome.org/GNOME/gtk/issues/1806
2019-04-03 23:23:24 +00:00
Matthias Clasen
64fd5158bf gdk: Change some async dnd api
The pattern we generally follow is to put the
async result right after the source object, in
finish functions. Do this for gdk_drop_read_finish.
2019-04-02 15:11:06 +00:00
Matthias Clasen
8e4e4401c5 gdk: Change some async clipboard api
The pattern we generally follow is to put the
async result right after the source object, in
finish functions. Do this for gdk_clipboard_read_finish.
2019-04-02 15:10:53 +00:00
Matthias Clasen
8ef4e231ec gdk: Stop implementing set_role
All but the X implementation of these were
empty anyway. And the X one is just setting
a property.
2019-03-27 17:29:17 -04:00
Matthias Clasen
c0aaa43122 Rename gdk_device_get_surface_at_position_double
We can drop the double suffix now.
2019-03-26 18:12:55 -04:00
Matthias Clasen
9021e7d3cd gdk: Stop using gdk_device_get_surface_at_position
We should always use the double variant.
2019-03-26 18:12:55 -04:00