Re: Learning to program sawfish



Quoting Rodrigo Amestica <ramestica nrao edu> on Thu, Sep 04 14:04:
>
> I'm trying to move windows with the keyboard in a way that probably makes 
> sense only to me

[ snip ]

> My thinking was like this: if the mouse is at the edge of the window and 
> the next motion will move the window away from it and it also happens that 
> there is an other window right below there then my moved window will lose 
> focus. I do not want that to happen.

Apparently there are more people that think this way than you realize.
I have attached a file called maybe-warp-cursor.jl that I scored way
back in 2002 (origins unknown, Google fails).  From what I can tell of
your description above, it does exactly what you want.  If a window
move would leave the cursor outside the window, warp the cursor too.

Use by putting the following in your .sawfish/rc:
(require 'maybe-warp-cursor)

Omen

-- 
Newton's Little-Known Seventh Law: A bird
in the hand is safer than one overhead.
; Borrowed from 'John N S Gill <jng renre-europe com>'
;; keep cursor inside windows when they move
(defun maybe-warp-to-window (w)
  "Warp cursor to the nearest bit of a window if it has focus and the pointer is currently elsewhere."
  (interactive "%W")
  (if (and (eq w (input-focus))
           (not (eq w (query-pointer-window)))
           (not (window-get w 'fixed-position))
           (not (window-get w 'ignored)))
      (let ((dims (window-frame-dimensions w))
            (coords (window-position w))
            (pointer (query-pointer))
            x y)
        (setq x (max (car coords) (min (car pointer) (+ (car coords) (- (car dims) 1)))))
        (setq y (max (cdr coords) (min (cdr pointer) (+ (cdr coords) (- (cdr dims) 1)))))
        (warp-cursor x y))))

(add-hook  'window-moved-hook maybe-warp-to-window)
(add-hook  'window-resized-hook maybe-warp-to-window)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]