about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChris Feng <chris.w.feng@gmail.com>2016-02-26T10·18+0800
committerChris Feng <chris.w.feng@gmail.com>2016-02-26T10·18+0800
commit74fba563b82c1a4d3a589c71041a5bf370709a9e (patch)
tree0a3667babcf6873ae3b2d94af5ae53b10ea7afe3
parentbc4aafec1683a27209aec33f44c3947e169860c6 (diff)
Do not wait for WM_STATE property events
* exwm-layout.el (exwm-layout--show, exwm-layout--hide): Save the state
directly.
-rw-r--r--exwm-layout.el43
1 files changed, 22 insertions, 21 deletions
diff --git a/exwm-layout.el b/exwm-layout.el
index 09428da4bbf4..76721a01a1c5 100644
--- a/exwm-layout.el
+++ b/exwm-layout.el
@@ -103,7 +103,8 @@
       (xcb:+request exwm--connection
           (make-instance 'xcb:icccm:set-WM_STATE
                          :window id :state xcb:icccm:WM_STATE:NormalState
-                         :icon xcb:Window:None)))
+                         :icon xcb:Window:None))
+      (setq exwm-state xcb:icccm:WM_STATE:NormalState))
     (xcb:+request exwm--connection
         (make-instance 'xcb:SendEvent
                        :propagate 0 :destination id
@@ -122,27 +123,27 @@
 
 (defun exwm-layout--hide (id)
   "Hide window ID."
-  (unless (eq xcb:icccm:WM_STATE:IconicState ;already hidden
-              (with-current-buffer (exwm--id->buffer id) exwm-state))
-    (exwm--log "Hide #x%x" id)
-    (xcb:+request exwm--connection
-        (make-instance 'xcb:ChangeWindowAttributes
-                       :window id :value-mask xcb:CW:EventMask
-                       :event-mask xcb:EventMask:NoEvent))
-    (xcb:+request exwm--connection (make-instance 'xcb:UnmapWindow :window id))
-    (xcb:+request exwm--connection
-        (make-instance 'xcb:ChangeWindowAttributes
-                       :window id :value-mask xcb:CW:EventMask
-                       :event-mask exwm--client-event-mask))
-    (with-current-buffer (exwm--id->buffer id)
+  (with-current-buffer (exwm--id->buffer id)
+    (unless (eq xcb:icccm:WM_STATE:IconicState exwm-state) ;already hidden
+      (exwm--log "Hide #x%x" id)
       (xcb:+request exwm--connection
-          (make-instance 'xcb:UnmapWindow :window exwm--container)))
-    (xcb:+request exwm--connection
-        (make-instance 'xcb:icccm:set-WM_STATE
-                       :window id
-                       :state xcb:icccm:WM_STATE:IconicState
-                       :icon xcb:Window:None))
-    (xcb:flush exwm--connection)))
+          (make-instance 'xcb:ChangeWindowAttributes
+                         :window id :value-mask xcb:CW:EventMask
+                         :event-mask xcb:EventMask:NoEvent))
+      (xcb:+request exwm--connection (make-instance 'xcb:UnmapWindow :window id))
+      (xcb:+request exwm--connection
+          (make-instance 'xcb:ChangeWindowAttributes
+                         :window id :value-mask xcb:CW:EventMask
+                         :event-mask exwm--client-event-mask))
+      (xcb:+request exwm--connection
+          (make-instance 'xcb:UnmapWindow :window exwm--container))
+      (xcb:+request exwm--connection
+          (make-instance 'xcb:icccm:set-WM_STATE
+                         :window id
+                         :state xcb:icccm:WM_STATE:IconicState
+                         :icon xcb:Window:None))
+      (setq exwm-state xcb:icccm:WM_STATE:IconicState)
+      (xcb:flush exwm--connection))))
 
 (defvar exwm-workspace--current)
 (defvar exwm-workspace--list)