|Scripts quick access edit this|
- Author: Fernando Carmona <email@example.com>
- Version: 0.2
- License: GPL 3 or later
- Download: Move-resize-by-key-cursor.jl (upload)
If mouse is not used for doing move/resize, the cursor will be placed in a good position for moving/resizing using keyboard.
This script was based on center-mouse-on-window-move and adds functionality for resizing.
When a user attempts to move/resize a window using the keyboard (setting a binding for it), this script will first warp the mouse cursor to convenient position of the window (but only if the user didn't use the mouse). It will center the cursor on the focused window for moving it, or put it on the bottom-right side for resizing
Without this script, the default behavior of Sawfish when moving the cursor with the keyboard can easily make it hit the sides of the screen (and even worse, when resizing the behavior depends on current mouse position). I think that this is rather a bug than a intended behavior, because this is really annoying for someone who likes to use the keyboard and has led to many other scripts that intend to replace this behavior with new functions.
This scripts takes a different approach, trying to improve the current move/resize commands that already exist in Sawfish and fixing this bug rather than creating yet another new command.
You can now set a binding (or a menu entry in the window-menu) for the standard move/resize Sawfish commands and move the window with the keyboard (or also with mouse) and then press enter.
The automatic cursor warping wont interfere if you are moving by clicking the title bar nor if you resize clicking the borders.
Copy this script somewhere in your load-path (~/.sawfish/lisp by default) and add the following line in your ~/.sawfish/rc file.
You can create a keybinding to "Move window interactively" or "Resize window interactively" using sawfish-ui.
You can also customize in sawfish-ui the number of pixels to move cursor with each keystroke (in tab Miscellaneus->Miscellaneus).
Or you can add it t your ~/sawfish/rc file. for example, the following line will make the cursor move 70 pixels when hitting the arrow keys:
(setq move-cursor-increment 70)
If you experience unwanted window move "dragged by" mouse pointer, then try changing all of (allow-events 'sync-both) to (allow-events 'async-pointer) in the code.