{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses, PatternGuards #-}
module XMonad.Layout.DragPane (
dragPane
, DragPane, DragType (..)
) where
import XMonad
import Data.Unique
import qualified XMonad.StackSet as W
import XMonad.Util.Invisible
import XMonad.Util.XUtils
halfHandleWidth :: Integral a => a
halfHandleWidth :: forall a. Integral a => a
halfHandleWidth = a
1
handleColor :: String
handleColor :: String
handleColor = String
"#000000"
dragPane :: DragType -> Double -> Double -> DragPane a
dragPane :: forall a. DragType -> Double -> Double -> DragPane a
dragPane = Invisible Maybe (Window, Rectangle, Int)
-> DragType -> Double -> Double -> DragPane a
forall a.
Invisible Maybe (Window, Rectangle, Int)
-> DragType -> Double -> Double -> DragPane a
DragPane (Maybe (Window, Rectangle, Int)
-> Invisible Maybe (Window, Rectangle, Int)
forall (m :: * -> *) a. m a -> Invisible m a
I Maybe (Window, Rectangle, Int)
forall a. Maybe a
Nothing)
data DragPane a =
DragPane (Invisible Maybe (Window,Rectangle,Int)) DragType Double Double
deriving ( Int -> DragPane a -> ShowS
[DragPane a] -> ShowS
DragPane a -> String
(Int -> DragPane a -> ShowS)
-> (DragPane a -> String)
-> ([DragPane a] -> ShowS)
-> Show (DragPane a)
forall a. Int -> DragPane a -> ShowS
forall a. [DragPane a] -> ShowS
forall a. DragPane a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Int -> DragPane a -> ShowS
showsPrec :: Int -> DragPane a -> ShowS
$cshow :: forall a. DragPane a -> String
show :: DragPane a -> String
$cshowList :: forall a. [DragPane a] -> ShowS
showList :: [DragPane a] -> ShowS
Show, ReadPrec [DragPane a]
ReadPrec (DragPane a)
Int -> ReadS (DragPane a)
ReadS [DragPane a]
(Int -> ReadS (DragPane a))
-> ReadS [DragPane a]
-> ReadPrec (DragPane a)
-> ReadPrec [DragPane a]
-> Read (DragPane a)
forall a. ReadPrec [DragPane a]
forall a. ReadPrec (DragPane a)
forall a. Int -> ReadS (DragPane a)
forall a. ReadS [DragPane a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: forall a. Int -> ReadS (DragPane a)
readsPrec :: Int -> ReadS (DragPane a)
$creadList :: forall a. ReadS [DragPane a]
readList :: ReadS [DragPane a]
$creadPrec :: forall a. ReadPrec (DragPane a)
readPrec :: ReadPrec (DragPane a)
$creadListPrec :: forall a. ReadPrec [DragPane a]
readListPrec :: ReadPrec [DragPane a]
Read )
data DragType = Horizontal | Vertical deriving ( Int -> DragType -> ShowS
[DragType] -> ShowS
DragType -> String
(Int -> DragType -> ShowS)
-> (DragType -> String) -> ([DragType] -> ShowS) -> Show DragType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DragType -> ShowS
showsPrec :: Int -> DragType -> ShowS
$cshow :: DragType -> String
show :: DragType -> String
$cshowList :: [DragType] -> ShowS
showList :: [DragType] -> ShowS
Show, ReadPrec [DragType]
ReadPrec DragType
Int -> ReadS DragType
ReadS [DragType]
(Int -> ReadS DragType)
-> ReadS [DragType]
-> ReadPrec DragType
-> ReadPrec [DragType]
-> Read DragType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS DragType
readsPrec :: Int -> ReadS DragType
$creadList :: ReadS [DragType]
readList :: ReadS [DragType]
$creadPrec :: ReadPrec DragType
readPrec :: ReadPrec DragType
$creadListPrec :: ReadPrec [DragType]
readListPrec :: ReadPrec [DragType]
Read )
instance LayoutClass DragPane a where
doLayout :: DragPane a
-> Rectangle -> Stack a -> X ([(a, Rectangle)], Maybe (DragPane a))
doLayout d :: DragPane a
d@(DragPane Invisible Maybe (Window, Rectangle, Int)
_ DragType
Vertical Double
_ Double
_) = (Rectangle -> Rectangle)
-> DragPane a
-> Rectangle
-> Stack a
-> X ([(a, Rectangle)], Maybe (DragPane a))
forall a.
(Rectangle -> Rectangle)
-> DragPane a
-> Rectangle
-> Stack a
-> X ([(a, Rectangle)], Maybe (DragPane a))
doLay Rectangle -> Rectangle
forall a. a -> a
id DragPane a
d
doLayout d :: DragPane a
d@(DragPane Invisible Maybe (Window, Rectangle, Int)
_ DragType
Horizontal Double
_ Double
_) = (Rectangle -> Rectangle)
-> DragPane a
-> Rectangle
-> Stack a
-> X ([(a, Rectangle)], Maybe (DragPane a))
forall a.
(Rectangle -> Rectangle)
-> DragPane a
-> Rectangle
-> Stack a
-> X ([(a, Rectangle)], Maybe (DragPane a))
doLay Rectangle -> Rectangle
mirrorRect DragPane a
d
handleMessage :: DragPane a -> SomeMessage -> X (Maybe (DragPane a))
handleMessage = DragPane a -> SomeMessage -> X (Maybe (DragPane a))
forall a. DragPane a -> SomeMessage -> X (Maybe (DragPane a))
handleMess
data SetFrac = SetFrac Int Double deriving ( Int -> SetFrac -> ShowS
[SetFrac] -> ShowS
SetFrac -> String
(Int -> SetFrac -> ShowS)
-> (SetFrac -> String) -> ([SetFrac] -> ShowS) -> Show SetFrac
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetFrac -> ShowS
showsPrec :: Int -> SetFrac -> ShowS
$cshow :: SetFrac -> String
show :: SetFrac -> String
$cshowList :: [SetFrac] -> ShowS
showList :: [SetFrac] -> ShowS
Show, ReadPrec [SetFrac]
ReadPrec SetFrac
Int -> ReadS SetFrac
ReadS [SetFrac]
(Int -> ReadS SetFrac)
-> ReadS [SetFrac]
-> ReadPrec SetFrac
-> ReadPrec [SetFrac]
-> Read SetFrac
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS SetFrac
readsPrec :: Int -> ReadS SetFrac
$creadList :: ReadS [SetFrac]
readList :: ReadS [SetFrac]
$creadPrec :: ReadPrec SetFrac
readPrec :: ReadPrec SetFrac
$creadListPrec :: ReadPrec [SetFrac]
readListPrec :: ReadPrec [SetFrac]
Read, SetFrac -> SetFrac -> Bool
(SetFrac -> SetFrac -> Bool)
-> (SetFrac -> SetFrac -> Bool) -> Eq SetFrac
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetFrac -> SetFrac -> Bool
== :: SetFrac -> SetFrac -> Bool
$c/= :: SetFrac -> SetFrac -> Bool
/= :: SetFrac -> SetFrac -> Bool
Eq)
instance Message SetFrac
handleMess :: DragPane a -> SomeMessage -> X (Maybe (DragPane a))
handleMess :: forall a. DragPane a -> SomeMessage -> X (Maybe (DragPane a))
handleMess d :: DragPane a
d@(DragPane mb :: Invisible Maybe (Window, Rectangle, Int)
mb@(I (Just (Window
win,Rectangle
_,Int
ident))) DragType
ty Double
delta Double
split) SomeMessage
x
| Just Event
e <- SomeMessage -> Maybe Event
forall m. Message m => SomeMessage -> Maybe m
fromMessage SomeMessage
x :: Maybe Event = do DragPane a -> Event -> X ()
forall a. DragPane a -> Event -> X ()
handleEvent DragPane a
d Event
e
Maybe (DragPane a) -> X (Maybe (DragPane a))
forall a. a -> X a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe (DragPane a)
forall a. Maybe a
Nothing
| Just LayoutMessages
Hide <- SomeMessage -> Maybe LayoutMessages
forall m. Message m => SomeMessage -> Maybe m
fromMessage SomeMessage
x = do Window -> X ()
hideWindow Window
win
Maybe (DragPane a) -> X (Maybe (DragPane a))
forall a. a -> X a
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe (DragPane a) -> X (Maybe (DragPane a)))
-> Maybe (DragPane a) -> X (Maybe (DragPane a))
forall a b. (a -> b) -> a -> b
$ DragPane a -> Maybe (DragPane a)
forall a. a -> Maybe a
Just (Invisible Maybe (Window, Rectangle, Int)
-> DragType -> Double -> Double -> DragPane a
forall a.
Invisible Maybe (Window, Rectangle, Int)
-> DragType -> Double -> Double -> DragPane a
DragPane Invisible Maybe (Window, Rectangle, Int)
mb DragType
ty Double
delta Double
split)
| Just LayoutMessages
ReleaseResources <- SomeMessage -> Maybe LayoutMessages
forall m. Message m => SomeMessage -> Maybe m
fromMessage SomeMessage
x = do Window -> X ()
deleteWindow Window
win
Maybe (DragPane a) -> X (Maybe (DragPane a))
forall a. a -> X a
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe (DragPane a) -> X (Maybe (DragPane a)))
-> Maybe (DragPane a) -> X (Maybe (DragPane a))
forall a b. (a -> b) -> a -> b
$ DragPane a -> Maybe (DragPane a)
forall a. a -> Maybe a
Just (Invisible Maybe (Window, Rectangle, Int)
-> DragType -> Double -> Double -> DragPane a
forall a.
Invisible Maybe (Window, Rectangle, Int)
-> DragType -> Double -> Double -> DragPane a
DragPane (Maybe (Window, Rectangle, Int)
-> Invisible Maybe (Window, Rectangle, Int)
forall (m :: * -> *) a. m a -> Invisible m a
I Maybe (Window, Rectangle, Int)
forall a. Maybe a
Nothing) DragType
ty Double
delta Double
split)
| Just Resize
Shrink <- SomeMessage -> Maybe Resize
forall m. Message m => SomeMessage -> Maybe m
fromMessage SomeMessage
x = Maybe (DragPane a) -> X (Maybe (DragPane a))
forall a. a -> X a
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe (DragPane a) -> X (Maybe (DragPane a)))
-> Maybe (DragPane a) -> X (Maybe (DragPane a))
forall a b. (a -> b) -> a -> b
$ DragPane a -> Maybe (DragPane a)
forall a. a -> Maybe a
Just (Invisible Maybe (Window, Rectangle, Int)
-> DragType -> Double -> Double -> DragPane a
forall a.
Invisible Maybe (Window, Rectangle, Int)
-> DragType -> Double -> Double -> DragPane a
DragPane Invisible Maybe (Window, Rectangle, Int)
mb DragType
ty Double
delta (Double
split Double -> Double -> Double
forall a. Num a => a -> a -> a
- Double
delta))
| Just Resize
Expand <- SomeMessage -> Maybe Resize
forall m. Message m => SomeMessage -> Maybe m
fromMessage SomeMessage
x = Maybe (DragPane a) -> X (Maybe (DragPane a))
forall a. a -> X a
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe (DragPane a) -> X (Maybe (DragPane a)))
-> Maybe (DragPane a) -> X (Maybe (DragPane a))
forall a b. (a -> b) -> a -> b
$ DragPane a -> Maybe (DragPane a)
forall a. a -> Maybe a
Just (Invisible Maybe (Window, Rectangle, Int)
-> DragType -> Double -> Double -> DragPane a
forall a.
Invisible Maybe (Window, Rectangle, Int)
-> DragType -> Double -> Double -> DragPane a
DragPane Invisible Maybe (Window, Rectangle, Int)
mb DragType
ty Double
delta (Double
split Double -> Double -> Double
forall a. Num a => a -> a -> a
+ Double
delta))
| Just (SetFrac Int
ident' Double
frac) <- SomeMessage -> Maybe SetFrac
forall m. Message m => SomeMessage -> Maybe m
fromMessage SomeMessage
x, Int
ident' Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
ident =
Maybe (DragPane a) -> X (Maybe (DragPane a))
forall a. a -> X a
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe (DragPane a) -> X (Maybe (DragPane a)))
-> Maybe (DragPane a) -> X (Maybe (DragPane a))
forall a b. (a -> b) -> a -> b
$ DragPane a -> Maybe (DragPane a)
forall a. a -> Maybe a
Just (Invisible Maybe (Window, Rectangle, Int)
-> DragType -> Double -> Double -> DragPane a
forall a.
Invisible Maybe (Window, Rectangle, Int)
-> DragType -> Double -> Double -> DragPane a
DragPane Invisible Maybe (Window, Rectangle, Int)
mb DragType
ty Double
delta Double
frac)
handleMess DragPane a
_ SomeMessage
_ = Maybe (DragPane a) -> X (Maybe (DragPane a))
forall a. a -> X a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe (DragPane a)
forall a. Maybe a
Nothing
handleEvent :: DragPane a -> Event -> X ()
handleEvent :: forall a. DragPane a -> Event -> X ()
handleEvent (DragPane (I (Just (Window
win,Rectangle
r,Int
ident))) DragType
ty Double
_ Double
_)
ButtonEvent{ev_window :: Event -> Window
ev_window = Window
thisw, ev_subwindow :: Event -> Window
ev_subwindow = Window
thisbw, ev_event_type :: Event -> EventType
ev_event_type = EventType
t }
| EventType
t EventType -> EventType -> Bool
forall a. Eq a => a -> a -> Bool
== EventType
buttonPress Bool -> Bool -> Bool
&& Window
thisw Window -> Window -> Bool
forall a. Eq a => a -> a -> Bool
== Window
win Bool -> Bool -> Bool
|| Window
thisbw Window -> Window -> Bool
forall a. Eq a => a -> a -> Bool
== Window
win =
(Position -> Position -> X ()) -> X () -> X ()
mouseDrag (\Position
ex Position
ey -> do
let frac :: Double
frac = case DragType
ty of
DragType
Vertical -> (Position -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral Position
ex Double -> Double -> Double
forall a. Num a => a -> a -> a
- Position -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Rectangle -> Position
rect_x Rectangle
r))Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/EventType -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Rectangle -> EventType
rect_width Rectangle
r)
DragType
Horizontal -> (Position -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral Position
ey Double -> Double -> Double
forall a. Num a => a -> a -> a
- Position -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Rectangle -> Position
rect_x Rectangle
r))Double -> Double -> Double
forall a. Fractional a => a -> a -> a
/EventType -> Double
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Rectangle -> EventType
rect_width Rectangle
r)
SetFrac -> X ()
forall a. Message a => a -> X ()
sendMessage (Int -> Double -> SetFrac
SetFrac Int
ident Double
frac))
(() -> X ()
forall a. a -> X a
forall (m :: * -> *) a. Monad m => a -> m a
return ())
handleEvent DragPane a
_ Event
_ = () -> X ()
forall a. a -> X a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
doLay :: (Rectangle -> Rectangle) -> DragPane a -> Rectangle -> W.Stack a -> X ([(a, Rectangle)], Maybe (DragPane a))
doLay :: forall a.
(Rectangle -> Rectangle)
-> DragPane a
-> Rectangle
-> Stack a
-> X ([(a, Rectangle)], Maybe (DragPane a))
doLay Rectangle -> Rectangle
mirror (DragPane Invisible Maybe (Window, Rectangle, Int)
mw DragType
ty Double
delta Double
split) Rectangle
r Stack a
s = do
let r' :: Rectangle
r' = Rectangle -> Rectangle
mirror Rectangle
r
(Rectangle
left', Rectangle
right') = Double -> Rectangle -> (Rectangle, Rectangle)
forall r. RealFrac r => r -> Rectangle -> (Rectangle, Rectangle)
splitHorizontallyBy Double
split Rectangle
r'
left :: Rectangle
left = case Rectangle
left' of Rectangle Position
x Position
y EventType
w EventType
h ->
Rectangle -> Rectangle
mirror (Rectangle -> Rectangle) -> Rectangle -> Rectangle
forall a b. (a -> b) -> a -> b
$ Position -> Position -> EventType -> EventType -> Rectangle
Rectangle Position
x Position
y (EventType
wEventType -> EventType -> EventType
forall a. Num a => a -> a -> a
-EventType
forall a. Integral a => a
halfHandleWidth) EventType
h
right :: Rectangle
right = case Rectangle
right' of
Rectangle Position
x Position
y EventType
w EventType
h ->
Rectangle -> Rectangle
mirror (Rectangle -> Rectangle) -> Rectangle -> Rectangle
forall a b. (a -> b) -> a -> b
$ Position -> Position -> EventType -> EventType -> Rectangle
Rectangle (Position
xPosition -> Position -> Position
forall a. Num a => a -> a -> a
+Position
forall a. Integral a => a
halfHandleWidth) Position
y (EventType
wEventType -> EventType -> EventType
forall a. Num a => a -> a -> a
-EventType
forall a. Integral a => a
halfHandleWidth) EventType
h
handr :: Rectangle
handr = case Rectangle
left' of
Rectangle Position
x Position
y EventType
w EventType
h ->
Rectangle -> Rectangle
mirror (Rectangle -> Rectangle) -> Rectangle -> Rectangle
forall a b. (a -> b) -> a -> b
$ Position -> Position -> EventType -> EventType -> Rectangle
Rectangle (Position
x Position -> Position -> Position
forall a. Num a => a -> a -> a
+ EventType -> Position
forall a b. (Integral a, Num b) => a -> b
fromIntegral EventType
w Position -> Position -> Position
forall a. Num a => a -> a -> a
- Position
forall a. Integral a => a
halfHandleWidth) Position
y (EventType
2EventType -> EventType -> EventType
forall a. Num a => a -> a -> a
*EventType
forall a. Integral a => a
halfHandleWidth) EventType
h
wrs :: [(a, Rectangle)]
wrs = case [a] -> [a]
forall a. [a] -> [a]
reverse (Stack a -> [a]
forall a. Stack a -> [a]
W.up Stack a
s) of
(a
master:[a]
_) -> [(a
master,Rectangle
left),(Stack a -> a
forall a. Stack a -> a
W.focus Stack a
s,Rectangle
right)]
[] -> case Stack a -> [a]
forall a. Stack a -> [a]
W.down Stack a
s of
(a
next:[a]
_) -> [(Stack a -> a
forall a. Stack a -> a
W.focus Stack a
s,Rectangle
left),(a
next,Rectangle
right)]
[] -> [(Stack a -> a
forall a. Stack a -> a
W.focus Stack a
s, Rectangle
r)]
if [(a, Rectangle)] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [(a, Rectangle)]
wrs Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
1
then case Invisible Maybe (Window, Rectangle, Int)
mw of
I (Just (Window
w,Rectangle
_,Int
ident)) -> do
Window
w' <- Window -> X ()
deleteWindow Window
w X () -> X Window -> X Window
forall a b. X a -> X b -> X b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Rectangle -> X Window
newDragWin Rectangle
handr
([(a, Rectangle)], Maybe (DragPane a))
-> X ([(a, Rectangle)], Maybe (DragPane a))
forall a. a -> X a
forall (m :: * -> *) a. Monad m => a -> m a
return ([(a, Rectangle)]
wrs, DragPane a -> Maybe (DragPane a)
forall a. a -> Maybe a
Just (DragPane a -> Maybe (DragPane a))
-> DragPane a -> Maybe (DragPane a)
forall a b. (a -> b) -> a -> b
$ Invisible Maybe (Window, Rectangle, Int)
-> DragType -> Double -> Double -> DragPane a
forall a.
Invisible Maybe (Window, Rectangle, Int)
-> DragType -> Double -> Double -> DragPane a
DragPane (Maybe (Window, Rectangle, Int)
-> Invisible Maybe (Window, Rectangle, Int)
forall (m :: * -> *) a. m a -> Invisible m a
I (Maybe (Window, Rectangle, Int)
-> Invisible Maybe (Window, Rectangle, Int))
-> Maybe (Window, Rectangle, Int)
-> Invisible Maybe (Window, Rectangle, Int)
forall a b. (a -> b) -> a -> b
$ (Window, Rectangle, Int) -> Maybe (Window, Rectangle, Int)
forall a. a -> Maybe a
Just (Window
w',Rectangle
r',Int
ident)) DragType
ty Double
delta Double
split)
I Maybe (Window, Rectangle, Int)
Nothing -> do
Window
w <- Rectangle -> X Window
newDragWin Rectangle
handr
Unique
i <- IO Unique -> X Unique
forall (m :: * -> *) a. MonadIO m => IO a -> m a
io IO Unique
newUnique
([(a, Rectangle)], Maybe (DragPane a))
-> X ([(a, Rectangle)], Maybe (DragPane a))
forall a. a -> X a
forall (m :: * -> *) a. Monad m => a -> m a
return ([(a, Rectangle)]
wrs, DragPane a -> Maybe (DragPane a)
forall a. a -> Maybe a
Just (DragPane a -> Maybe (DragPane a))
-> DragPane a -> Maybe (DragPane a)
forall a b. (a -> b) -> a -> b
$ Invisible Maybe (Window, Rectangle, Int)
-> DragType -> Double -> Double -> DragPane a
forall a.
Invisible Maybe (Window, Rectangle, Int)
-> DragType -> Double -> Double -> DragPane a
DragPane (Maybe (Window, Rectangle, Int)
-> Invisible Maybe (Window, Rectangle, Int)
forall (m :: * -> *) a. m a -> Invisible m a
I (Maybe (Window, Rectangle, Int)
-> Invisible Maybe (Window, Rectangle, Int))
-> Maybe (Window, Rectangle, Int)
-> Invisible Maybe (Window, Rectangle, Int)
forall a b. (a -> b) -> a -> b
$ (Window, Rectangle, Int) -> Maybe (Window, Rectangle, Int)
forall a. a -> Maybe a
Just (Window
w,Rectangle
r',Unique -> Int
hashUnique Unique
i)) DragType
ty Double
delta Double
split)
else ([(a, Rectangle)], Maybe (DragPane a))
-> X ([(a, Rectangle)], Maybe (DragPane a))
forall a. a -> X a
forall (m :: * -> *) a. Monad m => a -> m a
return ([(a, Rectangle)]
wrs, Maybe (DragPane a)
forall a. Maybe a
Nothing)
newDragWin :: Rectangle -> X Window
newDragWin :: Rectangle -> X Window
newDragWin Rectangle
r = do
let mask :: Maybe Window
mask = Window -> Maybe Window
forall a. a -> Maybe a
Just (Window -> Maybe Window) -> Window -> Maybe Window
forall a b. (a -> b) -> a -> b
$ Window
exposureMask Window -> Window -> Window
forall a. Bits a => a -> a -> a
.|. Window
buttonPressMask
Window
w <- Rectangle -> Maybe Window -> String -> Bool -> X Window
createNewWindow Rectangle
r Maybe Window
mask String
handleColor Bool
False
Window -> X ()
showWindow Window
w
Display
d <- (XConf -> Display) -> X Display
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks XConf -> Display
display
IO () -> X ()
forall a. IO a -> X a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> X ()) -> IO () -> X ()
forall a b. (a -> b) -> a -> b
$ Display -> Window -> IO ()
lowerWindow Display
d Window
w
Window -> X Window
forall a. a -> X a
forall (m :: * -> *) a. Monad m => a -> m a
return Window
w