about summary refs log tree commit diff
path: root/exwm-layout.el
diff options
context:
space:
mode:
authorChris Feng <chris.w.feng@gmail.com>2016-02-20T13·52+0800
committerChris Feng <chris.w.feng@gmail.com>2016-02-20T13·52+0800
commite3d33a4aad6b5748e9352501b2c6cb058379025f (patch)
tree0e3d16cfbbf04e7990fd18a6372ef6a582a773fd /exwm-layout.el
parent1c79e1c2384128915357ea629fc2a0503bd36733 (diff)
Prevent Emacs frames from restacking themselves
Putting Emacs frames (workspace frames, floating frames) into dedicated
containers greatly simplifies the stacking order management and totally
fixes relevant issues.

* exwm-floating.el (exwm-floating--set-floating): Create floating frame
container.  Remove redundant stacking order modification code.
(exwm-floating--unset-floating): Destroy the floating frame container.
No need to reparent the X window container.
(exwm-floating--do-moveresize): Resize the floating frame container.
* exwm-input.el (exwm-input--update-focus): No need to restack frames.
* exwm-layout.el (exwm-layout--show, exwm-layout--set-frame-fullscreen)
(exwm-layout-enlarge-window): Resize the floating frame container.
* exwm-manage.el (exwm-manage--on-ConfigureRequest): Re-enable stacking
order modification on ConfigureRequest.

* exwm-workspace.el (exwm-workspace--confirm-kill-emacs): Reparent out all
frames on exit.  No need to remove selected events or created resources.
(exwm-workspace--init): Create workspace frame containers.

