aboutsummaryrefslogtreecommitdiff
path: root/src/Internal/Keys.hs
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2022-03-18 17:47:40 -0600
committerJosh Rahm <joshuarahm@gmail.com>2022-10-09 12:19:45 -0600
commit1edf73036adf0f17e6ac4808a2a35d768d80db86 (patch)
treead1277c42eef73aaf6208713520b52e332fb29ab /src/Internal/Keys.hs
parent395ed34bf02faf2c05c84101ab63f4917ca1aed9 (diff)
downloadrde-1edf73036adf0f17e6ac4808a2a35d768d80db86.tar.gz
rde-1edf73036adf0f17e6ac4808a2a35d768d80db86.tar.bz2
rde-1edf73036adf0f17e6ac4808a2a35d768d80db86.zip
Add experimental motion events. Not super useful at the moment, but might be in the future.
Diffstat (limited to 'src/Internal/Keys.hs')
-rw-r--r--src/Internal/Keys.hs17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/Internal/Keys.hs b/src/Internal/Keys.hs
index 0fd3d52..195e12f 100644
--- a/src/Internal/Keys.hs
+++ b/src/Internal/Keys.hs
@@ -1,6 +1,7 @@
{-# LANGUAGE RankNTypes #-}
module Internal.Keys (applyKeys) where
+import Control.Monad.Loops (iterateWhile)
import Control.Monad.Fix (fix)
import Graphics.X11.ExtraTypes.XF86;
import Internal.KeysM
@@ -230,6 +231,19 @@ keymap = runKeys $ do
bind xK_q $ do
shiftMod $ spawn "xmonad --recompile && xmonad --restart"
+
+ justMod $ subkeys $ do
+
+ bind xK_q $
+ (justMod -|- noMod) $ do
+ firstMotion@(x, y) <- nextMotion
+ (x', y') <- iterateWhile (==firstMotion) nextMotion
+
+ logs $ printf "Motion: (%d, %d) (%d, %d)" x y x' y'
+
+ if (x' - x) < 0
+ then mediaPrev
+ else mediaNext
bind xK_r $ do
justMod runDMenu
@@ -319,7 +333,7 @@ keymap = runKeys $ do
-- Z is reserved to create sub keybindings to do various things.
-- I don't really use these at the moment.
bind xK_h $ noMod mediaPrev
-
+ bind xK_j $ noMod playPause
bind xK_l $ noMod mediaNext
-- Centers the current focused window. i.e. toggles the Zoom layout
@@ -402,6 +416,7 @@ mouseMap = runButtons $ do
(button7, mediaNext)
]
+
let continuous :: [(Button, X ())] -> Button -> Window -> X ()
continuous actions button w = do
case find ((==button) . fst) actions of