Commit Graph

8033 Commits

Author SHA1 Message Date
51d9cfd6a6 Merge branch 'work/zzag/backport-cursor-shape-v1' into 'gtk-3-24'
wayland: Backport GNOME/gtk!8247

See merge request GNOME/gtk!8257
2025-03-05 14:08:15 +00:00
90390d6493 fix: [draw] The application interface is unresponsive to clicks.
problem:
After switching screens using a KVM switch, there is a probability
that the application interface will become unresponsive to clicks.

analysis:
The valid size range supported by the Cairo surface is [0,32767].
If the width and height exceed this range, the surface's status is set
to CAIRO_STATUS_INVALID_SIZE, indicating an invalid size exception.
In this exception state, Cairo does not have a clipping region.

When determining whether the window needs to be drawn,
the function gdk_cairo_get_clip_rectangle() is used to check
if the cairo_t has a clipping region. If there is none, the window
and its child windows will not be drawn (i.e., the draw signal will not be emitted).

If an error occurs in the X server and a value exceeding Cairo's
valid size is provided in the ConfigureNotify, it will result in
the window and its child windows not being drawn.
Therefore, we will add range checks here to avoid this special situation.
2025-03-04 19:32:31 +08:00
d6cb3b4a2a wayland: Fix none cursor check
We should skip going through the look up table if the cursor name is
"none", i.e. when g_str_equal() returns true or 1.

(cherry picked from commit 7ee2e50dc4f0898f7d56d67017c36414618f2e82)
2025-03-03 01:51:31 +02:00
580846fcdc wayland: Go back to the old none cursor
Upstream found this enum value objectionable,
despite being a perfectly good CSS cursor.

(cherry picked from commit eda5bd5242a9b04ed5c1e9f43592c7fc9d8dca4a)
2025-03-03 01:51:31 +02:00
b281c8035f wayland: Support the cursor-shape protocol
If present, use the cursor-shape protocol instead of manually
updating a pointer surface. This commit supports both v1 of the
protocol and the (still unmerged) v2 additions to the enumeration.

This was tested with both kwin and mutter.

(cherry picked from commit a63d6d1dc7a8ebdf61c682196f89917846cbe8ac)
2025-03-03 01:51:31 +02:00
cc14115d09 wayland: Support the all-resize cursor
Add all-resize to the list of names that we want to guarantee.
We use move as the fallback for it. The idea is that all-resize
will be visually compatible with resize cursors, and move will
be visually compatible with dnd cursors. And it is nice to
have two distinct names, so the metaphors can be changed without
clashing.

(cherry picked from commit 79ba34f1aa82de7d06c19109582f7df5f144a6c1)
2025-03-03 01:51:31 +02:00
f44e7b4f67 x11: Support the all-resize cursor
This is an alternative name for the move cursor.

(cherry picked from commit 1eaa4eb4051c42242f1eadd2d5e45b45a94d2e8d)
2025-03-03 01:51:31 +02:00
1cfd1fcd04 gdk: Touch up cursor name docs
Make the table provide usage hints, and line things up more
nicely.

(cherry picked from commit a948157a6c4e56b8ce7e10e702987f03cd1d13c3)
2025-03-03 01:51:28 +02:00
4e005ec603 gdk/wayland: Avoid grab crossing on idle tablets
Tablets require a tool in proximity to have an active surface
to send pointer events to. Avoid the grab-induced crossing events
on tablets that don't have a tool in proximity at the time of
creating the grab.

Fixes #1188, Fixes #3116

