Skip to content

Commit

Permalink
Add the option to override behavior after a window is reparented via a
Browse files Browse the repository at this point in the history
hook so that the tiling wm can wait to map a reparented window until
it has been configured
  • Loading branch information
mwitmer committed Feb 3, 2014
1 parent 4f9d22a commit 82ae11f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
33 changes: 15 additions & 18 deletions module/guile-wm/module/tiling.scm
Original file line number Diff line number Diff line change
Expand Up @@ -377,23 +377,6 @@

;; Make this module the window manager

(define (tiling-on-map map-request)
(and=> (tile-window selected-tile) hide-x-window!)
(let ((parent (on-map map-request)))
(move-x-window! parent selected-tile)
(select-tile selected-tile)
(add-wm-hook!
unmap-notify-hook
(lambda (event parent)
(discard-hidden-x-window! parent)
(when (and (tile-window selected-tile)
(xid= (tile-window selected-tile) parent))
(set-tile-window! selected-tile #f)
(restore-window))))))

(define (tiling-on-configure configure-request)
(on-configure configure-request))

(define (tiling-click-to-focus button-press)
(and-let* ((win (tile-at
(xref button-press 'root-x)
Expand All @@ -408,6 +391,20 @@
(change-window-attributes blank-x-window #:back-pixmap 'parent-relative)
(set! selected-tile (frame-content (car frame-list)))
(listen! button-press-event 'click-to-focus tiling-click-to-focus)
(add-wm-hook!
after-reparent-hook
(lambda (child parent)
(and=> (tile-window selected-tile) hide-x-window!)
(move-x-window! parent selected-tile)
(select-tile selected-tile)
(add-wm-hook!
unmap-notify-hook
(lambda (event parent)
(discard-hidden-x-window! parent)
(when (and (tile-window selected-tile)
(xid= (tile-window selected-tile) parent))
(set-tile-window! selected-tile #f)
(restore-window))))))
;; Start redirecting map/configure/circulate requests right away so
;; that we don't miss any of them
(solicit
Expand All @@ -417,7 +414,7 @@
(change-window-attributes (current-root)
#:event-mask (cons 'button-press old-events))
(solicit
(begin-redirect! tiling-on-map tiling-on-configure on-circulate)))))))
(begin-redirect! on-map on-configure on-circulate)))))))

;; This does the initial work of detecting the frames

Expand Down
27 changes: 15 additions & 12 deletions module/guile-wm/reparent.scm
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,28 @@ the child window is unmapped."
#:height (max (+ (xref configure 'height) child-border y) 0)
#:width (max (+ (xref configure 'width) child-border x) 0))))))

;; Call with: unmap-notify event, parent window
(define-public unmap-notify-hook (make-wm-hook 2))
;; Call with: child window, parent window
(define-public after-reparent-hook (make-wm-hook 2))
;; Support for basic reparenting

(define-public (on-map map-request)
(define xcb-conn (current-xcb-connection))
(define original-parent (xref map-request 'parent))
(define child (xref map-request 'window))
(define parent
(if (not (hashv-ref reparents (xid->integer child)))
(let ((new-parent (basic-window-create 0 0 1 1 2 '())))
(grab new-parent)
(wm-reparent-window child new-parent 0 0)
(map-window child)
(map-window new-parent)
(set-focus child)
new-parent)
(hashv-ref reparents (xid->integer child))))
(set-window-state! child window-state-normal)
parent)
(if (not (hashv-ref reparents (xid->integer child)))
(let ((new-parent (basic-window-create 0 0 1 1 2 '())))
(grab new-parent)
(wm-reparent-window child new-parent 0 0)
(map-window child)
(cond
((wm-hook-empty? after-reparent-hook)
(map-window child)
(map-window new-parent)
(set-window-state! child window-state-normal)
(set-focus child))
(else (run-wm-hook after-reparent-hook child new-parent))))))

(define-public (on-configure configure-request)
(define value-mask (xref configure-request 'value-mask))
Expand Down

0 comments on commit 82ae11f

Please sign in to comment.