Re: [gtkmm] Getting notfified when window opens on display?



Toralf Lund wrote:

Anastasios Bassoukos wrote:

On Mon, 2004-02-02 at 20:40, Toralf Lund wrote:

/Actually, I think I'll rephrase the question from earlier today... I
might have asked:

Is there a way I can setup gtkmm so that my app is notified whenever a
new window is opened on the current display?

With XLib you can do this by checking for "Substructure" events
(SubstructureNotifyMask) of type "CreateNotify" on the root window. In
other words, if I can catch an XLib event in general, the problem is
probably solved, but I'm open to other solutions, too.

- Toralf/


Hi,
Depends on why you want to do that. I think that gtk or gdk drops notifications for unknown windows - but I may be wrong, as it has been two years since I last looked at that.
Have you checked the Window Manager-related protocols?


Yes and no. I haven't checked the specs at freedesktop.org etc. (yet), but I do know exactly what XLib event I'm looking for, and how I might catch it if I weren't using a toolkit. Using XLib event calls directly in a Gtk application is probably a bad idea, however, as Gtk has its own way of dealing with events.


OK. I figured it out at last. The key to it all lies in the function
gdk_window_add_filter() and/or its C++ equivalent
Gdk_Window::add_filter(). These may be used to add an "event filter" in
the form of a callback to which gdk will pass all events for a window
before doing anything else with them. The filter is expected to check
the event using the normal Xlib structures, do whatever it needs to do
based on the actual event, and tell GDK via the return value how to
proceed with the event (i.e. whether all necessary handling was done in
the filter, or if GDK should proceed with the event. The filter may also
translate the event.)

I'm using this in combination with XSelectInput() to make sure the
correct event is passed to the application in the first place, and
gdk_window_foreign_new(GDK_ROOT_WINDOW()) to find the root window
(Question: Is this necessary, or is there already a GdkWindow or
Gdk_Window for the root), and all works rather well now.



HTH,
Tassos

--
Beware of he who would deny you access to information, for in his
heart he dreams himself your master." -- Commissioner Pravin Lal, Sid Meier's Alpha Centauri




_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list



--
Toralf Lund <toralf procaptura com> +47 66 85 51 22
ProCaptura AS                       +47 66 85 51 00 (switchboard)
http://www.procaptura.com/~toralf   +47 66 85 51 01 (fax)






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