about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChris Feng <chris.w.feng@gmail.com>2016-07-22T04·31+0800
committerChris Feng <chris.w.feng@gmail.com>2016-07-22T04·31+0800
commit5529790b039ec6bac3e5eb7da17931b1dec50c64 (patch)
treea57e79748f3a8f8e6e89f8eab794488c36622e92
parent6ecd8b921fade26f30bdf4c0b047fcc9d9b57e9d (diff)
; * exwm-input.el: Prevent moving/resizing a tiling X window.
-rw-r--r--exwm-input.el54
1 files changed, 31 insertions, 23 deletions
diff --git a/exwm-input.el b/exwm-input.el
index b79a55127d47..fa7883f32da5 100644
--- a/exwm-input.el
+++ b/exwm-input.el
@@ -205,41 +205,49 @@ This value should always be overwritten.")
 (defun exwm-input--on-ButtonPress (data _synthetic)
   "Handle ButtonPress event."
   (let ((obj (make-instance 'xcb:ButtonPress))
-        (mode xcb:Allow:SyncPointer))
+        (mode xcb:Allow:SyncPointer)
+        window buffer frame)
     (xcb:unmarshal obj data)
     (with-slots (detail time event state) obj
       (setq exwm-input--timestamp time)
+      (setq window (get-buffer-window (exwm--id->buffer event) t)
+            buffer (window-buffer window))
       (cond ((and (= state exwm-input--move-mask)
-                  (= detail exwm-input--move-keysym))
+                  (= detail exwm-input--move-keysym)
+                  ;; Either an undecorated or a floating X window.
+                  (with-current-buffer buffer
+                    (or (not (eq major-mode 'exwm-mode))
+                        exwm--floating-frame)))
              ;; Move
              (exwm-floating--start-moveresize
               event xcb:ewmh:_NET_WM_MOVERESIZE_MOVE))
             ((and (= state exwm-input--resize-mask)
-                  (= detail exwm-input--resize-keysym))
+                  (= detail exwm-input--resize-keysym)
+                  (with-current-buffer buffer
+                    (or (not (eq major-mode 'exwm-mode))
+                        exwm--floating-frame)))
              ;; Resize
              (exwm-floating--start-moveresize event))
             (t
              ;; Click to focus
-             (let ((window (get-buffer-window (exwm--id->buffer event) t))
-                   frame)
-               (unless (eq window (selected-window))
-                 (setq frame (window-frame window))
-                 (unless (eq frame exwm-workspace--current)
-                   (if (exwm-workspace--workspace-p frame)
-                       ;; The X window is on another workspace
-                       (exwm-workspace-switch frame)
-                     (with-current-buffer (window-buffer window)
-                       (when (and (eq major-mode 'exwm-mode)
-                                  (not (eq exwm--frame
-                                           exwm-workspace--current)))
-                         ;; The floating X window is on another workspace
-                         (exwm-workspace-switch exwm--frame)))))
-                 ;; It has been reported that the `window' may have be deleted
-                 (if (window-live-p window)
-                     (select-window window)
-                   (setq window
-                         (get-buffer-window (exwm--id->buffer event) t))
-                   (when window (select-window window)))))
+             (unless (eq window (selected-window))
+               (setq frame (window-frame window))
+               (unless (eq frame exwm-workspace--current)
+                 (if (exwm-workspace--workspace-p frame)
+                     ;; The X window is on another workspace
+                     (exwm-workspace-switch frame)
+                   (with-current-buffer buffer
+                     (when (and (eq major-mode 'exwm-mode)
+                                (not (eq exwm--frame
+                                         exwm-workspace--current)))
+                       ;; The floating X window is on another workspace
+                       (exwm-workspace-switch exwm--frame)))))
+               ;; It has been reported that the `window' may have be deleted
+               (if (window-live-p window)
+                   (select-window window)
+                 (setq window
+                       (get-buffer-window (exwm--id->buffer event) t))
+                 (when window (select-window window))))
              ;; The event should be replayed
              (setq mode xcb:Allow:ReplayPointer))))
     (xcb:+request exwm--connection