Repository navigation
Conversation
-setinputfocus: writes _NET_WM_USER_TIME from -lastTime. -lastTime answers CurrentTime, which is 0, before the backend has seen an event and again once the last event is more than half a second old. In this property 0 means the window should not get the focus when it is mapped, so Mutter stacks the window below the focused one. An application's first window opens behind whatever the user was looking at, and it can look as if the application didn't start. -setinputfocus: now writes the property only when -lastTime has a real time. A window that had one keeps it. XSetInputFocus is unchanged. Testing: Tests/x11/usertime.m starts the x11 tests' stand-in EWMH window manager, because the backend writes the property only under one, and reads _NET_WM_USER_TIME back after -setinputfocus:. A window focused before any event, and one focused once the last event is out of date, must have no property. A window focused just after an event must have that event's time, which guards against the write being lost altogether. Focusing that window again later must leave its time alone. It reads only the property, so that is enough to catch the 0 being written; what a window manager does with the property isn't tested there. Without this change 3 of the 4 checks fail; with it all 4 pass. The whole suite, with libs-gui 549f63913: 290 passed, none failed; on master with the new test added, 287 passed and only those 3 failed. Under GNOME Shell 48.7 (X11, private Xvfb), with another application's window focused, a small program opened a window with -makeKeyAndOrderFront: when launching finished, 3 runs each: - master: the window has _NET_WM_USER_TIME 0 and stays below the other application's window; - with this change: it has no property and comes up on top. The same runs opened a second window 3 seconds later, after the other application had been activated again. On master it stays behind; with this change it comes up on top, because the choice is then left to the window manager's own rules. Not covered: a real Wayland session (XWayland), other window managers, and windows the gui decorates. AI assistance: this change, its test and this description were written with Claude (Anthropic's Claude Code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
-[XGServer setinputfocus:]writes_NET_WM_USER_TIMEfrom-lastTime.-lastTimeanswersCurrentTime, which is 0, before the backend has seen an event and again once the last event is more than half a second old. In this property 0 means the window should not get the focus when it is mapped, and Mutter stacks such a window below the focused one. So under GNOME an application's first window can open behind whatever the user was looking at, and it can look as if the application didn't start.This is the symptom of #62. #65 (
0504204), which closed that issue, passes onDESKTOP_STARTUP_IDand doesn't touch this property. It is in master, and this still reproduces on master when the application is started without a startup ID.The change writes the property only when
-lastTimehas a real time. A window that already has one keeps it.XSetInputFocusis unchanged.Under GNOME Shell 48.7 (X11, private Xvfb), with another application's window focused, a small program opened a window with
-makeKeyAndOrderFront:when launching finished, and a second one 3 seconds later, after the other application had been activated again. 3 runs each:d378734)_NET_WM_USER_TIMEThe last row is a change in behaviour you may want to weigh. On master, a window opened more than half a second after the application's last event stays behind, as a side effect of the 0. With this change the backend reports no time for it, so it's left to the window manager's own rules, and under Mutter it came up over the application the user had moved to. If you'd rather keep that behaviour, the check could be limited to the case before the first event, but
-lastTimedoesn't separate the two today.Testing:
Tests/x11/usertime.mstarts the x11 tests' stand-in EWMH window manager, because the backend writes the property only under one, and reads_NET_WM_USER_TIMEback after-setinputfocus:.It reads only the property, so it catches the 0 being written but not what a window manager does with it. Without the change 3 of the 4 checks fail; with it all 4 pass. The whole suite, with libs-gui
549f63913: 290 passed, none failed. On master with the new test added: 287 passed, and only those 3 failed. The changed file and the test also pass a syntax check with GCC's Objective-C front end.Not covered: a real Wayland session (XWayland), other window managers, windows the gui decorates, and a launch with a startup ID (the runs above had none). The test depends on the half-second limit in
XGServerEvent.m.AI assistance: this change, its test and this description were written with Claude (Anthropic's Claude Code).
🤖 Generated with Claude Code