[gtk+] x11: Introduce _gdk_x11_get_xatom_for_display_printf()
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] x11: Introduce _gdk_x11_get_xatom_for_display_printf()
- Date: Tue, 19 Feb 2013 13:49:53 +0000 (UTC)
commit 13eeb6ca33c1fb7e4d80b3e4b560a521741b5a1f
Author: Benjamin Otte <otte redhat com>
Date: Mon Feb 18 16:59:06 2013 +0100
x11: Introduce _gdk_x11_get_xatom_for_display_printf()
and use it instead of caching the atom in the GdkScreenX11.
gdk/x11/gdkprivate-x11.h | 4 ++++
gdk/x11/gdkproperty-x11.c | 20 ++++++++++++++++++++
gdk/x11/gdkscreen-x11.c | 25 +++++++++----------------
gdk/x11/gdkscreen-x11.h | 1 -
4 files changed, 33 insertions(+), 17 deletions(-)
---
diff --git a/gdk/x11/gdkprivate-x11.h b/gdk/x11/gdkprivate-x11.h
index 9d127dc..0701616 100644
--- a/gdk/x11/gdkprivate-x11.h
+++ b/gdk/x11/gdkprivate-x11.h
@@ -297,6 +297,10 @@ void _gdk_x11_precache_atoms (GdkDisplay *display,
const gchar * const *atom_names,
gint n_atoms);
+Atom _gdk_x11_get_xatom_for_display_printf (GdkDisplay *display,
+ const gchar *format,
+ ...) G_GNUC_PRINTF (2, 3);
+
GdkFilterReturn
_gdk_x11_dnd_filter (GdkXEvent *xev,
GdkEvent *event,
diff --git a/gdk/x11/gdkproperty-x11.c b/gdk/x11/gdkproperty-x11.c
index 3d843d2..2318a2e 100644
--- a/gdk/x11/gdkproperty-x11.c
+++ b/gdk/x11/gdkproperty-x11.c
@@ -461,6 +461,26 @@ gdk_x11_get_xatom_by_name_for_display (GdkDisplay *display,
gdk_atom_intern (atom_name, FALSE));
}
+Atom
+_gdk_x11_get_xatom_for_display_printf (GdkDisplay *display,
+ const gchar *format,
+ ...)
+{
+ va_list args;
+ char *atom_name;
+ Atom atom;
+
+ va_start (args, format);
+ atom_name = g_strdup_vprintf (format, args);
+ va_end (args);
+
+ atom = gdk_x11_get_xatom_by_name_for_display (display, atom_name);
+
+ g_free (atom_name);
+
+ return atom;
+}
+
/**
* gdk_x11_get_xatom_by_name:
* @atom_name: a string
diff --git a/gdk/x11/gdkscreen-x11.c b/gdk/x11/gdkscreen-x11.c
index ac0b843..1c26042 100644
--- a/gdk/x11/gdkscreen-x11.c
+++ b/gdk/x11/gdkscreen-x11.c
@@ -434,27 +434,23 @@ gdk_x11_screen_get_screen_number (GdkScreen *screen)
return GDK_X11_SCREEN (screen)->screen_num;
}
+static Atom
+get_cm_atom (GdkX11Screen *x11_screen)
+{
+ return _gdk_x11_get_xatom_for_display_printf (x11_screen->display, "_NET_WM_CM_S%d",
x11_screen->screen_num);
+}
+
static gboolean
check_is_composited (GdkDisplay *display,
GdkX11Screen *x11_screen)
{
- Atom xselection = gdk_x11_atom_to_xatom_for_display (display, x11_screen->cm_selection_atom);
Window xwindow;
- xwindow = XGetSelectionOwner (GDK_DISPLAY_XDISPLAY (display), xselection);
+ xwindow = XGetSelectionOwner (GDK_DISPLAY_XDISPLAY (display), get_cm_atom (x11_screen));
return xwindow != None;
}
-static GdkAtom
-make_cm_atom (int screen_number)
-{
- gchar *name = g_strdup_printf ("_NET_WM_CM_S%d", screen_number);
- GdkAtom atom = gdk_atom_intern (name, FALSE);
- g_free (name);
- return atom;
-}
-
static void
init_monitor_geometry (GdkX11Monitor *monitor,
int x, int y, int width, int height)
@@ -1076,9 +1072,8 @@ _gdk_x11_screen_setup (GdkScreen *screen)
{
GdkX11Screen *x11_screen = GDK_X11_SCREEN (screen);
- x11_screen->cm_selection_atom = make_cm_atom (x11_screen->screen_num);
gdk_display_request_selection_notification (x11_screen->display,
- x11_screen->cm_selection_atom);
+ gdk_x11_xatom_to_atom_for_display (x11_screen->display,
get_cm_atom (x11_screen)));
x11_screen->is_composited = check_is_composited (x11_screen->display, x11_screen);
}
@@ -1194,10 +1189,8 @@ _gdk_x11_screen_process_owner_change (GdkScreen *screen,
#ifdef HAVE_XFIXES
XFixesSelectionNotifyEvent *selection_event = (XFixesSelectionNotifyEvent *)event;
GdkX11Screen *x11_screen = GDK_X11_SCREEN (screen);
- Atom xcm_selection_atom = gdk_x11_atom_to_xatom_for_display (x11_screen->display,
- x11_screen->cm_selection_atom);
- if (selection_event->selection == xcm_selection_atom)
+ if (selection_event->selection == get_cm_atom (x11_screen))
{
gboolean composited = selection_event->owner != None;
diff --git a/gdk/x11/gdkscreen-x11.h b/gdk/x11/gdkscreen-x11.h
index ffee2cf..1dea300 100644
--- a/gdk/x11/gdkscreen-x11.h
+++ b/gdk/x11/gdkscreen-x11.h
@@ -56,7 +56,6 @@ struct _GdkX11Screen
gint xft_dpi;
/* Window manager */
- GdkAtom cm_selection_atom;
long last_wmspec_check_time;
Window wmspec_check_window;
char *window_manager_name;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]