From 1c8101afbf8eda6f990cde6b551a6bd59e1f7dfd Mon Sep 17 00:00:00 2001 From: Chris Feng Date: Sun, 25 Sep 2016 19:58:16 +0800 Subject: [PATCH] Fix a frame resizing problem for Lucid build * exwm-manage.el (exwm-manage--frame-outer-id-list): New variable for storing frame window-outer-id's. (exwm-manage--add-frame, exwm-manage--remove-frame): New functions for adding/removing ids to/from the variable. (exwm-manage--init): Add the functions to the corresponding hooks. (exwm-manage--on-ConfigureRequest): Check for frames and avoid handling them. --- exwm-manage.el | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/exwm-manage.el b/exwm-manage.el index 42a4353..52c324d 100644 --- a/exwm-manage.el +++ b/exwm-manage.el @@ -560,6 +560,20 @@ Would you like to kill it? " (defconst exwm-manage--width-delta-min 5) (defconst exwm-manage--height-delta-min 5) +(defvar exwm-manage--frame-outer-id-list nil + "List of window-outer-id's of all frames.") + +(defun exwm-manage--add-frame (frame) + "Run in `after-make-frame-functions'." + (push (string-to-number (frame-parameter frame 'outer-window-id)) + exwm-manage--frame-outer-id-list)) + +(defun exwm-manage--remove-frame (frame) + "Run in `delete-frame-functions'." + (setq exwm-manage--frame-outer-id-list + (delq (string-to-number (frame-parameter frame 'outer-window-id)) + exwm-manage--frame-outer-id-list))) + (defun exwm-manage--on-ConfigureRequest (data _synthetic) "Handle ConfigureRequest event." (let ((obj (make-instance 'xcb:ConfigureRequest)) @@ -638,14 +652,19 @@ border-width: %d; sibling: #x%x; stack-mode: %d" nil t))) (exwm--log "ConfigureWindow (preserve geometry)") ;; Configure the unmanaged window. - (xcb:+request exwm--connection - (make-instance 'xcb:ConfigureWindow - :window window - :value-mask value-mask - :x x :y y :width width :height height - :border-width border-width - :sibling sibling - :stack-mode stack-mode)))))) + ;; But Emacs frames should be excluded. Generally we don't + ;; receive ConfigureRequest events from Emacs frames since we + ;; have set OverrideRedirect on them, but this is not true for + ;; Lucid build (as of 25.1). + (unless (memq window exwm-manage--frame-outer-id-list) + (xcb:+request exwm--connection + (make-instance 'xcb:ConfigureWindow + :window window + :value-mask value-mask + :x x :y y :width width :height height + :border-width border-width + :sibling sibling + :stack-mode stack-mode))))))) (xcb:flush exwm--connection)) (declare-function exwm-layout--iconic-state-p "exwm-layout.el" (&optional id)) @@ -698,6 +717,8 @@ border-width: %d; sibling: #x%x; stack-mode: %d" :name-len (length atom-name) :name atom-name)) 'atom))) + (add-hook 'after-make-frame-functions #'exwm-manage--add-frame) + (add-hook 'delete-frame-functions #'exwm-manage--remove-frame) (xcb:+event exwm--connection 'xcb:ConfigureRequest #'exwm-manage--on-ConfigureRequest) (xcb:+event exwm--connection 'xcb:MapRequest #'exwm-manage--on-MapRequest)