Skip to content

Commit

Permalink
If present, select the active window in the current screen
Browse files Browse the repository at this point in the history
  • Loading branch information
luisbocanegra committed Apr 25, 2024
1 parent f3724f9 commit 0eb7e52
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions package/contents/ui/tools/focusTopWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,32 @@ function printLog(strings, ...values) {
}
}
const windows = workspace.windowList();
printLog`PPSE: Focusing top window...\n`
printLog`Focusing top window...\n`
var topWindow
let stackPosition = -1


var currentScreen = workspace.screenAt(workspace.cursorPos)
// TODO is this needed at all if workspace.activeScreen should always have the screen with cursor?
var currentScreen = workspace.screenAt(workspace.cursorPos)
var currentDesktop = workspace.currentDesktop
printLog`active screen: ${workspace.activeScreen.name} current: ${currentScreen.name}`
for (var i = 0; i < windows.length; i++) {
if (windows[i].output === workspace.activeScreen && !windows[i].desktopWindow && windows[i].normalWindow && !windows[i].minimized && windows[i].moveable && !windows[i].hidden) {
if (windows[i].stackingOrder > stackPosition) {
topWindow = windows[i]
let window = windows[i]
if (window.output === workspace.activeScreen
&& (window.onAllDesktops || window.desktops.includes(currentDesktop))
&& !window.desktopWindow
&& window.normalWindow
&& !window.minimized
&& !window.hidden
) {
if (window.active) {
topWindow = window
break
}
if (window.stackingOrder > stackPosition) {
topWindow = window
}
stackPosition = windows[i].stackingOrder
stackPosition = window.stackingOrder
}
}
workspace.activeWindow = topWindow
resut = ("Top: " + topWindow.caption + "|" + topWindow.resourceName + "|" + topWindow.resourceClass + "|" + topWindow.stackingOrder + "|" + topWindow.output.name)
const resut = ("Top: " + topWindow.caption + "|" + topWindow.resourceName + "|" + topWindow.resourceClass + "|" + topWindow.stackingOrder + "|" + topWindow.output.name)
printLog`${resut}`

0 comments on commit 0eb7e52

Please sign in to comment.