1575 Commits

Author SHA1 Message Date
Kovid Goyal
e36f6ac1b8 Use most recently focused OS Window when available to guess the monitor to use for fractional scale
Slight improvement in odds of guessing right for subsequent OS Windows.
2026-07-21 13:02:23 +05:30
Kovid Goyal
bb1088a87a Wayland: Fix using remote control to resize OS windows on some tiling compositors leading to broken rendering 2026-07-21 10:12:34 +05:30
Kovid Goyal
6ed833e163 Wayland: get initial window size in cells working in most cases on hyprland/sway with fractional scaling by using the fractional scale of the primary monitor 2026-07-21 10:03:40 +05:30
Kovid Goyal
fe9828a0e4 Workaround for dragging not starting on niri
niri for some reason known only to itself does not send any pointer
leave/data device enter/data source events when it accepts a grab. The
only event it seems to send is surface enter on the drag icon surface,
and that too it sends that event much later.

Handle this bonkers behavior by retrying the sync multiple times to
detect if niri has accepted the drag or not.

Fixes #10271
2026-07-21 09:04:45 +05:30
Dan Egnor
db14d7c220 Wayland: map first window at correct size with fractional scaling
The first OS window on Wayland is created at scale 1 because the
compositor only sends the fractional scale after the surface exists.
The initial size in cells is therefore computed with scale-1 cell
metrics and the window is mapped a few cells too small. The existing
post-map recompute calls glfwSetWindowSize(), but on Wayland that loses
to the compositor's authoritative configure, which re-asserts the size
it recorded at map time. So a window that receives focus (the normal
interactive case) stays too small; a background window that never gets
an activated configure happens to keep the resized value, which is why
it can look fixed.

Correct the size while the window is still unmapped instead. GLFW gains
a hook (glfwWaylandSetInitialWindowSizeCallback) that it invokes when
the fractional scale is applied during creation -- mutter, kwin and niri
send the scale before the first configure -- letting the embedder
recompute the cell-based logical size for the real scale before the
window is mapped. The compositor then records the correct size and its
activation configure agrees, so there is nothing to race.

The existing post-map recompute is kept as a fallback for compositors
that only send the scale after the first configure (sway, Hyprland).

Also add glfwCocoaSetWindowLevel to the glfw.py wrapper generator list:
it was present in the committed glfw-wrapper but missing from the
generator, so regenerating the wrapper (required to add the hook above)
would otherwise drop it and break the macOS build.
2026-07-18 20:48:11 -07:00
Kovid Goyal
4b7aac4999 macOS: Use a private API to ensure OS window is shown on the currently active space when toggled
Fixes #8740
2026-07-16 08:43:06 +05:30
Sinity
0dc74cd93b Wayland: fail window creation cleanly when the OpenGL context cannot be created
_glfwPlatformCreateWindow() ignored the return value of
attach_opengl_context_to_window(), so when EGL is unavailable (for
example libEGL cannot be loaded) it reported success with
window->context left zeroed. glfwCreateWindow() then proceeded to
_glfwRefreshContextAttribs() -> glfwMakeContextCurrent(), which calls
the NULL context.makeCurrent pointer: kitty crashes with SIGSEGV
instead of reporting "Failed to create GLFWwindow. This usually
happens because of old/broken OpenGL drivers." as intended. The X11
backend already propagates these failures.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-11 21:04:38 +02:00
lsdhophora
00029d0a6f Fix IME popup position after text_input re-enters on Wayland
When a kitty window regains text-input focus (e.g. switching back to a
workspace in sway, unminimizing, or unlocking the screen), the
zwp_text_input_v3::enter event is fired. However, text_input_enter()
only called enable + set_content_type without restoring the cursor
rectangle. If the compositor does not re-send wl_keyboard.enter at the
same time, kitty never updates the IME position, causing the popup to
appear at the top-left corner.

Restore the last known cursor rectangle in text_input_enter() so the
IME popup immediately appears at the correct position.
2026-07-09 08:22:06 +08:00
zhaolei
e7a7362d54 Make first mouse clicks activate and pass through
Allow the first mouse click on an inactive Cocoa OS window to be delivered to kitty instead of only activating the window.

Make the matching kitty-internal behavior consistent by forwarding clicks that switch focus to another kitty window in the currently focused OS window. This lets the same first click both focus the target kitty window and perform the click action, including forwarding to mouse-tracking applications.
2026-07-07 15:51:20 +08:00
MiguelRegueiro
0b95d43833 Fix Wayland drag source startup on FreeBSD 2026-07-06 21:07:08 +02:00
MiguelRegueiro
aedb75d4f3 Fix FreeBSD Wayland build 2026-07-06 21:07:01 +02:00
Kovid Goyal
804438fb8d Merge branch 'macos-topmost-panel' of https://github.com/agmitron/kitty 2026-07-04 12:14:04 +05:30
Kovid Goyal
0bb8502f31 Increase timeout for receiving capabilities from notification daemon
Fixes #10215
2026-07-03 13:43:41 +05:30
Aleksei Gmitron
8c32f093bb wip: MacOS-specific config settings 2026-06-21 22:31:03 +04:00
Kovid Goyal
285c576ddd Merge branch 'fix-wayland-start-drag-silently-ignored' of https://github.com/ttys3/kitty 2026-06-18 10:37:36 +05:30
Kovid Goyal
bdfcfc4fc2 Another stab at #10152 2026-06-16 05:43:25 +05:30
Kovid Goyal
1dc3730782 macOS: handle the OS calling insertText: with a nil string
Fixes #10152
2026-06-15 13:36:18 +05:30
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
Aleksei Gmitron
511cb7b0b9 wip: add --layer=shell for menu bars 2026-06-11 09:29:48 +04: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
Aleksei Gmitron
c79bba89ff feat: add topmost functionality for MacOS 2026-06-07 17:50:12 +04:00
Connor Welsh
fb4d05f7e8 Wayland: Fix crash hiding titlebar on layer-shell windows
inform_compositor_of_window_geometry() calls xdg_surface_set_window_geometry()
unconditionally, but layer-shell surfaces (e.g. those from `kitten panel`) have
no xdg_surface. With hide_window_decorations set to titlebar-only, the panel hits
this geometry call during creation and dereferences the NULL proxy, crashing in
wl_proxy_get_version() with SIGSEGV.

