aboutsummaryrefslogtreecommitdiff
path: root/src/Rahm/Desktop/MouseMotion.hs
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2022-11-21 12:05:03 -0700
committerJosh Rahm <rahm@google.com>2022-11-21 12:05:03 -0700
commitee9be16599f20aef6d1d3fd15666c00452f85aba (patch)
tree1aed66c1de2ce201463e3becc2d452d4a8aa2992 /src/Rahm/Desktop/MouseMotion.hs
parenta1636c65e05d02f7d4fc408137e1d37b412ce890 (diff)
downloadrde-ee9be16599f20aef6d1d3fd15666c00452f85aba.tar.gz
rde-ee9be16599f20aef6d1d3fd15666c00452f85aba.tar.bz2
rde-ee9be16599f20aef6d1d3fd15666c00452f85aba.zip
Format with ormolu.
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)