[comp.windows.x] How do I block X events?

ac1@csug.cs.rdg.ac.uk (Andrew Cunningham) (11/16/90)

I am writing an X application using the Motif toolkit (on HP-UX 7.0, if it
makes a difference).  The program has to perform a computationally intensive
task from time to time, and I'd like to be able to block the user interface
while this is going on.  Ideally I want to 

	a) Display an hourglass cursor over the whole application

	b) Ignore any mouse/keyboard events until the operation is 
	   complete.

Can anyone enlighten me as to how I could perform either or both of
these tasks?

ADVthanxANCE
AndyC

Yours etc,                      | e-mail: ac1@csug.cs.reading.ac.uk
Captain B.J. Smethwick          |------------------------------------------
in a white wine sauce with      | Nobody agrees with my opinions, though
shallots, mushrooms and garlic. | everybody is entitled to them.

etaylor@wilkins.iaims.bcm.tmc.edu (Eric Taylor) (11/17/90)

|> 
|> I am writing an X application using the Motif toolkit (on HP-UX 7.0, if it
|> makes a difference).  The program has to perform a computationally intensive
|> task from time to time, and I'd like to be able to block the user interface
|> while this is going on.  Ideally I want to 
|> 
|> 	a) Display an hourglass cursor over the whole application
|> 
|> 	b) Ignore any mouse/keyboard events until the operation is 
|> 	   complete.
|> 
|> Can anyone enlighten me as to how I could perform either or both of
|> these tasks?
|> 
|> ADVthanxANCE
|> AndyC

First use XDefineCursor for each shell widget widget that
is up.

Call XFlush

Do your computation.

Remove all mouse events from the queue
	(XCheckWindowEvent or something like that).

XDefineCursor back to normal.
--
					Eric Taylor
					Baylor College of Medicine
					etaylor@wilkins.bmc.tmc.edu
					(713) 798-3776

cjmchale@swift.cs.tcd.ie (11/17/90)

In article <1990Nov15.190220.20413@csug.rdg.ac.uk>,
ac1@csug.cs.rdg.ac.uk (Andrew Cunningham) writes:
> I am writing an X application using the Motif toolkit (on HP-UX 7.0, if it
> makes a difference).  The program has to perform a computationally intensive
> task from time to time, and I'd like to be able to block the user interface
> while this is going on.  Ideally I want to 
> 
> 	a) Display an hourglass cursor over the whole application
> 
> 	b) Ignore any mouse/keyboard events until the operation is 
> 	   complete.
> 
> Can anyone enlighten me as to how I could perform either or both of
> these tasks?

Create an InputOnly window big enough to cover the entire appliction.
Set up the do_not_propagate_mask on this window so that no no events
are propagated; this takes vare of b). Set the cursor of this window
to be an hourglass cursor; this takes care of a).

When the CPU intensive task is finished you simply either destroy the
window or unmap it to return to "normal" operation.


Regards,
Ciaran.
-- 
Ciaran McHale		"An inappropiate joke for every occasion"
Department of Computer Science, Trinity College, Dublin 2, Ireland.
Telephone: +353-1-772941 ext 1538    FAX: +353-1-772204   Telex: 93782 TCD EI
email: cjmchale@cs.tcd.ie	or	cjmchale%cs.tcd.ie@cunyvm.cuny.edu
	My opinions are.

mouse@LARRY.MCRCIM.MCGILL.EDU (11/18/90)

>> I am writing an X application [which] has to perform a
>> computationally intensive task from time to time, and I'd like to be
>> able to block the user interface while this is going on.  Ideally I
>> want to 

>> 	a) Display an hourglass cursor over the whole application

>> 	b) Ignore any mouse/keyboard events until the operation is
>> 	   complete.

> Create an InputOnly window big enough to cover the entire appliction.

Note that this window should be a child of your toplevel window, not a
new child of the root.  Also, if the application creates multiple
children of the root, you need to do this for each one.

> Set up the do_not_propagate_mask on this window so that no no events
> are propagated; this takes vare of b).

This doesn't take care of keyboard events when the pointer is not in
the window.  (This can happen when the window manager is not using
PointerRoot focus, or when it is but is forwarding keystrokes with
XSendEvent.)

> Set the cursor of this window to be an hourglass cursor; this takes
> care of a).

Yes.

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu

asente@adobe.com (Paul Asente) (11/20/90)

In article <1990Nov15.190220.20413@csug.rdg.ac.uk> ac1@csug.cs.rdg.ac.uk (Andrew Cunningham) writes:
>I am writing an X application using the Motif toolkit (on HP-UX 7.0, if it
>makes a difference).  The program has to perform a computationally intensive
>task from time to time, and I'd like to be able to block the user interface
>while this is going on.  Ideally I want to 
>
>	a) Display an hourglass cursor over the whole application

Use Xlib for this.

>	b) Ignore any mouse/keyboard events until the operation is 
>	   complete.

Call

	XtSetSensitive(your_root_shell_widget, FALSE);

when you want to start ignoring events.  Call

	XtSetSensitive(your_root_shell_widget, TRUE);

to start processing them again.  This will ignore mouse and keyboard events
while still passing through expose events and the like.  Be sure to do

	while (XtAppPending(app_context)) {
		XtAppProcessEvent(app_context, XtIMAll);
	}

periodically during your task to process expose events.  Also do it before
resensitizing your user interface to make sure any queued-up mouse or
keyboard events are thrown away.

	-paul asente
		asente@adobe.com	...decwrl!adobe!asente