[gtk+] x11: Register wm_protocols function with gdk_window_add_filter()
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] x11: Register wm_protocols function with gdk_window_add_filter()
- Date: Tue, 1 Feb 2011 05:33:35 +0000 (UTC)
commit 609ddee632b336232b5a9768a98459e48d15d242
Author: Benjamin Otte <otte redhat com>
Date: Tue Feb 1 05:31:41 2011 +0100
x11: Register wm_protocols function with gdk_window_add_filter()
The client message code is about to go away, so we need to use a
different way to get at ClientMessage output.
gdk/x11/gdkdisplay-x11.c | 26 ++++++++++++++------------
gdk/x11/gdkdisplay-x11.h | 4 ++++
gdk/x11/gdkmain-x11.c | 4 ++++
3 files changed, 22 insertions(+), 12 deletions(-)
---
diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c
index 23dd567..e7742bd 100644
--- a/gdk/x11/gdkdisplay-x11.c
+++ b/gdk/x11/gdkdisplay-x11.c
@@ -1016,21 +1016,28 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
return return_val;
}
-static GdkFilterReturn
-gdk_wm_protocols_filter (GdkXEvent *xev,
- GdkEvent *event,
- gpointer data)
+GdkFilterReturn
+_gdk_wm_protocols_filter (GdkXEvent *xev,
+ GdkEvent *event,
+ gpointer data)
{
XEvent *xevent = (XEvent *)xev;
GdkWindow *win = event->any.window;
GdkDisplay *display;
Atom atom;
- if (!win)
- return GDK_FILTER_REMOVE;
+ if (!GDK_IS_X11_WINDOW (win))
+ return GDK_FILTER_CONTINUE;
+
+ if (xevent->type != ClientMessage)
+ return GDK_FILTER_CONTINUE;
display = GDK_WINDOW_DISPLAY (win);
- atom = (Atom)xevent->xclient.data.l[0];
+
+ if (xevent->xclient.message_type != gdk_x11_get_xatom_by_name_for_display (display, "WM_PROTOCOLS"))
+ return GDK_FILTER_CONTINUE;
+
+ atom = (Atom) xevent->xclient.data.l[0];
if (atom == gdk_x11_get_xatom_by_name_for_display (display, "WM_DELETE_WINDOW"))
{
@@ -1113,11 +1120,6 @@ gdk_event_init (GdkDisplay *display)
device_manager = gdk_display_get_device_manager (display);
gdk_x11_event_source_add_translator ((GdkEventSource *) display_x11->event_source,
GDK_EVENT_TRANSLATOR (device_manager));
-
- gdk_display_add_client_message_filter (display,
- gdk_atom_intern_static_string ("WM_PROTOCOLS"),
- gdk_wm_protocols_filter,
- NULL);
}
static void
diff --git a/gdk/x11/gdkdisplay-x11.h b/gdk/x11/gdkdisplay-x11.h
index cd72cfa..a18d647 100644
--- a/gdk/x11/gdkdisplay-x11.h
+++ b/gdk/x11/gdkdisplay-x11.h
@@ -146,6 +146,10 @@ GdkScreen *_gdk_x11_display_screen_for_xrootwin (GdkDisplay *display,
void _gdk_x11_display_error_event (GdkDisplay *display,
XErrorEvent *error);
+GdkFilterReturn _gdk_wm_protocols_filter (GdkXEvent *xev,
+ GdkEvent *event,
+ gpointer data);
+
G_END_DECLS
#endif /* __GDK_X11_DISPLAY__ */
diff --git a/gdk/x11/gdkmain-x11.c b/gdk/x11/gdkmain-x11.c
index 9cf0878..469e019 100644
--- a/gdk/x11/gdkmain-x11.c
+++ b/gdk/x11/gdkmain-x11.c
@@ -116,6 +116,10 @@ _gdk_x11_windowing_init (void)
{
XSetErrorHandler (gdk_x_error);
XSetIOErrorHandler (gdk_x_io_error);
+
+ gdk_window_add_filter (NULL,
+ _gdk_wm_protocols_filter,
+ NULL);
}
GdkGrabStatus
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]