773pages on
this wiki
Add New Page
Talk0 Share


Script allows to move maximized windows to another head. It retains and tries to adapt maximization attributes to the new head.


(require 'sawfish.wm.state.maximize)
(require 'sawfish.wm.util.stacking)

(defvar ensc/old-head nil)
(defvar ensc/frame-delta nil)

(defun ensc/before-move-window (w)
  (setq ensc/old-head (current-head w))
  (let ((head-dim (head-dimensions ensc/old-head))
	(frame-dim (window-dimensions w)))
    (setq ensc/frame-delta
	  (cons (- (car head-dim) (car frame-dim))
		(- (cdr head-dim) (cdr frame-dim)))))
  (setq move-resize-directions
	;; HACK: that's a copy of the first part of (infer-directions)
	;; and must be adapted when this function is modified
	(if (window-get w 'fixed-position)
	  (list 'vertical 'horizontal 'head))))

(defun ensc/move-window (w)
  (when (and move-lock-when-maximized
	     (window-maximized-p w)
	     (pointer-head)) ; when moving into smaller head, this can be nil
    (let* ((cur-head (pointer-head))
	   (cur-frame-dim (window-frame-dimensions w))
	   (cur-head-offset (head-offset cur-head))
	   (cur-head-dim (head-dimensions cur-head)))
      (unless (equal ensc/old-head cur-head)
	(when (window-maximized-vertically-p w)
	  (setq move-resize-y (cdr cur-head-offset))
	  (setq move-resize-height (- (cdr cur-head-dim)
				      (cdr ensc/frame-delta))))
	(when (window-maximized-horizontally-p w)
	  (setq move-resize-x (car cur-head-offset))
	  (setq move-resize-width (- (car cur-head-dim)
				     (car ensc/frame-delta))))

	(when (eq move-resize-mode 'opaque)
	  (raise-window* w))

	(setq ensc/old-head cur-head)))

(add-hook 'before-move-hook (lambda (w) (ensc/before-move-window w)))
(add-hook 'while-moving-hook (lambda (w) (ensc/move-window w)))


Window will be resized to the wrong size when the new head has another reserved area (e.g. no panel).

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.