(cherry picked from commit d8919311b18bb0b89121c88405f757d6cee2e7cb)
2025-02-25 23:15:44 -08:00
Aki
40072ff1ab macos: Fix inverted pen Y tilt on macOS
- Negate tilt.y in Cocoa pen handling to correct inverted Y tilt axis
- see 0f128fd7c5/src/plugins/platforms/cocoa/qnsview_tablet.mm (L63)
- see https://source.chromium.org/chromium/chromium/src/+/main:components/input/web_input_event_builders_mac.mm;drc=0af5ffa1e4cc4cc4f818725f8fee93ec57855e4b;l=421
2025-01-31 10:59:06 +08:00
67438caa3d gdk: fix crash on Wayland with already destroyed surface.
See crash reliably reproduced on GIMP when a popup is destroyed on a
drag-begin callback and Wayland data listener callbacks calls the
enter() callback with a NULL surface.

Cf. https://gitlab.gnome.org/GNOME/gimp/-/issues/10515
2025-01-17 11:16:38 +00:00
41bd9e4290 [quartz] GdkQuartzNSWindow: Pad only the content_rect width.
On Quartz the drawing region must be padded out to a multiple of 4 px
on regular displays and 8 px on Retina ones. Failing to do so used to
cause smearing on multi-monitor mixed-DPI systems but that seems to
have been fixed. There remains a visible flicker in animations.