Guard on window->wl.xdg.surface: layer-shell surfaces manage geometry via the
layer surface, so the xdg call is skipped. Normal toplevels are unaffected.
2026-05-30 16:14:55 -04:00
copilot-swe-agent[bot]
0146b02aaf Fix #10082: Re-apply _NET_WM_STATE for X11 layer shell windows on each show
Some window managers (e.g. kwin_x11) clear _NET_WM_STATE when a window
is unmapped/withdrawn. This caused layer shell windows to lose states like
_NET_WM_STATE_ABOVE, _NET_WM_STATE_SKIP_TASKBAR, etc. when hidden and
re-shown via toggle. The result was inconsistent behaviour between the
first show and subsequent shows.

Fix by calling update_wm_hints() before XMapWindow in
_glfwPlatformShowWindow() for layer shell windows, which re-applies all
WM state properties (_NET_WM_STATE, window type, strut, size hints)
before each map operation.
2026-05-28 02:07:59 +00:00
Kovid Goyal
2096948cbc Wayland: Only use key repeat events from server is repeat rate == 0
Fixes #10070
2026-05-26 08:31:52 +05:30
Kovid Goyal
a17b2df580 Fix #10054 2026-05-22 07:57:41 +05:30
copilot-swe-agent[bot]
9ef08fd865 glfw/input.c: fix dedup to swap duplicates to end instead of overwriting pointers
Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/071dfd57-73e7-4daa-8d35-955bec8b1c4b

Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
2026-05-19 02:12:29 +00:00
copilot-swe-agent[bot]
1aaae286a8 glfw/input.c: remove duplicate mimetypes in _glfwInputDropEvent using verstable
Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/2d7a111f-7d98-4cb0-b085-823736cbf5db

Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
2026-05-19 02:00:12 +00:00
copilot-swe-agent[bot]
c7ded8b8fd fix: send XdndStatus(rejected) instead of XdndFinished on non-accepting window
Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/dc998620-35db-456d-8355-63e39f385464

Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
2026-05-18 05:02:06 +00:00
Kovid Goyal
3118901800 Add some DnD debug statements for X11 2026-05-18 10:20:16 +05:30
Kovid Goyal
57a94d132f When hardlink fails fallback to full copy 2026-05-17 21:12:34 +05:30
Kovid Goyal
f4463703b1 Create a placeholder directory rather than a file when we are transferring directories 2026-05-17 12:40:12 +05:30
Kovid Goyal
75b99a3cbf Fix drop state update on move incorrect when transitioning between windows 2026-05-17 07:50:41 +05:30
Kovid Goyal
613e1ccbe3 ... 2026-05-16 16:58:32 +05:30
Kovid Goyal
0e3a193db6 macOS APIs are really really bonkers 2026-05-16 16:49:47 +05:30
Kovid Goyal
ffec9a854a macOS: Resolve file reference URLs before using them to populate text/uri-list 2026-05-16 16:28:50 +05:30
Kovid Goyal
12e2f80df3 Dont make temp dir world writeable 2026-05-16 13:24:45 +05:30
Kovid Goyal
c278e82ab5 Rewrite macOS drop handling code to workaround Apple's insanely limited API 2026-05-16 13:06:23 +05:30
Kovid Goyal
418ea57382 Have fire_drag_finished cleanup even if no window is present 2026-05-15 13:39:31 +05:30
Kovid Goyal
7e42ef73d3 file promise providers are anyway stored globally so no need to store them on draggingItem's user info 2026-05-15 13:34:53 +05:30
Kovid Goyal
69800d89c0 ... 2026-05-15 13:31:22 +05:30
Kovid Goyal
320bd90ebb macOS: Pass drop intent to OS 2026-05-15 12:58:53 +05:30
Kovid Goyal
35cd3d37f2 Fix dnd from remote to finder on macOS 2026-05-15 10:00:38 +05:30
Kovid Goyal
2a903c724c Fix missing Block_copy 2026-05-15 08:22:30 +05:30
copilot-swe-agent[bot]
d3b12031bd replace C11 atomics with dispatch_group_t to fix undeclared identifier errors
Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/2f0107b0-a6e4-447c-8178-60d65038df4b

Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
2026-05-14 11:38:44 +00:00
copilot-swe-agent[bot]
983185cc62 use atomic counter and url.absoluteString in file-promise uri-list implementation
Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/c28b23d9-b2b8-42d8-914c-85a253d34b12

Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
2026-05-14 11:16:44 +00:00
copilot-swe-agent[bot]
71dbfcd7ff implement TODO: receive file promises into temp dir for text/uri-list DnD on macOS
Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/c28b23d9-b2b8-42d8-914c-85a253d34b12

Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
2026-05-14 11:12:51 +00:00
Kovid Goyal
e9b41513d4 ... 2026-05-14 16:32:35 +05:30
Kovid Goyal
1ff9165335 Store uri-list items as promises correctly 2026-05-14 16:25:29 +05:30
Kovid Goyal
61ea2b4a38 ... 2026-05-14 15:27:26 +05:30
Kovid Goyal
307717213b Set the correct filename for uri-list items 2026-05-14 14:42:52 +05:30