[comp.sys.sgi] Changing windows

sfd@earthquake.Berkeley.EDU (Scott Drellishak) (11/16/90)

I know how to change the current window using the gl libraries.  I call
a certain routine (whose name eludes me) with the window id of the window
I want to become the current graphics window.  Suppose, however, I wanted
to allow the user to select the new graphics window with the mouse.  Is
there a function which returns the id of the window the mouse is currently
contained by (ACK! I've ended a sentence with a preposition)?

And don't tell me to RTFM.  I'm just a student, and the full manuals for
the machines (Personal Irises, by the way) are locked away in a vault
somewhere.  Thanks in advance.

Scott Drellishak, sfd@ocf.berkeley.edu

dmlaur@phoenix.Princeton.EDU (David M. Laur) (11/17/90)

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

gavin@krypton.asd.sgi.com (Gavin Bell) (11/19/90)

>Suppose, I wanted
>to allow the user to select the new graphics window with the mouse.  Is
>there a function which returns the id of the window the mouse is currently
>contained by (ACK! I've ended a sentence with a preposition)?

Sure (kind of); get the positions of the windows you're controlling
using getorigin() and getsize(); then figure out which of these
windows the mouse click was inside (easy, of course, until the GL
allows arbitrarily shaped windows).  If it is contained inside more
than one window, use the windepth() function to figure out which
window is on top.

Standard disclaimer number 2:
	I've never actually coded this, but have every reason to believe
	that it will work.  I have no idea if and/or when the GL will
	support arbitrarily shaped windows, and am not an Official
	Spokesperson (TM) for Silicon Graphics.
--
--gavin     (gavin@sgi.com,  (415)335-1024)

lroy@sgi.com (Linda Roy) (11/20/90)

>Suppose, I wanted
>to allow the user to select the new graphics window with the mouse.  Is
>there a function which returns the id of the window the mouse is currently
>contained by (ACK! I've ended a sentence with a preposition)?
>

Look at 2.7.3 The Event Queue and 2.7.4 Window Manager Devices 
in the SGI 4Sight Programmer's Guide.


To select between multiple windows using the mouse location, queue INPUTCHANGE
which will be entered on the queue each time the mouse move into a different
window.  The value listed with the INPUTCHANGE is the graphics window id.

The events REDRAW and DEPTHCHANGE also return the graphics window id
and are needed to control redaw events and push/pops of a window.

in your initialization:
 
   qdevice( INPUTCHANGE );  /* may be done automatically */


in your mouse event loop:

   dev = qread(&value);
   if (dev == INPUTCHANGE )
     /* value returned is the current graphics window id */


Linda

mase@nttcvg.NTT.JP (Kenji Mase) (11/22/90)

In article <4125@idunno.Princeton.EDU> dmlaur@phoenix.Princeton.EDU writes:
   ::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?
   ::
   ::So ... the canonical input tracking idiom looks like this:
   ::......


I am new to be here and having similar problem in finding mouse
position and controlling windows.

I want to control(open from icon or close) windows which may be
created by ***other processes*** such as wsh or so. For example, a clock,
a calendar and a wsh window are opened by running user.ps when I login.
Then, I want to close those windows to icons or vise versa by moving
mouse cursor position in a different process calling setvaluator(MOUSEs,).

This is possible on SUN workstations SunView by looing for its
parent window and whose children by calling win_getlink(),
win_screenget(), and so on.

I assume the 4Sight system must be housekeeping those information to
know which window or icon, whatever process created them,  is being
located by mouse, too. I can't find any documantation about this so
far. 

Could anybody help me? Thank you.

--
-kenji
==========================================
Kenji Mase (mase%nttcvg.ntt.jp@relay.cs.net)
      Vision and Graphics group
      Visual Perception Lab. NTT Human Interface Labs.
      Nippon Telegraph and Telephone Corp. , Japan

msc@ramoth.esd.sgi.com (Mark Callow) (11/27/90)

In article <1409@nttcvg.ntt.jp>, mase@nttcvg.NTT.JP (Kenji Mase) writes:
|> I am new to be here and having similar problem in finding mouse
|> position and controlling windows.
|> 
|> I want to control(open from icon or close) windows which may be
|> created by ***other processes*** such as wsh or so. For example, a clock,
|> a calendar and a wsh window are opened by running user.ps when I login.
|> Then, I want to close those windows to icons or vise versa by moving
|> mouse cursor position in a different process calling setvaluator(MOUSEs,).
|> 
You can do it but only by writing some PostScript code.  It's a bit
complicated.  I can give you more details if you like but in view of the
impending demise of NeWS on the IRIS it's probably not worth your time. You
would have to do it again under X under X.

-- 
From the TARDIS of Mark Callow
msc@ramoth.sgi.com, ...{ames,decwrl}!sgi!msc
"Spirits of genius are always opposed by mediocre minds" - Albert Einstein