Search the FAQ Archives

3 - A - B - C - D - E - F - G - H - I - J - K - L - M
N - O - P - Q - R - S - T - U - V - W - X - Y - Z
faqs.org - Internet FAQ Archives

comp.windows.x Frequently Asked Questions (FAQ) 7/7
Section - 170) How do I make a "busy cursor" while my application is computing?

( Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Part7 - Single Page )
[ Usenet FAQs | Web FAQs | Documents | RFC Index | Business Photos and Profiles ]


Top Document: comp.windows.x Frequently Asked Questions (FAQ) 7/7
Previous Document: 169) How can my application tell if it is being run under X?
Next Document: 171) How do I fork without hanging my parent X program?
See reader questions & answers on this topic! - Help others by sharing your knowledge
Is it necessary to call XDefineCursor() for every window in my application?

	The easiest thing to do is to create a single InputOnly window that
is as large as the largest possible screen; make it a child of your toplevel
window (which must be realized) and it will be clipped to that window, so it
won't affect any other application. (It needs to be as big as the largest
possible screen in case the user enlarges the window while it is busy or
moves elsewhere within a virtual desktop.) Substitute "toplevel" with your
top-most widget here (similar code should work for Xlib-only applications;
just use your top Window):

     unsigned long valuemask;
     XSetWindowAttributes attributes;

     /* Ignore device events while the busy cursor is displayed. */
     valuemask = CWDontPropagate | CWCursor;
     attributes.do_not_propagate_mask =  (KeyPressMask | KeyReleaseMask |
         ButtonPressMask | ButtonReleaseMask | PointerMotionMask);
     attributes.cursor = XCreateFontCursor(XtDisplay(toplevel), XC_watch);

     /* The window will be as big as the display screen, and clipped by
        its own parent window, so we never have to worry about resizing */
     XCreateWindow(XtDisplay(toplevel), XtWindow(toplevel), 0, 0,
         65535, 65535, (unsigned int) 0, 0, InputOnly,
         CopyFromParent, valuemask, &attributes);

where the maximum size above could be replaced by the real size of the screen,
particularly to avoid servers which have problems with windows larger than
32767.

When you want to use this busy cursor, map and raise this window; to go back to
normal, unmap it. This will automatically keep you from getting extra mouse
events; depending on precisely how the window manager works, it may or may not
have a similar effect on keystrokes as well.

In addition, note also that most of the Xaw widgets support an XtNcursor 
resource which can be temporarily reset, should you merely wish to change the
cursor without blocking pointer events.

[thanks to Andrew Wason (aw@cellar.bae.bellcore.com), Dan Heller 
(now argv@z-code.com), and mouse@larry.mcrcim.mcgill.edu; 11/90,5/91]

User Contributions:

Comment about this article, ask questions, or add new information about this topic:

CAPTCHA




Top Document: comp.windows.x Frequently Asked Questions (FAQ) 7/7
Previous Document: 169) How can my application tell if it is being run under X?
Next Document: 171) How do I fork without hanging my parent X program?

Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Part7 - Single Page

[ Usenet FAQs | Web FAQs | Documents | RFC Index ]

Send corrections/additions to the FAQ Maintainer:
faq%craft@uunet.uu.net (X FAQ maintenance address)





Last Update March 27 2014 @ 02:12 PM