diff options
-rw-r--r-- | ChangeLog | 37 | ||||
-rw-r--r-- | ChangeLog.pre-2-0 | 37 | ||||
-rw-r--r-- | ChangeLog.pre-2-10 | 37 | ||||
-rw-r--r-- | ChangeLog.pre-2-2 | 37 | ||||
-rw-r--r-- | ChangeLog.pre-2-4 | 37 | ||||
-rw-r--r-- | ChangeLog.pre-2-6 | 37 | ||||
-rw-r--r-- | ChangeLog.pre-2-8 | 37 | ||||
-rw-r--r-- | gdk/gdkselection.h | 56 | ||||
-rw-r--r-- | gdk/gdktypes.h | 10 | ||||
-rw-r--r-- | gdk/linux-fb/gdkproperty-fb.c | 49 | ||||
-rw-r--r-- | gdk/win32/gdkproperty-win32.c | 25 | ||||
-rw-r--r-- | gdk/x11/gdkdnd-x11.c | 191 | ||||
-rw-r--r-- | gdk/x11/gdkevents-x11.c | 97 | ||||
-rw-r--r-- | gdk/x11/gdkglobals-x11.c | 2 | ||||
-rw-r--r-- | gdk/x11/gdkkeys-x11.c | 3 | ||||
-rw-r--r-- | gdk/x11/gdkmain-x11.c | 6 | ||||
-rw-r--r-- | gdk/x11/gdkprivate-x11.h | 2 | ||||
-rw-r--r-- | gdk/x11/gdkproperty-x11.c | 330 | ||||
-rw-r--r-- | gdk/x11/gdkselection-x11.c | 55 | ||||
-rw-r--r-- | gdk/x11/gdkwindow-x11.c | 97 | ||||
-rw-r--r-- | gdk/x11/gdkx.h | 5 | ||||
-rw-r--r-- | gtk/gtkclist.c | 6 | ||||
-rw-r--r-- | gtk/gtkctree.c | 2 | ||||
-rw-r--r-- | gtk/gtkdnd.c | 6 | ||||
-rw-r--r-- | gtk/gtkplug.c | 8 | ||||
-rw-r--r-- | gtk/gtksocket.c | 12 | ||||
-rw-r--r-- | gtk/gtkwidget.c | 4 | ||||
-rw-r--r-- | tests/testdnd.c | 4 | ||||
-rw-r--r-- | tests/testselection.c | 10 |
29 files changed, 900 insertions, 339 deletions
@@ -1,3 +1,40 @@ +Sun Oct 21 23:27:00 2001 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkwidget.c (gtk_widget_translate_coordinates): Fix + problem with g_return_if_fail return value. + + * gdk/x11/gdkproperty-x11.c docs/Changes-2.0.txt: Move over the + virtual atom code from the gdk-multihead branch, removing the per-display + part. Virtualizing atoms needs to be done now to prevent compat + breakage in direct Xlib accessing code in the future. (#62208) + + * gdk/x11/gdkx.h: gdk/gdk/x11/gdkproperty-x11.c: Export + gdk_x11_xatom_to_atom, gdk_x11_atom_to_xatom(). + + * gdk/gdktypes.h docs/Changes-2.0.txt: Make GdkAtom + an opaque pointer type so the compiler catches attempts + to mingle it with X atoms. + + * gdk/x11/{gdkdnd-x11.c,gdkevents-x11.c,gdkglobals-x11.c, + gdkkeys-x11.c, gdkmain-x11.c, gdkprivate-x11.c, + gdkproperty-x11.c, gdkselection-x11.c, gdkwindow-x11.c} + gtk/{gtkclist.c,gtkctree.c,gtkdnd.c,gtkplug.c,gtksocket.c} + tests/testdnd.c,tests/testselection.c: + Fix up for above atom changes. + + * gdk/gdkselection.h (GDK_SELECTION_CLIPBOARD): Add, since we + now have the ability to add custom predefines. + + * gtk/{gtkentry.c,gtklabel.c,gtkoldeditable.c,gtktextview.c}: + Use GDK_SELECTION_CLIPBOARD instead of GDK_NONE in calls + to gtk_clipboard_get(). + + * gdk/win32/gdkproperty-win32.c: Add CLIPBOARD, fix up + for GdkAtom => pointer change. + + * gdk/linux-fb/gdkproperty-fb.c: Fix handling of predefined + atoms, fix for GdkAtom => pointer change. + Mon Oct 22 00:26:46 2001 Kristian Rietveld <kristian@planet.nl> * gtk/gtkspinbutton.c: remove ARROW_SIZE constant, use diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 3516accb45..438b5e3d7d 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,40 @@ +Sun Oct 21 23:27:00 2001 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkwidget.c (gtk_widget_translate_coordinates): Fix + problem with g_return_if_fail return value. + + * gdk/x11/gdkproperty-x11.c docs/Changes-2.0.txt: Move over the + virtual atom code from the gdk-multihead branch, removing the per-display + part. Virtualizing atoms needs to be done now to prevent compat + breakage in direct Xlib accessing code in the future. (#62208) + + * gdk/x11/gdkx.h: gdk/gdk/x11/gdkproperty-x11.c: Export + gdk_x11_xatom_to_atom, gdk_x11_atom_to_xatom(). + + * gdk/gdktypes.h docs/Changes-2.0.txt: Make GdkAtom + an opaque pointer type so the compiler catches attempts + to mingle it with X atoms. + + * gdk/x11/{gdkdnd-x11.c,gdkevents-x11.c,gdkglobals-x11.c, + gdkkeys-x11.c, gdkmain-x11.c, gdkprivate-x11.c, + gdkproperty-x11.c, gdkselection-x11.c, gdkwindow-x11.c} + gtk/{gtkclist.c,gtkctree.c,gtkdnd.c,gtkplug.c,gtksocket.c} + tests/testdnd.c,tests/testselection.c: + Fix up for above atom changes. + + * gdk/gdkselection.h (GDK_SELECTION_CLIPBOARD): Add, since we + now have the ability to add custom predefines. + + * gtk/{gtkentry.c,gtklabel.c,gtkoldeditable.c,gtktextview.c}: + Use GDK_SELECTION_CLIPBOARD instead of GDK_NONE in calls + to gtk_clipboard_get(). + + * gdk/win32/gdkproperty-win32.c: Add CLIPBOARD, fix up + for GdkAtom => pointer change. + + * gdk/linux-fb/gdkproperty-fb.c: Fix handling of predefined + atoms, fix for GdkAtom => pointer change. + Mon Oct 22 00:26:46 2001 Kristian Rietveld <kristian@planet.nl> * gtk/gtkspinbutton.c: remove ARROW_SIZE constant, use diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 3516accb45..438b5e3d7d 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,40 @@ +Sun Oct 21 23:27:00 2001 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkwidget.c (gtk_widget_translate_coordinates): Fix + problem with g_return_if_fail return value. + + * gdk/x11/gdkproperty-x11.c docs/Changes-2.0.txt: Move over the + virtual atom code from the gdk-multihead branch, removing the per-display + part. Virtualizing atoms needs to be done now to prevent compat + breakage in direct Xlib accessing code in the future. (#62208) + + * gdk/x11/gdkx.h: gdk/gdk/x11/gdkproperty-x11.c: Export + gdk_x11_xatom_to_atom, gdk_x11_atom_to_xatom(). + + * gdk/gdktypes.h docs/Changes-2.0.txt: Make GdkAtom + an opaque pointer type so the compiler catches attempts + to mingle it with X atoms. + + * gdk/x11/{gdkdnd-x11.c,gdkevents-x11.c,gdkglobals-x11.c, + gdkkeys-x11.c, gdkmain-x11.c, gdkprivate-x11.c, + gdkproperty-x11.c, gdkselection-x11.c, gdkwindow-x11.c} + gtk/{gtkclist.c,gtkctree.c,gtkdnd.c,gtkplug.c,gtksocket.c} + tests/testdnd.c,tests/testselection.c: + Fix up for above atom changes. + + * gdk/gdkselection.h (GDK_SELECTION_CLIPBOARD): Add, since we + now have the ability to add custom predefines. + + * gtk/{gtkentry.c,gtklabel.c,gtkoldeditable.c,gtktextview.c}: + Use GDK_SELECTION_CLIPBOARD instead of GDK_NONE in calls + to gtk_clipboard_get(). + + * gdk/win32/gdkproperty-win32.c: Add CLIPBOARD, fix up + for GdkAtom => pointer change. + + * gdk/linux-fb/gdkproperty-fb.c: Fix handling of predefined + atoms, fix for GdkAtom => pointer change. + Mon Oct 22 00:26:46 2001 Kristian Rietveld <kristian@planet.nl> * gtk/gtkspinbutton.c: remove ARROW_SIZE constant, use diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 3516accb45..438b5e3d7d 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,40 @@ +Sun Oct 21 23:27:00 2001 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkwidget.c (gtk_widget_translate_coordinates): Fix + problem with g_return_if_fail return value. + + * gdk/x11/gdkproperty-x11.c docs/Changes-2.0.txt: Move over the + virtual atom code from the gdk-multihead branch, removing the per-display + part. Virtualizing atoms needs to be done now to prevent compat + breakage in direct Xlib accessing code in the future. (#62208) + + * gdk/x11/gdkx.h: gdk/gdk/x11/gdkproperty-x11.c: Export + gdk_x11_xatom_to_atom, gdk_x11_atom_to_xatom(). + + * gdk/gdktypes.h docs/Changes-2.0.txt: Make GdkAtom + an opaque pointer type so the compiler catches attempts + to mingle it with X atoms. + + * gdk/x11/{gdkdnd-x11.c,gdkevents-x11.c,gdkglobals-x11.c, + gdkkeys-x11.c, gdkmain-x11.c, gdkprivate-x11.c, + gdkproperty-x11.c, gdkselection-x11.c, gdkwindow-x11.c} + gtk/{gtkclist.c,gtkctree.c,gtkdnd.c,gtkplug.c,gtksocket.c} + tests/testdnd.c,tests/testselection.c: + Fix up for above atom changes. + + * gdk/gdkselection.h (GDK_SELECTION_CLIPBOARD): Add, since we + now have the ability to add custom predefines. + + * gtk/{gtkentry.c,gtklabel.c,gtkoldeditable.c,gtktextview.c}: + Use GDK_SELECTION_CLIPBOARD instead of GDK_NONE in calls + to gtk_clipboard_get(). + + * gdk/win32/gdkproperty-win32.c: Add CLIPBOARD, fix up + for GdkAtom => pointer change. + + * gdk/linux-fb/gdkproperty-fb.c: Fix handling of predefined + atoms, fix for GdkAtom => pointer change. + Mon Oct 22 00:26:46 2001 Kristian Rietveld <kristian@planet.nl> * gtk/gtkspinbutton.c: remove ARROW_SIZE constant, use diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 3516accb45..438b5e3d7d 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,40 @@ +Sun Oct 21 23:27:00 2001 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkwidget.c (gtk_widget_translate_coordinates): Fix + problem with g_return_if_fail return value. + + * gdk/x11/gdkproperty-x11.c docs/Changes-2.0.txt: Move over the + virtual atom code from the gdk-multihead branch, removing the per-display + part. Virtualizing atoms needs to be done now to prevent compat + breakage in direct Xlib accessing code in the future. (#62208) + + * gdk/x11/gdkx.h: gdk/gdk/x11/gdkproperty-x11.c: Export + gdk_x11_xatom_to_atom, gdk_x11_atom_to_xatom(). + + * gdk/gdktypes.h docs/Changes-2.0.txt: Make GdkAtom + an opaque pointer type so the compiler catches attempts + to mingle it with X atoms. + + * gdk/x11/{gdkdnd-x11.c,gdkevents-x11.c,gdkglobals-x11.c, + gdkkeys-x11.c, gdkmain-x11.c, gdkprivate-x11.c, + gdkproperty-x11.c, gdkselection-x11.c, gdkwindow-x11.c} + gtk/{gtkclist.c,gtkctree.c,gtkdnd.c,gtkplug.c,gtksocket.c} + tests/testdnd.c,tests/testselection.c: + Fix up for above atom changes. + + * gdk/gdkselection.h (GDK_SELECTION_CLIPBOARD): Add, since we + now have the ability to add custom predefines. + + * gtk/{gtkentry.c,gtklabel.c,gtkoldeditable.c,gtktextview.c}: + Use GDK_SELECTION_CLIPBOARD instead of GDK_NONE in calls + to gtk_clipboard_get(). + + * gdk/win32/gdkproperty-win32.c: Add CLIPBOARD, fix up + for GdkAtom => pointer change. + + * gdk/linux-fb/gdkproperty-fb.c: Fix handling of predefined + atoms, fix for GdkAtom => pointer change. + Mon Oct 22 00:26:46 2001 Kristian Rietveld <kristian@planet.nl> * gtk/gtkspinbutton.c: remove ARROW_SIZE constant, use diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 3516accb45..438b5e3d7d 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,40 @@ +Sun Oct 21 23:27:00 2001 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkwidget.c (gtk_widget_translate_coordinates): Fix + problem with g_return_if_fail return value. + + * gdk/x11/gdkproperty-x11.c docs/Changes-2.0.txt: Move over the + virtual atom code from the gdk-multihead branch, removing the per-display + part. Virtualizing atoms needs to be done now to prevent compat + breakage in direct Xlib accessing code in the future. (#62208) + + * gdk/x11/gdkx.h: gdk/gdk/x11/gdkproperty-x11.c: Export + gdk_x11_xatom_to_atom, gdk_x11_atom_to_xatom(). + + * gdk/gdktypes.h docs/Changes-2.0.txt: Make GdkAtom + an opaque pointer type so the compiler catches attempts + to mingle it with X atoms. + + * gdk/x11/{gdkdnd-x11.c,gdkevents-x11.c,gdkglobals-x11.c, + gdkkeys-x11.c, gdkmain-x11.c, gdkprivate-x11.c, + gdkproperty-x11.c, gdkselection-x11.c, gdkwindow-x11.c} + gtk/{gtkclist.c,gtkctree.c,gtkdnd.c,gtkplug.c,gtksocket.c} + tests/testdnd.c,tests/testselection.c: + Fix up for above atom changes. + + * gdk/gdkselection.h (GDK_SELECTION_CLIPBOARD): Add, since we + now have the ability to add custom predefines. + + * gtk/{gtkentry.c,gtklabel.c,gtkoldeditable.c,gtktextview.c}: + Use GDK_SELECTION_CLIPBOARD instead of GDK_NONE in calls + to gtk_clipboard_get(). + + * gdk/win32/gdkproperty-win32.c: Add CLIPBOARD, fix up + for GdkAtom => pointer change. + + * gdk/linux-fb/gdkproperty-fb.c: Fix handling of predefined + atoms, fix for GdkAtom => pointer change. + Mon Oct 22 00:26:46 2001 Kristian Rietveld <kristian@planet.nl> * gtk/gtkspinbutton.c: remove ARROW_SIZE constant, use diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 3516accb45..438b5e3d7d 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,40 @@ +Sun Oct 21 23:27:00 2001 Owen Taylor <otaylor@redhat.com> + + * gtk/gtkwidget.c (gtk_widget_translate_coordinates): Fix + problem with g_return_if_fail return value. + + * gdk/x11/gdkproperty-x11.c docs/Changes-2.0.txt: Move over the + virtual atom code from the gdk-multihead branch, removing the per-display + part. Virtualizing atoms needs to be done now to prevent compat + breakage in direct Xlib accessing code in the future. (#62208) + + * gdk/x11/gdkx.h: gdk/gdk/x11/gdkproperty-x11.c: Export + gdk_x11_xatom_to_atom, gdk_x11_atom_to_xatom(). + + * gdk/gdktypes.h docs/Changes-2.0.txt: Make GdkAtom + an opaque pointer type so the compiler catches attempts + to mingle it with X atoms. + + * gdk/x11/{gdkdnd-x11.c,gdkevents-x11.c,gdkglobals-x11.c, + gdkkeys-x11.c, gdkmain-x11.c, gdkprivate-x11.c, + gdkproperty-x11.c, gdkselection-x11.c, gdkwindow-x11.c} + gtk/{gtkclist.c,gtkctree.c,gtkdnd.c,gtkplug.c,gtksocket.c} + tests/testdnd.c,tests/testselection.c: + Fix up for above atom changes. + + * gdk/gdkselection.h (GDK_SELECTION_CLIPBOARD): Add, since we + now have the ability to add custom predefines. + + * gtk/{gtkentry.c,gtklabel.c,gtkoldeditable.c,gtktextview.c}: + Use GDK_SELECTION_CLIPBOARD instead of GDK_NONE in calls + to gtk_clipboard_get(). + + * gdk/win32/gdkproperty-win32.c: Add CLIPBOARD, fix up + for GdkAtom => pointer change. + + * gdk/linux-fb/gdkproperty-fb.c: Fix handling of predefined + atoms, fix for GdkAtom => pointer change. + Mon Oct 22 00:26:46 2001 Kristian Rietveld <kristian@planet.nl> * gtk/gtkspinbutton.c: remove ARROW_SIZE constant, use diff --git a/gdk/gdkselection.h b/gdk/gdkselection.h index 94723d6b4d..8659f37956 100644 --- a/gdk/gdkselection.h +++ b/gdk/gdkselection.h @@ -7,35 +7,33 @@ extern "C" { #endif /* __cplusplus */ -/* The next three types define enums for predefined atoms relating - to selections. In general, one will need to use gdk_intern_atom */ - -typedef enum -{ - GDK_SELECTION_PRIMARY = 1, - GDK_SELECTION_SECONDARY = 2 -} GdkSelection; - -typedef enum -{ - GDK_TARGET_BITMAP = 5, - GDK_TARGET_COLORMAP = 7, - GDK_TARGET_DRAWABLE = 17, - GDK_TARGET_PIXMAP = 20, - GDK_TARGET_STRING = 31 -} GdkTarget; - -typedef enum -{ - GDK_SELECTION_TYPE_ATOM = 4, - GDK_SELECTION_TYPE_BITMAP = 5, - GDK_SELECTION_TYPE_COLORMAP = 7, - GDK_SELECTION_TYPE_DRAWABLE = 17, - GDK_SELECTION_TYPE_INTEGER = 19, - GDK_SELECTION_TYPE_PIXMAP = 20, - GDK_SELECTION_TYPE_WINDOW = 33, - GDK_SELECTION_TYPE_STRING = 31 -} GdkSelectionType; +/* Predefined atoms relating to selections. In general, one will need to use + * gdk_intern_atom + */ +#define GDK_SELECTION_PRIMARY _GDK_MAKE_ATOM (1) +#define GDK_SELECTION_SECONDARY _GDK_MAKE_ATOM (2) +#define GDK_SELECTION_CLIPBOARD _GDK_MAKE_ATOM (69) +#define GDK_TARGET_BITMAP _GDK_MAKE_ATOM (5) +#define GDK_TARGET_COLORMAP _GDK_MAKE_ATOM (7) +#define GDK_TARGET_DRAWABLE _GDK_MAKE_ATOM (17) +#define GDK_TARGET_PIXMAP _GDK_MAKE_ATOM (20) +#define GDK_TARGET_STRING _GDK_MAKE_ATOM (3) +#define GDK_SELECTION_TYPE_ATOM _GDK_MAKE_ATOM (4) +#define GDK_SELECTION_TYPE_BITMAP _GDK_MAKE_ATOM (5) +#define GDK_SELECTION_TYPE_COLORMAP _GDK_MAKE_ATOM (7) +#define GDK_SELECTION_TYPE_DRAWABLE _GDK_MAKE_ATOM (17) +#define GDK_SELECTION_TYPE_INTEGER _GDK_MAKE_ATOM (19) +#define GDK_SELECTION_TYPE_PIXMAP _GDK_MAKE_ATOM (20) +#define GDK_SELECTION_TYPE_WINDOW _GDK_MAKE_ATOM (33) +#define GDK_SELECTION_TYPE_STRING _GDK_MAKE_ATOM (3) + +#ifndef GDK_DISABLE_DEPRECATED + +typedef GdkAtom GdkSelection; +typedef GdkAtom GdkTarget; +typedef GdkAtom GdkSelectionType; + +#endif /* GDK_DISABLE_DEPRECATED */ /* Selections */ diff --git a/gdk/gdktypes.h b/gdk/gdktypes.h index caea6fd49c..d27374d9e1 100644 --- a/gdk/gdktypes.h +++ b/gdk/gdktypes.h @@ -51,7 +51,6 @@ #include <gdkconfig.h> /* some common magic values */ -#define GDK_NONE 0L #define GDK_CURRENT_TIME 0L #define GDK_PARENT_RELATIVE 1L @@ -76,7 +75,14 @@ typedef struct _GdkSpan GdkSpan; * on Win32, wchar_t is unsigned short. */ typedef guint32 GdkWChar; -typedef gulong GdkAtom; + +typedef struct _GdkAtom *GdkAtom; + +#define GDK_ATOM_TO_POINTER(atom) (atom) +#define GDK_POINTER_TO_ATOM(ptr) ((GdkAtom)(ptr)) + +#define _GDK_MAKE_ATOM(val) ((GdkAtom)GUINT_TO_POINTER(val)) +#define GDK_NONE _GDK_MAKE_ATOM (0) #ifdef GDK_NATIVE_WINDOW_POINTER typedef gpointer GdkNativeWindow; diff --git a/gdk/linux-fb/gdkproperty-fb.c b/gdk/linux-fb/gdkproperty-fb.c index e870f35433..38156e6ee7 100644 --- a/gdk/linux-fb/gdkproperty-fb.c +++ b/gdk/linux-fb/gdkproperty-fb.c @@ -38,13 +38,58 @@ gdk_atom_intern (const gchar *atom_name, { g_return_val_if_fail (atom_name != NULL, GDK_NONE); - return g_quark_from_string (atom_name); + if (strcmp (atom_name, "PRIMARY") == 0) + return GDK_SELECTION_PRIMARY; + else if (strcmp (atom_name, "SECONDARY") == 0) + return GDK_SELECTION_SECONDARY; + else if (strcmp (atom_name, "CLIPBOARD") == 0) + return GDK_SELECTION_CLIPBOARD; + else if (strcmp (atom_name, "ATOM") == 0) + return GDK_SELECTION_TYPE_ATOM; + else if (strcmp (atom_name, "BITMAP") == 0) + return GDK_SELECTION_TYPE_BITMAP; + else if (strcmp (atom_name, "COLORMAP") == 0) + return GDK_SELECTION_TYPE_COLORMAP; + else if (strcmp (atom_name, "DRAWABLE") == 0) + return GDK_SELECTION_TYPE_DRAWABLE; + else if (strcmp (atom_name, "INTEGER") == 0) + return GDK_SELECTION_TYPE_INTEGER; + else if (strcmp (atom_name, "PIXMAP") == 0) + return GDK_SELECTION_TYPE_PIXMAP; + else if (strcmp (atom_name, "WINDOW") == 0) + return GDK_SELECTION_TYPE_WINDOW; + else if (strcmp (atom_name, "STRING") == 0) + return GDK_SELECTION_TYPE_STRING; + else + return GUINT_TO_POINTER (256 + g_quark_from_string (atom_name)); } gchar* gdk_atom_name (GdkAtom atom) { - return g_strdup (g_quark_to_string (atom)); + if (atom < 256) + { + + switch (GPOINTER_TO_UINT (atom)) + { + case GDK_SELECTION_PRIMARY: return g_strdup ("PRIMARY"); + case GDK_SELECTION_SECONDARY: return g_strdup ("SECONDARY"); + case GDK_SELECTION_CLIPBOARD: return g_strdup ("CLIPBOARD"); + case GDK_SELECTION_TYPE_ATOM: return g_strdup ("ATOM"); + case GDK_SELECTION_TYPE_BITMAP: return g_strdup ("BITMAP"); + case GDK_SELECTION_TYPE_COLORMAP: return g_strdup ("COLORMAP"); + case GDK_SELECTION_TYPE_DRAWABLE: return g_strdup ("DRAWABLE"); + case GDK_SELECTION_TYPE_INTEGER: return g_strdup ("INTEGER"); + case GDK_SELECTION_TYPE_PIXMAP: return g_strdup ("PIXMAP"); + case GDK_SELECTION_TYPE_WINDOW: return g_strdup ("WINDOW"); + case GDK_SELECTION_TYPE_STRING: return g_strdup ("STRING"); + default: + g_warning (G_STRLOC "Invalid atom"); + return g_strdup ("<invalid>"); + } + } + else + return g_strdup (g_quark_to_string (atom - 256)); } static void diff --git a/gdk/win32/gdkproperty-win32.c b/gdk/win32/gdkproperty-win32.c index ef912e95d3..a6d6b31985 100644 --- a/gdk/win32/gdkproperty-win32.c +++ b/gdk/win32/gdkproperty-win32.c @@ -41,17 +41,20 @@ gdk_atom_intern (const gchar *atom_name, { GdkAtom retval; static GHashTable *atom_hash = NULL; + ATOM win32_atom; if (!atom_hash) atom_hash = g_hash_table_new (g_str_hash, g_str_equal); - retval = GPOINTER_TO_UINT (g_hash_table_lookup (atom_hash, atom_name)); + retval = g_hash_table_lookup (atom_hash, atom_name); if (!retval) { if (strcmp (atom_name, "PRIMARY") == 0) retval = GDK_SELECTION_PRIMARY; else if (strcmp (atom_name, "SECONDARY") == 0) retval = GDK_SELECTION_SECONDARY; + else if (strcmp (atom_name, "CLIPBOARD") == 0) + retval = GDK_SELECTION_CLIPBOARD; else if (strcmp (atom_name, "ATOM") == 0) retval = GDK_SELECTION_TYPE_ATOM; else if (strcmp (atom_name, "BITMAP") == 0) @@ -70,15 +73,16 @@ gdk_atom_intern (const gchar *atom_name, retval = GDK_SELECTION_TYPE_STRING; else { - retval = GlobalFindAtom (atom_name); + win32_atom = GlobalFindAtom (atom_name); if (only_if_exists && retval == 0) - retval = 0; + win32_atom = 0; else - retval = GlobalAddAtom (atom_name); + win32_atom = GlobalAddAtom (atom_name); + retval = GUINT_TO_POINTER (win32_atom); } g_hash_table_insert (atom_hash, g_strdup (atom_name), - GUINT_TO_POINTER (retval)); + retval); } return retval; @@ -88,11 +92,13 @@ gchar * gdk_atom_name (GdkAtom atom) { gchar name[256]; + ATOM win32_atom; switch (atom) { case GDK_SELECTION_PRIMARY: return g_strdup ("PRIMARY"); case GDK_SELECTION_SECONDARY: return g_strdup ("SECONDARY"); + case GDK_SELECTION_CLIPBOARD: return g_strdup ("CLIPBOARD"); case GDK_SELECTION_TYPE_ATOM: return g_strdup ("ATOM"); case GDK_SELECTION_TYPE_BITMAP: return g_strdup ("BITMAP"); case GDK_SELECTION_TYPE_COLORMAP: return g_strdup ("COLORMAP"); @@ -102,9 +108,12 @@ gdk_atom_name (GdkAtom atom) case GDK_SELECTION_TYPE_WINDOW: return g_strdup ("WINDOW"); case GDK_SELECTION_TYPE_STRING: return g_strdup ("STRING"); } - if (atom < 0xC000) - return g_strdup_printf ("#%x", (guint) atom); - else if (GlobalGetAtomName (atom, name, sizeof (name)) == 0) + + win32_atom = GPOINTER_TO_UINT (atom); + + if (win32_atom < 0xC000) + return g_strdup_printf ("#%x", atom); + else if (GlobalGetAtomName (win32_atom, name, sizeof (name)) == 0) return NULL; return g_strdup (name); } diff --git a/gdk/x11/gdkdnd-x11.c b/gdk/x11/gdkdnd-x11.c index 024651576f..8f229db631 100644 --- a/gdk/x11/gdkdnd-x11.c +++ b/gdk/x11/gdkdnd-x11.c @@ -61,8 +61,8 @@ typedef struct { struct _GdkDragContextPrivateX11 { GdkDragContext context; - GdkAtom motif_selection; - GdkAtom xdnd_selection; + Atom motif_selection; + Atom xdnd_selection; guint ref_count; guint16 last_x; /* Coordinates from last event */ @@ -489,7 +489,7 @@ get_client_window_at_coords_recurse (Window win, static Atom wm_state_atom = None; if (!wm_state_atom) - wm_state_atom = gdk_atom_intern ("WM_STATE", FALSE); + wm_state_atom = gdk_x11_get_xatom_by_name ("WM_STATE"); XGetWindowProperty (gdk_display, win, wm_state_atom, 0, 0, False, AnyPropertyType, @@ -616,7 +616,7 @@ get_client_window_at_coords_recurse (Window win, static Atom wm_state_atom = None; if (!wm_state_atom) - wm_state_atom = gdk_atom_intern ("WM_STATE", FALSE); + wm_state_atom = gdk_x11_get_xatom_by_name ("WM_STATE"); XGetWindowProperty (gdk_display, win, wm_state_atom, 0, 0, False, AnyPropertyType, @@ -768,7 +768,7 @@ print_target_list (GList *targets) { while (targets) { - gchar *name = gdk_atom_name (GPOINTER_TO_INT (targets->data)); + gchar *name = gdk_atom_name (GDK_POINTER_TO_ATOM (targets->data)); g_message ("\t%s", name); g_free (name); targets = targets->next; @@ -851,8 +851,8 @@ typedef struct _MotifDragReceiverInfo { static Window motif_drag_window = None; static GdkWindow *motif_drag_gdk_window = NULL; -static GdkAtom motif_drag_targets_atom = GDK_NONE; -static GdkAtom motif_drag_receiver_info_atom = GDK_NONE; +static Atom motif_drag_targets_atom = None; +static Atom motif_drag_receiver_info_atom = None; /* Target table handling */ @@ -879,14 +879,14 @@ motif_drag_window_filter (GdkXEvent *xevent, return GDK_FILTER_REMOVE; } -static Atom motif_drag_window_atom = GDK_NONE; +static Atom motif_drag_window_atom = None; static Window motif_lookup_drag_window (Display *display) { Window retval = None; gulong bytes_after, nitems; - GdkAtom type; + Atom type; gint format; guchar *data; @@ -917,7 +917,7 @@ motif_find_drag_window (gboolean create) if (!motif_drag_window) { if (!motif_drag_window_atom) - motif_drag_window_atom = gdk_atom_intern ("_MOTIF_DRAG_WINDOW", TRUE); + motif_drag_window_atom = gdk_x11_get_xatom_by_name ("_MOTIF_DRAG_WINDOW"); motif_drag_window = motif_lookup_drag_window (gdk_display); @@ -977,12 +977,12 @@ static void motif_read_target_table (void) { gulong bytes_after, nitems; - GdkAtom type; + Atom type; gint format; gint i, j; if (!motif_drag_targets_atom) - motif_drag_targets_atom = gdk_atom_intern ("_MOTIF_DRAG_TARGETS", FALSE); + motif_drag_targets_atom = gdk_x11_get_xatom_by_name ("_MOTIF_DRAG_TARGETS"); if (motif_target_lists) { @@ -1117,7 +1117,7 @@ motif_target_table_check (GList *sorted) } static gint -motif_add_to_target_table (GList *targets) +motif_add_to_target_table (GList *targets) /* targets is list of GdkAtom */ { GList *sorted = NULL; gint index = -1; @@ -1128,7 +1128,8 @@ motif_add_to_target_table (GList *targets) while (targets) { - sorted = g_list_insert_sorted (sorted, targets->data, targets_sort_func); + Atom xatom = gdk_x11_atom_to_xatom (GDK_POINTER_TO_ATOM (targets->data)); + sorted = g_list_insert_sorted (sorted, GUINT_TO_POINTER (xatom), targets_sort_func); targets = targets->next; } @@ -1304,10 +1305,10 @@ motif_set_targets (GdkDragContext *context) GdkDragContextPrivateX11 *private = PRIVATE_DATA (context); MotifDragInitiatorInfo info; gint i; - static GdkAtom motif_drag_initiator_info = GDK_NONE; + static Atom motif_drag_initiator_info = None; if (!motif_drag_initiator_info) - motif_drag_initiator_info = gdk_atom_intern ("_MOTIF_DRAG_INITIATOR_INFO", FALSE); + motif_drag_initiator_info = gdk_x11_get_xatom_by_name ("_MOTIF_DRAG_INITIATOR_INFO"); info.byte_order = local_byte_order; info.protocol_version = 0; @@ -1319,7 +1320,7 @@ motif_set_targets (GdkDragContext *context) gchar buf[20]; g_snprintf(buf, 20, "_GDK_SELECTION_%d", i); - private->motif_selection = gdk_atom_intern (buf, FALSE); + private->motif_selection = gdk_x11_get_xatom_by_name (buf); if (!XGetSelectionOwner (gdk_display, private->motif_selection)) break; } @@ -1345,7 +1346,7 @@ motif_check_dest (Window win) unsigned long nitems, after; if (!motif_drag_receiver_info_atom) - motif_drag_receiver_info_atom = gdk_atom_intern ("_MOTIF_DRAG_RECEIVER_INFO", FALSE); + motif_drag_receiver_info_atom = gdk_x11_get_xatom_by_name ("_MOTIF_DRAG_RECEIVER_INFO"); gdk_error_trap_push (); XGetWindowProperty (gdk_display, win, @@ -1376,8 +1377,7 @@ motif_check_dest (Window win) } } - return retval ? win : GDK_NONE; - + return retval ? win : None; } static void @@ -1388,7 +1388,7 @@ motif_send_enter (GdkDragContext *context, GdkDragContextPrivateX11 *private = PRIVATE_DATA (context); xev.xclient.type = ClientMessage; - xev.xclient.message_type = gdk_atom_intern ("_MOTIF_DRAG_AND_DROP_MESSAGE", FALSE); + xev.xclient.message_type = gdk_x11_get_xatom_by_name ("_MOTIF_DRAG_AND_DROP_MESSAGE"); xev.xclient.format = 8; xev.xclient.window = GDK_DRAWABLE_XID (context->dest_window); @@ -1417,7 +1417,7 @@ motif_send_leave (GdkDragContext *context, XEvent xev; xev.xclient.type = ClientMessage; - xev.xclient.message_type = gdk_atom_intern ("_MOTIF_DRAG_AND_DROP_MESSAGE", FALSE); + xev.xclient.message_type = gdk_x11_get_xatom_by_name ("_MOTIF_DRAG_AND_DROP_MESSAGE"); xev.xclient.format = 8; xev.xclient.window = GDK_DRAWABLE_XID (context->dest_window); @@ -1447,7 +1447,7 @@ motif_send_motion (GdkDragContext *context, GdkDragContextPrivateX11 *private = PRIVATE_DATA (context); xev.xclient.type = ClientMessage; - xev.xclient.message_type = gdk_atom_intern ("_MOTIF_DRAG_AND_DROP_MESSAGE", FALSE); + xev.xclient.message_type = gdk_x11_get_xatom_by_name ("_MOTIF_DRAG_AND_DROP_MESSAGE"); xev.xclient.format = 8; xev.xclient.window = GDK_DRAWABLE_XID (context->dest_window); @@ -1490,7 +1490,7 @@ motif_send_drop (GdkDragContext *context, guint32 time) GdkDragContextPrivateX11 *private = PRIVATE_DATA (context); xev.xclient.type = ClientMessage; - xev.xclient.message_type = gdk_atom_intern ("_MOTIF_DRAG_AND_DROP_MESSAGE", FALSE); + xev.xclient.message_type = gdk_x11_get_xatom_by_name ("_MOTIF_DRAG_AND_DROP_MESSAGE"); xev.xclient.format = 8; xev.xclient.window = GDK_DRAWABLE_XID (context->dest_window); @@ -1515,14 +1515,14 @@ motif_send_drop (GdkDragContext *context, guint32 time) /* Target Side */ static gboolean -motif_read_initiator_info (Window source_window, - Atom atom, - GList **targets, - GdkAtom *selection) +motif_read_initiator_info (Window source_window, + Atom atom, + GList **targets, /* GdkAtom */ + Atom *selection) { GList *tmp_list; - static GdkAtom motif_drag_initiator_info = GDK_NONE; - GdkAtom type; + static Atom motif_drag_initiator_info = None; + Atom type; gint format; gulong nitems; gulong bytes_after; @@ -1530,7 +1530,7 @@ motif_read_initiator_info (Window source_window, MotifDragInitiatorInfo *initiator_info; if (!motif_drag_initiator_info) - motif_drag_initiator_info = gdk_atom_intern ("_MOTIF_DRAG_INITIATOR_INFO", FALSE); + motif_drag_initiator_info = gdk_x11_get_xatom_by_name ("_MOTIF_DRAG_INITIATOR_INFO"); gdk_error_trap_push (); XGetWindowProperty (gdk_display, source_window, atom, @@ -1564,8 +1564,8 @@ motif_read_initiator_info (Window source_window, *targets = NULL; while (tmp_list) { - *targets = g_list_prepend (*targets, - tmp_list->data); + GdkAtom atom = gdk_x11_xatom_to_atom (GPOINTER_TO_UINT (tmp_list->data)); + *targets = g_list_prepend (*targets, GDK_ATOM_TO_POINTER (atom)); tmp_list = tmp_list->prev; } @@ -1627,10 +1627,10 @@ motif_drag_context_new (GdkWindow *dest_window, gdk_window_ref (dest_window); new_context->start_time = timestamp; - if (!motif_read_initiator_info(source_window, - atom, - &new_context->targets, - &private->motif_selection)) + if (!motif_read_initiator_info (source_window, + atom, + &new_context->targets, + &private->motif_selection)) { gdk_drag_context_unref (new_context); return NULL; @@ -1868,7 +1868,7 @@ motif_dnd_filter (GdkXEvent *xev, guint16 flags; guint32 timestamp; guint32 source_window; - GdkAtom atom; + Atom atom; gint16 x_root, y_root; gboolean is_reply; @@ -1942,14 +1942,14 @@ motif_dnd_filter (GdkXEvent *xev, static struct { gchar *name; - GdkAtom atom; + Atom atom; GdkDragAction action; } xdnd_actions_table[] = { - { "XdndActionCopy", GDK_NONE, GDK_ACTION_COPY }, - { "XdndActionMove", GDK_NONE, GDK_ACTION_MOVE }, - { "XdndActionLink", GDK_NONE, GDK_ACTION_LINK }, - { "XdndActionAsk", GDK_NONE, GDK_ACTION_ASK }, - { "XdndActionPrivate", GDK_NONE, GDK_ACTION_COPY }, + { "XdndActionCopy", None, GDK_ACTION_COPY }, + { "XdndActionMove", None, GDK_ACTION_MOVE }, + { "XdndActionLink", None, GDK_ACTION_LINK }, + { "XdndActionAsk", None, GDK_ACTION_ASK }, + { "XdndActionPrivate", None, GDK_ACTION_COPY }, }; static const gint xdnd_n_actions = sizeof(xdnd_actions_table) / sizeof(xdnd_actions_table[0]); @@ -1962,11 +1962,11 @@ xdnd_initialize_actions (void) xdnd_actions_initialized = TRUE; for (i=0; i < xdnd_n_actions; i++) - xdnd_actions_table[i].atom = gdk_atom_intern (xdnd_actions_table[i].name, FALSE); + xdnd_actions_table[i].atom = gdk_x11_get_xatom_by_name (xdnd_actions_table[i].name); } static GdkDragAction -xdnd_action_from_atom (GdkAtom atom) +xdnd_action_from_atom (Atom atom) { gint i; @@ -1980,7 +1980,7 @@ xdnd_action_from_atom (GdkAtom atom) return 0; } -static GdkAtom +static Atom xdnd_action_to_atom (GdkDragAction action) { gint i; @@ -1992,10 +1992,10 @@ xdnd_action_to_atom (GdkDragAction action) if (action == xdnd_actions_table[i].action) return xdnd_actions_table[i].atom; - return GDK_NONE; + return None; } -static GdkAtom xdnd_aware_atom = GDK_NONE; +static Atom xdnd_aware_atom = None; /* Source side */ @@ -2007,7 +2007,7 @@ xdnd_status_filter (GdkXEvent *xev, XEvent *xevent = (XEvent *)xev; guint32 dest_window = xevent->xclient.data.l[0]; guint32 flags = xevent->xclient.data.l[1]; - GdkAtom action = xevent->xclient.data.l[4]; + Atom action = xevent->xclient.data.l[4]; GdkDragContext *context; GDK_NOTE (DND, @@ -2072,23 +2072,23 @@ static void xdnd_set_targets (GdkDragContext *context) { GdkDragContextPrivateX11 *private = PRIVATE_DATA (context); - GdkAtom *atomlist; + Atom *atomlist; GList *tmp_list = context->targets; gint i; gint n_atoms = g_list_length (context->targets); - atomlist = g_new (GdkAtom, n_atoms); + atomlist = g_new (Atom, n_atoms); i = 0; while (tmp_list) { - atomlist[i] = GPOINTER_TO_INT (tmp_list->data); + atomlist[i] = gdk_x11_atom_to_xatom (GDK_POINTER_TO_ATOM (tmp_list->data)); tmp_list = tmp_list->next; i++; } XChangeProperty (GDK_DRAWABLE_XDISPLAY (context->source_window), GDK_DRAWABLE_XID (context->source_window), - gdk_atom_intern ("XdndTypeList", FALSE), + gdk_x11_get_xatom_by_name ("XdndTypeList"), XA_ATOM, 32, PropModeReplace, (guchar *)atomlist, n_atoms); @@ -2101,7 +2101,7 @@ static void xdnd_set_actions (GdkDragContext *context) { GdkDragContextPrivateX11 *private = PRIVATE_DATA (context); - GdkAtom *atomlist; + Atom *atomlist; gint i; gint n_atoms; guint actions; @@ -2120,7 +2120,7 @@ xdnd_set_actions (GdkDragContext *context) } } - atomlist = g_new (GdkAtom, n_atoms); + atomlist = g_new (Atom, n_atoms); actions = context->actions; n_atoms = 0; @@ -2136,7 +2136,7 @@ xdnd_set_actions (GdkDragContext *context) XChangeProperty (GDK_DRAWABLE_XDISPLAY (context->source_window), GDK_DRAWABLE_XID (context->source_window), - gdk_atom_intern ("XdndActionList", FALSE), + gdk_x11_get_xatom_by_name ("XdndActionList"), XA_ATOM, 32, PropModeReplace, (guchar *)atomlist, n_atoms); @@ -2173,7 +2173,7 @@ xdnd_send_enter (GdkDragContext *context) GdkDragContextPrivateX11 *private = PRIVATE_DATA (context); xev.xclient.type = ClientMessage; - xev.xclient.message_type = gdk_atom_intern ("XdndEnter", FALSE); + xev.xclient.message_type = gdk_x11_get_xatom_by_name ("XdndEnter"); xev.xclient.format = 32; xev.xclient.window = private->drop_xid ? private->drop_xid : @@ -2185,7 +2185,7 @@ xdnd_send_enter (GdkDragContext *context) xev.xclient.data.l[4] = 0; if (!private->xdnd_selection) - private->xdnd_selection = gdk_atom_intern ("XdndSelection", FALSE); + private->xdnd_selection = gdk_x11_get_xatom_by_name ("XdndSelection"); if (g_list_length (context->targets) > 3) { @@ -2200,7 +2200,7 @@ xdnd_send_enter (GdkDragContext *context) while (tmp_list) { - xev.xclient.data.l[i] = GPOINTER_TO_INT (tmp_list->data); + xev.xclient.data.l[i] = gdk_x11_atom_to_xatom (GDK_POINTER_TO_ATOM (tmp_list->data)); tmp_list = tmp_list->next; i++; } @@ -2225,7 +2225,7 @@ xdnd_send_leave (GdkDragContext *context) GdkDragContextPrivateX11 *private = PRIVATE_DATA (context); xev.xclient.type = ClientMessage; - xev.xclient.message_type = gdk_atom_intern ("XdndLeave", FALSE); + xev.xclient.message_type = gdk_x11_get_xatom_by_name ("XdndLeave"); xev.xclient.format = 32; xev.xclient.window = private->drop_xid ? private->drop_xid : @@ -2254,7 +2254,7 @@ xdnd_send_drop (GdkDragContext *context, guint32 time) XEvent xev; xev.xclient.type = ClientMessage; - xev.xclient.message_type = gdk_atom_intern ("XdndDrop", FALSE); + xev.xclient.message_type = gdk_x11_get_xatom_by_name ("XdndDrop"); xev.xclient.format = 32; xev.xclient.window = private->drop_xid ? private->drop_xid : @@ -2287,7 +2287,7 @@ xdnd_send_motion (GdkDragContext *context, XEvent xev; xev.xclient.type = ClientMessage; - xev.xclient.message_type = gdk_atom_intern ("XdndPosition", FALSE); + xev.xclient.message_type = gdk_x11_get_xatom_by_name ("XdndPosition"); xev.xclient.format = 32; xev.xclient.window = private->drop_xid ? private->drop_xid : @@ -2317,20 +2317,20 @@ xdnd_check_dest (Window win) Atom type = None; int format; unsigned long nitems, after; - GdkAtom *version; + Atom *version; Window *proxy_data; Window proxy; - static GdkAtom xdnd_proxy_atom = GDK_NONE; + static Atom xdnd_proxy_atom = None; gint old_warnings = _gdk_error_warnings; if (!xdnd_proxy_atom) - xdnd_proxy_atom = gdk_atom_intern ("XdndProxy", FALSE); + xdnd_proxy_atom = gdk_x11_get_xatom_by_name ("XdndProxy"); if (!xdnd_aware_atom) - xdnd_aware_atom = gdk_atom_intern ("XdndAware", FALSE); + xdnd_aware_atom = gdk_x11_get_xatom_by_name ("XdndAware"); - proxy = GDK_NONE; + proxy = None; _gdk_error_code = 0; _gdk_error_warnings = 0; @@ -2381,7 +2381,7 @@ xdnd_check_dest (Window win) _gdk_error_warnings = old_warnings; _gdk_error_code = 0; - return retval ? (proxy ? proxy : win) : GDK_NONE; + return retval ? (proxy ? proxy : win) : None; } /* Target side */ @@ -2405,7 +2405,7 @@ xdnd_read_actions (GdkDragContext *context) XGetWindowProperty (GDK_DRAWABLE_XDISPLAY (context->source_window), GDK_DRAWABLE_XID (context->source_window), - gdk_atom_intern ("XdndActionList", FALSE), 0, 65536, + gdk_x11_get_xatom_by_name ("XdndActionList"), 0, 65536, False, XA_ATOM, &type, &format, &nitems, &after, (guchar **)&data); @@ -2458,7 +2458,7 @@ xdnd_source_window_filter (GdkXEvent *xev, GdkDragContext *context = cb_data; if ((xevent->xany.type == PropertyNotify) && - (xevent->xproperty.atom == gdk_atom_intern ("XdndActionList", FALSE))) + (xevent->xproperty.atom == gdk_x11_get_xatom_by_name ("XdndActionList"))) { xdnd_read_actions (context); @@ -2561,7 +2561,7 @@ xdnd_enter_filter (GdkXEvent *xev, gdk_error_trap_push (); XGetWindowProperty (GDK_DRAWABLE_XDISPLAY (event->any.window), source_window, - gdk_atom_intern ("XdndTypeList", FALSE), 0, 65536, + gdk_x11_get_xatom_by_name ("XdndTypeList"), 0, 65536, False, XA_ATOM, &type, &format, &nitems, &after, (guchar **)&data); @@ -2573,7 +2573,7 @@ xdnd_enter_filter (GdkXEvent *xev, for (i=0; i<nitems; i++) new_context->targets = g_list_append (new_context->targets, - GUINT_TO_POINTER (data[i])); + GDK_ATOM_TO_POINTER (gdk_x11_xatom_to_atom (data[i]))); XFree(data); } @@ -2582,7 +2582,7 @@ xdnd_enter_filter (GdkXEvent *xev, for (i=0; i<3; i++) if (xevent->xclient.data.l[2+i]) new_context->targets = g_list_append (new_context->targets, - GUINT_TO_POINTER (xevent->xclient.data.l[2+i])); + GDK_ATOM_TO_POINTER (gdk_x11_xatom_to_atom (xevent->xclient.data.l[2+i]))); } #ifdef G_ENABLE_DEBUG @@ -2599,7 +2599,7 @@ xdnd_enter_filter (GdkXEvent *xev, current_dest_drag = new_context; (PRIVATE_DATA (new_context))->xdnd_selection = - gdk_atom_intern ("XdndSelection", FALSE); + gdk_x11_get_xatom_by_name ("XdndSelection"); return GDK_FILTER_TRANSLATE; } @@ -2642,7 +2642,7 @@ xdnd_position_filter (GdkXEvent *xev, gint16 x_root = xevent->xclient.data.l[2] >> 16; gint16 y_root = xevent->xclient.data.l[2] & 0xffff; guint32 time = xevent->xclient.data.l[3]; - GdkAtom action = xevent->xclient.data.l[4]; + Atom action = xevent->xclient.data.l[4]; GDK_NOTE (DND, g_message ("XdndPosition: source_window: %#x position: (%d, %d) time: %d action: %ld", @@ -2772,7 +2772,6 @@ GdkDragContext * gdk_drag_begin (GdkWindow *window, GList *targets) { - GList *tmp_list; GdkDragContext *new_context; g_return_val_if_fail (window != NULL, NULL); @@ -2782,15 +2781,7 @@ gdk_drag_begin (GdkWindow *window, new_context->source_window = window; gdk_window_ref (window); - tmp_list = g_list_last (targets); - new_context->targets = NULL; - while (tmp_list) - { - new_context->targets = g_list_prepend (new_context->targets, - tmp_list->data); - tmp_list = tmp_list->prev; - } - + new_context->targets = g_list_copy (targets); new_context->actions = 0; return new_context; @@ -2835,7 +2826,7 @@ gdk_drag_get_protocol (guint32 xid, _gdk_error_code = 0; XGetWindowProperty (gdk_display, xid, - gdk_atom_intern ("ENLIGHTENMENT_DESKTOP", FALSE), + gdk_x11_get_xatom_by_name ("ENLIGHTENMENT_DESKTOP"), 0, 0, False, AnyPropertyType, &type, &format, &nitems, &after, &data); if ((_gdk_error_code == 0) && type != None) @@ -2855,7 +2846,7 @@ gdk_drag_get_protocol (guint32 xid, _gdk_error_code = 0; XGetWindowProperty (gdk_display, win, - gdk_atom_intern ("__SWM_VROOT", FALSE), + gdk_x11_get_xatom_by_name ("__SWM_VROOT"), 0, 0, False, AnyPropertyType, &type, &format, &nitems, &data); if ((_gdk_error_code == 0) && type != None) @@ -2873,7 +2864,7 @@ gdk_drag_get_protocol (guint32 xid, } *protocol = GDK_DRAG_PROTO_NONE; - return GDK_NONE; + return None; } void @@ -2894,7 +2885,7 @@ gdk_drag_find_window (GdkDragContext *context, dest = get_client_window_at_coords (private->window_cache, drag_window ? - GDK_DRAWABLE_XID (drag_window) : GDK_NONE, + GDK_DRAWABLE_XID (drag_window) : None, x_root, y_root); if (private->dest_xid != dest) @@ -3044,7 +3035,7 @@ gdk_drag_motion (GdkDragContext *context, GdkEvent temp_event; if (g_list_find (context->targets, - GUINT_TO_POINTER (gdk_atom_intern ("application/x-rootwin-drop", FALSE)))) + GDK_ATOM_TO_POINTER (gdk_atom_intern ("application/x-rootwin-drop", FALSE)))) context->action = context->suggested_action; else context->action = 0; @@ -3131,7 +3122,7 @@ gdk_drag_status (GdkDragContext *context, if (context->protocol == GDK_DRAG_PROTO_MOTIF) { xev.xclient.type = ClientMessage; - xev.xclient.message_type = gdk_atom_intern ("_MOTIF_DRAG_AND_DROP_MESSAGE", FALSE); + xev.xclient.message_type = gdk_x11_get_xatom_by_name ("_MOTIF_DRAG_AND_DROP_MESSAGE"); xev.xclient.format = 8; xev.xclient.window = GDK_DRAWABLE_XID (context->source_window); @@ -3188,7 +3179,7 @@ gdk_drag_status (GdkDragContext *context, else if (context->protocol == GDK_DRAG_PROTO_XDND) { xev.xclient.type = ClientMessage; - xev.xclient.message_type = gdk_atom_intern ("XdndStatus", FALSE); + xev.xclient.message_type = gdk_x11_get_xatom_by_name ("XdndStatus"); xev.xclient.format = 32; xev.xclient.window = GDK_DRAWABLE_XID (context->source_window); @@ -3224,7 +3215,7 @@ gdk_drop_reply (GdkDragContext *context, XEvent xev; xev.xclient.type = ClientMessage; - xev.xclient.message_type = gdk_atom_intern ("_MOTIF_DRAG_AND_DROP_MESSAGE", FALSE); + xev.xclient.message_type = gdk_x11_get_xatom_by_name ("_MOTIF_DRAG_AND_DROP_MESSAGE"); xev.xclient.format = 8; MOTIF_XCLIENT_BYTE (&xev, 0) = XmDROP_START | 0x80; @@ -3259,7 +3250,7 @@ gdk_drop_finish (GdkDragContext *context, XEvent xev; xev.xclient.type = ClientMessage; - xev.xclient.message_type = gdk_atom_intern ("XdndFinished", FALSE); + xev.xclient.message_type = gdk_x11_get_xatom_by_name ("XdndFinished"); xev.xclient.format = 32; xev.xclient.window = GDK_DRAWABLE_XID (context->source_window); @@ -3294,12 +3285,12 @@ gdk_window_register_dnd (GdkWindow *window) /* Set Motif drag receiver information property */ if (!motif_drag_receiver_info_atom) - motif_drag_receiver_info_atom = gdk_atom_intern ("_MOTIF_DRAG_RECEIVER_INFO", FALSE); + motif_drag_receiver_info_atom = gdk_x11_get_xatom_by_name ("_MOTIF_DRAG_RECEIVER_INFO"); info.byte_order = local_byte_order; info.protocol_version = 0; info.protocol_style = XmDRAG_DYNAMIC; - info.proxy_window = GDK_NONE; + info.proxy_window = None; info.num_drop_sites = 0; info.total_size = sizeof(info); @@ -3313,7 +3304,7 @@ gdk_window_register_dnd (GdkWindow *window) /* Set XdndAware */ if (!xdnd_aware_atom) - xdnd_aware_atom = gdk_atom_intern ("XdndAware", FALSE); + xdnd_aware_atom = gdk_x11_get_xatom_by_name ("XdndAware"); /* The property needs to be of type XA_ATOM, not XA_INTEGER. Blech */ XChangeProperty (GDK_DRAWABLE_XDISPLAY (window), @@ -3337,9 +3328,9 @@ gdk_drag_get_selection (GdkDragContext *context) g_return_val_if_fail (context != NULL, GDK_NONE); if (context->protocol == GDK_DRAG_PROTO_MOTIF) - return (PRIVATE_DATA (context))->motif_selection; + return gdk_x11_xatom_to_atom ((PRIVATE_DATA (context))->motif_selection); else if (context->protocol == GDK_DRAG_PROTO_XDND) - return (PRIVATE_DATA (context))->xdnd_selection; + return gdk_x11_xatom_to_atom ((PRIVATE_DATA (context))->xdnd_selection); else return GDK_NONE; } diff --git a/gdk/x11/gdkevents-x11.c b/gdk/x11/gdkevents-x11.c index 67c951cac0..8ba6d3f72c 100644 --- a/gdk/x11/gdkevents-x11.c +++ b/gdk/x11/gdkevents-x11.c @@ -162,9 +162,9 @@ _gdk_events_init (void) g_source_set_can_recurse (source, TRUE); g_source_attach (source, NULL); - _gdk_wm_window_protocols[0] = gdk_atom_intern ("WM_DELETE_WINDOW", FALSE); - _gdk_wm_window_protocols[1] = gdk_atom_intern ("WM_TAKE_FOCUS", FALSE); - _gdk_wm_window_protocols[2] = gdk_atom_intern ("_NET_WM_PING", FALSE); + _gdk_wm_window_protocols[0] = gdk_x11_get_xatom_by_name ("WM_DELETE_WINDOW"); + _gdk_wm_window_protocols[1] = gdk_x11_get_xatom_by_name ("WM_TAKE_FOCUS"); + _gdk_wm_window_protocols[2] = gdk_x11_get_xatom_by_name ("_NET_WM_PING"); gdk_add_client_message_filter (gdk_atom_intern ("WM_PROTOCOLS", FALSE), gdk_wm_protocols_filter, NULL); @@ -286,8 +286,8 @@ gdk_add_client_message_filter (GdkAtom message_type, client_filters = g_list_prepend (client_filters, filter); } -static GdkAtom wm_state_atom = 0; -static GdkAtom wm_desktop_atom = 0; +static Atom wm_state_atom = 0; +static Atom wm_desktop_atom = 0; static void gdk_check_wm_state_changed (GdkWindow *window) @@ -296,11 +296,11 @@ gdk_check_wm_state_changed (GdkWindow *window) gint format; gulong nitems; gulong bytes_after; - GdkAtom *atoms = NULL; + Atom *atoms = NULL; gulong i; - GdkAtom sticky_atom; - GdkAtom maxvert_atom; - GdkAtom maxhorz_atom; + Atom sticky_atom; + Atom maxvert_atom; + Atom maxhorz_atom; gboolean found_sticky, found_maxvert, found_maxhorz; GdkWindowState old_state; @@ -308,10 +308,10 @@ gdk_check_wm_state_changed (GdkWindow *window) return; if (wm_state_atom == 0) - wm_state_atom = gdk_atom_intern ("_NET_WM_STATE", FALSE); + wm_state_atom = gdk_x11_get_xatom_by_name ("_NET_WM_STATE"); if (wm_desktop_atom == 0) - wm_desktop_atom = gdk_atom_intern ("_NET_WM_DESKTOP", FALSE); + wm_desktop_atom = gdk_x11_get_xatom_by_name ("_NET_WM_DESKTOP"); XGetWindowProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window), wm_state_atom, 0, G_MAXLONG, @@ -321,9 +321,9 @@ gdk_check_wm_state_changed (GdkWindow *window) if (type != None) { - sticky_atom = gdk_atom_intern ("_NET_WM_STATE_STICKY", FALSE); - maxvert_atom = gdk_atom_intern ("_NET_WM_STATE_MAXIMIZED_VERT", FALSE); - maxhorz_atom = gdk_atom_intern ("_NET_WM_STATE_MAXIMIZED_HORZ", FALSE); + sticky_atom = gdk_x11_get_xatom_by_name ("_NET_WM_STATE_STICKY"); + maxvert_atom = gdk_x11_get_xatom_by_name ("_NET_WM_STATE_MAXIMIZED_VERT"); + maxhorz_atom = gdk_x11_get_xatom_by_name ("_NET_WM_STATE_MAXIMIZED_HORZ"); found_sticky = FALSE; found_maxvert = FALSE; @@ -1373,15 +1373,12 @@ gdk_event_translate (GdkEvent *event, case PropertyNotify: GDK_NOTE (EVENTS, - gchar *atom = gdk_atom_name (xevent->xproperty.atom); g_message ("property notify:\twindow: %ld, atom(%ld): %s%s%s", xevent->xproperty.window, xevent->xproperty.atom, - atom ? "\"" : "", - atom ? atom : "unknown", - atom ? "\"" : ""); - g_free (atom); - ); + "\"", + gdk_x11_get_xatom_name (xevent->xproperty.atom), + "\"")); if (window_private == NULL) { @@ -1391,18 +1388,18 @@ gdk_event_translate (GdkEvent *event, event->property.type = GDK_PROPERTY_NOTIFY; event->property.window = window; - event->property.atom = xevent->xproperty.atom; + event->property.atom = gdk_x11_xatom_to_atom (xevent->xproperty.atom); event->property.time = xevent->xproperty.time; event->property.state = xevent->xproperty.state; if (wm_state_atom == 0) - wm_state_atom = gdk_atom_intern ("_NET_WM_STATE", FALSE); + wm_state_atom = gdk_x11_get_xatom_by_name ("_NET_WM_STATE"); if (wm_desktop_atom == 0) - wm_desktop_atom = gdk_atom_intern ("_NET_WM_DESKTOP", FALSE); + wm_desktop_atom = gdk_x11_get_xatom_by_name ("_NET_WM_DESKTOP"); - if (event->property.atom == wm_state_atom || - event->property.atom == wm_desktop_atom) + if (xevent->xproperty.atom == wm_state_atom || + xevent->xproperty.atom == wm_desktop_atom) { /* If window state changed, then synthesize those events. */ gdk_check_wm_state_changed (event->property.window); @@ -1419,7 +1416,7 @@ gdk_event_translate (GdkEvent *event, { event->selection.type = GDK_SELECTION_CLEAR; event->selection.window = window; - event->selection.selection = xevent->xselectionclear.selection; + event->selection.selection = gdk_x11_xatom_to_atom (xevent->xselectionclear.selection); event->selection.time = xevent->xselectionclear.time; } else @@ -1434,9 +1431,9 @@ gdk_event_translate (GdkEvent *event, event->selection.type = GDK_SELECTION_REQUEST; event->selection.window = window; - event->selection.selection = xevent->xselectionrequest.selection; - event->selection.target = xevent->xselectionrequest.target; - event->selection.property = xevent->xselectionrequest.property; + event->selection.selection = gdk_x11_xatom_to_atom (xevent->xselectionrequest.selection); + event->selection.target = gdk_x11_xatom_to_atom (xevent->xselectionrequest.target); + event->selection.property = gdk_x11_xatom_to_atom (xevent->xselectionrequest.property); event->selection.requestor = xevent->xselectionrequest.requestor; event->selection.time = xevent->xselectionrequest.time; @@ -1450,9 +1447,9 @@ gdk_event_translate (GdkEvent *event, event->selection.type = GDK_SELECTION_NOTIFY; event->selection.window = window; - event->selection.selection = xevent->xselection.selection; - event->selection.target = xevent->xselection.target; - event->selection.property = xevent->xselection.property; + event->selection.selection = gdk_x11_xatom_to_atom (xevent->xselection.selection); + event->selection.target = gdk_x11_xatom_to_atom (xevent->xselection.target); + event->selection.property = gdk_x11_xatom_to_atom (xevent->xselection.property); event->selection.time = xevent->xselection.time; break; @@ -1470,6 +1467,7 @@ gdk_event_translate (GdkEvent *event, { GList *tmp_list; GdkFilterReturn result = GDK_FILTER_CONTINUE; + GdkAtom message_type = gdk_x11_xatom_to_atom (xevent->xclient.message_type); GDK_NOTE (EVENTS, g_message ("client message:\twindow: %ld", @@ -1479,7 +1477,7 @@ gdk_event_translate (GdkEvent *event, while (tmp_list) { GdkClientFilter *filter = tmp_list->data; - if (filter->type == xevent->xclient.message_type) + if (filter->type == message_type) { result = (*filter->function) (xevent, event, filter->data); break; @@ -1506,7 +1504,7 @@ gdk_event_translate (GdkEvent *event, { event->client.type = GDK_CLIENT_EVENT; event->client.window = window; - event->client.message_type = xevent->xclient.message_type; + event->client.message_type = message_type; event->client.data_format = xevent->xclient.format; memcpy(&event->client.data, &xevent->xclient.data, sizeof(event->client.data)); @@ -1592,7 +1590,7 @@ gdk_wm_protocols_filter (GdkXEvent *xev, { XEvent *xevent = (XEvent *)xev; - if ((Atom) xevent->xclient.data.l[0] == gdk_atom_intern ("WM_DELETE_WINDOW", FALSE)) + if ((Atom) xevent->xclient.data.l[0] == gdk_x11_get_xatom_by_name ("WM_DELETE_WINDOW")) { /* The delete window request specifies a window * to delete. We don't actually destroy the @@ -1610,7 +1608,7 @@ gdk_wm_protocols_filter (GdkXEvent *xev, return GDK_FILTER_TRANSLATE; } - else if ((Atom) xevent->xclient.data.l[0] == gdk_atom_intern ("WM_TAKE_FOCUS", FALSE)) + else if ((Atom) xevent->xclient.data.l[0] == gdk_x11_get_xatom_by_name ("WM_TAKE_FOCUS")) { GdkWindow *win = event->any.window; Window focus_win = GDK_WINDOW_IMPL_X11(((GdkWindowObject *)win)->impl)->focus_window; @@ -1626,7 +1624,7 @@ gdk_wm_protocols_filter (GdkXEvent *xev, XSync (GDK_WINDOW_XDISPLAY (win), False); gdk_error_trap_pop (); } - else if ((Atom) xevent->xclient.data.l[0] == gdk_atom_intern ("_NET_WM_PING", FALSE)) + else if ((Atom) xevent->xclient.data.l[0] == gdk_x11_get_xatom_by_name ("_NET_WM_PING")) { XEvent xev = *xevent; @@ -1774,7 +1772,7 @@ gdk_event_send_client_message (GdkEvent *event, guint32 xid) sev.xclient.format = event->client.data_format; sev.xclient.window = xid; memcpy(&sev.xclient.data, &event->client.data, sizeof(sev.xclient.data)); - sev.xclient.message_type = event->client.message_type; + sev.xclient.message_type = gdk_x11_atom_to_xatom (event->client.message_type); return gdk_send_xevent (xid, False, NoEventMask, &sev); } @@ -1785,7 +1783,7 @@ gdk_event_send_client_message_to_all_recurse (XEvent *xev, guint32 xid, guint level) { - static GdkAtom wm_state_atom = GDK_NONE; + static Atom wm_state_atom = None; Atom type = None; int format; unsigned long nitems, after; @@ -1798,7 +1796,7 @@ gdk_event_send_client_message_to_all_recurse (XEvent *xev, int i; if (!wm_state_atom) - wm_state_atom = gdk_atom_intern ("WM_STATE", FALSE); + wm_state_atom = gdk_x11_get_xatom_by_name ("WM_STATE"); _gdk_error_warnings = FALSE; _gdk_error_code = 0; @@ -1860,7 +1858,7 @@ gdk_event_send_clientmessage_toall (GdkEvent *event) sev.xclient.display = gdk_display; sev.xclient.format = event->client.data_format; memcpy(&sev.xclient.data, &event->client.data, sizeof(sev.xclient.data)); - sev.xclient.message_type = event->client.message_type; + sev.xclient.message_type = gdk_x11_atom_to_xatom (event->client.message_type); gdk_event_send_client_message_to_all_recurse(&sev, _gdk_root_window, 0); @@ -1891,7 +1889,7 @@ gdk_flush (void) XSync (gdk_display, False); } -static GdkAtom timestamp_prop_atom = 0; +static Atom timestamp_prop_atom = 0; static Bool timestamp_predicate (Display *display, @@ -1930,7 +1928,7 @@ gdk_x11_get_server_time (GdkWindow *window) g_return_val_if_fail (!GDK_WINDOW_DESTROYED (window), 0); if (!timestamp_prop_atom) - timestamp_prop_atom = gdk_atom_intern ("GDK_TIMESTAMP_PROP", FALSE); + timestamp_prop_atom = gdk_x11_get_xatom_by_name ("GDK_TIMESTAMP_PROP"); xdisplay = GDK_WINDOW_XDISPLAY (window); xwindow = GDK_WINDOW_XWINDOW (window); @@ -1967,10 +1965,11 @@ gdk_x11_get_server_time (GdkWindow *window) gboolean gdk_net_wm_supports (GdkAtom property) { - static GdkAtom wmspec_check_atom = 0; - static GdkAtom wmspec_supported_atom = 0; - static GdkAtom *atoms = NULL; + static Atom wmspec_check_atom = 0; + static Atom wmspec_supported_atom = 0; + static Atom *atoms = NULL; static gulong n_atoms = 0; + Atom xproperty = gdk_x11_atom_to_xatom (property); Atom type; gint format; gulong nitems; @@ -1986,7 +1985,7 @@ gdk_net_wm_supports (GdkAtom property) i = 0; while (i < n_atoms) { - if (atoms[i] == property) + if (atoms[i] == xproperty) return TRUE; ++i; @@ -2010,10 +2009,10 @@ gdk_net_wm_supports (GdkAtom property) */ if (wmspec_check_atom == 0) - wmspec_check_atom = gdk_atom_intern ("_NET_SUPPORTING_WM_CHECK", FALSE); + wmspec_check_atom = gdk_x11_get_xatom_by_name ("_NET_SUPPORTING_WM_CHECK"); if (wmspec_supported_atom == 0) - wmspec_supported_atom = gdk_atom_intern ("_NET_SUPPORTED", FALSE); + wmspec_supported_atom = gdk_x11_get_xatom_by_name ("_NET_SUPPORTED"); XGetWindowProperty (gdk_display, _gdk_root_window, wmspec_check_atom, 0, G_MAXLONG, diff --git a/gdk/x11/gdkglobals-x11.c b/gdk/x11/gdkglobals-x11.c index ffa30896c3..2efdaca07d 100644 --- a/gdk/x11/gdkglobals-x11.c +++ b/gdk/x11/gdkglobals-x11.c @@ -37,7 +37,7 @@ gint _gdk_screen; Window _gdk_root_window; Window _gdk_leader_window; Atom _gdk_wm_window_protocols[3]; -Atom _gdk_selection_property; +GdkAtom _gdk_selection_property; GdkWindowObject *_gdk_xgrab_window = NULL; /* Window that currently holds the * x pointer grab diff --git a/gdk/x11/gdkkeys-x11.c b/gdk/x11/gdkkeys-x11.c index 25fdd4a684..27524b09d6 100644 --- a/gdk/x11/gdkkeys-x11.c +++ b/gdk/x11/gdkkeys-x11.c @@ -215,14 +215,13 @@ get_direction (void) result = PANGO_DIRECTION_LTR; else { - name = gdk_atom_name (xkb->names->groups[state_rec.locked_group]); + name = gdk_x11_get_xatom_name (xkb->names->groups[state_rec.locked_group]); if (g_strcasecmp (name, "arabic") == 0 || g_strcasecmp (name, "hebrew") == 0 || g_strcasecmp (name, "israelian") == 0) result = PANGO_DIRECTION_RTL; else result = PANGO_DIRECTION_LTR; - g_free (name); } return result; diff --git a/gdk/x11/gdkmain-x11.c b/gdk/x11/gdkmain-x11.c index e0c2ed61bf..bc526a33e8 100644 --- a/gdk/x11/gdkmain-x11.c +++ b/gdk/x11/gdkmain-x11.c @@ -144,7 +144,7 @@ _gdk_windowing_init_check (int argc, char **argv) pid = getpid(); XChangeProperty (gdk_display, _gdk_leader_window, - gdk_atom_intern ("_NET_WM_PID", FALSE), + gdk_x11_get_xatom_by_name ("_NET_WM_PID"), XA_CARDINAL, 32, PropModeReplace, (guchar *)&pid, 1); @@ -552,13 +552,13 @@ gdk_set_sm_client_id (const gchar* sm_client_id) if (sm_client_id && strcmp (sm_client_id, "")) { XChangeProperty (gdk_display, _gdk_leader_window, - gdk_atom_intern ("SM_CLIENT_ID", FALSE), + gdk_x11_get_xatom_by_name ("SM_CLIENT_ID"), XA_STRING, 8, PropModeReplace, sm_client_id, strlen(sm_client_id)); } else XDeleteProperty (gdk_display, _gdk_leader_window, - gdk_atom_intern ("SM_CLIENT_ID", FALSE)); + gdk_x11_get_xatom_by_name ("SM_CLIENT_ID")); } void diff --git a/gdk/x11/gdkprivate-x11.h b/gdk/x11/gdkprivate-x11.h index b22b0a3fdd..8b960974fb 100644 --- a/gdk/x11/gdkprivate-x11.h +++ b/gdk/x11/gdkprivate-x11.h @@ -159,7 +159,7 @@ extern Atom _gdk_wm_window_protocols[]; extern const int _gdk_nenvent_masks; extern const int _gdk_event_mask_table[]; extern gint _gdk_screen; -extern Atom _gdk_selection_property; +extern GdkAtom _gdk_selection_property; extern gchar *_gdk_display_name; extern Window _gdk_leader_window; diff --git a/gdk/x11/gdkproperty-x11.c b/gdk/x11/gdkproperty-x11.c index 08c055dd29..c242b6bea2 100644 --- a/gdk/x11/gdkproperty-x11.c +++ b/gdk/x11/gdkproperty-x11.c @@ -28,67 +28,285 @@ #include <X11/Xatom.h> #include <string.h> +#include "gdk.h" /* For gdk_error_trap_push/pop() */ #include "gdkx.h" #include "gdkproperty.h" #include "gdkprivate.h" -GdkAtom -gdk_atom_intern (const gchar *atom_name, - gboolean only_if_exists) +static GPtrArray *virtual_atom_array; +static GHashTable *virtual_atom_hash; +static GHashTable *atom_to_virtual; +static GHashTable *atom_from_virtual; + +static gchar *XAtomsStrings[] = { + /* These are all the standard predefined X atoms */ + "NONE", + "PRIMARY", + "SECONDARY", + "ARC", + "ATOM", + "BITMAP", + "CARDINAL", + "COLORMAP", + "CURSOR", + "CUT_BUFFER0", + "CUT_BUFFER1", + "CUT_BUFFER2", + "CUT_BUFFER3", + "CUT_BUFFER4", + "CUT_BUFFER5", + "CUT_BUFFER6", + "CUT_BUFFER7", + "DRAWABLE", + "FONT", + "INTEGER", + "PIXMAP", + "POINT", + "RECTANGLE", + "RESOURCE_MANAGER", + "RGB_COLOR_MAP", + "RGB_BEST_MAP", + "RGB_BLUE_MAP", + "RGB_DEFAULT_MAP", + "RGB_GRAY_MAP", + "RGB_GREEN_MAP", + "RGB_RED_MAP", + "STRING", + "VISUALID", + "WINDOW", + "WM_COMMAND", + "WM_HINTS", + "WM_CLIENT_MACHINE", + "WM_ICON_NAME", + "WM_ICON_SIZE", + "WM_NAME", + "WM_NORMAL_HINTS", + "WM_SIZE_HINTS", + "WM_ZOOM_HINTS", + "MIN_SPACE", + "NORM_SPACE", + "MAX_SPACE", "END_SPACE", + "SUPERSCRIPT_X", + "SUPERSCRIPT_Y", + "SUBSCRIPT_X", + "SUBSCRIPT_Y", + "UNDERLINE_POSITION", + "UNDERLINE_THICKNESS", + "STRIKEOUT_ASCENT", + "STRIKEOUT_DESCENT", + "ITALIC_ANGLE", + "X_HEIGHT", + "QUAD_WIDTH", + "WEIGHT", + "POINT_SIZE", + "RESOLUTION", + "COPYRIGHT", + "NOTICE", + "FONT_NAME", + "FAMILY_NAME", + "FULL_NAME", + "CAP_HEIGHT", + "WM_CLASS", + "WM_TRANSIENT_FOR", + /* Below here, these our our additions. Increment N_CUSTOM_PREDEFINED + * if you add any. + */ + "CLIPBOARD" /* = 69 */ +}; + +#define N_CUSTOM_PREDEFINED 1 + +#define ATOM_TO_INDEX(atom) (GPOINTER_TO_UINT(atom)) +#define INDEX_TO_ATOM(atom) ((GdkAtom)GUINT_TO_POINTER(atom)) + +void +insert_atom_pair (GdkAtom virtual_atom, + Atom xatom) { - GdkAtom retval; - static GHashTable *atom_hash = NULL; + if (!atom_from_virtual) + { + atom_from_virtual = g_hash_table_new (g_direct_hash, NULL); + atom_to_virtual = g_hash_table_new (g_direct_hash, NULL); + } - g_return_val_if_fail (atom_name != NULL, GDK_NONE); - - if (!atom_hash) - atom_hash = g_hash_table_new (g_str_hash, g_str_equal); + g_hash_table_insert (atom_from_virtual, + GDK_ATOM_TO_POINTER (virtual_atom), GUINT_TO_POINTER (xatom)); + g_hash_table_insert (atom_to_virtual, + GUINT_TO_POINTER (xatom), GDK_ATOM_TO_POINTER (virtual_atom)); +} - retval = GPOINTER_TO_UINT (g_hash_table_lookup (atom_hash, atom_name)); - if (!retval) +/** + * gdk_x11_atom_to_xatom: + * @atom: A #GdkAtom + * + * Convert from a #GdkAtom to the X atom for the default GDK display + * with the same string value.x + * + * Return value: the X atom corresponding to @atom. + **/ +Atom +gdk_x11_atom_to_xatom (GdkAtom atom) +{ + Atom xatom = None; + + if (ATOM_TO_INDEX (atom) < G_N_ELEMENTS (XAtomsStrings) - N_CUSTOM_PREDEFINED) + return ATOM_TO_INDEX (atom); + + if (atom_from_virtual) + xatom = GPOINTER_TO_UINT (g_hash_table_lookup (atom_from_virtual, + GDK_ATOM_TO_POINTER (atom))); + if (!xatom) { - retval = XInternAtom (gdk_display, atom_name, only_if_exists); + char *name; + + g_return_val_if_fail (ATOM_TO_INDEX (atom) < virtual_atom_array->len, None); - if (retval != None) - g_hash_table_insert (atom_hash, - g_strdup (atom_name), - GUINT_TO_POINTER (retval)); + name = g_ptr_array_index (virtual_atom_array, ATOM_TO_INDEX (atom)); + + xatom = XInternAtom (gdk_display, name, FALSE); + insert_atom_pair (atom, xatom); } - return retval; + return xatom; } -gchar* -gdk_atom_name (GdkAtom atom) +/** + * gdk_x11_xatom_to_atom: + * @xatom: an X atom for the default GDK display + * + * Convert from an X atom for the default display to the corresponding + * #GdkAtom. + * + * Return value: the corresponding G#dkAtom. + **/ +GdkAtom +gdk_x11_xatom_to_atom (Atom xatom) { - gchar *t; - gchar *name; - gint old_error_warnings; - - /* If this atom doesn't exist, we'll die with an X error unless - we take precautions */ + GdkAtom virtual_atom = GDK_NONE; + + if (xatom < G_N_ELEMENTS (XAtomsStrings) - N_CUSTOM_PREDEFINED) + return INDEX_TO_ATOM (xatom); + + if (atom_to_virtual) + virtual_atom = GDK_POINTER_TO_ATOM (g_hash_table_lookup (atom_to_virtual, + GUINT_TO_POINTER (xatom))); + + if (!virtual_atom) + { + /* If this atom doesn't exist, we'll die with an X error unless + * we take precautions + */ + char *name; + gdk_error_trap_push (); + name = XGetAtomName (gdk_display, xatom); + if (gdk_error_trap_pop ()) + { + g_warning (G_STRLOC " invalid X atom: %ld", xatom); + } + else + { + virtual_atom = gdk_atom_intern (name, FALSE); + XFree (name); + + insert_atom_pair (virtual_atom, xatom); + } + } - old_error_warnings = _gdk_error_warnings; - _gdk_error_warnings = 0; - _gdk_error_code = 0; - t = XGetAtomName (gdk_display, atom); - _gdk_error_warnings = old_error_warnings; + return virtual_atom; +} - if (_gdk_error_code) +static void +virtual_atom_check_init (void) +{ + if (!virtual_atom_hash) { - if (t) - XFree (t); - - return NULL; + gint i; + + virtual_atom_hash = g_hash_table_new (g_str_hash, g_str_equal); + virtual_atom_array = g_ptr_array_new (); + + for (i = 0; i < G_N_ELEMENTS (XAtomsStrings); i++) + { + g_ptr_array_add (virtual_atom_array, XAtomsStrings[i]); + g_hash_table_insert (virtual_atom_hash, XAtomsStrings[i], + GUINT_TO_POINTER (i)); + } } - else +} + +GdkAtom +gdk_atom_intern (const gchar *atom_name, + gboolean only_if_exists) +{ + GdkAtom result; + + virtual_atom_check_init (); + + result = GDK_POINTER_TO_ATOM (g_hash_table_lookup (virtual_atom_hash, atom_name)); + if (!result) { - name = g_strdup (t); - if (t) - XFree (t); + result = INDEX_TO_ATOM (virtual_atom_array->len); - return name; + g_ptr_array_add (virtual_atom_array, g_strdup (atom_name)); + g_hash_table_insert (virtual_atom_hash, + g_ptr_array_index (virtual_atom_array, + ATOM_TO_INDEX (result)), + GDK_ATOM_TO_POINTER (result)); } + + return result; +} + +static G_CONST_RETURN char * +get_atom_name (GdkAtom atom) +{ + virtual_atom_check_init (); + + if (ATOM_TO_INDEX (atom) < virtual_atom_array->len) + return g_strdup (g_ptr_array_index (virtual_atom_array, ATOM_TO_INDEX (atom))); + else + return NULL; +} + +gchar * +gdk_atom_name (GdkAtom atom) +{ + return g_strdup (get_atom_name (atom)); +} + +/** + * gdk_x11_get_xatom_by_name: + * @atom_name: a string + * + * Returns the X atom for GDK's default display corresponding to @atom_name. + * This function caches the result, so if called repeatedly it is much + * faster than XInternAtom, which is a round trip to the server each time. + * + * Return value: a X atom for GDK's default display. + **/ +Atom +gdk_x11_get_xatom_by_name (const gchar *atom_name) +{ + return gdk_x11_atom_to_xatom (gdk_atom_intern (atom_name, FALSE)); +} + +/** + * gdk_x11_get_xatom_name: + * @xatom: an X atom for GDK's default display + * + * Returns the name of an X atom for GDK's default display. This + * function is meant mainly for debugging, so for convenience, unlike + * XAtomName() and gdk_atom_name(), the result doesn't need to + * be freed. Also, this function will never return %NULL, even + * if @xatom is invalid. + * + * Return value: name of the X atom; this string is owned by GTK+, + * so it shouldn't be modifed or freed. + **/ +G_CONST_RETURN gchar * +gdk_x11_get_xatom_name (Atom xatom) +{ + return get_atom_name (gdk_x11_xatom_to_atom (xatom)); } gboolean @@ -105,6 +323,8 @@ gdk_property_get (GdkWindow *window, { Display *xdisplay; Window xwindow; + Atom xproperty; + Atom xtype; Atom ret_prop_type; gint ret_format; gulong ret_nitems; @@ -114,6 +334,9 @@ gdk_property_get (GdkWindow *window, g_return_val_if_fail (!window || GDK_IS_WINDOW (window), FALSE); + xproperty = gdk_x11_atom_to_xatom (property); + xtype = gdk_x11_atom_to_xatom (type); + if (window) { if (GDK_WINDOW_DESTROYED (window)) @@ -129,9 +352,9 @@ gdk_property_get (GdkWindow *window, } ret_data = NULL; - XGetWindowProperty (xdisplay, xwindow, property, + XGetWindowProperty (xdisplay, xwindow, xproperty, offset, (length + 3) / 4, pdelete, - type, &ret_prop_type, &ret_format, + xtype, &ret_prop_type, &ret_format, &ret_nitems, &ret_bytes_after, &ret_data); @@ -140,19 +363,17 @@ gdk_property_get (GdkWindow *window, } if (actual_property_type) - *actual_property_type = ret_prop_type; + *actual_property_type = gdk_x11_xatom_to_atom (ret_prop_type); if (actual_format_type) *actual_format_type = ret_format; - if ((type != AnyPropertyType) && (ret_prop_type != type)) + if ((type != AnyPropertyType) && (ret_prop_type != xtype)) { - gchar *rn, *pn; - XFree (ret_data); - rn = gdk_atom_name(ret_prop_type); - pn = gdk_atom_name(type); - g_warning("Couldn't match property type %s to %s\n", rn, pn); - g_free(rn); g_free(pn); + + g_warning("Couldn't match property type %s to %s\n", + gdk_x11_get_xatom_name (ret_prop_type), + gdk_x11_get_xatom_name (xtype)); return FALSE; } @@ -199,9 +420,14 @@ gdk_property_change (GdkWindow *window, { Display *xdisplay; Window xwindow; + Atom xproperty; + Atom xtype; g_return_if_fail (!window || GDK_IS_WINDOW (window)); + xproperty = gdk_x11_atom_to_xatom (property); + xtype = gdk_x11_atom_to_xatom (type); + if (window) { if (GDK_WINDOW_DESTROYED (window)) @@ -216,7 +442,7 @@ gdk_property_change (GdkWindow *window, xwindow = _gdk_root_window; } - XChangeProperty (xdisplay, xwindow, property, type, + XChangeProperty (xdisplay, xwindow, xproperty, xtype, format, mode, (guchar *)data, nelements); } @@ -243,5 +469,5 @@ gdk_property_delete (GdkWindow *window, xwindow = _gdk_root_window; } - XDeleteProperty (xdisplay, xwindow, property); + XDeleteProperty (xdisplay, xwindow, gdk_x11_atom_to_xatom (property)); } diff --git a/gdk/x11/gdkselection-x11.c b/gdk/x11/gdkselection-x11.c index eae9020133..e48d1f36a2 100644 --- a/gdk/x11/gdkselection-x11.c +++ b/gdk/x11/gdkselection-x11.c @@ -77,7 +77,7 @@ _gdk_selection_filter_clear_event (XSelectionClearEvent *event) while (tmp_list) { OwnerInfo *info = tmp_list->data; - if (info->selection == event->selection) + if (info->selection == gdk_x11_xatom_to_atom (event->selection)) { if ((GDK_DRAWABLE_XID (info->owner) == event->window && event->serial >= info->serial)) @@ -103,9 +103,12 @@ gdk_selection_owner_set (GdkWindow *owner, { Display *xdisplay; Window xwindow; + Atom xselection; GSList *tmp_list; OwnerInfo *info; + xselection = gdk_x11_atom_to_xatom (selection); + if (owner) { if (GDK_WINDOW_DESTROYED (owner)) @@ -143,9 +146,9 @@ gdk_selection_owner_set (GdkWindow *owner, owner_list = g_slist_prepend (owner_list, info); } - XSetSelectionOwner (xdisplay, selection, xwindow, time); + XSetSelectionOwner (xdisplay, xselection, xwindow, time); - return (XGetSelectionOwner (xdisplay, selection) == xwindow); + return (XGetSelectionOwner (xdisplay, xselection) == xwindow); } GdkWindow* @@ -153,7 +156,7 @@ gdk_selection_owner_get (GdkAtom selection) { Window xwindow; - xwindow = XGetSelectionOwner (gdk_display, selection); + xwindow = XGetSelectionOwner (gdk_display, gdk_x11_atom_to_xatom (selection)); if (xwindow == None) return NULL; @@ -169,8 +172,11 @@ gdk_selection_convert (GdkWindow *requestor, if (GDK_WINDOW_DESTROYED (requestor)) return; - XConvertSelection (GDK_WINDOW_XDISPLAY (requestor), selection, target, - _gdk_selection_property, GDK_WINDOW_XID (requestor), time); + XConvertSelection (GDK_WINDOW_XDISPLAY (requestor), + gdk_x11_atom_to_xatom (selection), + gdk_x11_atom_to_xatom (target), + gdk_x11_atom_to_xatom (_gdk_selection_property), + GDK_WINDOW_XID (requestor), time); } gint @@ -182,7 +188,7 @@ gdk_selection_property_get (GdkWindow *requestor, gulong nitems; gulong nbytes; gulong length; - GdkAtom prop_type; + Atom prop_type; gint prop_format; guchar *t = NULL; @@ -199,12 +205,13 @@ gdk_selection_property_get (GdkWindow *requestor, t = NULL; XGetWindowProperty (GDK_WINDOW_XDISPLAY (requestor), GDK_WINDOW_XID (requestor), - _gdk_selection_property, 0, 0, False, + gdk_x11_atom_to_xatom (_gdk_selection_property), + 0, 0, False, AnyPropertyType, &prop_type, &prop_format, &nitems, &nbytes, &t); if (ret_type) - *ret_type = prop_type; + *ret_type = gdk_x11_xatom_to_atom (prop_type); if (ret_format) *ret_format = prop_format; @@ -230,14 +237,30 @@ gdk_selection_property_get (GdkWindow *requestor, Otherwise there's no guarantee we'll win the race ... */ XGetWindowProperty (GDK_DRAWABLE_XDISPLAY (requestor), GDK_DRAWABLE_XID (requestor), - _gdk_selection_property, 0, (nbytes + 3) / 4, False, + gdk_x11_atom_to_xatom (_gdk_selection_property), + 0, (nbytes + 3) / 4, False, AnyPropertyType, &prop_type, &prop_format, &nitems, &nbytes, &t); if (prop_type != None) { *data = g_new (guchar, length); - memcpy (*data, t, length); + + if (prop_type == XA_ATOM) + { + Atom* atoms = (Atom*) t; + GdkAtom* atoms_dest = (GdkAtom*) *data; + gint num_atom, i; + + num_atom = (length - 1) / sizeof (GdkAtom); + for (i=0; i < num_atom; i++) + atoms_dest[i] = gdk_x11_xatom_to_atom (atoms[i]); + } + else + { + memcpy (*data, t, length); + } + if (t) XFree (t); return length-1; @@ -264,9 +287,9 @@ gdk_selection_send_notify (guint32 requestor, xevent.send_event = True; xevent.display = gdk_display; xevent.requestor = requestor; - xevent.selection = selection; - xevent.target = target; - xevent.property = property; + xevent.selection = gdk_x11_atom_to_xatom (selection); + xevent.target = gdk_x11_atom_to_xatom (target); + xevent.property = gdk_x11_atom_to_xatom (property); xevent.time = time; gdk_send_xevent (requestor, False, NoEventMask, (XEvent*) &xevent); @@ -287,7 +310,7 @@ gdk_text_property_to_text_list (GdkAtom encoding, return 0; property.value = (guchar *)text; - property.encoding = encoding; + property.encoding = gdk_x11_atom_to_xatom (encoding); property.format = format; property.nitems = length; res = XmbTextPropertyToTextList (GDK_DISPLAY(), &property, list, &count); @@ -489,7 +512,7 @@ gdk_string_to_compound_text (const gchar *str, } if (encoding) - *encoding = property.encoding; + *encoding = gdk_x11_xatom_to_atom (property.encoding); if (format) *format = property.format; if (ctext) diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index 5ac6d7b60f..be79501995 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -298,7 +298,7 @@ _gdk_windowing_window_init (void) gdk_xid_table_insert (&_gdk_root_window, _gdk_parent_root); } -static GdkAtom wm_client_leader_atom = GDK_NONE; +static Atom wm_client_leader_atom = None; /** * gdk_window_new: @@ -590,14 +590,14 @@ gdk_window_new (GdkWindow *parent, XSetWMHints (xdisplay, xid, &wm_hints); if (!wm_client_leader_atom) - wm_client_leader_atom = gdk_atom_intern ("WM_CLIENT_LEADER", FALSE); + wm_client_leader_atom = gdk_x11_get_xatom_by_name ("WM_CLIENT_LEADER"); /* This will set WM_CLIENT_MACHINE and WM_LOCALE_NAME */ XSetWMProperties (xdisplay, xid, NULL, NULL, NULL, 0, NULL, NULL, NULL); pid = getpid (); XChangeProperty (xdisplay, xid, - gdk_atom_intern ("_NET_WM_PID", FALSE), + gdk_x11_get_xatom_by_name ("_NET_WM_PID"), XA_CARDINAL, 32, PropModeReplace, (guchar *)&pid, 1); @@ -754,9 +754,9 @@ _gdk_windowing_window_destroy (GdkWindow *window, xevent.type = ClientMessage; xevent.window = GDK_WINDOW_XID (window); - xevent.message_type = gdk_atom_intern ("WM_PROTOCOLS", FALSE); + xevent.message_type = gdk_x11_get_xatom_by_name ("WM_PROTOCOLS"); xevent.format = 32; - xevent.data.l[0] = gdk_atom_intern ("WM_DELETE_WINDOW", FALSE); + xevent.data.l[0] = gdk_x11_get_xatom_by_name ("WM_DELETE_WINDOW"); xevent.data.l[1] = CurrentTime; XSendEvent (GDK_WINDOW_XDISPLAY (window), @@ -800,7 +800,7 @@ static void set_initial_hints (GdkWindow *window) { GdkWindowObject *private; - GdkAtom atoms[5]; + Atom atoms[5]; gint i; private = (GdkWindowObject*) window; @@ -831,21 +831,21 @@ set_initial_hints (GdkWindow *window) if (private->state & GDK_WINDOW_STATE_MAXIMIZED) { - atoms[i] = gdk_atom_intern ("_NET_WM_STATE_MAXIMIZED_VERT", FALSE); + atoms[i] = gdk_x11_get_xatom_by_name ("_NET_WM_STATE_MAXIMIZED_VERT"); ++i; - atoms[i] = gdk_atom_intern ("_NET_WM_STATE_MAXIMIZED_HORZ", FALSE); + atoms[i] = gdk_x11_get_xatom_by_name ("_NET_WM_STATE_MAXIMIZED_HORZ"); ++i; } if (private->state & GDK_WINDOW_STATE_STICKY) { - atoms[i] = gdk_atom_intern ("_NET_WM_STATE_STICKY", FALSE); + atoms[i] = gdk_x11_get_xatom_by_name ("_NET_WM_STATE_STICKY"); ++i; } if (private->modal_hint) { - atoms[i] = gdk_atom_intern ("_NET_WM_STATE_MODAL", FALSE); + atoms[i] = gdk_x11_get_xatom_by_name ("_NET_WM_STATE_MODAL"); ++i; } @@ -853,7 +853,7 @@ set_initial_hints (GdkWindow *window) { XChangeProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window), - gdk_atom_intern ("_NET_WM_STATE", FALSE), + gdk_x11_get_xatom_by_name ("_NET_WM_STATE"), XA_ATOM, 32, PropModeReplace, (guchar*) atoms, i); } @@ -863,7 +863,7 @@ set_initial_hints (GdkWindow *window) atoms[0] = 0xFFFFFFFF; XChangeProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window), - gdk_atom_intern ("_NET_WM_DESKTOP", FALSE), + gdk_x11_get_xatom_by_name ("_NET_WM_DESKTOP"), XA_CARDINAL, 32, PropModeReplace, (guchar*) atoms, 1); } @@ -1359,7 +1359,7 @@ gdk_window_focus (GdkWindow *window, xev.xclient.send_event = True; xev.xclient.window = GDK_WINDOW_XWINDOW (window); xev.xclient.display = gdk_display; - xev.xclient.message_type = gdk_atom_intern ("_NET_ACTIVE_WINDOW", FALSE); + xev.xclient.message_type = gdk_x11_get_xatom_by_name ("_NET_ACTIVE_WINDOW"); xev.xclient.format = 32; xev.xclient.data.l[0] = 0; @@ -1468,7 +1468,7 @@ void gdk_window_set_type_hint (GdkWindow *window, GdkWindowTypeHint hint) { - GdkAtom atom; + Atom atom; g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); @@ -1479,35 +1479,35 @@ gdk_window_set_type_hint (GdkWindow *window, switch (hint) { case GDK_WINDOW_TYPE_HINT_DIALOG: - atom = gdk_atom_intern ("_NET_WM_WINDOW_TYPE_DIALOG", FALSE); + atom = gdk_x11_get_xatom_by_name ("_NET_WM_WINDOW_TYPE_DIALOG"); break; case GDK_WINDOW_TYPE_HINT_MENU: - atom = gdk_atom_intern ("_NET_WM_WINDOW_TYPE_MENU", FALSE); + atom = gdk_x11_get_xatom_by_name ("_NET_WM_WINDOW_TYPE_MENU"); break; case GDK_WINDOW_TYPE_HINT_TOOLBAR: - atom = gdk_atom_intern ("_NET_WM_WINDOW_TYPE_TOOLBAR", FALSE); + atom = gdk_x11_get_xatom_by_name ("_NET_WM_WINDOW_TYPE_TOOLBAR"); break; default: g_warning ("Unknown hint %d passed to gdk_window_set_type_hint", hint); /* Fall thru */ case GDK_WINDOW_TYPE_HINT_NORMAL: - atom = gdk_atom_intern ("_NET_WM_WINDOW_TYPE_NORMAL", FALSE); + atom = gdk_x11_get_xatom_by_name ("_NET_WM_WINDOW_TYPE_NORMAL"); break; } XChangeProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window), - gdk_atom_intern ("_NET_WM_WINDOW_TYPE", FALSE), + gdk_x11_get_xatom_by_name ("_NET_WM_WINDOW_TYPE"), XA_ATOM, 32, PropModeReplace, (guchar *)&atom, 1); } static void -gdk_wmspec_change_state (gboolean add, +gdk_wmspec_change_state (gboolean add, GdkWindow *window, - GdkAtom state1, - GdkAtom state2) + GdkAtom state1, + GdkAtom state2) { XEvent xev; @@ -1520,11 +1520,11 @@ gdk_wmspec_change_state (gboolean add, xev.xclient.send_event = True; xev.xclient.display = gdk_display; xev.xclient.window = GDK_WINDOW_XID (window); - xev.xclient.message_type = gdk_atom_intern ("_NET_WM_STATE", FALSE); + xev.xclient.message_type = gdk_x11_get_xatom_by_name ("_NET_WM_STATE"); xev.xclient.format = 32; xev.xclient.data.l[0] = add ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE; - xev.xclient.data.l[1] = state1; - xev.xclient.data.l[2] = state2; + xev.xclient.data.l[1] = gdk_x11_atom_to_xatom (state1); + xev.xclient.data.l[2] = gdk_x11_atom_to_xatom (state2); XSendEvent (gdk_display, _gdk_root_window, False, SubstructureRedirectMask | SubstructureNotifyMask, @@ -1761,25 +1761,28 @@ utf8_is_latin1 (const gchar *str) */ static void set_text_property (GdkWindow *window, - GdkAtom property, + Atom property, const gchar *utf8_str) { guchar *prop_text = NULL; - GdkAtom prop_type; + Atom prop_type; gint prop_length; gint prop_format; if (utf8_is_latin1 (utf8_str)) { - prop_type = GDK_TARGET_STRING; + prop_type = XA_STRING; prop_text = gdk_utf8_to_string_target (utf8_str); prop_length = strlen (prop_text); prop_format = 8; } else { - gdk_utf8_to_compound_text (utf8_str, &prop_type, &prop_format, + GdkAtom gdk_type; + + gdk_utf8_to_compound_text (utf8_str, &gdk_type, &prop_format, &prop_text, &prop_length); + prop_type = gdk_x11_atom_to_xatom (gdk_type); } if (prop_text) @@ -1820,21 +1823,21 @@ gdk_window_set_title (GdkWindow *window, XChangeProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window), - gdk_atom_intern ("_NET_WM_NAME", FALSE), - gdk_atom_intern ("UTF8_STRING", FALSE), 8, + gdk_x11_get_xatom_by_name ("_NET_WM_NAME"), + gdk_x11_get_xatom_by_name ("UTF8_STRING"), 8, PropModeReplace, title, strlen (title)); - set_text_property (window, gdk_atom_intern ("WM_NAME", FALSE), title); + set_text_property (window, gdk_x11_get_xatom_by_name ("WM_NAME"), title); if (!gdk_window_icon_name_set (window)) { XChangeProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window), - gdk_atom_intern ("_NET_WM_ICON_NAME", FALSE), - gdk_atom_intern ("UTF8_STRING", FALSE), 8, + gdk_x11_get_xatom_by_name ("_NET_WM_ICON_NAME"), + gdk_x11_get_xatom_by_name ("UTF8_STRING"), 8, PropModeReplace, title, strlen (title)); - set_text_property (window, gdk_atom_intern ("WM_ICON_NAME", FALSE), title); + set_text_property (window, gdk_x11_get_xatom_by_name ("WM_ICON_NAME"), title); } } @@ -1868,11 +1871,11 @@ gdk_window_set_role (GdkWindow *window, { if (role) XChangeProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window), - gdk_atom_intern ("WM_WINDOW_ROLE", FALSE), XA_STRING, + gdk_x11_get_xatom_by_name ("WM_WINDOW_ROLE"), XA_STRING, 8, PropModeReplace, role, strlen (role)); else XDeleteProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window), - gdk_atom_intern ("WM_WINDOW_ROLE", FALSE)); + gdk_x11_get_xatom_by_name ("WM_WINDOW_ROLE")); } } @@ -2196,7 +2199,7 @@ gdk_window_get_deskrelative_origin (GdkWindow *window, if (!GDK_WINDOW_DESTROYED (window)) { if (!atom) - atom = gdk_atom_intern ("ENLIGHTENMENT_DESKTOP", FALSE); + atom = gdk_x11_get_xatom_by_name ("ENLIGHTENMENT_DESKTOP"); win = GDK_WINDOW_XID (window); while (XQueryTree (GDK_WINDOW_XDISPLAY (window), win, &root, &parent, @@ -2828,7 +2831,7 @@ gdk_window_set_icon_list (GdkWindow *window, { XChangeProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window), - gdk_atom_intern ("_NET_WM_ICON", FALSE), + gdk_x11_get_xatom_by_name ("_NET_WM_ICON"), XA_CARDINAL, 32, PropModeReplace, (guchar*) data, size); @@ -2837,7 +2840,7 @@ gdk_window_set_icon_list (GdkWindow *window, { XDeleteProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window), - gdk_atom_intern ("_NET_WM_ICON", FALSE)); + gdk_x11_get_xatom_by_name ("_NET_WM_ICON")); } } @@ -2930,11 +2933,11 @@ gdk_window_set_icon_name (GdkWindow *window, XChangeProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window), - gdk_atom_intern ("_NET_WM_ICON_NAME", FALSE), - gdk_atom_intern ("UTF8_STRING", FALSE), 8, + gdk_x11_get_xatom_by_name ("_NET_WM_ICON_NAME"), + gdk_x11_get_xatom_by_name ("UTF8_STRING"), 8, PropModeReplace, name, strlen (name)); - set_text_property (window, gdk_atom_intern ("WM_ICON_NAME", FALSE), name); + set_text_property (window, gdk_x11_get_xatom_by_name ("WM_ICON_NAME"), name); } /** @@ -3058,7 +3061,7 @@ gdk_window_stick (GdkWindow *window) xev.xclient.send_event = True; xev.xclient.window = GDK_WINDOW_XWINDOW (window); xev.xclient.display = gdk_display; - xev.xclient.message_type = gdk_atom_intern ("_NET_WM_DESKTOP", FALSE); + xev.xclient.message_type = gdk_x11_get_xatom_by_name ("_NET_WM_DESKTOP"); xev.xclient.format = 32; xev.xclient.data.l[0] = 0xFFFFFFFF; @@ -3110,7 +3113,7 @@ gdk_window_unstick (GdkWindow *window) * one that matters much in practice. */ XGetWindowProperty (gdk_display, _gdk_root_window, - gdk_atom_intern ("_NET_CURRENT_DESKTOP", FALSE), + gdk_x11_get_xatom_by_name ("_NET_CURRENT_DESKTOP"), 0, G_MAXLONG, False, XA_CARDINAL, &type, &format, &nitems, &bytes_after, (guchar **)¤t_desktop); @@ -3122,7 +3125,7 @@ gdk_window_unstick (GdkWindow *window) xev.xclient.send_event = True; xev.xclient.window = GDK_WINDOW_XWINDOW (window); xev.xclient.display = gdk_display; - xev.xclient.message_type = gdk_atom_intern ("_NET_WM_DESKTOP", FALSE); + xev.xclient.message_type = gdk_x11_get_xatom_by_name ("_NET_WM_DESKTOP"); xev.xclient.format = 32; xev.xclient.data.l[0] = *current_desktop; @@ -4077,7 +4080,7 @@ wmspec_moveresize (GdkWindow *window, xev.xclient.send_event = True; xev.xclient.display = gdk_display; xev.xclient.window = GDK_WINDOW_XID (window); - xev.xclient.message_type = gdk_atom_intern ("_NET_WM_MOVERESIZE", FALSE); + xev.xclient.message_type = gdk_x11_get_xatom_by_name ("_NET_WM_MOVERESIZE"); xev.xclient.format = 32; xev.xclient.data.l[0] = root_x; xev.xclient.data.l[1] = root_y; diff --git a/gdk/x11/gdkx.h b/gdk/x11/gdkx.h index 9e68a85e00..f38d2118f8 100644 --- a/gdk/x11/gdkx.h +++ b/gdk/x11/gdkx.h @@ -112,6 +112,11 @@ void gdk_x11_ungrab_server (void); /* returns TRUE if we support the given WM spec feature */ gboolean gdk_net_wm_supports (GdkAtom property); +Atom gdk_x11_atom_to_xatom (GdkAtom atom); +GdkAtom gdk_x11_xatom_to_atom (Atom xatom); +Atom gdk_x11_get_xatom_by_name (const gchar *atom_name); +G_CONST_RETURN gchar *gdk_x11_get_xatom_name (Atom xatom); + #ifndef GDK_DISABLE_DEPRECATED Display * gdk_x11_font_get_xdisplay (GdkFont *font); diff --git a/gtk/gtkclist.c b/gtk/gtkclist.c index f83a02b5e0..4d35839036 100644 --- a/gtk/gtkclist.c +++ b/gtk/gtkclist.c @@ -7450,7 +7450,7 @@ gtk_clist_drag_leave (GtkWidget *widget, list = context->targets; while (list) { - if (atom == GPOINTER_TO_INT (list->data)) + if (atom == GDK_POINTER_TO_ATOM (list->data)) { GTK_CLIST_GET_CLASS (clist)->draw_drag_highlight (clist, @@ -7505,7 +7505,7 @@ gtk_clist_drag_motion (GtkWidget *widget, list = context->targets; while (list) { - if (atom == GPOINTER_TO_INT (list->data)) + if (atom == GDK_POINTER_TO_ATOM (list->data)) break; list = list->next; } @@ -7581,7 +7581,7 @@ gtk_clist_drag_drop (GtkWidget *widget, list = context->targets; while (list) { - if (atom == GPOINTER_TO_INT (list->data)) + if (atom == GDK_POINTER_TO_ATOM (list->data)) return TRUE; list = list->next; } diff --git a/gtk/gtkctree.c b/gtk/gtkctree.c index 1fac2ce5cb..f5615edb73 100644 --- a/gtk/gtkctree.c +++ b/gtk/gtkctree.c @@ -5988,7 +5988,7 @@ gtk_ctree_drag_motion (GtkWidget *widget, list = context->targets; while (list) { - if (atom == GPOINTER_TO_INT (list->data)) + if (atom == GDK_POINTER_TO_ATOM (list->data)) break; list = list->next; } diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c index 78210ecf10..bebb9b49af 100644 --- a/gtk/gtkdnd.c +++ b/gtk/gtkdnd.c @@ -1353,7 +1353,7 @@ gtk_drag_proxy_begin (GtkWidget *widget, while (tmp_list) { gtk_target_list_add (source_info->target_list, - GPOINTER_TO_UINT (tmp_list->data), 0, 0); + GDK_POINTER_TO_ATOM (tmp_list->data), 0, 0); tmp_list = tmp_list->next; } @@ -2446,7 +2446,7 @@ gtk_drag_source_check_selection (GtkDragSourceInfo *info, tmp_list = info->selections; while (tmp_list) { - if (GPOINTER_TO_UINT (tmp_list->data) == selection) + if (GDK_POINTER_TO_ATOM (tmp_list->data) == selection) return; tmp_list = tmp_list->next; } @@ -2546,7 +2546,7 @@ gtk_drag_source_release_selections (GtkDragSourceInfo *info, GList *tmp_list = info->selections; while (tmp_list) { - GdkAtom selection = GPOINTER_TO_UINT (tmp_list->data); + GdkAtom selection = GDK_POINTER_TO_ATOM (tmp_list->data); if (gdk_selection_owner_get (selection) == info->ipc_widget->window) gtk_selection_owner_set (NULL, selection, time); tmp_list = tmp_list->next; diff --git a/gtk/gtkplug.c b/gtk/gtkplug.c index 9004e39c96..ed9ef18123 100644 --- a/gtk/gtkplug.c +++ b/gtk/gtkplug.c @@ -850,7 +850,7 @@ send_xembed_message (GtkPlug *plug, xevent.xclient.window = GDK_WINDOW_XWINDOW (plug->socket_window); xevent.xclient.type = ClientMessage; - xevent.xclient.message_type = gdk_atom_intern ("_XEMBED", FALSE); + xevent.xclient.message_type = gdk_x11_get_xatom_by_name ("_XEMBED"); xevent.xclient.format = 32; xevent.xclient.data.l[0] = time; xevent.xclient.data.l[1] = message; @@ -918,7 +918,7 @@ xembed_set_info (GdkWindow *gdk_window, Window window = GDK_WINDOW_XWINDOW (gdk_window); unsigned long buffer[2]; - Atom xembed_info_atom = gdk_atom_intern ("_XEMBED_INFO", FALSE); + Atom xembed_info_atom = gdk_x11_get_xatom_by_name ("_XEMBED_INFO"); buffer[1] = 0; /* Protocol version */ buffer[1] = flags; @@ -1015,7 +1015,7 @@ gtk_plug_filter_func (GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data) switch (xevent->type) { case ClientMessage: - if (xevent->xclient.message_type == gdk_atom_intern ("_XEMBED", FALSE)) + if (xevent->xclient.message_type == gdk_x11_get_xatom_by_name ("_XEMBED")) { handle_xembed_message (plug, xevent->xclient.data.l[1], @@ -1027,7 +1027,7 @@ gtk_plug_filter_func (GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data) return GDK_FILTER_REMOVE; } - else if (xevent->xclient.message_type == gdk_atom_intern ("WM_DELETE_WINDOW", FALSE)) + else if (xevent->xclient.message_type == gdk_x11_get_xatom_by_name ("WM_DELETE_WINDOW")) { /* We filter these out because we take being reparented back to the * root window as the reliable end of the embedding protocol diff --git a/gtk/gtksocket.c b/gtk/gtksocket.c index 205aed7144..0b6661c03d 100644 --- a/gtk/gtksocket.c +++ b/gtk/gtksocket.c @@ -1077,7 +1077,7 @@ send_xembed_message (GtkSocket *socket, xevent.xclient.window = GDK_WINDOW_XWINDOW (socket->plug_window); xevent.xclient.type = ClientMessage; - xevent.xclient.message_type = gdk_atom_intern ("_XEMBED", FALSE); + xevent.xclient.message_type = gdk_x11_get_xatom_by_name ("_XEMBED"); xevent.xclient.format = 32; xevent.xclient.data.l[0] = time; xevent.xclient.data.l[1] = message; @@ -1101,7 +1101,7 @@ xembed_get_info (GdkWindow *gdk_window, { Display *display = GDK_WINDOW_XDISPLAY (gdk_window); Window window = GDK_WINDOW_XWINDOW (gdk_window); - Atom xembed_info_atom = gdk_atom_intern ("_XEMBED_INFO", FALSE); + Atom xembed_info_atom = gdk_x11_get_xatom_by_name ("_XEMBED_INFO"); Atom type; int format; unsigned long nitems, bytes_after; @@ -1244,7 +1244,7 @@ gtk_socket_filter_func (GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data) switch (xevent->type) { case ClientMessage: - if (xevent->xclient.message_type == gdk_atom_intern ("_XEMBED", FALSE)) + if (xevent->xclient.message_type == gdk_x11_get_xatom_by_name ("_XEMBED")) { handle_xembed_message (socket, xevent->xclient.data.l[1], @@ -1394,8 +1394,8 @@ gtk_socket_filter_func (GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data) { GdkDragProtocol protocol; - if ((xevent->xproperty.atom == gdk_atom_intern ("XdndAware", FALSE)) || - (xevent->xproperty.atom == gdk_atom_intern ("_MOTIF_DRAG_RECEIVER_INFO", FALSE))) + if ((xevent->xproperty.atom == gdk_x11_get_xatom_by_name ("XdndAware")) || + (xevent->xproperty.atom == gdk_x11_get_xatom_by_name ("_MOTIF_DRAG_RECEIVER_INFO"))) { gdk_error_trap_push (); if (gdk_drag_get_protocol (xevent->xproperty.window, &protocol)) @@ -1405,7 +1405,7 @@ gtk_socket_filter_func (GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data) gdk_flush (); gdk_error_trap_pop (); } - else if (xevent->xproperty.atom == gdk_atom_intern ("_XEMBED_INFO", FALSE)) + else if (xevent->xproperty.atom == gdk_x11_get_xatom_by_name ("_XEMBED_INFO")) { unsigned long flags; diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 78082201b8..267657299a 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -2405,8 +2405,8 @@ gtk_widget_translate_coordinates (GtkWidget *src_widget, GtkWidget *ancestor; GdkWindow *window; - g_return_if_fail (GTK_IS_WIDGET (src_widget)); - g_return_if_fail (GTK_IS_WIDGET (dest_widget)); + g_return_val_if_fail (GTK_IS_WIDGET (src_widget), FALSE); + g_return_val_if_fail (GTK_IS_WIDGET (dest_widget), FALSE); ancestor = gtk_widget_common_ancestor (src_widget, dest_widget); if (!ancestor || !GTK_WIDGET_REALIZED (src_widget) || !GTK_WIDGET_REALIZED (dest_widget)) diff --git a/tests/testdnd.c b/tests/testdnd.c index be36c4e9d5..cbc1bfb58e 100644 --- a/tests/testdnd.c +++ b/tests/testdnd.c @@ -320,7 +320,7 @@ target_drag_motion (GtkWidget *widget, tmp_list = context->targets; while (tmp_list) { - char *name = gdk_atom_name (GPOINTER_TO_UINT (tmp_list->data)); + char *name = gdk_atom_name (GDK_POINTER_TO_ATOM (tmp_list->data)); g_print ("%s\n", name); g_free (name); @@ -346,7 +346,7 @@ target_drag_drop (GtkWidget *widget, if (context->targets) { gtk_drag_get_data (widget, context, - GPOINTER_TO_INT (context->targets->data), + GDK_POINTER_TO_ATOM (context->targets->data), time); return TRUE; } diff --git a/tests/testselection.c b/tests/testselection.c index 73345435b9..1731fe57c0 100644 --- a/tests/testselection.c +++ b/tests/testselection.c @@ -289,9 +289,8 @@ selection_received (GtkWidget *widget, GtkSelectionData *data) if (seltype == SEL_TYPE_NONE) { char *name = gdk_atom_name (data->type); - g_print("Don't know how to handle type: %s (%ld)\n", - name?name:"<unknown>", - data->type); + g_print("Don't know how to handle type: %s\n", + name?name:"<unknown>"); return; } @@ -335,9 +334,8 @@ selection_received (GtkWidget *widget, GtkSelectionData *data) default: { char *name = gdk_atom_name (data->type); - g_print("Can't convert type %s (%ld) to string\n", - name?name:"<unknown>", - data->type); + g_print("Can't convert type %s to string\n", + name?name:"<unknown>"); position = data->length; continue; } |