Re: [Sawfish] window-position in after-move-hook returns old window position?

[ Thread Index | Date Index | More lists.tuxfamily.org/sawfish Archives ]


I ended up using `while-moving-hook` during which the window always
reports its correct position (curiously).

I ended up with the following script:

    (defun get-window-x (window)
        (car (window-position window)))

    (defun handle-window-entering-sticky-zone (window)
        (if (window-sticky-p window)
            (window-put window 'original-sticky-value 'true)
            (window-put window 'original-sticky-value 'false))
        (make-window-sticky window))

    (defun handle-window-leaving-sticky-zone (window)
        (if (window-sticky-p window)
            (if (not (= (window-get window 'original-sticky-value) 'true))
                (make-window-unsticky window)))
            (window-put window 'original-sticky-value nil))

    (defun has-original-sticky-value (window)
        (not (= (window-get window 'original-sticky-value) nil)))

    (defun is-in-automatic-sticky-zone (window)
        (>= (get-window-x window) 1800))

    (defun sticky-second-monitor-window-toggler (window)
        (if (is-in-automatic-sticky-zone window)
            (if (not (has-original-sticky-value window))
                (handle-window-entering-sticky-zone window))
            (if (has-original-sticky-value window)
                (handle-window-leaving-sticky-zone window))))

    (add-hook 'add-window-hook sticky-second-monitor-window-toggler)
    (add-hook 'place-window-hook sticky-second-monitor-window-toggler)
    (add-hook 'while-moving-hook sticky-second-monitor-window-toggler)

Which is far from perfect, but gets the job done for me.

-- 
Sawfish ML


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/