aboutsummaryrefslogtreecommitdiff
path: root/src/Rahm/Desktop/MouseMotion.hs
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2022-11-21 20:57:42 -0700
committerJosh Rahm <joshuarahm@gmail.com>2022-11-21 20:57:42 -0700
commit8888a83ef06d16d4bdd3c06bef721fff43f04175 (patch)
treef94c6175c935a05846b6322d29625e354ff2cd17 /src/Rahm/Desktop/MouseMotion.hs
parente76a1c089951a72055bc8fc35808ccfa8988ddec (diff)
parent7d6e83479719e04b77a8230a7ecf03e971cd5fc6 (diff)
downloadrde-8888a83ef06d16d4bdd3c06bef721fff43f04175.tar.gz
rde-8888a83ef06d16d4bdd3c06bef721fff43f04175.tar.bz2
rde-8888a83ef06d16d4bdd3c06bef721fff43f04175.zip
Merge branch 'v017' of josher.dev:rde into v017
Diffstat (limited to 'src/Rahm/Desktop/MouseMotion.hs')
-rw-r--r--src/Rahm/Desktop/MouseMotion.hs24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/Rahm/Desktop/MouseMotion.hs b/src/Rahm/Desktop/MouseMotion.hs
index cacb52f..7c71644 100644
--- a/src/Rahm/Desktop/MouseMotion.hs
+++ b/src/Rahm/Desktop/MouseMotion.hs
@@ -1,18 +1,19 @@
-module Rahm.Desktop.MouseMotion where
+{-# LANGUAGE BangPatterns #-}
-import XMonad
+module Rahm.Desktop.MouseMotion where
-import Control.Monad (void, forever)
-import Text.Printf
-import Rahm.Desktop.Submap
-import Control.Monad.Loops (iterateWhile)
+import Control.Monad (forever, void)
import Control.Monad.Fix (fix)
-import Rahm.Desktop.Logger
-
-import Linear.V2
+import Control.Monad.Loops (iterateWhile)
import Linear.Metric
+import Linear.V2
+import Rahm.Desktop.Logger
+import Rahm.Desktop.Submap
+import Text.Printf
+import XMonad
data Quadrant = NE | SE | SW | NW deriving (Enum, Show)
+
data Direction = CW | CCW deriving (Enum, Show)
getQuadrant :: (Num a, Ord a) => (a, a) -> Quadrant
@@ -21,16 +22,16 @@ getQuadrant (x, y) | x < 0 && y >= 0 = SE
getQuadrant (x, y) | x < 0 && y < 0 = SW
getQuadrant (x, y) = NW
-
getDirection :: Quadrant -> Quadrant -> Maybe Direction
+
getDirectory a b | a == b = Nothing
+
getDirection SW SE = Just CCW
getDirection SE NE = Just CCW
getDirection NE NW = Just CCW
getDirection NW SW = Just CCW
getDirection _ _ = Just CW
-
liftMouseMotionM :: X a -> MouseMotionM a
liftMouseMotionM = MouseMotionM . fmap Just
@@ -41,7 +42,6 @@ motion = MouseMotionM $ do
Right button -> do
logs Info "Button %s" (show button)
return Nothing
-
Left motion -> return (Just $ uncurry V2 motion)
motionSize :: Int -> MouseMotionM (V2 Int)