aboutsummaryrefslogtreecommitdiff
path: root/src/Internal/Keys.hs
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2022-03-28 10:01:01 -0600
committerJosh Rahm <rahm@google.com>2022-03-28 10:01:01 -0600
commit67f325a17b81d7818db8d17ce261f5cda3d2ed93 (patch)
tree02baee57c408816a961f69e17b6af696cec0e957 /src/Internal/Keys.hs
parentcfb489be45b8222c4984b344ee4e1f2e760dd3b7 (diff)
parenta7129b68fb7fa4f7cea52513fad7223dcbba9801 (diff)
downloadrde-67f325a17b81d7818db8d17ce261f5cda3d2ed93.tar.gz
rde-67f325a17b81d7818db8d17ce261f5cda3d2ed93.tar.bz2
rde-67f325a17b81d7818db8d17ce261f5cda3d2ed93.zip
Merge branch 'v017' of git.josher.dev:rde into v017
Diffstat (limited to 'src/Internal/Keys.hs')
-rw-r--r--src/Internal/Keys.hs60
1 files changed, 49 insertions, 11 deletions
diff --git a/src/Internal/Keys.hs b/src/Internal/Keys.hs
index 58d2ecb..ed10952 100644
--- a/src/Internal/Keys.hs
+++ b/src/Internal/Keys.hs
@@ -1,6 +1,7 @@
{-# LANGUAGE RankNTypes #-}
module Internal.Keys (applyKeys) where
+import Internal.Intercept (setIntercept)
import Control.Monad.Loops (iterateWhile)
import Control.Monad.Fix (fix)
import Graphics.X11.ExtraTypes.XF86;
@@ -45,6 +46,7 @@ import Internal.Lib
import Internal.DMenu
import Internal.PassMenu
import Internal.Logger
+import Internal.ScreenRotate (screenRotateForward, screenRotateBackward)
type KeyMap l = XConfig l -> Map (KeyMask, KeySym) (X ())
type ButtonsMap l = XConfig l -> Map (KeyMask, Button) (Window -> X ())
@@ -245,6 +247,12 @@ keymap = runKeys $ do
then mediaPrev
else mediaNext
+ bind xK_t $
+
+ (justMod -|- noMod) $
+ setIntercept (modMask config, xK_i) $
+ logs $ "Intercepted!"
+
bind xK_r $ do
justMod runDMenu
shiftMod $ sendMessage DoRotate
@@ -385,6 +393,17 @@ mouseMap = runButtons $ do
Map.lookup button (mouseMap config)
subMouse = submapButtonsWithKey defaultButtons . flip runButtons config
+
+ let continuous :: [(Button, X ())] -> Button -> Window -> X ()
+ continuous actions button w = do
+ case find ((==button) . fst) actions of
+ Just (_, action) -> action
+ Nothing -> return ()
+
+ (subMouse $
+ forM_ (map fst actions) $ \b ->
+ bind b $ noMod $ \w -> continuous actions b w) w
+
bind button1 $ do
justMod $ \w -> focus w >> mouseMoveWindow w >> windows W.shiftMaster
@@ -415,6 +434,9 @@ mouseMap = runButtons $ do
bind button14 $ do
noMod $ \_ -> click >> sendMessage ToggleZoom
+ bind button15 $ do
+ noMod $ \_ -> spawn "pavucontrol"
+
let mediaButtons = [
(button4, increaseVolume),
(button5, decreaseVolume),
@@ -425,19 +447,32 @@ mouseMap = runButtons $ do
(button7, mediaNext)
]
+ forM_ (map fst mediaButtons) $ \b ->
+ bind b $ noMod $ continuous mediaButtons b
- let continuous :: [(Button, X ())] -> Button -> Window -> X ()
- continuous actions button w = do
- case find ((==button) . fst) actions of
- Just (_, action) -> action
- Nothing -> return ()
+ bind button15 $ do
- (subMouse $
- forM_ (map fst mediaButtons) $ \b ->
- bind b $ noMod $ \w -> continuous actions b w) w
+ noMod $ subMouse $ do
+
+ bind button15 $ do
+ noMod $ \_ -> jumpToLast
- forM_ (map fst mediaButtons) $ \b ->
- bind b $ noMod $ continuous mediaButtons b
+
+ let workspaceButtons = [
+ (button2, swapMaster),
+
+ (button9, relativeWorkspaceShift next),
+ (button8, relativeWorkspaceShift prev),
+
+ (button4, windows W.focusUp),
+ (button5, windows W.focusDown),
+
+ (button7, windows screenRotateForward),
+ (button6, windows screenRotateBackward)
+ ]
+
+ forM_ (map fst workspaceButtons) $ \b ->
+ bind b $ noMod $ continuous workspaceButtons b
applyKeys :: XConfig l -> IO (XConfig l)
applyKeys config =
@@ -451,4 +486,7 @@ click = do
modifyWindowBorder :: Integer -> SpacingModifier
modifyWindowBorder i = ModifyWindowBorder $ \(Border a b c d) ->
- Border (a + i) (b + i) (c + i) (d + i)
+ Border (clip $ a + i) (clip $ b + i) (clip $ c + i) (clip $ d + i)
+
+ where clip i | i < 0 = 0
+ clip i | otherwise = i