Fix problem with g_return_if_fail return value.

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.
This commit is contained in:
Owen Taylor 2001-10-22 04:34:42 +00:00 committed by Owen Taylor
parent 724a552c7d
commit 46dde80428
29 changed files with 905 additions and 344 deletions

View File

@ -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> Mon Oct 22 00:26:46 2001 Kristian Rietveld <kristian@planet.nl>
* gtk/gtkspinbutton.c: remove ARROW_SIZE constant, use * gtk/gtkspinbutton.c: remove ARROW_SIZE constant, use

View File

@ -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> Mon Oct 22 00:26:46 2001 Kristian Rietveld <kristian@planet.nl>
* gtk/gtkspinbutton.c: remove ARROW_SIZE constant, use * gtk/gtkspinbutton.c: remove ARROW_SIZE constant, use

View File

@ -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> Mon Oct 22 00:26:46 2001 Kristian Rietveld <kristian@planet.nl>
* gtk/gtkspinbutton.c: remove ARROW_SIZE constant, use * gtk/gtkspinbutton.c: remove ARROW_SIZE constant, use

View File

@ -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> Mon Oct 22 00:26:46 2001 Kristian Rietveld <kristian@planet.nl>
* gtk/gtkspinbutton.c: remove ARROW_SIZE constant, use * gtk/gtkspinbutton.c: remove ARROW_SIZE constant, use

View File

@ -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> Mon Oct 22 00:26:46 2001 Kristian Rietveld <kristian@planet.nl>
* gtk/gtkspinbutton.c: remove ARROW_SIZE constant, use * gtk/gtkspinbutton.c: remove ARROW_SIZE constant, use

View File

@ -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> Mon Oct 22 00:26:46 2001 Kristian Rietveld <kristian@planet.nl>
* gtk/gtkspinbutton.c: remove ARROW_SIZE constant, use * gtk/gtkspinbutton.c: remove ARROW_SIZE constant, use

View File

@ -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> Mon Oct 22 00:26:46 2001 Kristian Rietveld <kristian@planet.nl>
* gtk/gtkspinbutton.c: remove ARROW_SIZE constant, use * gtk/gtkspinbutton.c: remove ARROW_SIZE constant, use

View File

