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 ) {
@@ -1904,31 +1908,48 @@ void CKeybindManager::resizeWindow(std::string args) {
1904
1908
PWINDOW->setHidden (false );
1905
1909
}
1906
1910
1907
- void CKeybindManager::circleNext (std::string arg) {
1911
+ std::optional<bool > getFloatStatus (CVarList args) {
1912
+ if (args.contains (" tile" ) || args.contains (" tiled" ))
1913
+ return false ;
1914
+ if (args.contains (" float" ) || args.contains (" floating" ))
1915
+ return true ;
1908
1916
1909
- if (g_pCompositor->m_pLastWindow .expired ()) {
1910
- // if we have a clear focus, find the first window and get the next focusable.
1911
- if (g_pCompositor->getWindowsOnWorkspace (g_pCompositor->m_pLastMonitor ->activeWorkspaceID ()) > 0 ) {
1912
- const auto PWINDOW = g_pCompositor->getFirstWindowOnWorkspace (g_pCompositor->m_pLastMonitor ->activeWorkspaceID ());
1917
+ return std::nullopt;
1918
+ }
1913
1919
1914
- switchToWindow (PWINDOW);
1915
- }
1920
+ bool argsIsPrevious (CVarList args) {
1921
+ return args.contains (" prev" ) || args.contains (" p" ) || args.contains (" last" ) || args.contains (" l" );
1922
+ }
1916
1923
1917
- return ;
1924
+ void CKeybindManager::circleNext (std::string arg) {
1925
+ if (g_pCompositor->m_pLastWindow .expired ()) {
1926
+ if (g_pCompositor->getWindowsOnWorkspace (g_pCompositor->m_pLastMonitor ->activeWorkspaceID ()) <= 0 )
1927
+ return ; // if we have a clear focus, find the first window and get the next focusable.
1928
+
1929
+ const auto PWINDOW = g_pCompositor->getFirstWindowOnWorkspace (g_pCompositor->m_pLastMonitor ->activeWorkspaceID ());
1930
+ switchToWindow (PWINDOW);
1918
1931
}
1919
1932
1920
- CVarList args{arg, 0 , ' s' , true };
1933
+ CVarList args{arg, 0 , ' s' , true };
1934
+ if (argsIsPrevious (arg))
1935
+ switchToWindow (g_pCompositor->getPrevWindowOnWorkspace (g_pCompositor->m_pLastWindow .lock (), true , getFloatStatus (arg)));
1936
+ else
1937
+ switchToWindow (g_pCompositor->getNextWindowOnWorkspace (g_pCompositor->m_pLastWindow .lock (), true , getFloatStatus (arg)));
1938
+ }
1921
1939
1922
- std::optional<bool > floatStatus = {};
1923
- if (args.contains (" tile" ) || args.contains (" tiled" ))
1924
- floatStatus = false ;
1925
- else if (args.contains (" float" ) || args.contains (" floating" ))
1926
- floatStatus = true ;
1940
+ void CKeybindManager::circleNextVisible (std::string arg) {
1941
+ if (g_pCompositor->m_pLastWindow .expired ()) {
1942
+ if (g_pCompositor->getWindowsOnWorkspace (g_pCompositor->m_pLastMonitor ->activeWorkspaceID ()) <= 0 )
1943
+ return ; // if we have a clear focus, find the first window and get the next focusable.
1944
+ const auto PWINDOW = g_pCompositor->getFirstWindowOnWorkspace (g_pCompositor->m_pLastMonitor ->activeWorkspaceID ());
1945
+ switchToWindow (PWINDOW);
1946
+ }
1927
1947
1928
- if (args.contains (" prev" ) || args.contains (" p" ) || args.contains (" last" ) || args.contains (" l" ))
1929
- switchToWindow (g_pCompositor->getPrevWindowOnWorkspace (g_pCompositor->m_pLastWindow .lock (), true , floatStatus));
1948
+ CVarList args{arg, 0 , ' s' , true };
1949
+ if (argsIsPrevious (args))
1950
+ switchToWindow (g_pCompositor->getPrevVisibleWindow (g_pCompositor->m_pLastWindow .lock (), true , getFloatStatus (args)));
1930
1951
else
1931
- switchToWindow (g_pCompositor->getNextWindowOnWorkspace (g_pCompositor->m_pLastWindow .lock (), true , floatStatus ));
1952
+ switchToWindow (g_pCompositor->getNextVisibleWindow (g_pCompositor->m_pLastWindow .lock (), true , getFloatStatus (args) ));
1932
1953
}
1933
1954
1934
1955
void CKeybindManager::focusWindow (std::string regexp) {
0 commit comments