mirror of
https://github.com/xmonad/xmonad.git
synced 2025-08-05 06:31:54 -07:00
Merge pull request #352 from slotThe/custom-cursor
X.Operations: Use custom cursor for dragging/resizing
This commit is contained in:
@@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
## unknown
|
## unknown
|
||||||
|
|
||||||
|
### Enhancements
|
||||||
|
|
||||||
|
* Added custom cursor shapes for resizing and moving windows.
|
||||||
|
|
||||||
## 0.17.0 (October 27, 2021)
|
## 0.17.0 (October 27, 2021)
|
||||||
|
|
||||||
### Enhancements
|
### Enhancements
|
||||||
|
@@ -654,14 +654,20 @@ float w = do
|
|||||||
|
|
||||||
-- | Accumulate mouse motion events
|
-- | Accumulate mouse motion events
|
||||||
mouseDrag :: (Position -> Position -> X ()) -> X () -> X ()
|
mouseDrag :: (Position -> Position -> X ()) -> X () -> X ()
|
||||||
mouseDrag f done = do
|
mouseDrag = mouseDragCursor Nothing
|
||||||
|
|
||||||
|
-- | Like 'mouseDrag', but with the ability to specify a custom cursor
|
||||||
|
-- shape.
|
||||||
|
mouseDragCursor :: Maybe Glyph -> (Position -> Position -> X ()) -> X () -> X ()
|
||||||
|
mouseDragCursor cursorGlyph f done = do
|
||||||
drag <- gets dragging
|
drag <- gets dragging
|
||||||
case drag of
|
case drag of
|
||||||
Just _ -> return () -- error case? we're already dragging
|
Just _ -> return () -- error case? we're already dragging
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
XConf { theRoot = root, display = d } <- ask
|
XConf { theRoot = root, display = d } <- ask
|
||||||
io $ grabPointer d root False (buttonReleaseMask .|. pointerMotionMask)
|
io $ do cursor <- maybe (pure none) (createFontCursor d) cursorGlyph
|
||||||
grabModeAsync grabModeAsync none none currentTime
|
grabPointer d root False (buttonReleaseMask .|. pointerMotionMask)
|
||||||
|
grabModeAsync grabModeAsync none cursor currentTime
|
||||||
modify $ \s -> s { dragging = Just (motion, cleanup) }
|
modify $ \s -> s { dragging = Just (motion, cleanup) }
|
||||||
where
|
where
|
||||||
cleanup = do
|
cleanup = do
|
||||||
@@ -679,7 +685,9 @@ mouseMoveWindow w = whenX (isClient w) $ withDisplay $ \d -> do
|
|||||||
(_, _, _, ox', oy', _, _, _) <- io $ queryPointer d w
|
(_, _, _, ox', oy', _, _, _) <- io $ queryPointer d w
|
||||||
let ox = fromIntegral ox'
|
let ox = fromIntegral ox'
|
||||||
oy = fromIntegral oy'
|
oy = fromIntegral oy'
|
||||||
mouseDrag (\ex ey -> do
|
mouseDragCursor
|
||||||
|
(Just xC_fleur)
|
||||||
|
(\ex ey -> do
|
||||||
io $ moveWindow d w (fromIntegral (fromIntegral (wa_x wa) + (ex - ox)))
|
io $ moveWindow d w (fromIntegral (fromIntegral (wa_x wa) + (ex - ox)))
|
||||||
(fromIntegral (fromIntegral (wa_y wa) + (ey - oy)))
|
(fromIntegral (fromIntegral (wa_y wa) + (ey - oy)))
|
||||||
float w
|
float w
|
||||||
@@ -692,12 +700,13 @@ mouseResizeWindow w = whenX (isClient w) $ withDisplay $ \d -> do
|
|||||||
wa <- io $ getWindowAttributes d w
|
wa <- io $ getWindowAttributes d w
|
||||||
sh <- io $ getWMNormalHints d w
|
sh <- io $ getWMNormalHints d w
|
||||||
io $ warpPointer d none w 0 0 0 0 (fromIntegral (wa_width wa)) (fromIntegral (wa_height wa))
|
io $ warpPointer d none w 0 0 0 0 (fromIntegral (wa_width wa)) (fromIntegral (wa_height wa))
|
||||||
mouseDrag (\ex ey -> do
|
mouseDragCursor
|
||||||
|
(Just xC_bottom_right_corner)
|
||||||
|
(\ex ey -> do
|
||||||
io $ resizeWindow d w `uncurry`
|
io $ resizeWindow d w `uncurry`
|
||||||
applySizeHintsContents sh (ex - fromIntegral (wa_x wa),
|
applySizeHintsContents sh (ex - fromIntegral (wa_x wa),
|
||||||
ey - fromIntegral (wa_y wa))
|
ey - fromIntegral (wa_y wa))
|
||||||
float w)
|
float w)
|
||||||
|
|
||||||
(float w)
|
(float w)
|
||||||
|
|
||||||
-- ---------------------------------------------------------------------
|
-- ---------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user