Skip to content

Fix focus loss during inline rename when pressing Alt+Shift - #3837

Closed
dronov-dmitry wants to merge 1 commit into
linuxmint:masterfrom
dronov-dmitry:fix-rename-focus-loss-alt-shift
Closed

dronov-dmitry wants to merge 1 commit into
linuxmint:masterfrom
dronov-dmitry:fix-rename-focus-loss-alt-shift

Conversation

@dronov-dmitry

@dronov-dmitry dronov-dmitry commented Sep 8, 2026 •

Copy link
Copy Markdown

Summary

When renaming a file or folder (F2) in Nemo, pressing Alt+Shift to switch keyboard
layout causes the rename text entry to lose focus. The rename operation is cancelled
and the file returns to its original name. This affects all three view modes:
Icon View, List View, and Compact View.

Root Cause

The rename guard at nemo-window.c correctly bypasses Nemo's own accelerator
bindings, but does NOT prevent GTK from processing the unhandled Alt key event.
The unhandled bare Alt key falls through to GTK's default handler, which interprets
it as a menubar toggle trigger, causing focus loss on the rename entry.

Fix

Consume bare Alt key press/release events during rename in
nemo_window_key_press_event() and nemo_window_key_release_event() before GTK
can process them as menubar toggles.

  • Only blocks bare Alt presses (no other modifiers) during rename
  • Alt+letter combinations (Alt+F, Alt+B for word movement) still work
  • Ctrl+Alt, Shift+Alt combinations still propagate normally
  • Minimal change contained to a single file

Testing

  1. Open Nemo in Icon View, List View, and Compact View
  2. Select a file and press F2 to rename
  3. While the rename text entry is focused, press Alt+Shift
  4. Expected: The keyboard layout switches, rename field keeps focus
  5. Before fix: Rename field loses focus, rename is cancelled

Additional test cases:

  • Alt+F / Alt+B should still move cursor by word in rename field
  • Alt+Tab should work normally when NOT in rename mode
  • Escape should cancel rename, Enter should confirm rename

Video:
https://youtu.be/pSitfxwCchM

Consuming bare Alt key press/release events during rename to prevent
GTK from interpreting them as menubar toggle triggers, which caused
the rename entry to lose focus and cancel the rename operation.

Affects Icon View, List View, and Compact View.
@mtwebster

Copy link
Copy Markdown
Member

Cannot reproduce in git master - you specify no environment/desktop... it's possible Cinnamon was causing this in 6.6, but no longer, and this really isn't the place to fix it anyhow.

@mtwebster mtwebster closed this Sep 24, 2026
@dronov-dmitry

Copy link
Copy Markdown
Author

Environment (as requested): Zorin OS 18.1, X11, GNOME Shell (not Cinnamon), GTK 3.24.41, nemo 6.7.6 — recorded 2026-09-08, video in the PR description.

Follow-up: after system updates on 2026-09-22 (GLib 2.80.0-6ubuntu3.8 → 3.9 among others) I can no longer reproduce this on current master, even manually — ~30 scripted XTEST runs (Alt+Shift bursts, bare Alt, timing variants, icon/list views) plus 4 manual variants (rename started from RU layout, immediate Alt+Shift, list view), with AT-SPI focus tracing confirming the rename entry never loses focus.

So it was either fixed indirectly upstream or is timing/environment-specific. I will not push to reopen — but feel free to ping me if a guarded fix turns out to be worthwhile; I can reopen with the environment details above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants