Commit graph

165 commits

Author SHA1 Message Date
ttyS3
98366076e1
fix(wayland): detect start_drag silently ignored by the compositor
The pointer_button_count check added in dc36e2165 uses the client side
view of the implicit grab, which is stale when the button release is
still in flight: glfwStartDrag passes the check, but by the time the
compositor processes wl_data_device.start_drag the implicit grab is
gone and the request is silently dropped. The data source then never
receives any event, so the tab drag state leaks forever, hijacking
mouse handling again, and the already created xdg_toplevel_drag
toplevel gets mapped as a stray undecorated window showing the drag
thumbnail that nothing ever destroys.

Detect this deterministically using protocol ordering: issue a
wl_display.sync right after start_drag. An accepted start_drag
synchronously produces events (wl_pointer.leave from the DND grab
taking over, wl_data_device.enter, wl_data_source events) that are
ordered before the sync callback. If the callback fires with none of
them seen, the request was dropped: cancel the drag, which notifies
the application (clearing the tab drag state) and destroys the drag
toplevel and data source.

Also defer mapping the drag toplevel until the session is confirmed,
so the stray window can never appear, not even for one frame.

Verified against headless GNOME Shell 50.2 (mutter) with injected
pointer timing scans: the unpatched build deadlocks with an orphaned
drag toplevel within ~13 fast flicks, the patched build catches every
race hit and cancels cleanly, with no deadlock, no stray window, and
normal slow drag/reorder/detach behaviour preserved.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-12 14:16:22 +08:00
ttyS3
dc36e21654
fix(tabs): mouse handling stuck after aborted tab drag on Wayland
A quick click-and-flick on a tab could leave all of kitty with mouse
input permanently redirected to the tab bar, making every window
unclickable and text selection impossible.

Starting a tab drag is asynchronous: the drag thumbnail is rendered on
the next frame before glfwStartDrag is called. If the button is
released in that window, wl_data_device_start_drag is sent with a stale
serial that no longer matches an active pointer implicit grab, so the
compositor silently ignores it. The wl_data_source then never receives
any event, on_drag_source_finished never runs, and the
tab_being_dragged state is stuck forever, hijacking all mouse events.

Fix in layers:
- glfw/Wayland: track the implicit grab (serial of the first button
  press and pressed-button count), use that serial for start_drag and
  refuse with EAGAIN when there is no active implicit grab instead of
  letting the compositor silently drop the request
- mouse.c: a left button release arriving while a tab drag is marked
  started but no system DND is active means the drag never launched
  (an active DND consumes the release on all platforms), so clear the
  drag state instead of waiting for DND events that will never come
- tabs.py: handle OSError from start_drag_with_data for tab drags the
  same way window drags already do; clear the potential-drag state when
  the release lands on the new-tab button or empty tab bar area
