[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freedesktop-xorg
Subject:    [Xlib and Xt] Handle SubstructureNotify events on the root window
From:       Andrew Troschinetz <ast () arlut ! utexas ! edu>
Date:       2009-02-25 17:32:40
Message-ID: D9804209-711C-432E-9EC9-4B4ED0835ED9 () arlut ! utexas ! edu
[Download RAW message or body]

I'd like to setup an Xt event callback on the root window for  
SubstructureNotify events, but I can't figure out how to do it without  
causing BadWindow Xlib errors and "Error: Event with wrong window" Xt  
errors.

Here's what I have:

	// ... XtToolkitInitialize(), XtCreateApplicationContext(), etc ...

	Display* display = XtOpenDisplay (...);
	Widget toplevel = XtAppCreateShell (...);
	Window root_window = XDefaultRootWindow (display);
	// And this is where I get lost, how do I get a Widget for the root  
window?

I've tried this:

	// Returns NULL, so this is a no-go
	Widget root_widget = XtWindowToWidget (display, root_window);

Also this:

	// Works but I get errors
	XtRegisterDrawable (display, root_window, toplevel);
	XSelectInput (display, root_window, SubstructureNotify Mask);
	XtAddRawEventHandler (toplebel, SubstructureNotify Mask, False,  
my_callback, NULL);

If I use XSetErrorHandler() and XtSetErrorHandler() to ignore the  
errors, then I get event callbacks when I want them. Somehow this  
doesn't seem like a good solution though.

Section 7.3.1 of the X Toolkit Programming Manual seems to suggest  
that this should be possible (**emphasis mine**):

"Sometimes an application must handle events for drawables that are  
not associated with widgets in its widget tree. Examples include  
handling GraphicsExpose and NoExposeevents on Pixmaps, and handling  
PropertyNotify events on the **root window**."

So is it possible to handle SubstructureNotify events on the root  
window?

--
Andrew Troschinetz
Applied Research Laboratories

_______________________________________________
xorg mailing list
xorg@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/xorg
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic