mirror of
https://github.com/hyprwm/Hypr.git
synced 2024-11-26 06:45:58 +01:00
Focus to a fullscreen window if present (manual focus)
This commit is contained in:
parent
df02ccaa75
commit
7da0c70be8
2 changed files with 33 additions and 8 deletions
|
@ -1286,19 +1286,33 @@ void CWindowManager::moveActiveWindowTo(char dir) {
|
||||||
warpCursorTo(CURRENTWINDOW->getPosition() + CURRENTWINDOW->getSize() / 2.f);
|
warpCursorTo(CURRENTWINDOW->getPosition() + CURRENTWINDOW->getSize() / 2.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CWindow* CWindowManager::getFullscreenWindowByWorkspace(const int& id) {
|
||||||
|
for (auto& window : windows) {
|
||||||
|
if (window.getWorkspaceID() == id && window.getFullscreen())
|
||||||
|
return &window;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void CWindowManager::moveActiveFocusTo(char dir) {
|
void CWindowManager::moveActiveFocusTo(char dir) {
|
||||||
const auto CURRENTWINDOW = getWindowFromDrawable(LastWindow);
|
const auto CURRENTWINDOW = getWindowFromDrawable(LastWindow);
|
||||||
|
|
||||||
if (!CURRENTWINDOW)
|
if (!CURRENTWINDOW)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const auto neighbor = getNeighborInDir(dir);
|
const auto PWORKSPACE = getWorkspaceByID(CURRENTWINDOW->getWorkspaceID());
|
||||||
|
|
||||||
if (!neighbor)
|
if (!PWORKSPACE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const auto NEIGHBOR = PWORKSPACE->getHasFullscreenWindow() ? getFullscreenWindowByWorkspace(PWORKSPACE->getID()) : getNeighborInDir(dir);
|
||||||
|
|
||||||
|
if (!NEIGHBOR)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// move the focus
|
// move the focus
|
||||||
setFocusedWindow(neighbor->getDrawable());
|
setFocusedWindow(NEIGHBOR->getDrawable());
|
||||||
|
|
||||||
// finish by moving the cursor to the current window
|
// finish by moving the cursor to the current window
|
||||||
warpCursorTo(CURRENTWINDOW->getPosition() + CURRENTWINDOW->getSize() / 2.f);
|
warpCursorTo(CURRENTWINDOW->getPosition() + CURRENTWINDOW->getSize() / 2.f);
|
||||||
|
@ -1324,13 +1338,23 @@ void CWindowManager::changeWorkspaceByID(int ID) {
|
||||||
|
|
||||||
activeWorkspaces[workspace.getMonitor()] = workspace.getID();
|
activeWorkspaces[workspace.getMonitor()] = workspace.getID();
|
||||||
|
|
||||||
// set the focus to any window on that workspace
|
// if not fullscreen set the focus to any window on that workspace
|
||||||
|
// if fullscreen, set to the fullscreen window
|
||||||
|
const auto PWORKSPACE = getWorkspaceByID(ID);
|
||||||
|
if (PWORKSPACE) {
|
||||||
|
if (!PWORKSPACE->getHasFullscreenWindow()) {
|
||||||
for (auto& window : windows) {
|
for (auto& window : windows) {
|
||||||
if (window.getWorkspaceID() == ID && window.getDrawable() > 0) {
|
if (window.getWorkspaceID() == ID && window.getDrawable() > 0) {
|
||||||
g_pWindowManager->setFocusedWindow(window.getDrawable());
|
setFocusedWindow(window.getDrawable());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
const auto PFULLWINDOW = getFullscreenWindowByWorkspace(ID);
|
||||||
|
if (PFULLWINDOW)
|
||||||
|
setFocusedWindow(PFULLWINDOW->getDrawable());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Update bar info
|
// Update bar info
|
||||||
updateBarInfo();
|
updateBarInfo();
|
||||||
|
|
|
@ -143,6 +143,7 @@ private:
|
||||||
SMonitor* getMonitorFromWorkspace(const int&);
|
SMonitor* getMonitorFromWorkspace(const int&);
|
||||||
void recalcEntireWorkspace(const int&);
|
void recalcEntireWorkspace(const int&);
|
||||||
void fixMasterWorkspaceOnClosed(CWindow* pWindow);
|
void fixMasterWorkspaceOnClosed(CWindow* pWindow);
|
||||||
|
CWindow* getFullscreenWindowByWorkspace(const int&);
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::unique_ptr<CWindowManager> g_pWindowManager = std::make_unique<CWindowManager>();
|
inline std::unique_ptr<CWindowManager> g_pWindowManager = std::make_unique<CWindowManager>();
|
||||||
|
|
Loading…
Reference in a new issue