🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.x
Article #38164

Re: sending events while grabbing pointer

#38164
From: Oliver Jones
Date: Sat, 12 Feb 1994 00:46
38 lines
2457 bytes
In article <2jf0nf$ouk@brt.brt.com>, Alex Pakter <alex@brt.com> wrote:
>	If the user clicks anywhere outside this shell, I need to catch this,
>so that my application can hide the popup shell.  Clicks outside the
>popup shell should not be processed except by my application.
>
>	I need keyboard input to be enabled so that the user can type into
>a text field on my application which is NOT on the popup shell.
>
>	So far I have attempted the following: 	
>	I do an XtGrabPointer, and I add event handlers on my application
>to catch all relevant events (ButtonPress, ButtonRelease, ButtonMotion).
>In the event handler, I do an XQueryPointer, and find out where the
>pointer is.  If it is in the shell, I use XSendEvent to forward the event
>to the appropriate subwindow of the shell.
>  If the click occurs outside the shell, I hide the shell, and do an
>XUngrabPointer.
>
>My problem?  It doesn't work. 

The grab feature in X provides for this sort of behavior
without recourse to XSendEvent.

When you grab the pointer, use a pointer_mode of GrabModeSync.

When you get an event which you decide is one of the ones
you want to handle by sending along to the ungrabbed destination,
call XAllowEvents (dpy, ReplayPointer, time);

This will end the grab and redispatch the event *from the server* normally.

When you get an event bound for your dialog box, call
XAllowEvents (dpy, SyncPointer, time);
and process the event.

For more information see p 426-429 of Introduction to the X Window System.

Oliver Jones
(sorry for the book plug)
Technical Details
Message-ID: <CL365M.CFH@world.std.com>
Path: arc1-ca.pugleaf.net!gmd.de!xlink.net!howland.reston.ans.net!europa.eng.gtefsd.com!news.umbc.edu!eff!news.kei.com!world!oj
References: <2jf0nf$ouk@brt.brt.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1078e5,a922d0c655114cab
X-Google-Attributes: gid1078e5,public
X-Google-Thread: 103734,a922d0c655114cab
X-Google-Attributes: gid103734,public
X-Google-Thread: 10e286,a922d0c655114cab
X-Google-Attributes: gid10e286,public
X-Google-Thread: 10b6ac,a922d0c655114cab
X-Google-Attributes: gid10b6ac,public
X-Google-ArrivalTime: 1994-02-11 16:46:33 PST
Newsgroups: comp.windows.x,comp.windows.x.motif,ba.windows.x,comp.windows.x.apps
Path: arc1-ca.pugleaf.net!gmd.de!xlink.net!howland.reston.ans.net!europa.eng.gtefsd.com!news.umbc.edu!eff!news.kei.com!world!oj
From: oj@world.std.com (Oliver Jones)
Subject: Re: sending events while grabbing pointer
Message-ID: <CL365M.CFH@world.std.com>
Organization: Vivo Software, Inc.
References: <2jf0nf$ouk@brt.brt.com>
Distribution: inet
Date: Sat, 12 Feb 1994 00:46:33 GMT
Lines: 38