[comp.sys.next] fun with window system hacks

mdixon@parc.xerox.com (Mike Dixon) (03/02/90)

here's some much needed functionality for the next: switching between
applications from the keyboard.  feed the file included below to pft,
and you can bind keys to running applications, so that cmd-cmd-<key>
will switch to that application (that's holding both cmd keys & hitting
a third key -- i wanted to pick something that wouldn't screw up anyone
else's keybindings...).  to bind a key to an application, just hit
cmd-cmd-shift-<key> while you're in that application.  i bind e to edit,
l to librarian, s to shell, and so forth...

as an added bonus, it enables a feature commented out of the window
system as distributed:  cmd-downarrow buries the selected window, and
cmd-uparrow pops the selected window to the top.

there's one thing i can't figure out, however:  although this mostly
works very well, jumping to an application that was hidden (a) doesn't
always unhide all its windows, and (b) leaves something confused, so that
if you then hide the application again some of the windows don't hide.
both these things are fixed by double-clicking the application's icon to
properly unhide it, but i'd very much appreciate someone explaining how
to do it right...

---------------------- cut here and feed to pft --------------------
currentshared true setshared
windowPackage1.0 begin

% copied and hacked from /usr/lib/NextStep/windowPackage1.0.ps
% mike dixon, 2/26/90

windowPackage /jumpTable 32 dict put

/handleCommand { 
    mark 10 1 roll
    1 index 65535 and				% ch
    dup 46 eq					% ch interrupt
    1 index 173 eq 				% ch interrupt upArrow
    2 index 175 eq				% ch interrupt upArrow downAr
    or or					% ch 
    {
	dup 173 eq				% ch			
	{
	    mouseWindow true //toInLevel exec
	} 
	{
	    dup 175 eq					% ch
	    {
			frontWindow false //toInLevel exec
	    } 
	    {
		pop
		/postByContext winexec
		mouseWindow currentwindowdict /pid get
		dup 0 ne				% pid
		{
		    //processId cvs dup			% str str
		    //shellCmd 10 			% str str sC 10 
		    3 -1 roll				% str sC 10 str
		    putinterval				% str
		    //shellCmd 10 			% str sC 10
		    3 -1 roll				% sC 10 str
		    length add 0 put
		    //shellCmd !
		} if
	    } ifelse 
	} ifelse
    } 
    { 0 ne
	5 index 24 and 24 eq and { % both command keys are down with a char
		/jumpTable pkget exch -16 bitshift % get jumpTable and keyCode
		5 index //Shiftmask and 0 ne {  % shift down as well -- define
			activeApp put
		} { get /contextActivate winexec } ifelse 
	} { /postByContext winexec } ifelse
    } ifelse
    cleartomark
} bind def

--

                                             .mike.