diff options
| author | Josh Rahm <rahm@josher.dev> | 2026-08-09 17:22:22 -0600 |
|---|---|---|
| committer | Josh Rahm <rahm@josher.dev> | 2026-08-09 17:22:22 -0600 |
| commit | a80d4e2d36b377b3466db3b2628b9dec71fcfce2 (patch) | |
| tree | a9109869c6bc4516ebeccc80b68fc314031e08aa /src | |
| parent | a66a73ebe45cbad857f8a2e30050cb94cc1ace39 (diff) | |
| download | rde-main.tar.gz rde-main.tar.bz2 rde-main.zip | |
Diffstat (limited to 'src')
| -rw-r--r-- | src/Rahm/Desktop/Keys.hs | 52 | ||||
| -rw-r--r-- | src/Rahm/Desktop/Keys/Dsl2.hs | 4 | ||||
| -rw-r--r-- | src/Rahm/Desktop/Server.hs | 39 | ||||
| -rw-r--r-- | src/Rahm/Desktop/TabletMode.hs | 7 |
4 files changed, 81 insertions, 21 deletions
diff --git a/src/Rahm/Desktop/Keys.hs b/src/Rahm/Desktop/Keys.hs index af1893b..f9d8b1f 100644 --- a/src/Rahm/Desktop/Keys.hs +++ b/src/Rahm/Desktop/Keys.hs @@ -118,6 +118,7 @@ import qualified Rahm.Desktop.StackSet as W import Rahm.Desktop.Submap ( escape, mapNextString, + nextButtonOrKeyEvent, submap, submapButtonsWithKey, ) @@ -323,6 +324,12 @@ button14 = 14 button15 :: Button button15 = 15 +syntheticKeyMoveLeft :: KeySym +syntheticKeyMoveLeft = 0x1110000000000000 + +syntheticKeyMoveRight :: KeySym +syntheticKeyMoveRight = 0x1110000000000001 + mapWindows :: (Ord b) => (a -> b) -> W.StackSet i l a s sd -> W.StackSet i l b s sd mapWindows fn (W.StackSet cur vis hidden float) = W.StackSet @@ -1168,8 +1175,24 @@ bindings = do bind syntheticKeyStartDrag $ noMod $ - subbind $ do - bind button1 $ noMod $ noWindow D.dragWindow + runMaybeT_ $ do + ev <- nextButtonOrKeyEvent + lift $ do + click + mapM_ stylusMoveWindow . W.peek =<< gets windowset + + bind syntheticKeyStartResize $ + noMod $ + runMaybeT_ $ do + ev <- nextButtonOrKeyEvent + lift $ do + click + mapM_ stylusResizeWindow . W.peek =<< gets windowset + + -- subbind $ do + -- bind button1 $ noMod $ noWindow $ do + -- logs Info "Start drag!" + -- D.dragWindow let button14Binder = do bind button3 $ @@ -1454,7 +1477,11 @@ rdeBasicCommandHandler = SyntheticKeySym mask keySym -> do logs Info "Got synthetic keysym mask %s %s" (show mask) (show keySym) keyMap <- asks (\c -> keys (config c) (config c)) - sequence_ $ Map.lookup (mask, keySym) keyMap + logs Info "Got keymap" + sequence_ $ + (logs Info "running command" >>) + <$> Map.lookup (mask, keySym) keyMap + logs Info "Finished thing" ToNextLayout -> sendMessage toNextLayout ) @@ -1474,6 +1501,25 @@ cornersConfig = myMouseMoveWindow = myMouseMoveWindows . Identity +stylusMoveWindow :: Window -> X () +stylusMoveWindow w = + D.mouseMoveWindowsAndThen + (mapM_ X.focus) + ( mconcat + [ D.ifReleased button2 D.sinkOnRelease + ] + ) + [w] + +stylusResizeWindow :: Window -> X () +stylusResizeWindow = + D.mouseResizeWindowAndThen + X.focus + ( mconcat + [ D.ifReleased button2 D.sinkOnRelease + ] + ) + myMouseMoveWindows :: (Foldable f) => f Window -> X () myMouseMoveWindows = D.mouseMoveWindowsAndThen diff --git a/src/Rahm/Desktop/Keys/Dsl2.hs b/src/Rahm/Desktop/Keys/Dsl2.hs index cd0035a..4aec9db 100644 --- a/src/Rahm/Desktop/Keys/Dsl2.hs +++ b/src/Rahm/Desktop/Keys/Dsl2.hs @@ -43,6 +43,7 @@ import Rahm.Desktop.Submap (ButtonOrKeyEvent (ButtonPress, KeyPress, event_keyco import Rahm.Desktop.XMobarLog (spawnXMobar) import Rahm.Desktop.XMobarLog.PendingBuffer (pushAddPendingBuffer, pushPendingBuffer, clearPendingBuffer) import XMonad +import XMonad.Util.Loggers (logSp) -- | A documented "thing." It is essentially an item with a string attached to -- it. A glorified tuple (String, t) @@ -290,6 +291,7 @@ resolveBindings (BindingsMap keyAndKeyCodeBindings buttonBindings _ _) = doSubmap :: forall l. XConfig l -> BindingsMap -> X () -> X () doSubmap conf (BindingsMap kbind bbind catk catb) after = do + logs Info "doSubmap" nextPressEvent $ \str -> \case (ButtonPress m b) -> do @@ -314,7 +316,9 @@ resolveBindings (BindingsMap keyAndKeyCodeBindings buttonBindings _ _) = _ -> False nextPressEvent fn = runMaybeT_ $ do + lift $ logs Info "Waiting for next press event..." ev <- nextButtonOrKeyEvent + lift $ logs Info "Got next press event ..." let str = case ev of ButtonPress m b -> "b" ++ show b KeyPress _ _ _ s -> s diff --git a/src/Rahm/Desktop/Server.hs b/src/Rahm/Desktop/Server.hs index 4bf1cbd..d137603 100644 --- a/src/Rahm/Desktop/Server.hs +++ b/src/Rahm/Desktop/Server.hs @@ -109,23 +109,28 @@ forkServer handler = do return ctx handleClient :: ServerContext c -> Socket -> IO () -handleClient chan conn = forever $ do - h <- socketToHandle conn ReadWriteMode - hSetBuffering h LineBuffering - hSetEncoding h utf8 - - finally - ( fix $ \loop -> do - result <- try (hGetLine h) - case result of - Left e - | isEOFError e -> return () - | otherwise -> throwIO (e :: IOError) - Right line -> do - handleLine chan line - loop - ) - (hClose h) +handleClient chan conn = + finally (loop BS.empty) (close conn) + where + loop buf = do + chunk <- recv conn 4096 + if BS.null chunk + then return () -- connection closed + else do + let buf' = buf <> chunk + (lines, rest) = splitLines buf' + mapM_ (handleLine chan . BSC.unpack) lines + loop rest + + splitLines :: BS.ByteString -> ([BS.ByteString], BS.ByteString) + splitLines bs = + case BSC.break (== '\n') bs of + (line, rest) + | BS.null rest -> ([], bs) + | otherwise -> + let remaining = BS.drop 1 rest + (ls, r) = splitLines remaining + in (line : ls, r) handleLine :: ServerContext c -> String -> IO () handleLine ctx line = case parser (commandHandler ctx) line of diff --git a/src/Rahm/Desktop/TabletMode.hs b/src/Rahm/Desktop/TabletMode.hs index b13e919..4d03ee5 100644 --- a/src/Rahm/Desktop/TabletMode.hs +++ b/src/Rahm/Desktop/TabletMode.hs @@ -31,6 +31,7 @@ module Rahm.Desktop.TabletMode tabletModeXMobarString, tabletModeCommandHandler, syntheticKeyStartDrag, + syntheticKeyStartResize, ) where @@ -68,6 +69,9 @@ import XMonad.Util.Run (runProcessWithInput) syntheticKeyStartDrag :: KeySym syntheticKeyStartDrag = 0x1100000000000011 +syntheticKeyStartResize :: KeySym +syntheticKeyStartResize = 0x1100000000000111 + -- | Rotation angle for the display data RotationAngle = -- | Normal orientation (0°) @@ -262,7 +266,8 @@ tabletModeXMobarString = do "<fc=#f08080><action=`rdectl shift . _`> ✗ </action></fc>", "<fc=#808080><action=`rofi -monitor -4 -display-run Execute -show run -normal-window`>\61728 </action></fc>", "<fc=#80f080><action=`rdectl next-rotation`> \58183 </action></fc>", - "<fc=#80f080><action=`sleep 0.2 && rdectl keysym " ++ show syntheticKeyStartDrag ++ "`> \983486 </action></fc>" + "<fc=#80f080><action=`sleep 0.2 && rdectl keysym " ++ show syntheticKeyStartDrag ++ "`> \983486 </action></fc>", + "<fc=#80f080><action=`sleep 0.2 && rdectl keysym " ++ show syntheticKeyStartResize ++ "`> \985704 </action></fc>" ] else "<action=`rdectl tablet-mode on`><fc=#66cc66> \61705 </fc></action>" ) |