NOTE: L'écoute par gnome-settings-daemon du répertoire /apps/gnome_settings_daemon/keybindings dans le fichier gnome-settings-daemon/plugins/keybindings/gsd-keybindings-manager.c n'est pas lié à cette configuration.
Brouillon gdk/x11/gdkevents-x11.c static gboolean gdk_event_translate (GdkDisplay *display, GdkEvent *event, XEvent *xevent, gboolean return_exposes) { if (_gdk_default_filters) { result = gdk_event_apply_filters (xevent, event, _gdk_default_filters); } ... switch (xevent->xvisibility.state) { case ClientMessage: tmp_list = display_x11->client_filters; GdkClientFilter *filter = tmp_list->data; result = (*filter->function) (xevent, event, filter->data); } } gdk/gdkglobals.c:GList *_gdk_default_filters = NULL; gdk/gdkinternals.h:extern GList *_gdk_default_filters; gdk/gdkwindow.c: void gdk_window_add_filter (GdkWindow *window, GdkFilterFunc function, gpointer data) { GdkWindowObject *private; GList *tmp_list; // ... private = (GdkWindowObject*) window; if (private) tmp_list = private->filters; else tmp_list = _gdk_default_filters; ///... if (private) private->filters = g_list_append (private->filters, filter); else _gdk_default_filters = g_list_append (_gdk_default_filters, filter); void gdk_window_remove_filter (GdkWindow *window, GdkFilterFunc function, gpointer data) { // same condition with private } gdkdisplaymanager.c: static GdkDisplay *default_display = NULL; setter: GdkDisplayManagerClass->set_property(GObject *object, PROP_DEFAULT_DISPLAY, const GValue *value) gdk_display_manager_set_property(GObject *object, PROP_DEFAULT_DISPLAY, const GValue *value); gdk_display_manager_set_default_display(GdkDisplayManager *display_manager, GdkDisplay *display) setter called by: gdk/gdkdisplay.c: gdk_display_dispose() ? getter: gdk_display_manager_get_default_display(0) gdk_display_get_default() plugins/keybindings/gsd-keybindings-manager.c add filter on gdk_screen_get_root_window (screen) Si on crée une application, gtk_init(), le filter du root_window sera un filtre sur un type GdkScreenX11. gdk/x11/gdkevents-x11.c: static Bool gdk_xsettings_watch_cb (Window window, Bool is_start, long mask, void *cb_data) { GdkWindow *gdkwin; GdkScreen *screen = cb_data; // ... gdkwin = gdk_window_lookup_for_display (gdk_screen_get_display (screen), window); gdk_window_add_filter (gdkwin, gdk_xsettings_client_event_filter, screen); // ... } gdk_xsettings_watch_cb is called by: void _gdk_x11_events_init_screen (GdkScreen *screen) { GdkScreenX11 *screen_x11 = GDK_SCREEN_X11 (screen); screen_x11->xsettings_client = xsettings_client_new_with_grab_funcs (screen_x11->xdisplay, screen_x11->screen_num, gdk_xsettings_notify_cb, gdk_xsettings_watch_cb, screen, refcounted_grab_server,refcounted_ungrab_server); }
Metacity adding
//core/display.c gboolean meta_display_open (void) { /* Get events */ meta_ui_add_event_func (the_display->xdisplay, event_callback, the_display); //ui/ui.c void meta_ui_add_event_func (Display *xdisplay, MetaEventFunc func, gpointer data) { g_return_if_fail (ef == NULL); ef = g_new (EventFunc, 1); ef->func = func; ef->data = data; gdk_window_add_filter (NULL, filter_func, ef); } } //ui/ui.c static GdkFilterReturn filter_func (GdkXEvent *xevent, GdkEvent *event, gpointer data) { g_return_val_if_fail (ef != NULL, GDK_FILTER_CONTINUE); if ((* ef->func) (xevent, ef->data)) return GDK_FILTER_REMOVE; else return GDK_FILTER_CONTINUE; } //core/display static gboolean event_callback (XEvent *event, gpointer data) { gboolean filter_out_event; ... filter_out_event = FALSE; switch (event->type) { case KeyPress: case KeyRelease: meta_display_process_key_event (display, window, event); break; } return filter_out_event; }