aboutsummaryrefslogtreecommitdiffstats
path: root/Main.hs
diff options
context:
space:
mode:
authordaniel <daniel@wagner-home.com>2007-03-28 12:15:40 +0200
committerdaniel <daniel@wagner-home.com>2007-03-28 12:15:40 +0200
commit6bdf7a9b136477cadaef81c7cbb725fbec705df3 (patch)
treeb8bff530640954bcf43aa1819ab9be2d6a0766e3 /Main.hs
parentfa39c478ec32fd04af0edd3f08321cf774da2a25 (diff)
downloadxmonad-6bdf7a9b136477cadaef81c7cbb725fbec705df3.tar.gz
xmonad-6bdf7a9b136477cadaef81c7cbb725fbec705df3.tar.xz
xmonad-6bdf7a9b136477cadaef81c7cbb725fbec705df3.zip
first shot at allowing click to focus windows
darcs-hash:20070328101540-c98ca-92140a718ff7491aa88895c0592cd9a964e671b0.gz
Diffstat (limited to 'Main.hs')
-rw-r--r--Main.hs19
1 files changed, 14 insertions, 5 deletions
diff --git a/Main.hs b/Main.hs
index 586831d..59c4d5f 100644
--- a/Main.hs
+++ b/Main.hs
@@ -120,6 +120,14 @@ grabKeys dpy rootw = do
-- Window manager clients normally should ignore this window if the
-- override_redirect member is True.
--
+
+safeFocus :: Window -> X ()
+safeFocus w = do ws <- gets workspace
+ if W.member w ws
+ then setFocus w
+ else do b <- isRoot w
+ when b setTopFocus
+
handle :: Event -> X ()
-- run window manager command
@@ -148,14 +156,15 @@ handle e@(MappingNotifyEvent {window = w}) = do
io $ refreshKeyboardMapping m
when (request e == mappingKeyboard) $ withDisplay $ io . flip grabKeys w
+-- click on an unfocussed window
+handle (ButtonEvent {window = w, event_type = t})
+ | t == buttonPress
+ = safeFocus w
+
-- entered a normal window
handle e@(CrossingEvent {window = w, event_type = t})
| t == enterNotify && mode e == notifyNormal && detail e /= notifyInferior
- = do ws <- gets workspace
- if W.member w ws
- then setFocus w
- else do b <- isRoot w
- when b setTopFocus
+ = safeFocus w
-- left a window, check if we need to focus root
handle e@(CrossingEvent {event_type = t})