- tabs.py/boss.py: clear drag state on drag finish/drop even when the
  dragged tab has already been closed

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 03:43:25 +00:00
Kovid Goyal
95593ef008
Wayland: Allow holding momentum scroll by putting two finger on touchpad. Fixes #9863 2026-04-14 09:39:57 +05:30
Kovid Goyal
dc55052f0c
Wayland: set drop accepted operations 2026-04-07 10:40:14 +05:30
Kovid Goyal
98931d99b0
Wayland: Fix momentum scrolling not working on compositors that send a stop frame with no axis information
Fixes #9653
2026-03-13 08:47:45 +05:30
copilot-swe-agent[bot]
4706243380
Fix GLFW drop API to always present full original MIME type list to callbacks
Fixes #9633
2026-03-10 20:10:44 +05:30
Kovid Goyal
5cc510dea4
Merge branch 'titlebar-only-wayland' of https://github.com/antoinecellerier/kitty 2026-02-23 19:19:30 +05:30
Kovid Goyal
b737eaad65
Cleanup previous PR
Use a single wl_surface for the drag icon. Whther it is attached to the
top level drag or not is determined based on availability.
2026-02-22 15:36:10 +05:30
copilot-swe-agent[bot]
accee908aa
Implement Wayland xdg-toplevel-drag protocol for make_toplevel in _glfwPlatformChangeDragImage
Fixes #9544
2026-02-22 14:53:34 +05:30
copilot-swe-agent[bot]
bcba8fc04c
Wayland: Add support for ext-background-effects
Fixes #9536
Fixes #9534
2026-02-21 20:56:40 +05:30
Kovid Goyal
a2b7a0cd6d
Port Cocoa drag source backend to new API 2026-02-18 11:20:17 +05:30
Kovid Goyal
e5eb63fcd0
Refactor drag source API to be async
Wayland implementation done. Other two backends remain.
2026-02-17 13:07:55 +05:30
Antoine Cellerier
ef4574ae97 Support hide_window_decorations titlebar-only on Wayland
Hide the CSD titlebar subsurface while keeping shadow borders for
resizing. On SSD compositors (GNOME), forces CSD mode to draw
kitty's own shadows without a titlebar.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-08 19:49:44 +01:00
Kovid Goyal
3cf24afdc0
Refactor drop API and implement it on Wayland 2026-02-08 22:05:14 +05:30
copilot-swe-agent[bot]
7ca6fd66f8
Fix self drag not working under Wayland
Fixes #9483
2026-02-07 15:10:54 +05:30
Kovid Goyal
07a9f2bcaa
API to start a drag 2026-02-07 13:50:16 +05:30
copilot-swe-agent[bot]
5ea35cbbfc
Refactor drag API to make it asynchronous
Fixes #9477
2026-02-07 08:59:34 +05:30
copilot-swe-agent[bot]
9b35c1b535
Allow changing drag acceptance asynchronously
Fixes #9465
2026-02-03 14:43:44 +05:30
copilot-swe-agent[bot]
fa6c76d3e3
Add a GLFW API to support starting drag operations
Fixes #9454
Fixes #9455
2026-02-02 20:49:00 +05:30
Kovid Goyal
9ef934cf54
Wayland: Remove usage of the Wayland color management protocol to inform compositors of the color space used by kitty
As is typical with Wayland, the protocol is poorly designed and
implemented even worse. Hyprland 0.53 has completely broken color
management.
https://github.com/hyprwm/Hyprland/discussions/12788
In addition it and mangowc crash when using color management with nouveau drivers.
https://github.com/kovidgoyal/kitty/issues/9030

KDE kwin does not support the sRGB transfer function. And the geniuses
at Wayland are any way planning to deprecate sRGB as a transfer function.

Only GNOME mutter seems to get it right.

Then there are people that are likely going to shoehorn this into EGL
instead of leaving it under application control via the protocol anyway.
https://github.com/KhronosGroup/EGL-Registry/issues/197