@ -7,35 +7,33 @@
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
/* The next three types define enums for predefined atoms relating /* Predefined atoms relating to selections. In general, one will need to use
to selections. In general, one will need to use gdk_intern_atom */ * 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)
typedef enum #ifndef GDK_DISABLE_DEPRECATED
{
GDK_SELECTION_PRIMARY = 1,
GDK_SELECTION_SECONDARY = 2
} GdkSelection;
typedef enum typedef GdkAtom GdkSelection;
{ typedef GdkAtom GdkTarget;
GDK_TARGET_BITMAP = 5, typedef GdkAtom GdkSelectionType;
GDK_TARGET_COLORMAP = 7,
GDK_TARGET_DRAWABLE = 17,
GDK_TARGET_PIXMAP = 20,
GDK_TARGET_STRING = 31
} GdkTarget;
typedef enum #endif /* GDK_DISABLE_DEPRECATED */
{
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;
/* Selections /* Selections
*/ */

View File

@ -51,7 +51,6 @@
#include <gdkconfig.h> #include <gdkconfig.h>
/* some common magic values */ /* some common magic values */
#define GDK_NONE 0L
#define GDK_CURRENT_TIME 0L #define GDK_CURRENT_TIME 0L
#define GDK_PARENT_RELATIVE 1L #define GDK_PARENT_RELATIVE 1L
@ -76,7 +75,14 @@ typedef struct _GdkSpan GdkSpan;
* on Win32, wchar_t is unsigned short. * on Win32, wchar_t is unsigned short.
*/ */
typedef guint32 GdkWChar; 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 #ifdef GDK_NATIVE_WINDOW_POINTER
typedef gpointer GdkNativeWindow; typedef gpointer GdkNativeWindow;

View File

@ -38,13 +38,58 @@ gdk_atom_intern (const gchar *atom_name,
{ {
g_return_val_if_fail (atom_name != NULL, GDK_NONE); 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* gchar*
gdk_atom_name (GdkAtom atom) 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 static void

View File

@ -41,17 +41,20 @@ gdk_atom_intern (const gchar *atom_name,
{ {
GdkAtom retval; GdkAtom retval;
static GHashTable *atom_hash = NULL; static GHashTable *atom_hash = NULL;
ATOM win32_atom;
if (!atom_hash) if (!atom_hash)
atom_hash = g_hash_table_new (g_str_hash, g_str_equal); 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 (!retval)
{ {
if (strcmp (atom_name, "PRIMARY") == 0) if (strcmp (atom_name, "PRIMARY") == 0)
retval = GDK_SELECTION_PRIMARY; retval = GDK_SELECTION_PRIMARY;
else if (strcmp (atom_name, "SECONDARY") == 0) else if (strcmp (atom_name, "SECONDARY") == 0)
retval = GDK_SELECTION_SECONDARY; retval = GDK_SELECTION_SECONDARY;
else if (strcmp (atom_name, "CLIPBOARD") == 0)
retval = GDK_SELECTION_CLIPBOARD;
else if (strcmp (atom_name, "ATOM") == 0) else if (strcmp (atom_name, "ATOM") == 0)
retval = GDK_SELECTION_TYPE_ATOM; retval = GDK_SELECTION_TYPE_ATOM;
else if (strcmp (atom_name, "BITMAP") == 0) else if (strcmp (atom_name, "BITMAP") == 0)
@ -70,15 +73,16 @@ gdk_atom_intern (const gchar *atom_name,
retval = GDK_SELECTION_TYPE_STRING; retval = GDK_SELECTION_TYPE_STRING;
else else
{ {
retval = GlobalFindAtom (atom_name); win32_atom = GlobalFindAtom (atom_name);
if (only_if_exists && retval == 0) if (only_if_exists && retval == 0)
retval = 0; win32_atom = 0;
else else
retval = GlobalAddAtom (atom_name); win32_atom = GlobalAddAtom (atom_name);
retval = GUINT_TO_POINTER (win32_atom);
} }
g_hash_table_insert (atom_hash, g_hash_table_insert (atom_hash,
g_strdup (atom_name), g_strdup (atom_name),
GUINT_TO_POINTER (retval)); retval);
} }
return retval; return retval;
@ -88,11 +92,13 @@ gchar *
gdk_atom_name (GdkAtom atom) gdk_atom_name (GdkAtom atom)
{ {
gchar name[256]; gchar name[256];
ATOM win32_atom;
switch (atom) switch (atom)
{ {
case GDK_SELECTION_PRIMARY: return g_strdup ("PRIMARY"); case GDK_SELECTION_PRIMARY: return g_strdup ("PRIMARY");
case GDK_SELECTION_SECONDARY: return g_strdup ("SECONDARY"); 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_ATOM: return g_strdup ("ATOM");
case GDK_SELECTION_TYPE_BITMAP: return g_strdup ("BITMAP"); case GDK_SELECTION_TYPE_BITMAP: return g_strdup ("BITMAP");
case GDK_SELECTION_TYPE_COLORMAP: return g_strdup ("COLORMAP"); 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_WINDOW: return g_strdup ("WINDOW");
case GDK_SELECTION_TYPE_STRING: return g_strdup ("STRING"); case GDK_SELECTION_TYPE_STRING: return g_strdup ("STRING");
} }
if (atom < 0xC000)
return g_strdup_printf ("#%x", (guint) atom); win32_atom = GPOINTER_TO_UINT (atom);
else if (GlobalGetAtomName (atom, name, sizeof (name)) == 0)
if (win32_atom < 0xC000)
return g_strdup_printf ("#%x", atom);
else if (GlobalGetAtomName (win32_atom, name, sizeof (name)) == 0)
return NULL; return NULL;
return g_strdup (name); return g_strdup (name);
} }

View File

@ -61,8 +61,8 @@ typedef struct {
struct _GdkDragContextPrivateX11 { struct _GdkDragContextPrivateX11 {
GdkDragContext context; GdkDragContext context;
GdkAtom motif_selection; Atom motif_selection;
GdkAtom xdnd_selection; Atom xdnd_selection;
guint ref_count; guint ref_count;
guint16 last_x; /* Coordinates from last event */ 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; static Atom wm_state_atom = None;
if (!wm_state_atom) 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, XGetWindowProperty (gdk_display, win,
wm_state_atom, 0, 0, False, AnyPropertyType, 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; static Atom wm_state_atom = None;
if (!wm_state_atom) 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, XGetWindowProperty (gdk_display, win,
wm_state_atom, 0, 0, False, AnyPropertyType, wm_state_atom, 0, 0, False, AnyPropertyType,
@ -768,7 +768,7 @@ print_target_list (GList *targets)
{ {
while (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_message ("\t%s", name);
g_free (name); g_free (name);
targets = targets->next; targets = targets->next;
@ -851,8 +851,8 @@ typedef struct _MotifDragReceiverInfo {
static Window motif_drag_window = None; static Window motif_drag_window = None;
static GdkWindow *motif_drag_gdk_window = NULL; static GdkWindow *motif_drag_gdk_window = NULL;
static GdkAtom motif_drag_targets_atom = GDK_NONE; static Atom motif_drag_targets_atom = None;
static GdkAtom motif_drag_receiver_info_atom = GDK_NONE; static Atom motif_drag_receiver_info_atom = None;
/* Target table handling */ /* Target table handling */
@ -879,14 +879,14 @@ motif_drag_window_filter (GdkXEvent *xevent,
return GDK_FILTER_REMOVE; return GDK_FILTER_REMOVE;
} }
static Atom motif_drag_window_atom = GDK_NONE; static Atom motif_drag_window_atom = None;
static Window static Window
motif_lookup_drag_window (Display *display) motif_lookup_drag_window (Display *display)
{ {
Window retval = None; Window retval = None;
gulong bytes_after, nitems; gulong bytes_after, nitems;
GdkAtom type; Atom type;
gint format; gint format;
guchar *data; guchar *data;
@ -917,7 +917,7 @@ motif_find_drag_window (gboolean create)
if (!motif_drag_window) if (!motif_drag_window)
{ {
if (!motif_drag_window_atom) 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); motif_drag_window = motif_lookup_drag_window (gdk_display);
@ -977,12 +977,12 @@ static void
motif_read_target_table (void) motif_read_target_table (void)
{ {
gulong bytes_after, nitems; gulong bytes_after, nitems;
GdkAtom type; Atom type;
gint format; gint format;
gint i, j; gint i, j;
if (!motif_drag_targets_atom) 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) if (motif_target_lists)
{ {
@ -1117,7 +1117,7 @@ motif_target_table_check (GList *sorted)
} }
static gint static gint
motif_add_to_target_table (GList *targets) motif_add_to_target_table (GList *targets) /* targets is list of GdkAtom */
{ {
GList *sorted = NULL; GList *sorted = NULL;
gint index = -1; gint index = -1;
@ -1128,7 +1128,8 @@ motif_add_to_target_table (GList *targets)
while (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; targets = targets->next;
} }
@ -1304,10 +1305,10 @@ motif_set_targets (GdkDragContext *context)
GdkDragContextPrivateX11 *private = PRIVATE_DATA (context); GdkDragContextPrivateX11 *private = PRIVATE_DATA (context);
MotifDragInitiatorInfo info; MotifDragInitiatorInfo info;
gint i; gint i;
static GdkAtom motif_drag_initiator_info = GDK_NONE; static Atom motif_drag_initiator_info = None;
if (!motif_drag_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");
info.byte_order = local_byte_order; info.byte_order = local_byte_order;
info.protocol_version = 0; info.protocol_version = 0;
@ -1319,7 +1320,7 @@ motif_set_targets (GdkDragContext *context)
gchar buf[20]; gchar buf[20];
g_snprintf(buf, 20, "_GDK_SELECTION_%d", i); 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)) if (!XGetSelectionOwner (gdk_display, private->motif_selection))
break; break;
} }
@ -1345,7 +1346,7 @@ motif_check_dest (Window win)
unsigned long nitems, after; unsigned long nitems, after;
if (!motif_drag_receiver_info_atom) 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 (); gdk_error_trap_push ();
XGetWindowProperty (gdk_display, win, XGetWindowProperty (gdk_display, win,
@ -1376,8 +1377,7 @@ motif_check_dest (Window win)
} }
} }
return retval ? win : GDK_NONE; return retval ? win : None;
} }
static void static void
@ -1388,7 +1388,7 @@ motif_send_enter (GdkDragContext *context,
GdkDragContextPrivateX11 *private = PRIVATE_DATA (context); GdkDragContextPrivateX11 *private = PRIVATE_DATA (context);
xev.xclient.type = ClientMessage; 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.format = 8;
xev.xclient.window = GDK_DRAWABLE_XID (context->dest_window); xev.xclient.window = GDK_DRAWABLE_XID (context->dest_window);
@ -1417,7 +1417,7 @@ motif_send_leave (GdkDragContext *context,
XEvent xev; XEvent xev;
xev.xclient.type = ClientMessage; 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.format = 8;
xev.xclient.window = GDK_DRAWABLE_XID (context->dest_window); xev.xclient.window = GDK_DRAWABLE_XID (context->dest_window);
@ -1447,7 +1447,7 @@ motif_send_motion (GdkDragContext *context,
GdkDragContextPrivateX11 *private = PRIVATE_DATA (context); GdkDragContextPrivateX11 *private = PRIVATE_DATA (context);
xev.xclient.type = ClientMessage; 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.format = 8;
xev.xclient.window = GDK_DRAWABLE_XID (context->dest_window); 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); GdkDragContextPrivateX11 *private = PRIVATE_DATA (context);
xev.xclient.type = ClientMessage; 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.format = 8;
xev.xclient.window = GDK_DRAWABLE_XID (context->dest_window); xev.xclient.window = GDK_DRAWABLE_XID (context->dest_window);
@ -1517,12 +1517,12 @@ motif_send_drop (GdkDragContext *context, guint32 time)
static gboolean static gboolean
motif_read_initiator_info (Window source_window, motif_read_initiator_info (Window source_window,
Atom atom, Atom atom,
GList **targets, GList **targets, /* GdkAtom */
GdkAtom *selection) Atom *selection)
{ {
GList *tmp_list; GList *tmp_list;
static GdkAtom motif_drag_initiator_info = GDK_NONE; static Atom motif_drag_initiator_info = None;
GdkAtom type; Atom type;
gint format; gint format;
gulong nitems; gulong nitems;
gulong bytes_after; gulong bytes_after;
@ -1530,7 +1530,7 @@ motif_read_initiator_info (Window source_window,
MotifDragInitiatorInfo *initiator_info; MotifDragInitiatorInfo *initiator_info;
if (!motif_drag_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 (); gdk_error_trap_push ();
XGetWindowProperty (gdk_display, source_window, atom, XGetWindowProperty (gdk_display, source_window, atom,
@ -1564,8 +1564,8 @@ motif_read_initiator_info (Window source_window,
*targets = NULL; *targets = NULL;
while (tmp_list) while (tmp_list)
{ {
*targets = g_list_prepend (*targets, GdkAtom atom = gdk_x11_xatom_to_atom (GPOINTER_TO_UINT (tmp_list->data));
tmp_list->data); *targets = g_list_prepend (*targets, GDK_ATOM_TO_POINTER (atom));
tmp_list = tmp_list->prev; tmp_list = tmp_list->prev;
} }
@ -1868,7 +1868,7 @@ motif_dnd_filter (GdkXEvent *xev,
guint16 flags; guint16 flags;
guint32 timestamp; guint32 timestamp;
guint32 source_window; guint32 source_window;
GdkAtom atom; Atom atom;
gint16 x_root, y_root; gint16 x_root, y_root;
gboolean is_reply; gboolean is_reply;
@ -1942,14 +1942,14 @@ motif_dnd_filter (GdkXEvent *xev,
static struct { static struct {
gchar *name; gchar *name;
GdkAtom atom; Atom atom;
GdkDragAction action; GdkDragAction action;
} xdnd_actions_table[] = { } xdnd_actions_table[] = {
{ "XdndActionCopy", GDK_NONE, GDK_ACTION_COPY }, { "XdndActionCopy", None, GDK_ACTION_COPY },
{ "XdndActionMove", GDK_NONE, GDK_ACTION_MOVE }, { "XdndActionMove", None, GDK_ACTION_MOVE },
{ "XdndActionLink", GDK_NONE, GDK_ACTION_LINK }, { "XdndActionLink", None, GDK_ACTION_LINK },
{ "XdndActionAsk", GDK_NONE, GDK_ACTION_ASK }, { "XdndActionAsk", None, GDK_ACTION_ASK },
{ "XdndActionPrivate", GDK_NONE, GDK_ACTION_COPY }, { "XdndActionPrivate", None, GDK_ACTION_COPY },
}; };
static const gint xdnd_n_actions = sizeof(xdnd_actions_table) / sizeof(xdnd_actions_table[0]); 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; xdnd_actions_initialized = TRUE;
for (i=0; i < xdnd_n_actions; i++) 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 static GdkDragAction
xdnd_action_from_atom (GdkAtom atom) xdnd_action_from_atom (Atom atom)
{ {
gint i; gint i;
@ -1980,7 +1980,7 @@ xdnd_action_from_atom (GdkAtom atom)
return 0; return 0;
} }
static GdkAtom static Atom
xdnd_action_to_atom (GdkDragAction action) xdnd_action_to_atom (GdkDragAction action)
{ {
gint i; gint i;
@ -1992,10 +1992,10 @@ xdnd_action_to_atom (GdkDragAction action)
if (action == xdnd_actions_table[i].action) if (action == xdnd_actions_table[i].action)
return xdnd_actions_table[i].atom; 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 */ /* Source side */
@ -2007,7 +2007,7 @@ xdnd_status_filter (GdkXEvent *xev,
XEvent *xevent = (XEvent *)xev; XEvent *xevent = (XEvent *)xev;
guint32 dest_window = xevent->xclient.data.l[0]; guint32 dest_window = xevent->xclient.data.l[0];
guint32 flags = xevent->xclient.data.l[1]; guint32 flags = xevent->xclient.data.l[1];
GdkAtom action = xevent->xclient.data.l[4]; Atom action = xevent->xclient.data.l[4];
GdkDragContext *context; GdkDragContext *context;
GDK_NOTE (DND, GDK_NOTE (DND,
@ -2072,23 +2072,23 @@ static void
xdnd_set_targets (GdkDragContext *context) xdnd_set_targets (GdkDragContext *context)
{ {
GdkDragContextPrivateX11 *private = PRIVATE_DATA (context); GdkDragContextPrivateX11 *private = PRIVATE_DATA (context);
GdkAtom *atomlist; Atom *atomlist;
GList *tmp_list = context->targets; GList *tmp_list = context->targets;
gint i; gint i;
gint n_atoms = g_list_length (context->targets); gint n_atoms = g_list_length (context->targets);
atomlist = g_new (GdkAtom, n_atoms); atomlist = g_new (Atom, n_atoms);
i = 0; i = 0;
while (tmp_list) 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; tmp_list = tmp_list->next;
i++; i++;
} }
XChangeProperty (GDK_DRAWABLE_XDISPLAY (context->source_window), XChangeProperty (GDK_DRAWABLE_XDISPLAY (context->source_window),
GDK_DRAWABLE_XID (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, XA_ATOM, 32, PropModeReplace,
(guchar *)atomlist, n_atoms); (guchar *)atomlist, n_atoms);
@ -2101,7 +2101,7 @@ static void
xdnd_set_actions (GdkDragContext *context) xdnd_set_actions (GdkDragContext *context)
{ {
GdkDragContextPrivateX11 *private = PRIVATE_DATA (context); GdkDragContextPrivateX11 *private = PRIVATE_DATA (context);
GdkAtom *atomlist; Atom *atomlist;
gint i; gint i;
gint n_atoms; gint n_atoms;
guint actions; 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; actions = context->actions;
n_atoms = 0; n_atoms = 0;
@ -2136,7 +2136,7 @@ xdnd_set_actions (GdkDragContext *context)
XChangeProperty (GDK_DRAWABLE_XDISPLAY (context->source_window), XChangeProperty (GDK_DRAWABLE_XDISPLAY (context->source_window),
GDK_DRAWABLE_XID (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, XA_ATOM, 32, PropModeReplace,
(guchar *)atomlist, n_atoms); (guchar *)atomlist, n_atoms);
@ -2173,7 +2173,7 @@ xdnd_send_enter (GdkDragContext *context)
GdkDragContextPrivateX11 *private = PRIVATE_DATA (context); GdkDragContextPrivateX11 *private = PRIVATE_DATA (context);
xev.xclient.type = ClientMessage; 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.format = 32;
xev.xclient.window = private->drop_xid ? xev.xclient.window = private->drop_xid ?
private->drop_xid : private->drop_xid :
@ -2185,7 +2185,7 @@ xdnd_send_enter (GdkDragContext *context)
xev.xclient.data.l[4] = 0; xev.xclient.data.l[4] = 0;
if (!private->xdnd_selection) 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) if (g_list_length (context->targets) > 3)
{ {
@ -2200,7 +2200,7 @@ xdnd_send_enter (GdkDragContext *context)
while (tmp_list) 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; tmp_list = tmp_list->next;
i++; i++;
} }
@ -2225,7 +2225,7 @@ xdnd_send_leave (GdkDragContext *context)
GdkDragContextPrivateX11 *private = PRIVATE_DATA (context); GdkDragContextPrivateX11 *private = PRIVATE_DATA (context);
xev.xclient.type = ClientMessage; 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.format = 32;
xev.xclient.window = private->drop_xid ? xev.xclient.window = private->drop_xid ?
private->drop_xid : private->drop_xid :
@ -2254,7 +2254,7 @@ xdnd_send_drop (GdkDragContext *context, guint32 time)
XEvent xev; XEvent xev;
xev.xclient.type = ClientMessage; 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.format = 32;
xev.xclient.window = private->drop_xid ? xev.xclient.window = private->drop_xid ?
private->drop_xid : private->drop_xid :
@ -2287,7 +2287,7 @@ xdnd_send_motion (GdkDragContext *context,
XEvent xev; XEvent xev;
xev.xclient.type = ClientMessage; 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.format = 32;
xev.xclient.window = private->drop_xid ? xev.xclient.window = private->drop_xid ?
private->drop_xid : private->drop_xid :
@ -2317,20 +2317,20 @@ xdnd_check_dest (Window win)
Atom type = None; Atom type = None;
int format; int format;
unsigned long nitems, after; unsigned long nitems, after;
GdkAtom *version; Atom *version;
Window *proxy_data; Window *proxy_data;
Window proxy; Window proxy;
static GdkAtom xdnd_proxy_atom = GDK_NONE; static Atom xdnd_proxy_atom = None;
gint old_warnings = _gdk_error_warnings; gint old_warnings = _gdk_error_warnings;
if (!xdnd_proxy_atom) 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) 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_code = 0;
_gdk_error_warnings = 0; _gdk_error_warnings = 0;
@ -2381,7 +2381,7 @@ xdnd_check_dest (Window win)
_gdk_error_warnings = old_warnings; _gdk_error_warnings = old_warnings;
_gdk_error_code = 0; _gdk_error_code = 0;
return retval ? (proxy ? proxy : win) : GDK_NONE; return retval ? (proxy ? proxy : win) : None;
} }
/* Target side */ /* Target side */
@ -2405,7 +2405,7 @@ xdnd_read_actions (GdkDragContext *context)
XGetWindowProperty (GDK_DRAWABLE_XDISPLAY (context->source_window), XGetWindowProperty (GDK_DRAWABLE_XDISPLAY (context->source_window),
GDK_DRAWABLE_XID (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, False, XA_ATOM, &type, &format, &nitems,
&after, (guchar **)&data); &after, (guchar **)&data);
@ -2458,7 +2458,7 @@ xdnd_source_window_filter (GdkXEvent *xev,
GdkDragContext *context = cb_data; GdkDragContext *context = cb_data;
if ((xevent->xany.type == PropertyNotify) && 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); xdnd_read_actions (context);
@ -2561,7 +2561,7 @@ xdnd_enter_filter (GdkXEvent *xev,
gdk_error_trap_push (); gdk_error_trap_push ();
XGetWindowProperty (GDK_DRAWABLE_XDISPLAY (event->any.window), XGetWindowProperty (GDK_DRAWABLE_XDISPLAY (event->any.window),
source_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, False, XA_ATOM, &type, &format, &nitems,
&after, (guchar **)&data); &after, (guchar **)&data);
@ -2573,7 +2573,7 @@ xdnd_enter_filter (GdkXEvent *xev,
for (i=0; i<nitems; i++) for (i=0; i<nitems; i++)
new_context->targets = g_list_append (new_context->targets, 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); XFree(data);
} }
@ -2582,7 +2582,7 @@ xdnd_enter_filter (GdkXEvent *xev,
for (i=0; i<3; i++) for (i=0; i<3; i++)
if (xevent->xclient.data.l[2+i]) if (xevent->xclient.data.l[2+i])
new_context->targets = g_list_append (new_context->targets, 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 #ifdef G_ENABLE_DEBUG
@ -2599,7 +2599,7 @@ xdnd_enter_filter (GdkXEvent *xev,
current_dest_drag = new_context; current_dest_drag = new_context;
(PRIVATE_DATA (new_context))->xdnd_selection = (PRIVATE_DATA (new_context))->xdnd_selection =
gdk_atom_intern ("XdndSelection", FALSE); gdk_x11_get_xatom_by_name ("XdndSelection");
return GDK_FILTER_TRANSLATE; return GDK_FILTER_TRANSLATE;
} }
@ -2642,7 +2642,7 @@ xdnd_position_filter (GdkXEvent *xev,
gint16 x_root = xevent->xclient.data.l[2] >> 16; gint16 x_root = xevent->xclient.data.l[2] >> 16;
gint16 y_root = xevent->xclient.data.l[2] & 0xffff; gint16 y_root = xevent->xclient.data.l[2] & 0xffff;
guint32 time = xevent->xclient.data.l[3]; guint32 time = xevent->xclient.data.l[3];
GdkAtom action = xevent->xclient.data.l[4]; Atom action = xevent->xclient.data.l[4];
GDK_NOTE (DND, GDK_NOTE (DND,
g_message ("XdndPosition: source_window: %#x position: (%d, %d) time: %d action: %ld", g_message ("XdndPosition: source_window: %#x position: (%d, %d) time: %d action: %ld",
@ -2772,7 +2772,6 @@ GdkDragContext *
gdk_drag_begin (GdkWindow *window, gdk_drag_begin (GdkWindow *window,
GList *targets) GList *targets)
{ {
GList *tmp_list;
GdkDragContext *new_context; GdkDragContext *new_context;
g_return_val_if_fail (window != NULL, NULL); g_return_val_if_fail (window != NULL, NULL);
@ -2782,15 +2781,7 @@ gdk_drag_begin (GdkWindow *window,
new_context->source_window = window; new_context->source_window = window;
gdk_window_ref (window); gdk_window_ref (window);
tmp_list = g_list_last (targets); new_context->targets = g_list_copy (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->actions = 0; new_context->actions = 0;
return new_context; return new_context;
@ -2835,7 +2826,7 @@ gdk_drag_get_protocol (guint32 xid,
_gdk_error_code = 0; _gdk_error_code = 0;
XGetWindowProperty (gdk_display, xid, XGetWindowProperty (gdk_display, xid,
gdk_atom_intern ("ENLIGHTENMENT_DESKTOP", FALSE), gdk_x11_get_xatom_by_name ("ENLIGHTENMENT_DESKTOP"),
0, 0, False, AnyPropertyType, 0, 0, False, AnyPropertyType,
&type, &format, &nitems, &after, &data); &type, &format, &nitems, &after, &data);
if ((_gdk_error_code == 0) && type != None) if ((_gdk_error_code == 0) && type != None)
@ -2855,7 +2846,7 @@ gdk_drag_get_protocol (guint32 xid,
_gdk_error_code = 0; _gdk_error_code = 0;
XGetWindowProperty (gdk_display, win, XGetWindowProperty (gdk_display, win,
gdk_atom_intern ("__SWM_VROOT", FALSE), gdk_x11_get_xatom_by_name ("__SWM_VROOT"),
0, 0, False, AnyPropertyType, 0, 0, False, AnyPropertyType,
&type, &format, &nitems, &data); &type, &format, &nitems, &data);
if ((_gdk_error_code == 0) && type != None) if ((_gdk_error_code == 0) && type != None)
@ -2873,7 +2864,7 @@ gdk_drag_get_protocol (guint32 xid,
} }
*protocol = GDK_DRAG_PROTO_NONE; *protocol = GDK_DRAG_PROTO_NONE;
return GDK_NONE; return None;
} }
void void
@ -2894,7 +2885,7 @@ gdk_drag_find_window (GdkDragContext *context,
dest = get_client_window_at_coords (private->window_cache, dest = get_client_window_at_coords (private->window_cache,
drag_window ? drag_window ?
GDK_DRAWABLE_XID (drag_window) : GDK_NONE, GDK_DRAWABLE_XID (drag_window) : None,
x_root, y_root); x_root, y_root);
if (private->dest_xid != dest) if (private->dest_xid != dest)
@ -3044,7 +3035,7 @@ gdk_drag_motion (GdkDragContext *context,
GdkEvent temp_event; GdkEvent temp_event;
if (g_list_find (context->targets, 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; context->action = context->suggested_action;
else else
context->action = 0; context->action = 0;
@ -3131,7 +3122,7 @@ gdk_drag_status (GdkDragContext *context,
if (context->protocol == GDK_DRAG_PROTO_MOTIF) if (context->protocol == GDK_DRAG_PROTO_MOTIF)
{ {
xev.xclient.type = ClientMessage; 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.format = 8;
xev.xclient.window = GDK_DRAWABLE_XID (context->source_window); 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) else if (context->protocol == GDK_DRAG_PROTO_XDND)
{ {
xev.xclient.type = ClientMessage; 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.format = 32;
xev.xclient.window = GDK_DRAWABLE_XID (context->source_window); xev.xclient.window = GDK_DRAWABLE_XID (context->source_window);
@ -3224,7 +3215,7 @@ gdk_drop_reply (GdkDragContext *context,
XEvent xev; XEvent xev;
xev.xclient.type = ClientMessage; 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.format = 8;
MOTIF_XCLIENT_BYTE (&xev, 0) = XmDROP_START | 0x80; MOTIF_XCLIENT_BYTE (&xev, 0) = XmDROP_START | 0x80;
@ -3259,7 +3250,7 @@ gdk_drop_finish (GdkDragContext *context,
XEvent xev; XEvent xev;
xev.xclient.type = ClientMessage; 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.format = 32;
xev.xclient.window = GDK_DRAWABLE_XID (context->source_window); 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 */ /* Set Motif drag receiver information property */
if (!motif_drag_receiver_info_atom) 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.byte_order = local_byte_order;
info.protocol_version = 0; info.protocol_version = 0;
info.protocol_style = XmDRAG_DYNAMIC; info.protocol_style = XmDRAG_DYNAMIC;
info.proxy_window = GDK_NONE; info.proxy_window = None;
info.num_drop_sites = 0; info.num_drop_sites = 0;
info.total_size = sizeof(info); info.total_size = sizeof(info);
@ -3313,7 +3304,7 @@ gdk_window_register_dnd (GdkWindow *window)
/* Set XdndAware */ /* Set XdndAware */
if (!xdnd_aware_atom) 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 */ /* The property needs to be of type XA_ATOM, not XA_INTEGER. Blech */
XChangeProperty (GDK_DRAWABLE_XDISPLAY (window), XChangeProperty (GDK_DRAWABLE_XDISPLAY (window),
@ -3337,9 +3328,9 @@ gdk_drag_get_selection (GdkDragContext *context)
g_return_val_if_fail (context != NULL, GDK_NONE); g_return_val_if_fail (context != NULL, GDK_NONE);
if (context->protocol == GDK_DRAG_PROTO_MOTIF) 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) 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 else
return GDK_NONE; return GDK_NONE;
} }

View File

@ -162,9 +162,9 @@ _gdk_events_init (void)
g_source_set_can_recurse (source, TRUE); g_source_set_can_recurse (source, TRUE);
g_source_attach (source, NULL); g_source_attach (source, NULL);
_gdk_wm_window_protocols[0] = gdk_atom_intern ("WM_DELETE_WINDOW", FALSE); _gdk_wm_window_protocols[0] = gdk_x11_get_xatom_by_name ("WM_DELETE_WINDOW");
_gdk_wm_window_protocols[1] = gdk_atom_intern ("WM_TAKE_FOCUS", FALSE); _gdk_wm_window_protocols[1] = gdk_x11_get_xatom_by_name ("WM_TAKE_FOCUS");
_gdk_wm_window_protocols[2] = gdk_atom_intern ("_NET_WM_PING", FALSE); _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_add_client_message_filter (gdk_atom_intern ("WM_PROTOCOLS", FALSE),
gdk_wm_protocols_filter, NULL); 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); client_filters = g_list_prepend (client_filters, filter);
} }
static GdkAtom wm_state_atom = 0; static Atom wm_state_atom = 0;
static GdkAtom wm_desktop_atom = 0; static Atom wm_desktop_atom = 0;
static void static void
gdk_check_wm_state_changed (GdkWindow *window) gdk_check_wm_state_changed (GdkWindow *window)
@ -296,11 +296,11 @@ gdk_check_wm_state_changed (GdkWindow *window)
gint format; gint format;
gulong nitems; gulong nitems;
gulong bytes_after; gulong bytes_after;
GdkAtom *atoms = NULL; Atom *atoms = NULL;
gulong i; gulong i;
GdkAtom sticky_atom; Atom sticky_atom;
GdkAtom maxvert_atom; Atom maxvert_atom;
GdkAtom maxhorz_atom; Atom maxhorz_atom;
gboolean found_sticky, found_maxvert, found_maxhorz; gboolean found_sticky, found_maxvert, found_maxhorz;
GdkWindowState old_state; GdkWindowState old_state;
@ -308,10 +308,10 @@ gdk_check_wm_state_changed (GdkWindow *window)
return; return;
if (wm_state_atom == 0) 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) 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), XGetWindowProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window),
wm_state_atom, 0, G_MAXLONG, wm_state_atom, 0, G_MAXLONG,
@ -321,9 +321,9 @@ gdk_check_wm_state_changed (GdkWindow *window)
if (type != None) if (type != None)
{ {
sticky_atom = gdk_atom_intern ("_NET_WM_STATE_STICKY", FALSE); sticky_atom = gdk_x11_get_xatom_by_name ("_NET_WM_STATE_STICKY");
maxvert_atom = gdk_atom_intern ("_NET_WM_STATE_MAXIMIZED_VERT", FALSE); maxvert_atom = gdk_x11_get_xatom_by_name ("_NET_WM_STATE_MAXIMIZED_VERT");
maxhorz_atom = gdk_atom_intern ("_NET_WM_STATE_MAXIMIZED_HORZ", FALSE); maxhorz_atom = gdk_x11_get_xatom_by_name ("_NET_WM_STATE_MAXIMIZED_HORZ");
found_sticky = FALSE; found_sticky = FALSE;
found_maxvert = FALSE; found_maxvert = FALSE;
@ -1373,15 +1373,12 @@ gdk_event_translate (GdkEvent *event,
case PropertyNotify: case PropertyNotify:
GDK_NOTE (EVENTS, GDK_NOTE (EVENTS,
gchar *atom = gdk_atom_name (xevent->xproperty.atom);
g_message ("property notify:\twindow: %ld, atom(%ld): %s%s%s", g_message ("property notify:\twindow: %ld, atom(%ld): %s%s%s",
xevent->xproperty.window, xevent->xproperty.window,
xevent->xproperty.atom, xevent->xproperty.atom,
atom ? "\"" : "", "\"",
atom ? atom : "unknown", gdk_x11_get_xatom_name (xevent->xproperty.atom),
atom ? "\"" : ""); "\""));
g_free (atom);
);
if (window_private == NULL) if (window_private == NULL)
{ {
@ -1391,18 +1388,18 @@ gdk_event_translate (GdkEvent *event,
event->property.type = GDK_PROPERTY_NOTIFY; event->property.type = GDK_PROPERTY_NOTIFY;
event->property.window = window; 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.time = xevent->xproperty.time;
event->property.state = xevent->xproperty.state; event->property.state = xevent->xproperty.state;
if (wm_state_atom == 0) 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) 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 || if (xevent->xproperty.atom == wm_state_atom ||
event->property.atom == wm_desktop_atom) xevent->xproperty.atom == wm_desktop_atom)
{ {
/* If window state changed, then synthesize those events. */ /* If window state changed, then synthesize those events. */
gdk_check_wm_state_changed (event->property.window); 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.type = GDK_SELECTION_CLEAR;
event->selection.window = window; 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; event->selection.time = xevent->xselectionclear.time;
} }
else else
@ -1434,9 +1431,9 @@ gdk_event_translate (GdkEvent *event,
event->selection.type = GDK_SELECTION_REQUEST; event->selection.type = GDK_SELECTION_REQUEST;
event->selection.window = window; event->selection.window = window;
event->selection.selection = xevent->xselectionrequest.selection; event->selection.selection = gdk_x11_xatom_to_atom (xevent->xselectionrequest.selection);
event->selection.target = xevent->xselectionrequest.target; event->selection.target = gdk_x11_xatom_to_atom (xevent->xselectionrequest.target);
event->selection.property = xevent->xselectionrequest.property; event->selection.property = gdk_x11_xatom_to_atom (xevent->xselectionrequest.property);
event->selection.requestor = xevent->xselectionrequest.requestor; event->selection.requestor = xevent->xselectionrequest.requestor;
event->selection.time = xevent->xselectionrequest.time; event->selection.time = xevent->xselectionrequest.time;
@ -1450,9 +1447,9 @@ gdk_event_translate (GdkEvent *event,
event->selection.type = GDK_SELECTION_NOTIFY; event->selection.type = GDK_SELECTION_NOTIFY;
event->selection.window = window; event->selection.window = window;
event->selection.selection = xevent->xselection.selection; event->selection.selection = gdk_x11_xatom_to_atom (xevent->xselection.selection);
event->selection.target = xevent->xselection.target; event->selection.target = gdk_x11_xatom_to_atom (xevent->xselection.target);
event->selection.property = xevent->xselection.property; event->selection.property = gdk_x11_xatom_to_atom (xevent->xselection.property);
event->selection.time = xevent->xselection.time; event->selection.time = xevent->xselection.time;
break; break;
@ -1470,6 +1467,7 @@ gdk_event_translate (GdkEvent *event,
{ {
GList *tmp_list; GList *tmp_list;
GdkFilterReturn result = GDK_FILTER_CONTINUE; GdkFilterReturn result = GDK_FILTER_CONTINUE;
GdkAtom message_type = gdk_x11_xatom_to_atom (xevent->xclient.message_type);
GDK_NOTE (EVENTS, GDK_NOTE (EVENTS,
g_message ("client message:\twindow: %ld", g_message ("client message:\twindow: %ld",
@ -1479,7 +1477,7 @@ gdk_event_translate (GdkEvent *event,
while (tmp_list) while (tmp_list)
{ {
GdkClientFilter *filter = tmp_list->data; GdkClientFilter *filter = tmp_list->data;
if (filter->type == xevent->xclient.message_type) if (filter->type == message_type)
{ {
result = (*filter->function) (xevent, event, filter->data); result = (*filter->function) (xevent, event, filter->data);
break; break;
@ -1506,7 +1504,7 @@ gdk_event_translate (GdkEvent *event,
{ {
event->client.type = GDK_CLIENT_EVENT; event->client.type = GDK_CLIENT_EVENT;
event->client.window = window; 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; event->client.data_format = xevent->xclient.format;
memcpy(&event->client.data, &xevent->xclient.data, memcpy(&event->client.data, &xevent->xclient.data,
sizeof(event->client.data)); sizeof(event->client.data));
@ -1592,7 +1590,7 @@ gdk_wm_protocols_filter (GdkXEvent *xev,
{ {
XEvent *xevent = (XEvent *)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 /* The delete window request specifies a window
* to delete. We don't actually destroy the * to delete. We don't actually destroy the
@ -1610,7 +1608,7 @@ gdk_wm_protocols_filter (GdkXEvent *xev,
return GDK_FILTER_TRANSLATE; 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; GdkWindow *win = event->any.window;
Window focus_win = GDK_WINDOW_IMPL_X11(((GdkWindowObject *)win)->impl)->focus_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); XSync (GDK_WINDOW_XDISPLAY (win), False);
gdk_error_trap_pop (); 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; 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.format = event->client.data_format;
sev.xclient.window = xid; sev.xclient.window = xid;
memcpy(&sev.xclient.data, &event->client.data, sizeof(sev.xclient.data)); 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); return gdk_send_xevent (xid, False, NoEventMask, &sev);
} }
@ -1785,7 +1783,7 @@ gdk_event_send_client_message_to_all_recurse (XEvent *xev,
guint32 xid, guint32 xid,
guint level) guint level)
{ {
static GdkAtom wm_state_atom = GDK_NONE; static Atom wm_state_atom = None;
Atom type = None; Atom type = None;
int format; int format;
unsigned long nitems, after; unsigned long nitems, after;
@ -1798,7 +1796,7 @@ gdk_event_send_client_message_to_all_recurse (XEvent *xev,
int i; int i;
if (!wm_state_atom) 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_warnings = FALSE;
_gdk_error_code = 0; _gdk_error_code = 0;
@ -1860,7 +1858,7 @@ gdk_event_send_clientmessage_toall (GdkEvent *event)
sev.xclient.display = gdk_display; sev.xclient.display = gdk_display;
sev.xclient.format = event->client.data_format; sev.xclient.format = event->client.data_format;
memcpy(&sev.xclient.data, &event->client.data, sizeof(sev.xclient.data)); 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); gdk_event_send_client_message_to_all_recurse(&sev, _gdk_root_window, 0);
@ -1891,7 +1889,7 @@ gdk_flush (void)
XSync (gdk_display, False); XSync (gdk_display, False);
} }
static GdkAtom timestamp_prop_atom = 0; static Atom timestamp_prop_atom = 0;
static Bool static Bool
timestamp_predicate (Display *display, 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); g_return_val_if_fail (!GDK_WINDOW_DESTROYED (window), 0);
if (!timestamp_prop_atom) 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); xdisplay = GDK_WINDOW_XDISPLAY (window);
xwindow = GDK_WINDOW_XWINDOW (window); xwindow = GDK_WINDOW_XWINDOW (window);
@ -1967,10 +1965,11 @@ gdk_x11_get_server_time (GdkWindow *window)
gboolean gboolean
gdk_net_wm_supports (GdkAtom property) gdk_net_wm_supports (GdkAtom property)
{ {
static GdkAtom wmspec_check_atom = 0; static Atom wmspec_check_atom = 0;
static GdkAtom wmspec_supported_atom = 0; static Atom wmspec_supported_atom = 0;
static GdkAtom *atoms = NULL; static Atom *atoms = NULL;
static gulong n_atoms = 0; static gulong n_atoms = 0;
Atom xproperty = gdk_x11_atom_to_xatom (property);
Atom type; Atom type;
gint format; gint format;
gulong nitems; gulong nitems;
@ -1986,7 +1985,7 @@ gdk_net_wm_supports (GdkAtom property)
i = 0; i = 0;
while (i < n_atoms) while (i < n_atoms)
{ {
if (atoms[i] == property) if (atoms[i] == xproperty)
return TRUE; return TRUE;
++i; ++i;
@ -2010,10 +2009,10 @@ gdk_net_wm_supports (GdkAtom property)
*/ */
if (wmspec_check_atom == 0) 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) 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, XGetWindowProperty (gdk_display, _gdk_root_window,
wmspec_check_atom, 0, G_MAXLONG, wmspec_check_atom, 0, G_MAXLONG,

View File

@ -37,7 +37,7 @@ gint _gdk_screen;
Window _gdk_root_window; Window _gdk_root_window;
Window _gdk_leader_window; Window _gdk_leader_window;
Atom _gdk_wm_window_protocols[3]; Atom _gdk_wm_window_protocols[3];
Atom _gdk_selection_property; GdkAtom _gdk_selection_property;
GdkWindowObject *_gdk_xgrab_window = NULL; /* Window that currently holds the GdkWindowObject *_gdk_xgrab_window = NULL; /* Window that currently holds the
* x pointer grab * x pointer grab

View File

@ -215,14 +215,13 @@ get_direction (void)
result = PANGO_DIRECTION_LTR; result = PANGO_DIRECTION_LTR;
else 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 || if (g_strcasecmp (name, "arabic") == 0 ||
g_strcasecmp (name, "hebrew") == 0 || g_strcasecmp (name, "hebrew") == 0 ||
g_strcasecmp (name, "israelian") == 0) g_strcasecmp (name, "israelian") == 0)
result = PANGO_DIRECTION_RTL; result = PANGO_DIRECTION_RTL;
else else
result = PANGO_DIRECTION_LTR; result = PANGO_DIRECTION_LTR;
g_free (name);
} }
return result; return result;

View File

@ -144,7 +144,7 @@ _gdk_windowing_init_check (int argc, char **argv)
pid = getpid(); pid = getpid();
XChangeProperty (gdk_display, _gdk_leader_window, 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, XA_CARDINAL, 32,
PropModeReplace, PropModeReplace,
(guchar *)&pid, 1); (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, "")) if (sm_client_id && strcmp (sm_client_id, ""))
{ {
XChangeProperty (gdk_display, _gdk_leader_window, 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, XA_STRING, 8, PropModeReplace,
sm_client_id, strlen(sm_client_id)); sm_client_id, strlen(sm_client_id));
} }
else else
XDeleteProperty (gdk_display, _gdk_leader_window, XDeleteProperty (gdk_display, _gdk_leader_window,
gdk_atom_intern ("SM_CLIENT_ID", FALSE)); gdk_x11_get_xatom_by_name ("SM_CLIENT_ID"));
} }
void void

View File

@ -159,7 +159,7 @@ extern Atom _gdk_wm_window_protocols[];
extern const int _gdk_nenvent_masks; extern const int _gdk_nenvent_masks;
extern const int _gdk_event_mask_table[]; extern const int _gdk_event_mask_table[];
extern gint _gdk_screen; extern gint _gdk_screen;
extern Atom _gdk_selection_property; extern GdkAtom _gdk_selection_property;
extern gchar *_gdk_display_name; extern gchar *_gdk_display_name;
extern Window _gdk_leader_window; extern Window _gdk_leader_window;

View File

@ -28,67 +28,285 @@
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <string.h> #include <string.h>
#include "gdk.h" /* For gdk_error_trap_push/pop() */
#include "gdkx.h" #include "gdkx.h"
#include "gdkproperty.h" #include "gdkproperty.h"
#include "gdkprivate.h" #include "gdkprivate.h"
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)
{
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_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));
}
/**
* 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)
{
char *name;
g_return_val_if_fail (ATOM_TO_INDEX (atom) < virtual_atom_array->len, None);
name = g_ptr_array_index (virtual_atom_array, ATOM_TO_INDEX (atom));
xatom = XInternAtom (gdk_display, name, FALSE);
insert_atom_pair (atom, xatom);
}
return xatom;
}
/**
* 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)
{
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);
}
}
return virtual_atom;
}
static void
virtual_atom_check_init (void)
{
if (!virtual_atom_hash)
{
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));
}
}
}
GdkAtom GdkAtom
gdk_atom_intern (const gchar *atom_name, gdk_atom_intern (const gchar *atom_name,
gboolean only_if_exists) gboolean only_if_exists)
{ {
GdkAtom retval; GdkAtom result;
static GHashTable *atom_hash = NULL;
g_return_val_if_fail (atom_name != NULL, GDK_NONE); virtual_atom_check_init ();
if (!atom_hash) result = GDK_POINTER_TO_ATOM (g_hash_table_lookup (virtual_atom_hash, atom_name));
atom_hash = g_hash_table_new (g_str_hash, g_str_equal); if (!result)
retval = GPOINTER_TO_UINT (g_hash_table_lookup (atom_hash, atom_name));
if (!retval)
{ {
retval = XInternAtom (gdk_display, atom_name, only_if_exists); result = INDEX_TO_ATOM (virtual_atom_array->len);
if (retval != None) g_ptr_array_add (virtual_atom_array, g_strdup (atom_name));
g_hash_table_insert (atom_hash, g_hash_table_insert (virtual_atom_hash,
g_strdup (atom_name), g_ptr_array_index (virtual_atom_array,
GUINT_TO_POINTER (retval)); ATOM_TO_INDEX (result)),
GDK_ATOM_TO_POINTER (result));
} }
return retval; 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 * gchar *
gdk_atom_name (GdkAtom atom) gdk_atom_name (GdkAtom atom)
{ {
gchar *t; return g_strdup (get_atom_name (atom));
gchar *name;
gint old_error_warnings;
/* If this atom doesn't exist, we'll die with an X error unless
we take precautions */
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;
if (_gdk_error_code)
{
if (t)
XFree (t);
return NULL;
} }
else
{
name = g_strdup (t);
if (t)
XFree (t);
return name; /**
* 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 gboolean
@ -105,6 +323,8 @@ gdk_property_get (GdkWindow *window,
{ {
Display *xdisplay; Display *xdisplay;
Window xwindow; Window xwindow;
Atom xproperty;
Atom xtype;
Atom ret_prop_type; Atom ret_prop_type;
gint ret_format; gint ret_format;
gulong ret_nitems; gulong ret_nitems;
@ -114,6 +334,9 @@ gdk_property_get (GdkWindow *window,
g_return_val_if_fail (!window || GDK_IS_WINDOW (window), FALSE); 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 (window)
{ {
if (GDK_WINDOW_DESTROYED (window)) if (GDK_WINDOW_DESTROYED (window))
@ -129,9 +352,9 @@ gdk_property_get (GdkWindow *window,
} }
ret_data = NULL; ret_data = NULL;
XGetWindowProperty (xdisplay, xwindow, property, XGetWindowProperty (xdisplay, xwindow, xproperty,
offset, (length + 3) / 4, pdelete, offset, (length + 3) / 4, pdelete,
type, &ret_prop_type, &ret_format, xtype, &ret_prop_type, &ret_format,
&ret_nitems, &ret_bytes_after, &ret_nitems, &ret_bytes_after,
&ret_data); &ret_data);
@ -140,19 +363,17 @@ gdk_property_get (GdkWindow *window,
} }
if (actual_property_type) 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) if (actual_format_type)
*actual_format_type = ret_format; *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); 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",
g_warning("Couldn't match property type %s to %s\n", rn, pn); gdk_x11_get_xatom_name (ret_prop_type),
g_free(rn); g_free(pn); gdk_x11_get_xatom_name (xtype));
return FALSE; return FALSE;
} }
@ -199,9 +420,14 @@ gdk_property_change (GdkWindow *window,
{ {
Display *xdisplay; Display *xdisplay;
Window xwindow; Window xwindow;
Atom xproperty;
Atom xtype;
g_return_if_fail (!window || GDK_IS_WINDOW (window)); 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 (window)
{ {
if (GDK_WINDOW_DESTROYED (window)) if (GDK_WINDOW_DESTROYED (window))
@ -216,7 +442,7 @@ gdk_property_change (GdkWindow *window,
xwindow = _gdk_root_window; xwindow = _gdk_root_window;
} }
XChangeProperty (xdisplay, xwindow, property, type, XChangeProperty (xdisplay, xwindow, xproperty, xtype,
format, mode, (guchar *)data, nelements); format, mode, (guchar *)data, nelements);
} }
@ -243,5 +469,5 @@ gdk_property_delete (GdkWindow *window,
xwindow = _gdk_root_window; xwindow = _gdk_root_window;
} }
XDeleteProperty (xdisplay, xwindow, property); XDeleteProperty (xdisplay, xwindow, gdk_x11_atom_to_xatom (property));
} }

View File

@ -77,7 +77,7 @@ _gdk_selection_filter_clear_event (XSelectionClearEvent *event)
while (tmp_list) while (tmp_list)
{ {
OwnerInfo *info = tmp_list->data; 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 && if ((GDK_DRAWABLE_XID (info->owner) == event->window &&
event->serial >= info->serial)) event->serial >= info->serial))
@ -103,9 +103,12 @@ gdk_selection_owner_set (GdkWindow *owner,
{ {
Display *xdisplay; Display *xdisplay;
Window xwindow; Window xwindow;
Atom xselection;
GSList *tmp_list; GSList *tmp_list;
OwnerInfo *info; OwnerInfo *info;
xselection = gdk_x11_atom_to_xatom (selection);
if (owner) if (owner)
{ {
if (GDK_WINDOW_DESTROYED (owner)) if (GDK_WINDOW_DESTROYED (owner))
@ -143,9 +146,9 @@ gdk_selection_owner_set (GdkWindow *owner,
owner_list = g_slist_prepend (owner_list, info); 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* GdkWindow*
@ -153,7 +156,7 @@ gdk_selection_owner_get (GdkAtom selection)
{ {
Window xwindow; Window xwindow;
xwindow = XGetSelectionOwner (gdk_display, selection); xwindow = XGetSelectionOwner (gdk_display, gdk_x11_atom_to_xatom (selection));
if (xwindow == None) if (xwindow == None)
return NULL; return NULL;
@ -169,8 +172,11 @@ gdk_selection_convert (GdkWindow *requestor,
if (GDK_WINDOW_DESTROYED (requestor)) if (GDK_WINDOW_DESTROYED (requestor))
return; return;
XConvertSelection (GDK_WINDOW_XDISPLAY (requestor), selection, target, XConvertSelection (GDK_WINDOW_XDISPLAY (requestor),
_gdk_selection_property, GDK_WINDOW_XID (requestor), time); 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 gint
@ -182,7 +188,7 @@ gdk_selection_property_get (GdkWindow *requestor,
gulong nitems; gulong nitems;
gulong nbytes; gulong nbytes;
gulong length; gulong length;
GdkAtom prop_type; Atom prop_type;
gint prop_format; gint prop_format;
guchar *t = NULL; guchar *t = NULL;
@ -199,12 +205,13 @@ gdk_selection_property_get (GdkWindow *requestor,
t = NULL; t = NULL;
XGetWindowProperty (GDK_WINDOW_XDISPLAY (requestor), XGetWindowProperty (GDK_WINDOW_XDISPLAY (requestor),
GDK_WINDOW_XID (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, AnyPropertyType, &prop_type, &prop_format,
&nitems, &nbytes, &t); &nitems, &nbytes, &t);
if (ret_type) if (ret_type)
*ret_type = prop_type; *ret_type = gdk_x11_xatom_to_atom (prop_type);
if (ret_format) if (ret_format)
*ret_format = prop_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 ... */ Otherwise there's no guarantee we'll win the race ... */
XGetWindowProperty (GDK_DRAWABLE_XDISPLAY (requestor), XGetWindowProperty (GDK_DRAWABLE_XDISPLAY (requestor),
GDK_DRAWABLE_XID (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, AnyPropertyType, &prop_type, &prop_format,
&nitems, &nbytes, &t); &nitems, &nbytes, &t);
if (prop_type != None) if (prop_type != None)
{ {
*data = g_new (guchar, length); *data = g_new (guchar, 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); memcpy (*data, t, length);
}
if (t) if (t)
XFree (t); XFree (t);
return length-1; return length-1;
@ -264,9 +287,9 @@ gdk_selection_send_notify (guint32 requestor,
xevent.send_event = True; xevent.send_event = True;
xevent.display = gdk_display; xevent.display = gdk_display;
xevent.requestor = requestor; xevent.requestor = requestor;
xevent.selection = selection; xevent.selection = gdk_x11_atom_to_xatom (selection);
xevent.target = target; xevent.target = gdk_x11_atom_to_xatom (target);
xevent.property = property; xevent.property = gdk_x11_atom_to_xatom (property);
xevent.time = time; xevent.time = time;
gdk_send_xevent (requestor, False, NoEventMask, (XEvent*) &xevent); gdk_send_xevent (requestor, False, NoEventMask, (XEvent*) &xevent);
@ -287,7 +310,7 @@ gdk_text_property_to_text_list (GdkAtom encoding,
return 0; return 0;
property.value = (guchar *)text; property.value = (guchar *)text;
property.encoding = encoding; property.encoding = gdk_x11_atom_to_xatom (encoding);
property.format = format; property.format = format;
property.nitems = length; property.nitems = length;
res = XmbTextPropertyToTextList (GDK_DISPLAY(), &property, list, &count); res = XmbTextPropertyToTextList (GDK_DISPLAY(), &property, list, &count);
@ -489,7 +512,7 @@ gdk_string_to_compound_text (const gchar *str,
} }
if (encoding) if (encoding)
*encoding = property.encoding; *encoding = gdk_x11_xatom_to_atom (property.encoding);
if (format) if (format)
*format = property.format; *format = property.format;
if (ctext) if (ctext)

View File

@ -298,7 +298,7 @@ _gdk_windowing_window_init (void)
gdk_xid_table_insert (&_gdk_root_window, _gdk_parent_root); 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: * gdk_window_new:
@ -590,14 +590,14 @@ gdk_window_new (GdkWindow *parent,
XSetWMHints (xdisplay, xid, &wm_hints); XSetWMHints (xdisplay, xid, &wm_hints);
if (!wm_client_leader_atom) 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 */ /* This will set WM_CLIENT_MACHINE and WM_LOCALE_NAME */
XSetWMProperties (xdisplay, xid, NULL, NULL, NULL, 0, NULL, NULL, NULL); XSetWMProperties (xdisplay, xid, NULL, NULL, NULL, 0, NULL, NULL, NULL);
pid = getpid (); pid = getpid ();
XChangeProperty (xdisplay, xid, XChangeProperty (xdisplay, xid,
gdk_atom_intern ("_NET_WM_PID", FALSE), gdk_x11_get_xatom_by_name ("_NET_WM_PID"),
XA_CARDINAL, 32, XA_CARDINAL, 32,
PropModeReplace, PropModeReplace,
(guchar *)&pid, 1); (guchar *)&pid, 1);
@ -754,9 +754,9 @@ _gdk_windowing_window_destroy (GdkWindow *window,
xevent.type = ClientMessage; xevent.type = ClientMessage;
xevent.window = GDK_WINDOW_XID (window); 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.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; xevent.data.l[1] = CurrentTime;
XSendEvent (GDK_WINDOW_XDISPLAY (window), XSendEvent (GDK_WINDOW_XDISPLAY (window),
@ -800,7 +800,7 @@ static void
set_initial_hints (GdkWindow *window) set_initial_hints (GdkWindow *window)
{ {
GdkWindowObject *private; GdkWindowObject *private;
GdkAtom atoms[5]; Atom atoms[5];
gint i; gint i;
private = (GdkWindowObject*) window; private = (GdkWindowObject*) window;
@ -831,21 +831,21 @@ set_initial_hints (GdkWindow *window)
if (private->state & GDK_WINDOW_STATE_MAXIMIZED) 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; ++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; ++i;
} }
if (private->state & GDK_WINDOW_STATE_STICKY) 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; ++i;
} }
if (private->modal_hint) 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; ++i;
} }
@ -853,7 +853,7 @@ set_initial_hints (GdkWindow *window)
{ {
XChangeProperty (GDK_WINDOW_XDISPLAY (window), XChangeProperty (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (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, XA_ATOM, 32, PropModeReplace,
(guchar*) atoms, i); (guchar*) atoms, i);
} }
@ -863,7 +863,7 @@ set_initial_hints (GdkWindow *window)
atoms[0] = 0xFFFFFFFF; atoms[0] = 0xFFFFFFFF;
XChangeProperty (GDK_WINDOW_XDISPLAY (window), XChangeProperty (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (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, XA_CARDINAL, 32, PropModeReplace,
(guchar*) atoms, 1); (guchar*) atoms, 1);
} }
@ -1359,7 +1359,7 @@ gdk_window_focus (GdkWindow *window,
xev.xclient.send_event = True; xev.xclient.send_event = True;
xev.xclient.window = GDK_WINDOW_XWINDOW (window); xev.xclient.window = GDK_WINDOW_XWINDOW (window);
xev.xclient.display = gdk_display; 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.format = 32;
xev.xclient.data.l[0] = 0; xev.xclient.data.l[0] = 0;
@ -1468,7 +1468,7 @@ void
gdk_window_set_type_hint (GdkWindow *window, gdk_window_set_type_hint (GdkWindow *window,
GdkWindowTypeHint hint) GdkWindowTypeHint hint)
{ {
GdkAtom atom; Atom atom;
g_return_if_fail (window != NULL); g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window)); g_return_if_fail (GDK_IS_WINDOW (window));
@ -1479,25 +1479,25 @@ gdk_window_set_type_hint (GdkWindow *window,
switch (hint) switch (hint)
{ {
case GDK_WINDOW_TYPE_HINT_DIALOG: 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; break;
case GDK_WINDOW_TYPE_HINT_MENU: 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; break;
case GDK_WINDOW_TYPE_HINT_TOOLBAR: 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; break;
default: default:
g_warning ("Unknown hint %d passed to gdk_window_set_type_hint", hint); g_warning ("Unknown hint %d passed to gdk_window_set_type_hint", hint);
/* Fall thru */ /* Fall thru */
case GDK_WINDOW_TYPE_HINT_NORMAL: 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; break;
} }
XChangeProperty (GDK_WINDOW_XDISPLAY (window), XChangeProperty (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (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, XA_ATOM, 32, PropModeReplace,
(guchar *)&atom, 1); (guchar *)&atom, 1);
} }
@ -1520,11 +1520,11 @@ gdk_wmspec_change_state (gboolean add,
xev.xclient.send_event = True; xev.xclient.send_event = True;
xev.xclient.display = gdk_display; xev.xclient.display = gdk_display;
xev.xclient.window = GDK_WINDOW_XID (window); 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.format = 32;
xev.xclient.data.l[0] = add ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE; xev.xclient.data.l[0] = add ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
xev.xclient.data.l[1] = state1; xev.xclient.data.l[1] = gdk_x11_atom_to_xatom (state1);
xev.xclient.data.l[2] = state2; xev.xclient.data.l[2] = gdk_x11_atom_to_xatom (state2);
XSendEvent (gdk_display, _gdk_root_window, False, XSendEvent (gdk_display, _gdk_root_window, False,
SubstructureRedirectMask | SubstructureNotifyMask, SubstructureRedirectMask | SubstructureNotifyMask,
@ -1761,25 +1761,28 @@ utf8_is_latin1 (const gchar *str)
*/ */
static void static void
set_text_property (GdkWindow *window, set_text_property (GdkWindow *window,
GdkAtom property, Atom property,
const gchar *utf8_str) const gchar *utf8_str)
{ {
guchar *prop_text = NULL; guchar *prop_text = NULL;
GdkAtom prop_type; Atom prop_type;
gint prop_length; gint prop_length;
gint prop_format; gint prop_format;
if (utf8_is_latin1 (utf8_str)) 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_text = gdk_utf8_to_string_target (utf8_str);
prop_length = strlen (prop_text); prop_length = strlen (prop_text);
prop_format = 8; prop_format = 8;
} }
else 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_text, &prop_length);
prop_type = gdk_x11_atom_to_xatom (gdk_type);
} }
if (prop_text) if (prop_text)
@ -1820,21 +1823,21 @@ gdk_window_set_title (GdkWindow *window,
XChangeProperty (GDK_WINDOW_XDISPLAY (window), XChangeProperty (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window), GDK_WINDOW_XID (window),
gdk_atom_intern ("_NET_WM_NAME", FALSE), gdk_x11_get_xatom_by_name ("_NET_WM_NAME"),
gdk_atom_intern ("UTF8_STRING", FALSE), 8, gdk_x11_get_xatom_by_name ("UTF8_STRING"), 8,
PropModeReplace, title, PropModeReplace, title,
strlen (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)) if (!gdk_window_icon_name_set (window))
{ {
XChangeProperty (GDK_WINDOW_XDISPLAY (window), XChangeProperty (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window), GDK_WINDOW_XID (window),
gdk_atom_intern ("_NET_WM_ICON_NAME", FALSE), gdk_x11_get_xatom_by_name ("_NET_WM_ICON_NAME"),
gdk_atom_intern ("UTF8_STRING", FALSE), 8, gdk_x11_get_xatom_by_name ("UTF8_STRING"), 8,
PropModeReplace, title, PropModeReplace, title,
strlen (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) if (role)
XChangeProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window), 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)); 8, PropModeReplace, role, strlen (role));
else else
XDeleteProperty (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window), 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 (!GDK_WINDOW_DESTROYED (window))
{ {
if (!atom) if (!atom)
atom = gdk_atom_intern ("ENLIGHTENMENT_DESKTOP", FALSE); atom = gdk_x11_get_xatom_by_name ("ENLIGHTENMENT_DESKTOP");
win = GDK_WINDOW_XID (window); win = GDK_WINDOW_XID (window);
while (XQueryTree (GDK_WINDOW_XDISPLAY (window), win, &root, &parent, 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), XChangeProperty (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window), GDK_WINDOW_XID (window),
gdk_atom_intern ("_NET_WM_ICON", FALSE), gdk_x11_get_xatom_by_name ("_NET_WM_ICON"),
XA_CARDINAL, 32, XA_CARDINAL, 32,
PropModeReplace, PropModeReplace,
(guchar*) data, size); (guchar*) data, size);
@ -2837,7 +2840,7 @@ gdk_window_set_icon_list (GdkWindow *window,
{ {
XDeleteProperty (GDK_WINDOW_XDISPLAY (window), XDeleteProperty (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (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), XChangeProperty (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window), GDK_WINDOW_XID (window),
gdk_atom_intern ("_NET_WM_ICON_NAME", FALSE), gdk_x11_get_xatom_by_name ("_NET_WM_ICON_NAME"),
gdk_atom_intern ("UTF8_STRING", FALSE), 8, gdk_x11_get_xatom_by_name ("UTF8_STRING"), 8,
PropModeReplace, name, PropModeReplace, name,
strlen (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.send_event = True;
xev.xclient.window = GDK_WINDOW_XWINDOW (window); xev.xclient.window = GDK_WINDOW_XWINDOW (window);
xev.xclient.display = gdk_display; 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.format = 32;
xev.xclient.data.l[0] = 0xFFFFFFFF; xev.xclient.data.l[0] = 0xFFFFFFFF;
@ -3110,7 +3113,7 @@ gdk_window_unstick (GdkWindow *window)
* one that matters much in practice. * one that matters much in practice.
*/ */
XGetWindowProperty (gdk_display, _gdk_root_window, 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, 0, G_MAXLONG,
False, XA_CARDINAL, &type, &format, &nitems, False, XA_CARDINAL, &type, &format, &nitems,
&bytes_after, (guchar **)&current_desktop); &bytes_after, (guchar **)&current_desktop);
@ -3122,7 +3125,7 @@ gdk_window_unstick (GdkWindow *window)
xev.xclient.send_event = True; xev.xclient.send_event = True;
xev.xclient.window = GDK_WINDOW_XWINDOW (window); xev.xclient.window = GDK_WINDOW_XWINDOW (window);
xev.xclient.display = gdk_display; 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.format = 32;
xev.xclient.data.l[0] = *current_desktop; xev.xclient.data.l[0] = *current_desktop;
@ -4077,7 +4080,7 @@ wmspec_moveresize (GdkWindow *window,
xev.xclient.send_event = True; xev.xclient.send_event = True;
xev.xclient.display = gdk_display; xev.xclient.display = gdk_display;
xev.xclient.window = GDK_WINDOW_XID (window); 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.format = 32;
xev.xclient.data.l[0] = root_x; xev.xclient.data.l[0] = root_x;
xev.xclient.data.l[1] = root_y; xev.xclient.data.l[1] = root_y;

View File

@ -112,6 +112,11 @@ void gdk_x11_ungrab_server (void);
/* returns TRUE if we support the given WM spec feature */ /* returns TRUE if we support the given WM spec feature */
gboolean gdk_net_wm_supports (GdkAtom property); 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 #ifndef GDK_DISABLE_DEPRECATED
Display * gdk_x11_font_get_xdisplay (GdkFont *font); Display * gdk_x11_font_get_xdisplay (GdkFont *font);

View File

@ -7450,7 +7450,7 @@ gtk_clist_drag_leave (GtkWidget *widget,
list = context->targets; list = context->targets;
while (list) 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 GTK_CLIST_GET_CLASS (clist)->draw_drag_highlight
(clist, (clist,
@ -7505,7 +7505,7 @@ gtk_clist_drag_motion (GtkWidget *widget,
list = context->targets; list = context->targets;
while (list) while (list)
{ {
if (atom == GPOINTER_TO_INT (list->data)) if (atom == GDK_POINTER_TO_ATOM (list->data))
break; break;
list = list->next; list = list->next;
} }
@ -7581,7 +7581,7 @@ gtk_clist_drag_drop (GtkWidget *widget,
list = context->targets; list = context->targets;
while (list) while (list)
{ {
if (atom == GPOINTER_TO_INT (list->data)) if (atom == GDK_POINTER_TO_ATOM (list->data))
return TRUE; return TRUE;
list = list->next; list = list->next;
} }

View File

@ -5988,7 +5988,7 @@ gtk_ctree_drag_motion (GtkWidget *widget,
list = context->targets; list = context->targets;
while (list) while (list)
{ {
if (atom == GPOINTER_TO_INT (list->data)) if (atom == GDK_POINTER_TO_ATOM (list->data))
break; break;
list = list->next; list = list->next;
} }

View File

@ -1353,7 +1353,7 @@ gtk_drag_proxy_begin (GtkWidget *widget,
while (tmp_list) while (tmp_list)
{ {
gtk_target_list_add (source_info->target_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; tmp_list = tmp_list->next;
} }
@ -2446,7 +2446,7 @@ gtk_drag_source_check_selection (GtkDragSourceInfo *info,
tmp_list = info->selections; tmp_list = info->selections;
while (tmp_list) while (tmp_list)
{ {
if (GPOINTER_TO_UINT (tmp_list->data) == selection) if (GDK_POINTER_TO_ATOM (tmp_list->data) == selection)
return; return;
tmp_list = tmp_list->next; tmp_list = tmp_list->next;
} }
@ -2546,7 +2546,7 @@ gtk_drag_source_release_selections (GtkDragSourceInfo *info,
GList *tmp_list = info->selections; GList *tmp_list = info->selections;
while (tmp_list) 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) if (gdk_selection_owner_get (selection) == info->ipc_widget->window)
gtk_selection_owner_set (NULL, selection, time); gtk_selection_owner_set (NULL, selection, time);
tmp_list = tmp_list->next; tmp_list = tmp_list->next;

View File

@ -850,7 +850,7 @@ send_xembed_message (GtkPlug *plug,
xevent.xclient.window = GDK_WINDOW_XWINDOW (plug->socket_window); xevent.xclient.window = GDK_WINDOW_XWINDOW (plug->socket_window);
xevent.xclient.type = ClientMessage; 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.format = 32;
xevent.xclient.data.l[0] = time; xevent.xclient.data.l[0] = time;
xevent.xclient.data.l[1] = message; xevent.xclient.data.l[1] = message;
@ -918,7 +918,7 @@ xembed_set_info (GdkWindow *gdk_window,
Window window = GDK_WINDOW_XWINDOW (gdk_window); Window window = GDK_WINDOW_XWINDOW (gdk_window);
unsigned long buffer[2]; 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] = 0; /* Protocol version */
buffer[1] = flags; buffer[1] = flags;
@ -1015,7 +1015,7 @@ gtk_plug_filter_func (GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data)
switch (xevent->type) switch (xevent->type)
{ {
case ClientMessage: 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, handle_xembed_message (plug,
xevent->xclient.data.l[1], xevent->xclient.data.l[1],
@ -1027,7 +1027,7 @@ gtk_plug_filter_func (GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data)
return GDK_FILTER_REMOVE; 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 /* We filter these out because we take being reparented back to the
* root window as the reliable end of the embedding protocol * root window as the reliable end of the embedding protocol

View File

@ -1077,7 +1077,7 @@ send_xembed_message (GtkSocket *socket,
xevent.xclient.window = GDK_WINDOW_XWINDOW (socket->plug_window); xevent.xclient.window = GDK_WINDOW_XWINDOW (socket->plug_window);
xevent.xclient.type = ClientMessage; 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.format = 32;
xevent.xclient.data.l[0] = time; xevent.xclient.data.l[0] = time;
xevent.xclient.data.l[1] = message; xevent.xclient.data.l[1] = message;
@ -1101,7 +1101,7 @@ xembed_get_info (GdkWindow *gdk_window,
{ {
Display *display = GDK_WINDOW_XDISPLAY (gdk_window); Display *display = GDK_WINDOW_XDISPLAY (gdk_window);
Window window = GDK_WINDOW_XWINDOW (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; Atom type;
int format; int format;
unsigned long nitems, bytes_after; unsigned long nitems, bytes_after;
@ -1244,7 +1244,7 @@ gtk_socket_filter_func (GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data)
switch (xevent->type) switch (xevent->type)
{ {
case ClientMessage: 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, handle_xembed_message (socket,
xevent->xclient.data.l[1], xevent->xclient.data.l[1],
@ -1394,8 +1394,8 @@ gtk_socket_filter_func (GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data)
{ {
GdkDragProtocol protocol; GdkDragProtocol protocol;
if ((xevent->xproperty.atom == gdk_atom_intern ("XdndAware", FALSE)) || if ((xevent->xproperty.atom == gdk_x11_get_xatom_by_name ("XdndAware")) ||
(xevent->xproperty.atom == gdk_atom_intern ("_MOTIF_DRAG_RECEIVER_INFO", FALSE))) (xevent->xproperty.atom == gdk_x11_get_xatom_by_name ("_MOTIF_DRAG_RECEIVER_INFO")))
{ {
gdk_error_trap_push (); gdk_error_trap_push ();
if (gdk_drag_get_protocol (xevent->xproperty.window, &protocol)) 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_flush ();
gdk_error_trap_pop (); 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; unsigned long flags;

View File

@ -2405,8 +2405,8 @@ gtk_widget_translate_coordinates (GtkWidget *src_widget,
GtkWidget *ancestor; GtkWidget *ancestor;
GdkWindow *window; GdkWindow *window;
g_return_if_fail (GTK_IS_WIDGET (src_widget)); g_return_val_if_fail (GTK_IS_WIDGET (src_widget), FALSE);
g_return_if_fail (GTK_IS_WIDGET (dest_widget)); g_return_val_if_fail (GTK_IS_WIDGET (dest_widget), FALSE);
ancestor = gtk_widget_common_ancestor (src_widget, dest_widget); ancestor = gtk_widget_common_ancestor (src_widget, dest_widget);
if (!ancestor || !GTK_WIDGET_REALIZED (src_widget) || !GTK_WIDGET_REALIZED (dest_widget)) if (!ancestor || !GTK_WIDGET_REALIZED (src_widget) || !GTK_WIDGET_REALIZED (dest_widget))

View File

@ -320,7 +320,7 @@ target_drag_motion (GtkWidget *widget,
tmp_list = context->targets; tmp_list = context->targets;
while (tmp_list) 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_print ("%s\n", name);
g_free (name); g_free (name);
@ -346,7 +346,7 @@ target_drag_drop (GtkWidget *widget,
if (context->targets) if (context->targets)
{ {
gtk_drag_get_data (widget, context, gtk_drag_get_data (widget, context,
GPOINTER_TO_INT (context->targets->data), GDK_POINTER_TO_ATOM (context->targets->data),
time); time);
return TRUE; return TRUE;
} }

View File

@ -289,9 +289,8 @@ selection_received (GtkWidget *widget, GtkSelectionData *data)
if (seltype == SEL_TYPE_NONE) if (seltype == SEL_TYPE_NONE)
{ {
char *name = gdk_atom_name (data->type); char *name = gdk_atom_name (data->type);
g_print("Don't know how to handle type: %s (%ld)\n", g_print("Don't know how to handle type: %s\n",
name?name:"<unknown>", name?name:"<unknown>");
data->type);
return; return;
} }
@ -335,9 +334,8 @@ selection_received (GtkWidget *widget, GtkSelectionData *data)
default: default:
{ {
char *name = gdk_atom_name (data->type); char *name = gdk_atom_name (data->type);
g_print("Can't convert type %s (%ld) to string\n", g_print("Can't convert type %s to string\n",
name?name:"<unknown>", name?name:"<unknown>");
data->type);
position = data->length; position = data->length;
continue; continue;
} }