home
hook-snooper
kgenmenu4sawfish
move-viewport
  · download
  · installation
  · private
  · programming
pager
turbo-X11
window-snooper

ideas
miscellaneous
sexyfish


EsperantÒC
iPerl
make.pl Opera utilities
This patch to sawfish allows it to interactively scroll the workspace by moving the viewport, not only by a screenfull as before, but by quarter screenfulls or even any distance you specify.  This makes it intuitively clearer that a viewport is only a means of looking at a workspace which is potentially much larger than the screen.

The screenshot shows a pager, i.e. a map, of a 2x3 workspace.  While before you could only see one of those six gridded cells, now you can move your viewport anywhere.  The light viewport would be useful for seeing the active window, which is positioned across four normal viewports.

You achieve that by preceding the call to the viewport moving functions with an emacs-style prefix argument.  This is a feature that sawfish has long had, but it lacked commands to enable you to set it.  This patch adds four kinds of commands for that:

  • The universal arg, which is implicitly 4, 16, 64, ...  It increases everytime you call it.  Viewport moving interprets this as a quarter screenfull for everytime it's called.
  • One for prompting you for it, which can be bound to a key or placed in a menu.  Viewport moving interprets this as the number of pixels to move.  (This one is also useful when you've used one of the other three, but want to edit or unset the prefix-arg.)
  • Digit argument, which looks at the event that called it.  It should be bound to ten key-combinations containing digits.  The result is adding a digit to the end of the number every time you call it.  The effect here is the same as for the previous one.
  • Negation of the prefix argument or -1.  Not really useful for viewport moving.
These prefix commands are of course generally useful.  Workspace scrolling is only one application of this.  Other commands (not only) in the viewport module, like activate-viewport-row, already made use of the prefix argument.  And in the future we're sure to see other uses.

Download

move-viewport.patch.gz (2kB)
move-viewport.tar.gz (whole files, 10kB)

Installation

Go to the right spot:
cd sawfish-1.0.1-build-directory
configure	# unless you already have
Unpack the archive with:
gzip -dc path-to-this-file/move-viewport.patch.gz | patch -p1
Build it:
make
Install it as root:
make install

Private Installation

This is instead of the above.  Go to the right spot:
cd ~/.sawfish
Unpack the archive with one of:
tar xzf move-viewport.tar.gz
gzip -dc move-viewport.tar.gz | tar xf -
Originally not, but as of sawfish 1.0.1 I had problems with this latter procedure.  Sawfish stubbornly continued loading the standard commands.jlc.  That might have been due to something unrelated?

Activation

You can use the GUI to assign the functions you see below to key-combinations of your liking.

Or, in your resource file you could add something like:

(require 'sawfish.wm.commands)
(bind-keys global-keymap
	   "W-Left"	'move-viewport-left
	   "W-Right"	'move-viewport-right
	   "W-Up"	'move-viewport-up
	   "W-Down"	'move-viewport-down

	   "W-p"	'set-prefix-arg
	   "W-0"	'numeric-arg
	   "W-1"	'numeric-arg
	   "W-2"	'numeric-arg
	   "W-3"	'numeric-arg
	   "W-4"	'numeric-arg
	   "W-5"	'numeric-arg
	   "W-6"	'numeric-arg
	   "W-7"	'numeric-arg
	   "W-8"	'numeric-arg
	   "W-9"	'numeric-arg
	   "W--"	'negative-arg
	   "W-u"	'universal-arg)
Or you may just want to put the prefix commands on a menu:
(rplacd (cdr root-menu)
         `(("Prefix Arg" set-prefix-arg)
	   ("Universal Arg" universal-arg)
	   ,@(cddr root-menu)))
The configuration proposed above binds quite a few key-combinations to your window-manager modifier key.  If that is set to something like meta, then the above will steal useful key-combinations from applications (emacs uses these).  You should set keys that you won't miss elsewhere, and the numeric-args must end in a digit.

Programming Advice

There are four ways of passing a number to a command as shown by the following spec letters:
  • p - when the command needs a number that sensibly defaults to 1, as in a repeat count
  • N - when the command needs a number
  • P - when the command needs a flag (arg present or not) and/or wants to distinguish the universal argument
  • n - like N but less flexible, so it shouldn't be used
(Last modified 2002-09-09)