Padding the GdkWindow width as well as the content frame and cairo
surface causes the frame clock to get frozen if multiple calls to
gtk_window_resize use the same size because
gdk_window_move_resize_internal sees a difference between the window
size and the requested size (the latter isn't padded out) and freezes updates. GdkQuartzNSWindow
windowDidResize is supposed to thaw them, but because the padded-out
width set for the frame doesn't change the window isn't resized and
the frame clock is never thawed.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/7188
2024-12-25 20:29:19 -08:00
c79539dc8c [quartz] GdkQuartzNSWindow: Extract func synthesize_configure_event.
To reduce duplicated code.
2024-12-25 20:27:56 -08:00
d50e6742e6 Merge branch 'clear-settings-portal-gtk-3-24' into 'gtk-3-24'
wayland: Clear settings_portal when going to fallback with no portal settings

See merge request GNOME/gtk!7757
2024-09-29 13:25:24 +00:00
5b5a32d445 wayland: Use the same default cursor size as gsettings schema
Fixes: #7043
2024-09-28 16:50:45 +04:00
eed43d6468 wayland: Clear settings_portal when going to fallback with no portal settings
All other code paths with goto fallback clear it, this makes the behavior consistent with them
2024-09-28 16:42:31 +04:00
e82f5ac4d2 wayland: Improve font setting fallback for real
dfea8c31d9 added a check for portal settings array length but what it really checks is the amount of dbus out arguments.

This commit makes it do what gtk4 does: really check array length.

Fixes: #3838
2024-09-27 15:19:07 +04:00
1cf0520454 Try to fix monitor geometry on sway
The Wayland protocols around outputs are truly a disaster.

This is a backport of 854e40c60c0d32 from main in the hope
of getting monitor geometry to work across compositors.

Fixes: #6939
2024-08-17 21:48:37 -04:00
1d93015e1f Merge branch 'fix-virtual-memory-leak' into 'gtk-3-24'
Ensure the staging_cairo_surface is destroyed before re-assigning it

See merge request GNOME/gtk!7206
2024-08-07 13:21:13 +00:00
b8435aab39 wayland: Add support for v2 of xdg_foreign protocol 2024-07-11 18:31:37 +02:00
a8a03a4852 Merge branch 'wgl-usage-across-threads-324' into 'gtk-3-24'
3.24: GDK-Win32: Use wrapper functions for calling core wgl* functions (backport from GTK-4.x)

See merge request GNOME/gtk!7284
2024-05-23 15:34:40 +00:00
71de45cb83 win32: Fix invisible dnd-move cursor
The cursor currently disappears while in DnD "move" action.
Fix by assigning a standard arrow cursor.
2024-05-22 20:41:57 +02:00
a0306f758f GDK-Win32: Add wrapper functions for calling core wgl* functions
This is a backport from the GTK-4.x update, so that we can aim to
support gtkglsink in gst-plugins-good even on Windows, beyond using
just Cairo in gstsink for rendering.

From the commit message in GTK-4.x, in commit 627ee674:

We might be dealing with GL contexts from different threads, which have more
gotchas when we are using libepoxy, so in case the function pointers for
these are invalidated by wglMakeCurrent() calls outside of GTK/GDK, such as
in GstGL, we want to use these functions that are directly linked to
opengl32.dll provided by the system/ICD, by linking to opengl32.lib.

This will ensure that we will indeed call the "correct" wgl* functions that
we need.
2024-05-22 19:26:31 +08:00
c07bffa624 quartz: Remove trackingArea double reference
Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/6704
2024-05-14 12:30:34 +02:00
b237989bb3 Ensure the staging_cairo_surface is destroyed before re-assigning it
Without doing so, memory regions allocated may not be freed in some cases.

Closes 6675.
2024-04-30 09:15:09 +08:00
bdddc3857c wayland: Always commit soon after xdg_surface.ack_configure
It's mandatory to reply to a xdg_surface.configure with a
xdg_surface.ack_configure, as well as a wl_surface.commit to have the
ack_configure to have any effect. We failed to do that if the new
configuration didn't cause any actual anything to change, meaning we'd
just ack_configure, but potentially never commit.

Fix this by requesting a 'after-paint' frame clock phase, while setting
the pending commit state to true. If we were already to paint, the new
requested phase would happen anyway, but to avoid double
wl_surface.commit when also using eglSwapBuffers*(), also avoid
performing the commit if we know the swap buffers will happen.
2024-04-14 21:24:19 +02:00
1c8ec31162 Sync drag cursors with GTK4
Use the same cursors during dnd as we do in GTK 4.
2024-04-04 10:31:39 +02:00
0844a88558 wayland: Guarantee dnd-move as a cursor name
We need to go back to using this, since move is widely abused
and thus can't change its image to one thats appropriate for dnd.
2024-04-04 10:31:08 +02:00
6754765a5a Revert 7237f5d0eb
This commit was identified as the cause for a GLArea transparency
regression. Bring the required code back.

Fixes: #6359
2024-03-28 07:58:37 +01:00
e29cd37ae6 Merge branch 'standard-cursor-names-3-24' into 'gtk-3-24'
wayland: Keep cursor types limping along

See merge request GNOME/gtk!7033
2024-03-15 02:19:28 +00:00
f1690a9a37 wayland: Keep cursor types limping along
Cursor themes have recently started to reduce their coverage of
'legacy' cursor names, and reduced to the standard names. Support
this for the few cursor types that are still used in GTK.
2024-03-14 21:45:19 -04:00
7e9676d658 Fix Cocoa pasteboard constants for gtk.
Corresponds to gdkselection-quartz changes in f30ed5ddc.
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/6480
2024-02-27 12:31:16 -08:00
9020a6f71e [gtk3/wayland] Infer resizable edges for tiled windows if possible.
This fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1871627

All GTK3/4 apps on non-GNOME desktops aren't resizable if they are
tiled.

This patch makes the non-tiled edges resizable if we have per-edge
tiling, but not per-edge resizing information.

We might want to make all edges resizable, but that might not be fine
for tiling compositors.
2024-02-27 15:18:41 +01:00
47601f5413 gdk/wayland: Clear current_tablet on pad leave
Fixes crash when handling tablet pad removal event after the
current_tablet has already been freed.
2024-02-11 15:03:04 +00:00
51b04c5007 wayland: Small fixup to monitor size handling
The first time this function is called, has_xdg_output() returns
true, but haven't yet received all the xdg-output events, so wait
for that to be done. Otherwise, the logical size is 0, and nothing
useful comes from that.
2024-01-31 14:12:40 +01:00
09373bf7ee [gtk3/wayland] Fix GdkMonitor sizes on Mutter without fractional scaling.
This is the gtk3 version of !6722.

This fixes a problem that is apparent in
https://bugzilla.mozilla.org/show_bug.cgi?id=1869724, but that also
reproduces on any GTK application as described in
https://bugzilla.mozilla.org/show_bug.cgi?id=1869724#c16.

xdg_output sizes might be physical if the compositor doesn't scale them,
it seems. So to report the correct logical geometry in GDK pixels, we
need to detect this case. We do this by checking whether the wl_output
size matches the xdg_output size.
2024-01-31 14:12:40 +01:00
5de743572e fix gtk-shell protocol handling 2024-01-24 01:08:43 +00:00
ba58b3a23d Fix for #6342 2024-01-19 23:01:22 +01:00
6880ac90a0 don't free monitor->name twice (fixes #6345) 2024-01-19 19:15:52 +01:00
a487deb189 Merge branch 'fix/monitor-name' into 'gtk-3-24'
Use xorg 'monitor' the right way.

See merge request GNOME/gtk!6680
2024-01-16 16:36:05 +00:00
adce74bc28 Free monitor name on finalize 2024-01-15 08:25:58 +01:00
a58ae95c87 gdkdisplay-wayland: Init selection before roundtrips
Some of the listeners connected during the initial roundtrip assume a
non-NULL selection, when they finally invoke functions such as
gdk_wayland_selection_ensure_offer(),
gdk_wayland_selection_ensure_primary_offer() or
gdk_wayland_selection_set_offer(). The GdkWaylandSelection should
therefore be initialized before the second series of roundtrips, as the
compositor may have already sent a selection by then.
2024-01-06 23:30:34 +01:00
345bfb494a Use consistent coordinates in get_toplevel_from_ns_event.
[NSView frame] returns a rectangle in the superview's coordinates, and the
superview of an NSWindow's content view (which is the only NSView that
GdkQuartz instantiates) is an undocumented NSThemeFrame. While it happens
to have the same origin as the content view and the same size as the
window's frame this isn't documented and so could change without notice.
Convert the window frame coordinates to the view's coordinate system to
ensure consistency.

