Skip to content

fix: correct operator precedence on grabOp tabbed-focus guard#524

Open
mayconrcmello wants to merge 1 commit intoforge-ext:mainfrom
mayconrcmello:fix/grabop-precedence-typo
Open

fix: correct operator precedence on grabOp tabbed-focus guard#524
mayconrcmello wants to merge 1 commit intoforge-ext:mainfrom
mayconrcmello:fix/grabop-precedence-typo

Conversation

@mayconrcmello
Copy link
Copy Markdown

Summary

updateMetaWorkspaceMonitor() has

if (!this.grabOp === Meta.GrabOp.WINDOW_BASE)
  this.updateTabbedFocus(existNodeWindow);

JavaScript binds ! tighter than ===, so this evaluates as (!this.grabOp) === Meta.GrabOp.WINDOW_BASE — a boolean compared to an integer, which is always false. updateTabbedFocus has never run from this code path.

Every other Meta.GrabOp comparison in the codebase is of the form grabOp === Meta.GrabOp.X (see lib/extension/utils.js lines 227–250, lib/extension/window.js line 2515 in the same file), so the typo is an isolated mistake.

Intent (matching the comment "Ensure that the workspace tiling is honored"): skip the update only when the grab op is WINDOW_BASE (i.e. don't yank tabbed focus mid-drag). Fix:

- if (!this.grabOp === Meta.GrabOp.WINDOW_BASE) this.updateTabbedFocus(existNodeWindow);
+ if (this.grabOp !== Meta.GrabOp.WINDOW_BASE) this.updateTabbedFocus(existNodeWindow);

User-visible effect

In a tabbed container, when a tabbed window is moved across workspaces or monitors without an active drag (e.g. via keyboard, programmatic move, dynamic workspace shift), the tab header should re-render to follow the focused window — currently it doesn't, because the updateTabbedFocus call is dead code.

Test plan

  • node --check
  • Move a window from a tabbed container to another workspace via Super+Shift+1..9: with the fix, the tab head on the source workspace re-renders correctly.

Notes

This is the kind of bug a typechecker (TS or even just eslint --no-mixed-operators) would catch on the first pass; might be worth wiring one in eventually, but out of scope for this fix.

In updateMetaWorkspaceMonitor():

  if (!this.grabOp === Meta.GrabOp.WINDOW_BASE)
    this.updateTabbedFocus(existNodeWindow);

`!` binds tighter than `===`, so this evaluates as
`(!this.grabOp) === Meta.GrabOp.WINDOW_BASE` — i.e. a boolean compared
to an integer, which is *always* false. updateTabbedFocus has therefore
never run from this code path.

The intent (matching every other GrabOp comparison in the codebase, all
of the form `grabOp === Meta.GrabOp.X`) is "skip the update only when
the grab op IS WINDOW_BASE" — i.e. don't yank tabbed focus while the
user is mid-drag. Replace with `this.grabOp !== Meta.GrabOp.WINDOW_BASE`.

Surfaces when a tabbed window is moved across workspaces/monitors
without an active grab — the tab head should follow the focus, but
currently doesn't.
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.

1 participant