Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!udel!princeton!phoenix!dmlaur From: dmlaur@phoenix.Princeton.EDU (David M. Laur) Newsgroups: comp.sys.sgi Subject: Re: Changing windows Summary: track INPUTCHANGE device Keywords: input focus window mouse Message-ID: <4125@idunno.Princeton.EDU> Date: 16 Nov 90 19:31:51 GMT References: <1990Nov16.031651.21667@agate.berkeley.edu> Sender: news@idunno.Princeton.EDU Organization: Princeton University, Princeton, New Jersey Lines: 78 In article <1990Nov16.031651.21667@agate.berkeley.edu> sfd@earthquake.Berkeley.EDU (Scott Drellishak) writes: > Suppose, however, I wanted to allow the user to select the new > graphics window with the mouse. Is there a way to find out which > window the mouse is over? There's really three (2.5?) concepts here: - which window's pixels will change when my program makes a call to a drawing routine (the 'current window') (set with the winset(id) gl fcn, btw) - which window is the mouse cursor over - which window (really process) has window manager input focus (will receive keyboard and mouse input) Under typical circumstances (one window per process) the window that the mouse is over is also the window which receives input; for a process with multiple windows, more book-keeping is required. There is no (documented) way to directly determine which window the mouse is over. Techniques that compare mouse coordinates with window frame coordinates can't account for partially obscured (pushed/popped) windows. Also for programs, like cedit, which want mouse input when the mouse is over another window (using the hold-any-key-before-moving-mouse technique), the concept of changed input focus is more important than absolute mouse position. So ... the canonical input tracking idiom looks like this: window_stuff () { int wids[Nwindows], has_input=0; short device, value; wids[n] = winopen("xxx"); /* etc, for each window */ qdevice(INPUTCHANGE); /* and other devices */ qdevice(LEFTMOUSE); /* for example */ while (interested) { device = qread(&value); /* wait for event */ switch( device ) { case INPUTCHANGE: has_input = value; /* this variable tracks input focus */ /* 0 == another process's window */ /* (or 4Sight window borders, etc) */ /* otherwise, id of one of yours */ break; case LEFTMOUSE: if (!value) break; /* skip up-click */ doFunction(has_input); /* for example */ /* this function might call winset(id); */ /* to change the current drawing window */ break; case (other devices): ... break; } } } -------------- David Laur Princeton University I am resplendent in divergence. Interactive Computer Graphics Lab - D.Byrne dmlaur@magritte.princeton.edu