Sigh. Wayland.
2026-01-15 09:53:09 +05:30
Kovid Goyal
c389f4d5b8
Wayland: Fix doubled key repeat events when compositor sends repeat events
Fixes #9374
2026-01-15 08:13:37 +05:30
Kovid Goyal
0f1362524b
Store more information about axis events from Wayland 2026-01-01 13:25:30 +05:30
Kovid Goyal
2ffa8cd7c2
Apparently gamma22 gives incorrect colors or at least colors different from rendering without color management. srgb transfer function gives expected colors. 2025-07-31 19:07:28 +05:30
Kovid Goyal
caa654b6b8
Also track needed color manager features 2025-07-31 18:53:24 +05:30
Kovid Goyal
d37bd7afcf
Create the sRGB colorspace description we need 2025-07-31 18:30:47 +05:30
Kovid Goyal
fe860d170f
Track that the compositor supports the sRGB primary 2025-07-31 15:39:55 +05:30
Kovid Goyal
46114c251b
Create the color manager object for a window surface 2025-07-31 15:24:21 +05:30
Kovid Goyal
8762576a5b
Also track support for extlinear transfer function 2025-07-31 15:12:26 +05:30
Kovid Goyal
d0a862bedb
Get the color manager capabilities from the compositor 2025-07-31 15:09:18 +05:30
Kovid Goyal
f04e963683
Bind the wayland color manager interface 2025-07-31 14:37:42 +05:30
Kovid Goyal
6f689f3221
Work on keyboard grabbing functionality 2025-05-18 11:37:11 +05:30
Kovid Goyal
8017945551
Wayland: Add support for the xdg-toplevel-tag protocol
Now you can use --name or its alias --os-window-tag to set the tag.
2025-05-15 09:35:42 +05:30
Kovid Goyal
88f4c829eb
Improve handling of output names
Now can use panel --output-name list to list available outputs.
Also, --output-name works on macOS
2025-05-13 15:29:37 +05:30
Kovid Goyal
c1b6b4494a
Implement starting kitty hidden
Fixes #3466
2025-04-23 08:50:02 +05:30
Kovid Goyal
5d2e258c35
Wayland: When the compositor supports the xdg-system-bell protocol use it to play the default bell sound 2025-04-16 15:48:51 +05:30
Kovid Goyal
49092f5a94
Add new wayland top level state enum values 2025-04-09 19:23:27 +05:30
Kovid Goyal
3b8e0e209b
Wayland: Allow overriding the kitty OS Window icon on compositors that implement the xdg-toplevel-icon protocol 2025-03-10 12:32:03 +05:30
Kovid Goyal
0c47f81187
Remove special casing for Hyprland
Hyprland has now been fixed to send only a single fractional scale
event, so no need for special casing it.
2025-01-22 18:53:46 +05:30
Kovid Goyal
0527db876b
Wayland niri: Fix 250ms delay on startup when using scale 1
We special case Hyprland, hopefully the special casing can be removed
once https://github.com/hyprwm/Hyprland/issues/9126 is fixed.

Fixes #8236
2025-01-21 16:40:32 +05:30
Kovid Goyal
7346aca56d
Function to probe for Wayland compositor name
Maybe needed to workaround #8236
2025-01-21 15:10:07 +05:30
Kovid Goyal
1ff74b86dc
Wayland GNOME: Workaround bug in mutter causing double tap on titlebar to not always work
Fixes #8054
2024-11-18 08:46:17 +05:30
Kovid Goyal
627360e5ad
Bind the idle inhibit protocol even though it is currently unused 2024-08-27 11:32:06 +05:30
Kovid Goyal
d7902f6b24
Wayland GNOME: Fix a small rendering artifact when docking a window at a screen edge or maximizing it
For some reason destroying the shadow surfaces causes mutter to render one of them at its old relative position. So workaround by not destroying the surfaces, modern mutter anyway seems to hide them when the window is docked.

Fixes #7701
2024-08-07 13:34:10 +05:30
Kovid Goyal
190566be8e
Wayland: Fix specifying the output name for the panel kitten not working
Fixes #7573
2024-06-25 12:53:37 +05:30
Kovid Goyal
88aa4d1de3
Revert 72272ab4fe
Apparently NVIDIA drivers dont handle this well. Sigh.

Go back to calling wl_egl_window_resize() before resizing the
framebuffer instead of before swapping in the resized framebuffer.
Logically, these should be equivalent, but...

Wayland is such an ongoing disaster.

Fixes #7493 (I hope).
2024-06-02 19:24:00 +05:30
Kovid Goyal
8c7994c0ac
Dont call wl_egl_window_resize on every swap 2024-04-24 10:04:06 +05:30
Kovid Goyal
72272ab4fe
Remove need for context switching
Call wl_egl_window_resize just buffer swapping buffers at which point
the context is already correct.

Also might workaround bugs in the NVIDIA driver: https://github.com/NVIDIA/egl-wayland/issues/52
2024-04-24 09:27:02 +05:30
Kovid Goyal
8d1b0e54af
Use double for wayland float calculation 2024-04-19 22:23:01 +05:30
Kovid Goyal
ac4eef7eb3
Another try at pointer frame support on Wayland
This time I think I got the wheel handling correct. At least works with
my wheel mouse.
2024-04-08 19:07:52 +05:30
Kovid Goyal
8fc96c5bd7
Make the debug logging functions consistent
They now all output the same format of:
[time since program start] msg
2024-04-08 12:53:55 +05:30