11
11
#include " debug/Log.hpp"
12
12
#include " helpers/varlist/VarList.hpp"
13
13
14
+ #include < hyprutils/string/VarList.hpp>
14
15
#include < optional>
15
16
#include < iterator>
16
17
#include < string>
@@ -91,6 +92,7 @@ CKeybindManager::CKeybindManager() {
91
92
m_mDispatchers[" resizeactive" ] = resizeActive;
92
93
m_mDispatchers[" moveactive" ] = moveActive;
93
94
m_mDispatchers[" cyclenext" ] = circleNext;
95
+ m_mDispatchers[" cyclenextvisible" ] = circleNextVisible;
94
96
m_mDispatchers[" focuswindowbyclass" ] = focusWindow;
95
97
m_mDispatchers[" focuswindow" ] = focusWindow;
96
98
m_mDispatchers[" tagwindow" ] = tagWindow;
@@ -311,8 +313,10 @@ bool CKeybindManager::tryMoveFocusToMonitor(CMonitor* monitor) {
311
313
}
312
314
313
315
void CKeybindManager::switchToWindow (PHLWINDOW PWINDOWTOCHANGETO) {
314
- const auto PLASTWINDOW = g_pCompositor->m_pLastWindow .lock ();
316
+ if (PWINDOWTOCHANGETO == nullptr )
317
+ return ;
315
318
319
+ const auto PLASTWINDOW = g_pCompositor->m_pLastWindow .lock ();
316
320
if (PWINDOWTOCHANGETO == PLASTWINDOW || !PWINDOWTOCHANGETO)
317
321
return ;
318
322
@@ -330,23 +334,23 @@ void CKeybindManager::switchToWindow(PHLWINDOW PWINDOWTOCHANGETO) {
330
334
331
335
if (!PWINDOWTOCHANGETO->m_bPinned )
332
336
g_pCompositor->setWindowFullscreen (PWINDOWTOCHANGETO, true , FSMODE);
333
- } else {
334
- updateRelativeCursorCoords ();
335
- g_pCompositor->focusWindow (PWINDOWTOCHANGETO);
336
- PWINDOWTOCHANGETO->warpCursor ();
337
+ return ;
338
+ }
339
+ updateRelativeCursorCoords ();
340
+ g_pCompositor->focusWindow (PWINDOWTOCHANGETO);
341
+ PWINDOWTOCHANGETO->warpCursor ();
337
342
338
- g_pInputManager->m_pForcedFocus = PWINDOWTOCHANGETO;
339
- g_pInputManager->simulateMouseMovement ();
340
- g_pInputManager->m_pForcedFocus .reset ();
343
+ g_pInputManager->m_pForcedFocus = PWINDOWTOCHANGETO;
344
+ g_pInputManager->simulateMouseMovement ();
345
+ g_pInputManager->m_pForcedFocus .reset ();
341
346
342
- if (PLASTWINDOW && PLASTWINDOW->m_iMonitorID != PWINDOWTOCHANGETO->m_iMonitorID ) {
343
- // event
344
- const auto PNEWMON = g_pCompositor->getMonitorFromID (PWINDOWTOCHANGETO->m_iMonitorID );
347
+ if (!PLASTWINDOW || PLASTWINDOW->m_iMonitorID == PWINDOWTOCHANGETO->m_iMonitorID )
348
+ return ;
345
349
346
- g_pCompositor-> setActiveMonitor (PNEWMON);
347
- }
348
- }
349
- };
350
+ // event
351
+ const auto PNEWMON = g_pCompositor-> getMonitorFromID (PWINDOWTOCHANGETO-> m_iMonitorID );
352
+ g_pCompositor-> setActiveMonitor (PNEWMON);
353
+ }
350
354
351
355
bool CKeybindManager::onKeyEvent (std::any event, SP<IKeyboard> pKeyboard) {
352
356
if (!g_pCompositor->m_bSessionActive || g_pCompositor->m_bUnsafeState ) {
@@ -1894,31 +1898,48 @@ void CKeybindManager::resizeWindow(std::string args) {
1894
1898
PWINDOW->setHidden (false );
1895
1899
}
1896
1900
1897
- void CKeybindManager::circleNext (std::string arg) {
1901
+ std::optional<bool > getFloatStatus (CVarList args) {
1902
+ if (args.contains (" tile" ) || args.contains (" tiled" ))
1903
+ return false ;
1904
+ if (args.contains (" float" ) || args.contains (" floating" ))
1905
+ return true ;
1898
1906
1899
- if (g_pCompositor->m_pLastWindow .expired ()) {
1900
- // if we have a clear focus, find the first window and get the next focusable.
1901
- if (g_pCompositor->getWindowsOnWorkspace (g_pCompositor->m_pLastMonitor ->activeWorkspaceID ()) > 0 ) {
1902
- const auto PWINDOW = g_pCompositor->getFirstWindowOnWorkspace (g_pCompositor->m_pLastMonitor ->activeWorkspaceID ());
1907
+ return std::nullopt;
1908
+ }
1903
1909
1904
- switchToWindow (PWINDOW);
1905
- }
1910
+ bool argsIsPrevious (CVarList args) {
1911
+ return args.contains (" prev" ) || args.contains (" p" ) || args.contains (" last" ) || args.contains (" l" );
1912
+ }
1906
1913
1907
- return ;
1914
+ void CKeybindManager::circleNext (std::string arg) {
1915
+ if (g_pCompositor->m_pLastWindow .expired ()) {
1916
+ if (g_pCompositor->getWindowsOnWorkspace (g_pCompositor->m_pLastMonitor ->activeWorkspaceID ()) <= 0 )
1917
+ return ; // if we have a clear focus, find the first window and get the next focusable.
1918
+
1919
+ const auto PWINDOW = g_pCompositor->getFirstWindowOnWorkspace (g_pCompositor->m_pLastMonitor ->activeWorkspaceID ());
1920
+ switchToWindow (PWINDOW);
1908
1921
}
1909
1922
1910
- CVarList args{arg, 0 , ' s' , true };
1923
+ CVarList args{arg, 0 , ' s' , true };
1924
+ if (argsIsPrevious (arg))
1925
+ switchToWindow (g_pCompositor->getPrevWindowOnWorkspace (g_pCompositor->m_pLastWindow .lock (), true , getFloatStatus (arg)));
1926
+ else
1927
+ switchToWindow (g_pCompositor->getNextWindowOnWorkspace (g_pCompositor->m_pLastWindow .lock (), true , getFloatStatus (arg)));
1928
+ }
1911
1929
1912
- std::optional<bool > floatStatus = {};
1913
- if (args.contains (" tile" ) || args.contains (" tiled" ))
1914
- floatStatus = false ;
1915
- else if (args.contains (" float" ) || args.contains (" floating" ))
1916
- floatStatus = true ;
1930
+ void CKeybindManager::circleNextVisible (std::string arg) {
1931
+ if (g_pCompositor->m_pLastWindow .expired ()) {
1932
+ if (g_pCompositor->getWindowsOnWorkspace (g_pCompositor->m_pLastMonitor ->activeWorkspaceID ()) <= 0 )
1933
+ return ; // if we have a clear focus, find the first window and get the next focusable.
1934
+ const auto PWINDOW = g_pCompositor->getFirstWindowOnWorkspace (g_pCompositor->m_pLastMonitor ->activeWorkspaceID ());
1935
+ switchToWindow (PWINDOW);
1936
+ }
1917
1937
1918
- if (args.contains (" prev" ) || args.contains (" p" ) || args.contains (" last" ) || args.contains (" l" ))
1919
- switchToWindow (g_pCompositor->getPrevWindowOnWorkspace (g_pCompositor->m_pLastWindow .lock (), true , floatStatus));
1938
+ CVarList args{arg, 0 , ' s' , true };
1939
+ if (argsIsPrevious (args))
1940
+ switchToWindow (g_pCompositor->getPrevVisibleWindow (g_pCompositor->m_pLastWindow .lock (), true , getFloatStatus (args)));
1920
1941
else
1921
- switchToWindow (g_pCompositor->getNextWindowOnWorkspace (g_pCompositor->m_pLastWindow .lock (), true , floatStatus ));
1942
+ switchToWindow (g_pCompositor->getNextVisibleWindow (g_pCompositor->m_pLastWindow .lock (), true , getFloatStatus (args) ));
1922
1943
}
1923
1944
1924
1945
void CKeybindManager::focusWindow (std::string regexp) {
0 commit comments