Hi all, here's an approach for "HotMove", HotSpot while moving a window. After finding out what I missunderstood about synthesize-event it wasn't hard to implement the "fix" for the corner-cases. I've tried three ways to achieve it and this one's the best I found. So re-compile Sawfish with the attached patch applied and do some configuration like: ( defvar-setq top-edge-move-function ( lambda () ( let ( ( win ( current-event-window ) ) ) ( maximize-window win ) ( release-windows #:warp win ) ) ) ) ( defvar-setq bottom-edge-move-function ( lambda () ( let ( ( win ( current-event-window ) ) ) ( destroy-window win ) ( release-windows #:center t ) ) ) ) While moving there are only top, bottom, left and right, no corners. ( release-windows ) does the trick at fixing the above two cases by sending a synthesized Escape- key-press to the root-window. #:warp win #:warp ( get-window-by-class-re "whatever" ) (...) warps the cursor the window afterwards (the pointer is else still at the edge) #:center t warps the cursor to the middle of the screen afterwards. Feel free to test it. Chris // hopes to get a reply, now there Teika is off :)
diff --git a/lisp/sawfish/wm/edge/actions.jl b/lisp/sawfish/wm/edge/actions.jl index 2649054..48e7a0e 100644 --- a/lisp/sawfish/wm/edge/actions.jl +++ b/lisp/sawfish/wm/edge/actions.jl @@ -39,20 +39,20 @@ :group edge-actions :type (choice none/hot-spot viewport-drag flip-workspace flip-viewport)) - (defcustom left-right-edge-move-action 'none + (defcustom left-right-edge-move-action 'none/hot-move "Action for the left and right screen-edge while moving a window." :group edge-actions - :type (choice none viewport-drag flip-workspace flip-viewport)) + :type (choice none/hot-move viewport-drag flip-workspace flip-viewport)) (defcustom top-bottom-edge-action 'none/hot-spot "Action for the top and bottom screen-edge." :group edge-actions :type (choice none/hot-spot viewport-drag flip-workspace flip-viewport)) - (defcustom top-bottom-edge-move-action 'none + (defcustom top-bottom-edge-move-action 'none/hot-move "Action for the top and bottom screen-edge while moving a window." :group edge-actions - :type (choice none viewport-drag flip-workspace flip-viewport)) + :type (choice none/hot-move viewport-drag flip-workspace flip-viewport)) (define (edge-action-call func edge) (case func @@ -64,6 +64,8 @@ (edge-flip-invoke edge 'viewport)) ((none/hot-spot) (hot-spot-invoke edge)) + ((none/hot-move) + (hot-move-invoke edge)) (t nil))) ;; Entry point without dragging diff --git a/lisp/sawfish/wm/edge/hot-spots.jl b/lisp/sawfish/wm/edge/hot-spots.jl index ba9a192..009a5fe 100644 --- a/lisp/sawfish/wm/edge/hot-spots.jl +++ b/lisp/sawfish/wm/edge/hot-spots.jl @@ -20,7 +20,8 @@ (define-structure sawfish.wm.edge.hot-spots - (export hot-spot-invoke) + (export hot-spot-invoke + hot-move-invoke) (open rep rep.system @@ -88,5 +89,38 @@ (mod hot-spot-delay 1000)) (when func ;; non-nil, but not a function? - (error "In hot-spot, you configuration of `%s' is wrong; it should be a function." spot)) + (error "In hot-spot, you configuration of spot `%s' is wrong; it should be a function." spot)) + ))) + + (defvar left-edge-move-function nil + "The function launched when hitting the left-edge.") + + (defvar top-edge-move-function nil + "The function launched when hitting the top-edge.") + + (defvar right-edge-move-function nil + "The function launched when hitting the right-edge.") + + (defvar bottom-edge-move-function nil + "The function launched when hitting the bottom-edge.") + + (define (hot-move-invoke spot) + (let ((func (case spot + ((left) + left-edge-move-function) + ((top) + top-edge-move-function) + ((right) + right-edge-move-function) + ((bottom) + bottom-edge-move-function)))) + (if (functionp func) + (make-timer (lambda () + (allow-events 'async-both) + (funcall func)) + (quotient hot-spot-delay 1000) + (mod hot-spot-delay 1000)) + (when func + ;; non-nil, but not a function? + (error "In hot-spot, you configuration of spot `%s' is wrong; it should be a function." spot)) )))) diff --git a/lisp/sawfish/wm/windows.jl b/lisp/sawfish/wm/windows.jl index 8d3cdf4..022fc99 100644 --- a/lisp/sawfish/wm/windows.jl +++ b/lisp/sawfish/wm/windows.jl @@ -60,6 +60,7 @@ call-after-property-changed call-after-state-changed rename-window + release-windows toggle-fixed-postion)) (open rep @@ -575,6 +576,16 @@ STATES has been changed. STATES may also be a single symbol." (define-command 'rename-window rename-window #:spec "%W\nsEnter new window name:") + (define (release-windows #!key warp center) + "Release all windows (commonly used for hot-spot while moving)." + (synthesize-event (lookup-event "ESC") 'root) + (if warp + (warp-cursor-to-window warp)) + (if center + (progn + (require 'sawfish.wm.commands.move-cursor) + (move-cursor-center)))) + (define (toggle-fixed-postion w) "Toggle the window property `fixed-position'." (if (window-get w 'fixed-position)
Attachment:
signature.asc
Description: This is a digitally signed message part.