From 587b4a4e204cdfa86e4630ec87991e415f031d73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9ana=20=E6=B1=9F?= Date: Tue, 18 Nov 2025 19:48:04 +0800 Subject: [PATCH] vanadium/xmonad: check if current before move --- .../vanadium/home/xmonad/xmonad.hs | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/nix/configurations/vanadium/home/xmonad/xmonad.hs b/nix/configurations/vanadium/home/xmonad/xmonad.hs index 39e5fa80..701e8fcb 100644 --- a/nix/configurations/vanadium/home/xmonad/xmonad.hs +++ b/nix/configurations/vanadium/home/xmonad/xmonad.hs @@ -151,24 +151,24 @@ myManageHook = myEventHandleHook :: Event -> X All myEventHandleHook = -- TODO: is there a way to always open certain sites in new windows in firefox? + -- TODO: stop full screen when move happens onTitleChange $ composeAll - [ isSpotify --> doShiftAndViewIfMoved multimediaWS - , isYouTube --> doShiftAndViewIfMoved multimediaWS - , isDiscord --> doShiftAndViewIfMoved chatWS - , isWhatsApp --> doShiftAndViewIfMoved chatWS - , isElement --> doShiftAndViewIfMoved chatWS + [ isSpotify --> doShiftAndViewIfCurrent multimediaWS + , isYouTube --> doShiftAndViewIfCurrent multimediaWS + , isDiscord --> doShiftAndViewIfCurrent chatWS + , isWhatsApp --> doShiftAndViewIfCurrent chatWS + , isElement --> doShiftAndViewIfCurrent chatWS ] --- If the title changes in the background, we don't want to greedy view that workspace. +-- | If the title changes in the background, we don't want to greedy view that workspace. -- Imagine Spotify playing in the background, a track change would focus that workspace. --- We prevent this by checking if the window is already there. -doShiftAndViewIfMoved :: WorkspaceId -> Query (Endo WindowSet) -doShiftAndViewIfMoved n = doF . shiftAndViewIfMoved n =<< ask - -shiftAndViewIfMoved :: WorkspaceId -> Window -> WindowSet -> WindowSet -shiftAndViewIfMoved n w s = case W.findTag w s of - Just from | n `W.tagMember` s && n /= from -> W.greedyView n $ W.shiftWin n w s - _ -> s +-- We prevent this by checking if the window is in the current workspace +doShiftAndViewIfCurrent :: WorkspaceId -> Query (Endo WindowSet) +doShiftAndViewIfCurrent n = doF . go =<< ask + where go :: Window -> WindowSet -> WindowSet + go w s = case W.findTag w s of + Just from | from == W.currentTag s -> W.greedyView n $ W.shiftWin n w s + _ -> s myStartupHook :: X () myStartupHook = do