* exwm-layout.el (exwm-layout-set-fullscreen):
* exwm-manage.el (exwm-manage--unmanage-window): Remove a redundant call to
`xcb:flush'.

* exwm-manage.el (exwm-manage--unmanage-window): Force unmap the X window.
Unmap the floating frame before reparent it.
Diffstat (limited to 'exwm-layout.el')
-rw-r--r--exwm-layout.el88
1 files changed, 55 insertions, 33 deletions
diff --git a/exwm-layout.el b/exwm-layout.el
index e3c1febc44..c9146de371 100644
--- a/exwm-layout.el
+++ b/exwm-layout.el
@@ -55,37 +55,46 @@
   (exwm--log "Show #x%x in %s" id window)
   (let* ((edges (window-inside-absolute-pixel-edges window))
          (width (- (elt edges 2) (elt edges 0)))
-         (height (- (elt edges 3) (elt edges 1))))
+         (height (- (elt edges 3) (elt edges 1)))
+         frame-width frame-height)
     (with-current-buffer (exwm--id->buffer id)
-      (if exwm--floating-frame
-          ;; A floating X window is of the same size as the Emacs window,
-          ;; whereas its container is of the same size as the Emacs frame.
-          (progn
-            (xcb:+request exwm--connection
-                (make-instance 'xcb:ConfigureWindow
-                               :window exwm--container
-                               :value-mask (logior xcb:ConfigWindow:Width
-                                                   xcb:ConfigWindow:Height)
-                               :width (frame-pixel-width exwm--floating-frame)
-                               :height (frame-pixel-height
-                                        exwm--floating-frame)))
-            (xcb:+request exwm--connection
-                (make-instance 'xcb:ConfigureWindow
-                               :window exwm--id
-                               :value-mask (logior xcb:ConfigWindow:X
-                                                   xcb:ConfigWindow:Y
-                                                   xcb:ConfigWindow:Width
-                                                   xcb:ConfigWindow:Height)
-                               :x exwm-floating-border-width
-                               :y exwm-floating-border-width
-                               :width width
-                               :height height)))
-        (let ((relative-edges (window-inside-pixel-edges window)))
-          (exwm-layout--resize-container id exwm--container
-                                         (elt relative-edges 0)
-                                         (elt relative-edges 1)
-                                         width height
-                                         (active-minibuffer-window))))
+      (if (not exwm--floating-frame)
+          (let ((relative-edges (window-inside-pixel-edges window)))
+            (exwm-layout--resize-container id exwm--container
+                                           (elt relative-edges 0)
+                                           (elt relative-edges 1)
+                                           width height
+                                           (active-minibuffer-window)))
+        ;; A floating X window is of the same size as the Emacs window,
+        ;; whereas its container is of the same size as the Emacs frame.
+        (setq frame-width (frame-pixel-width exwm--floating-frame)
+              frame-height (frame-pixel-height exwm--floating-frame))
+        (xcb:+request exwm--connection
+            (make-instance 'xcb:ConfigureWindow
+                           :window exwm--container
+                           :value-mask (logior xcb:ConfigWindow:Width
+                                               xcb:ConfigWindow:Height)
+                           :width frame-width
+                           :height frame-height))
+        (xcb:+request exwm--connection
+            (make-instance 'xcb:ConfigureWindow
+                           :window (frame-parameter exwm--floating-frame
+                                                    'exwm-container)
+                           :value-mask (logior xcb:ConfigWindow:Width
+                                               xcb:ConfigWindow:Height)
+                           :width frame-width
+                           :height frame-height))
+        (xcb:+request exwm--connection
+            (make-instance 'xcb:ConfigureWindow
+                           :window exwm--id
+                           :value-mask (logior xcb:ConfigWindow:X
+                                               xcb:ConfigWindow:Y
+                                               xcb:ConfigWindow:Width
+                                               xcb:ConfigWindow:Height)
+                           :x exwm-floating-border-width
+                           :y exwm-floating-border-width
+                           :width width
+                           :height height)))
       ;; Make the resizing take effect.
       (xcb:flush exwm--connection)
       (xcb:+request exwm--connection (make-instance 'xcb:MapWindow :window id))
@@ -151,8 +160,7 @@
                            (make-instance 'xcb:GetGeometry
                                           :drawable exwm--container))))
         (setq exwm--floating-frame-position
-              (vector (slot-value geometry 'x) (slot-value geometry 'y))))
-      (xcb:flush exwm--connection))
+              (vector (slot-value geometry 'x) (slot-value geometry 'y)))))
     (exwm-layout--resize-container exwm--id exwm--container 0 0
                                    (exwm-workspace--current-width)
                                    (exwm-workspace--current-height))
@@ -205,12 +213,14 @@
                                      :width (x-display-pixel-width)
                                      :height (x-display-pixel-height))))
         (id (frame-parameter frame 'exwm-outer-id))
+        (container (frame-parameter frame 'exwm-container))
         (workspace (frame-parameter frame 'exwm-workspace)))
     (with-slots (x y width height) geometry
       (when (and (eq frame exwm-workspace--current)
                  (exwm-workspace--minibuffer-own-frame-p))
         (exwm-workspace--resize-minibuffer-frame width height))
-      (exwm-layout--resize-container id workspace x y width height)
+      (exwm-layout--resize-container id container 0 0 width height)
+      (exwm-layout--resize-container nil workspace x y width height t)
       (xcb:flush exwm--connection)))
   (cl-incf exwm-layout--fullscreen-frame-count))
 
@@ -349,6 +359,12 @@ windows."
                                                     'exwm-outer-id)
                            :value-mask xcb:ConfigWindow:Width
                            :width width))
+        (xcb:+request exwm--connection
+            (make-instance 'xcb:ConfigureWindow
+                           :window (frame-parameter exwm--floating-frame
+                                                    'exwm-container)
+                           :value-mask xcb:ConfigWindow:Width
+                           :width width))
         (xcb:flush exwm--connection))))
    (t
     (let* ((height (frame-pixel-height))
@@ -375,6 +391,12 @@ windows."
                                                     'exwm-outer-id)
                            :value-mask xcb:ConfigWindow:Height
                            :height height))
+        (xcb:+request exwm--connection
+            (make-instance 'xcb:ConfigureWindow
+                           :window (frame-parameter exwm--floating-frame
+                                                    'exwm-container)
+                           :value-mask xcb:ConfigWindow:Height
+                           :height height))
         (xcb:flush exwm--connection))))))
 
 ;;;###autoload