Skip to content

Commit

Permalink
When focusing a frame under the mouse, prefer to focus its topmost tr…
Browse files Browse the repository at this point in the history
…ansient.
  • Loading branch information
gijsbers committed Jul 21, 2024
1 parent 8b30a83 commit 45b67d7
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/wmmgr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2133,11 +2133,7 @@ YFrameWindow *YWindowManager::getLastFocus(bool skipAllWorkspaces, int workspace
if (workspace == AllWorkspaces)
workspace = activeWorkspace();

YFrameWindow *toFocus = nullptr;

if (toFocus == nullptr) {
toFocus = workspaces[workspace].focused;
}
YFrameWindow *toFocus = workspaces[workspace].focused;

if (toFocus != nullptr) {
if (toFocus->isUnmapped() ||
Expand All @@ -2152,6 +2148,25 @@ YFrameWindow *YWindowManager::getLastFocus(bool skipAllWorkspaces, int workspace

if (toFocus == nullptr && clickFocus == false) {
toFocus = getFrameUnderMouse(workspace);
YFrameWindow* previous = nullptr;
while (toFocus != previous) {
previous = toFocus;
for (YFrameClient* trans = toFocus->transient();
trans; trans = trans->nextTransient()) {
YFrameWindow* frame = trans->getFrame();
if (frame && frame != toFocus &&
frame->isUnmapped() == false &&
frame->visibleOn(workspace) &&
frame->avoidFocus() == false &&
trans->destroyed() == false &&
trans != taskBar &&
(frame->getActiveLayer() > toFocus->getActiveLayer() ||
(frame->getActiveLayer() == toFocus->getActiveLayer()
&& frame->isBefore(toFocus)))) {
toFocus = frame;
}
}
}
}

if (toFocus == nullptr) {
Expand Down

0 comments on commit 45b67d7

Please sign in to comment.