diff options
author | outfoxxed <[email protected]> | 2023-07-19 03:39:45 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2023-07-19 12:39:45 +0200 |
commit | 5cd5631fb226e315a233473c961714ed1c73840f (patch) | |
tree | 2d1297195b663a649562573e6ac62c5dc4c2ee0e | |
parent | b8a7b090927de245ce9271d115b5bff459810a1a (diff) | |
download | Hyprland-5cd5631fb226e315a233473c961714ed1c73840f.tar.gz Hyprland-5cd5631fb226e315a233473c961714ed1c73840f.zip |
Add bringWindowToTop function to IHyprLayout (#2747)
* Add bringWindowToTop function to IHyprLayout
* Rename `bringWindowToTop` to `requestFocusForWindow`
* Fix doc
-rw-r--r-- | src/Window.cpp | 11 | ||||
-rw-r--r-- | src/layout/IHyprLayout.cpp | 9 | ||||
-rw-r--r-- | src/layout/IHyprLayout.hpp | 7 |
3 files changed, 17 insertions, 10 deletions
diff --git a/src/Window.cpp b/src/Window.cpp index 30a0029e..6be36f5e 100644 --- a/src/Window.cpp +++ b/src/Window.cpp @@ -234,16 +234,7 @@ void CWindow::createToplevelHandle() { // handle events hyprListener_toplevelActivate.initCallback( - &m_phForeignToplevel->events.request_activate, - [&](void* owner, void* data) { - if (isHidden() && m_sGroupData.pNextWindow) { - // grouped, change the current to us - setGroupCurrent(this); - } - - g_pCompositor->focusWindow(this); - }, - this, "Toplevel"); + &m_phForeignToplevel->events.request_activate, [&](void* owner, void* data) { g_pLayoutManager->getCurrentLayout()->requestFocusForWindow(this); }, this, "Toplevel"); hyprListener_toplevelFullscreen.initCallback( &m_phForeignToplevel->events.request_fullscreen, diff --git a/src/layout/IHyprLayout.cpp b/src/layout/IHyprLayout.cpp index 1315692b..15e1e687 100644 --- a/src/layout/IHyprLayout.cpp +++ b/src/layout/IHyprLayout.cpp @@ -519,4 +519,13 @@ CWindow* IHyprLayout::getNextWindowCandidate(CWindow* pWindow) { return PWINDOWCANDIDATE; } +void IHyprLayout::requestFocusForWindow(CWindow* pWindow) { + if (pWindow->isHidden() && pWindow->m_sGroupData.pNextWindow) { + // grouped, change the current to this window + pWindow->setGroupCurrent(pWindow); + } + + g_pCompositor->focusWindow(pWindow); +} + IHyprLayout::~IHyprLayout() {} diff --git a/src/layout/IHyprLayout.hpp b/src/layout/IHyprLayout.hpp index a6bd1829..eff0d3e6 100644 --- a/src/layout/IHyprLayout.hpp +++ b/src/layout/IHyprLayout.hpp @@ -148,6 +148,13 @@ interface IHyprLayout { */ virtual void replaceWindowDataWith(CWindow* from, CWindow* to) = 0; + /* + Called via the foreign toplevel activation protocol. + Focuses a window, bringing it to the top of its group if applicable. + May be ignored. + */ + virtual void requestFocusForWindow(CWindow*); + private: Vector2D m_vBeginDragXY; Vector2D m_vLastDragXY; |