; * exwm-input.el: Prevent moving/resizing a tiling X window.

This commit is contained in:
Chris Feng 2016-07-22 12:31:22 +08:00
parent 6ecd8b921f
commit 5529790b03

View file

@ -205,30 +205,38 @@ This value should always be overwritten.")
(defun exwm-input--on-ButtonPress (data _synthetic) (defun exwm-input--on-ButtonPress (data _synthetic)
"Handle ButtonPress event." "Handle ButtonPress event."
(let ((obj (make-instance 'xcb:ButtonPress)) (let ((obj (make-instance 'xcb:ButtonPress))
(mode xcb:Allow:SyncPointer)) (mode xcb:Allow:SyncPointer)
window buffer frame)
(xcb:unmarshal obj data) (xcb:unmarshal obj data)
(with-slots (detail time event state) obj (with-slots (detail time event state) obj
(setq exwm-input--timestamp time) (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) (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 ;; Move
(exwm-floating--start-moveresize (exwm-floating--start-moveresize
event xcb:ewmh:_NET_WM_MOVERESIZE_MOVE)) event xcb:ewmh:_NET_WM_MOVERESIZE_MOVE))
((and (= state exwm-input--resize-mask) ((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 ;; Resize
(exwm-floating--start-moveresize event)) (exwm-floating--start-moveresize event))
(t (t
;; Click to focus ;; Click to focus
(let ((window (get-buffer-window (exwm--id->buffer event) t))
frame)
(unless (eq window (selected-window)) (unless (eq window (selected-window))
(setq frame (window-frame window)) (setq frame (window-frame window))
(unless (eq frame exwm-workspace--current) (unless (eq frame exwm-workspace--current)
(if (exwm-workspace--workspace-p frame) (if (exwm-workspace--workspace-p frame)
;; The X window is on another workspace ;; The X window is on another workspace
(exwm-workspace-switch frame) (exwm-workspace-switch frame)
(with-current-buffer (window-buffer window) (with-current-buffer buffer
(when (and (eq major-mode 'exwm-mode) (when (and (eq major-mode 'exwm-mode)
(not (eq exwm--frame (not (eq exwm--frame
exwm-workspace--current))) exwm-workspace--current)))
@ -239,7 +247,7 @@ This value should always be overwritten.")
(select-window window) (select-window window)
(setq window (setq window
(get-buffer-window (exwm--id->buffer event) t)) (get-buffer-window (exwm--id->buffer event) t))
(when window (select-window window))))) (when window (select-window window))))
;; The event should be replayed ;; The event should be replayed
(setq mode xcb:Allow:ReplayPointer)))) (setq mode xcb:Allow:ReplayPointer))))
(xcb:+request exwm--connection (xcb:+request exwm--connection