Checking for X events with GDK



Hi all... I picked up the following code from the GNOME Pager applet
source and I'm trying to modify it.

void select_root_properties(void)
{
  GtkWidget *dummy_win;
  
  gdk_error_warnings = 0;
  dummy_win = gtk_window_new(GTK_WINDOW_POPUP);
  gtk_widget_realize(dummy_win);
  gdk_window_set_user_data(GDK_ROOT_PARENT(), dummy_win);
  gdk_window_ref(GDK_ROOT_PARENT());
  gdk_xid_table_insert(&(GDK_WINDOW_XWINDOW(GDK_ROOT_PARENT())), 
		       GDK_ROOT_PARENT());
  gtk_signal_connect(GTK_OBJECT(dummy_win), "property_notify_event",
		     GTK_SIGNAL_FUNC(cb_root_prop_change), NULL);
  XSelectInput(GDK_DISPLAY(), GDK_WINDOW_XWINDOW(GDK_ROOT_PARENT()), 
	       PropertyChangeMask);
}

What I want to have my program do, eventually, is something similar to
this code... watch for MapNotify events on the root window and then
watch for DestroyNotify Events on another dynamic set of windows (a
pager-like program, basically, but a different implementation.)

This code seems to be roughly similar to how one would do it in Xt,
but the functions used seem to be internal to GDK and I can't find
much good documentation. Can someone give me a good explanation of
what's going on there?

FYI, this is basically how it works in Xt:

[in main]

	dummy = XtVaCreateWidget("dummy", coreWidgetClass, paned,
		XtNwidth, 1, XtNheight, 1, NULL);
	XtRegisterDrawable(dpy, root, dummy);
	XSelectInput(dpy, root, SubstructureNotifyMask);
	XtAddRawEventHandler(dummy, SubstructureNotifyMask, False,
		examine_event, NULL);

[in a function called by examine_event upon success]

	XtRegisterDrawable(dpy, w, dummy);
	XSelectInput(dpy, w, StructureNotifyMask);

I can get the events properly with that, so I just need to know how to
so the same thing in GTK. Thanks!

-- 
"Perfection [in design] is achieved not when there is nothing left to
add, but rather when there is nothing left to take away."
                                          -- Antoine de Saint-Exupery



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]