Newsgroups: comp.windows.x
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!snorkelwacker.mit.edu!bloom-beacon!dont-send-mail-to-path-lines
From: Stuart.Marks@eng.sun.COM (Stuart Marks)
Subject: Re: Forcing an EnterNotify event
Message-ID: <9104301835.AA04687@trantor.Eng.Sun.COM>
Sender: daemon@athena.mit.edu (Mr Background)
Organization: The Internet
Date: 30 Apr 91 18:35:15 GMT
Lines: 40


das15@cunixa.cc.columbia.edu (Douglas A Scott) wrote:
    How can a force a newly mapped window to receive an EnterNotify event?

The only thing you really need to do is to make sure that the window has
selected for the event before it gets mapped.  If you map a window and, as
a result of this action, the pointer ends up in the window, you should get
an EnterNotify event.

    I need to do this so that my program can tell which of a possible large
    number of windows is the currently "selected" one.  

I don't know what your application requires, but the "selected" window may
not necessarily be the one under the pointer.  Perhaps you should be
tracking the input focus (using FocusIn and FocusOut events) instead.

							I have tried
    mapping it, flushing all the events (to be sure it is actually visible)
    and then doing an XWarpPointer() into the window, but it is not
    generating the event I need.

Please don't warp the pointer around.  There should be no need to warp the
pointer to generate the EnterNotify event.  It's also almost always a bad
idea, but that point has already been belabored on this list.

				  If this *should* be doing it, it is
    possible that it is this X server on my NeXT that is the problem, but I
    wanted to be sure there was a standard way to generate such an event.

I'm not familiar with the NeXT X server.  It's possible that there is a
server bug.  Write a simple test program that selects for crossing events
and then maps the window such that the pointer ends up in the window.  The
program should get the EnterNotify event.  If it doesn't, it's probably a
server bug.  Try it on a different server.

s'marks

Stuart W. Marks			ARPA: smarks@eng.sun.com
Windows & Graphics Software	UUCP: sun!smarks
Sun Microsystems, Inc.