Use the view's bounds instead of its frame: The bounds rectangle is in the
view's coordinate system. Use the parent NSWindow's frame instead of the
private NSThemeFrame's. This ensures that all coordinate comparisons have
the same reference.

Finally, the macOS coordinate systems origin is at the bottom left, so the
title bar is between the content view's height and the window's height,
not in negative y in the view's coordinates. Adjust the y comparisons
accordingly.

Fixes #6297
2023-12-25 11:10:12 -08:00
19b515dcd8 Rework after first review 2023-12-21 13:51:45 +01:00
ab860da1b9 Merge branch 'gtk3-wayland-suspended' into 'gtk-3-24'
[gtk3/wayland] Expose XDG-shell suspended state via the visibility state

See merge request GNOME/gtk!6630
2023-12-21 12:24:36 +00:00
57acc7142f Rework to get rid of get_monitor_by_output 2023-12-20 14:31:01 +01:00
d4ca79bb96 Use xorg 'monitor' the right way. See #2013 2023-12-20 07:17:33 +01:00
432ed07105 Merge branch 'work/zzag/avoid-scaling-cairo-surface-twic3' into 'gtk-3-24'
wayland: Fix wl_buffer size for custom cursors

See merge request GNOME/gtk!6637
2023-12-19 01:11:15 +00:00
99a816c361 gdkkeys-win32c: change registry key not found g_warning to g_debug
On Windows with certain keyboard layout combinations you can get a
benign terminal warning like this:
Could not open registry key 'SYSTEM\CurrentControlSet\Control\Keyboard
Layouts\D0010413'
When using a lot of plug-ins, like GIMP does, this warning can show up
a lot of times.
The code after this warning, still has another last check, that, when it
fails, will show a warning.

We change the first g_warning to a g_debug statement, to reduce the
amount of warning messages.

Closes #5109
2023-12-18 11:35:43 -05:00
58039edf69 [gtk3/wayland] Expose XDG-shell suspended state via visibility events.
This allows Wayland compositors to tell GTK applications whether a
window is effectively invisible.
2023-12-18 12:15:16 +01:00