From e2b1a43f10b40a5ec8ffcdc6bf055d9d0c82b519 Mon Sep 17 00:00:00 2001 From: Erwann Chenede Date: Wed, 27 Jun 2001 16:58:33 +0000 Subject: [PATCH] Last fixed to make gtk Dnd fully work with virtual atoms. --- gdk/x11/gdkproperty-x11.c | 552 +++++++++++++++++++------------------- gdk/x11/gdkscreen-x11.c | 1 + gdk/x11/gdkwindow-x11.c | 8 +- gtk/gtkdnd.c | 2 +- gtk/gtkselection.c | 2 +- gtk/gtkwindow.c | 6 +- 6 files changed, 285 insertions(+), 286 deletions(-) diff --git a/gdk/x11/gdkproperty-x11.c b/gdk/x11/gdkproperty-x11.c index 601297dc86..c0c1dfb4f3 100644 --- a/gdk/x11/gdkproperty-x11.c +++ b/gdk/x11/gdkproperty-x11.c @@ -34,217 +34,209 @@ #include "gdkinternals.h" #include "gdkdisplay-x11.h" #include "gdkscreen-x11.h" -#include "gdkselection.h" /* only from predefined atom */ +#include "gdkselection.h" /* only from predefined atom */ typedef struct { - GdkDisplay *display; - GSList *atom_list; + GdkDisplay *display; + GSList *atom_list; } GdkAtomDisplayList; typedef struct { - GdkAtom virtual_atom; - GdkAtom x_atom; + GdkAtom virtual_atom; + GdkAtom x_atom; } GdkAtomMap; static GSList *display_atom_lists = NULL; -typedef struct { - GQuark virtual_atom; - Atom x_atom; -} PredefinedAtoms; - -typedef struct { - PredefinedAtoms list[67]; - GQuark min; - GQuark max; -} PredefinedAtomsCache; - -static PredefinedAtomsCache pac; +static GdkAtom min_predef_virtual_atom; +static GdkAtom max_predef_virtual_atom; static gboolean predefined_atom_cache_initialised = FALSE; -gchar *XAtomsStrings [] = { -"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" +G_LOCK_DEFINE_STATIC (gdk_atom_predefined); + +gchar *XAtomsStrings[] = { + "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" }; static gboolean check_if_predefined_atom (atom) { - /* if the atom is a protocol atom then don't do - * the real - virtual or virtual real convertion */ - if (atom < XA_LAST_PREDEFINED) - return TRUE; - return FALSE; + /* if the atom is a protocol atom then don't do + * the real - virtual or virtual real convertion */ + if (atom < XA_LAST_PREDEFINED) + return TRUE; + return FALSE; } -GdkAtom -gdk_x11_get_real_atom (GdkDisplay *display, GdkAtom virtual_atom, gboolean only_if_exists) +GdkAtom +gdk_x11_get_real_atom (GdkDisplay * display, GdkAtom virtual_atom, + gboolean only_if_exists) { GdkAtomMap *atom_map; GdkAtomDisplayList *atom_display_list; GSList *tmp_atom_display_list; GSList *tmp_atom_map_list; gboolean found = FALSE; - + if (check_if_predefined_atom (virtual_atom)) - { - /*g_print ("We got a predefined atom %ld\n", virtual_atom);*/ - return virtual_atom; - } - - if (display_atom_lists == NULL) - { - atom_map = g_new0 (GdkAtomMap, 1); - atom_map->virtual_atom = virtual_atom; - atom_map->x_atom = XInternAtom (GDK_DISPLAY_XDISPLAY (display), - g_quark_to_string (virtual_atom), - only_if_exists); - if (!atom_map->x_atom) { - g_free (atom_map); -/* g_print ("Fail XInternAtom\n");*/ - return 0; + return virtual_atom; + } + + if (display_atom_lists == NULL) + { + atom_map = g_new0 (GdkAtomMap, 1); + atom_map->virtual_atom = virtual_atom; + atom_map->x_atom = XInternAtom (GDK_DISPLAY_XDISPLAY (display), + g_quark_to_string (virtual_atom), + only_if_exists); + if (!atom_map->x_atom) + { + g_free (atom_map); + return 0; + } + atom_display_list = g_new0 (GdkAtomDisplayList, 1); + atom_display_list->display = display; + atom_display_list->atom_list = + g_slist_append (atom_display_list->atom_list, atom_map); + display_atom_lists = + g_slist_append (display_atom_lists, atom_display_list); + return atom_map->x_atom; } - atom_display_list = g_new0 (GdkAtomDisplayList, 1); - atom_display_list->display = display; - atom_display_list->atom_list = g_slist_append (atom_display_list->atom_list, - atom_map); - display_atom_lists = g_slist_append (display_atom_lists, atom_display_list); -/* g_print ("first Get REAL(%d) (%s) return X Atom is %d\n", virtual_atom, g_quark_to_string (virtual_atom), atom_map->x_atom);*/ - return atom_map->x_atom; - } /* find atom map list for display */ tmp_atom_display_list = display_atom_lists; while (tmp_atom_display_list && !found) - { - if (((GdkAtomDisplayList*)tmp_atom_display_list->data)->display == display) - found = TRUE; - else - tmp_atom_display_list = tmp_atom_display_list->next; - } - if (found) - { - /* check is atom is already cached */ - tmp_atom_map_list = ((GdkAtomDisplayList *)tmp_atom_display_list->data)->atom_list; - atom_display_list = ((GdkAtomDisplayList *)tmp_atom_display_list->data); - while (tmp_atom_map_list) { - if (((GdkAtomMap *)tmp_atom_map_list->data)->virtual_atom == virtual_atom) - { - return ((GdkAtomMap *)tmp_atom_map_list->data)->x_atom; - } - tmp_atom_map_list = tmp_atom_map_list->next; + if (((GdkAtomDisplayList *) tmp_atom_display_list->data)->display == + display) + found = TRUE; + else + tmp_atom_display_list = tmp_atom_display_list->next; } - /* not found get and add mapping */ - atom_map = g_new0 (GdkAtomMap, 1); - atom_map->virtual_atom = virtual_atom; - atom_map->x_atom = XInternAtom (GDK_DISPLAY_XDISPLAY (display), - g_quark_to_string (virtual_atom), - only_if_exists); - if (!atom_map->x_atom) + if (found) { - g_free (atom_map); - return None; + /* check is atom is already cached */ + tmp_atom_map_list = + ((GdkAtomDisplayList *) tmp_atom_display_list->data)->atom_list; + atom_display_list = + ((GdkAtomDisplayList *) tmp_atom_display_list->data); + while (tmp_atom_map_list) + { + if (((GdkAtomMap *) tmp_atom_map_list->data)->virtual_atom == + virtual_atom) + { + return ((GdkAtomMap *) tmp_atom_map_list->data)->x_atom; + } + tmp_atom_map_list = tmp_atom_map_list->next; + } + /* not found get and add mapping */ + atom_map = g_new0 (GdkAtomMap, 1); + atom_map->virtual_atom = virtual_atom; + atom_map->x_atom = XInternAtom (GDK_DISPLAY_XDISPLAY (display), + g_quark_to_string (virtual_atom), + only_if_exists); + if (!atom_map->x_atom) + { + g_free (atom_map); + return None; + } + atom_display_list->atom_list = + g_slist_append (atom_display_list->atom_list, atom_map); + return atom_map->x_atom; } - atom_display_list->atom_list = g_slist_append (atom_display_list->atom_list, - atom_map); - -/* g_print ("Get REAL(%d) (%s) return X Atom is %d\n", virtual_atom, g_quark_to_string (virtual_atom), atom_map->x_atom);*/ - return atom_map->x_atom; - } - /* new display list and new atom */ + /* new display list and new atom */ atom_map = g_new0 (GdkAtomMap, 1); atom_map->virtual_atom = virtual_atom; atom_map->x_atom = XInternAtom (GDK_DISPLAY_XDISPLAY (display), - g_quark_to_string (virtual_atom), - only_if_exists); + g_quark_to_string (virtual_atom), + only_if_exists); if (!atom_map->x_atom) { g_free (atom_map); return 0; - } + } atom_display_list = g_new0 (GdkAtomDisplayList, 1); atom_display_list->display = display; atom_display_list->atom_list = g_slist_append (atom_display_list->atom_list, - atom_map); + atom_map); display_atom_lists = g_slist_append (display_atom_lists, atom_display_list); -/* g_print ("!New Display! Get REAL(%d) (%s) return X Atom is %d\n", virtual_atom, g_quark_to_string (virtual_atom), atom_map->x_atom);*/ - return atom_map->x_atom; + return atom_map->x_atom; } GdkAtom -gdk_x11_get_virtual_atom (GdkDisplay *display, GdkAtom xatom) +gdk_x11_get_virtual_atom (GdkDisplay * display, GdkAtom xatom) { GdkAtomMap *atom_map; GdkAtomDisplayList *atom_display_list; @@ -254,82 +246,83 @@ gdk_x11_get_virtual_atom (GdkDisplay *display, GdkAtom xatom) gboolean found = FALSE; if (check_if_predefined_atom (xatom)) - { - /*g_print ("We got a predefined atom %ld\n", xatom);*/ - return xatom; - } + { + return xatom; + } if (display_atom_lists == NULL) - { - atom_map = g_new0 (GdkAtomMap, 1); - atom_map->x_atom = xatom; - xatom_string = XGetAtomName (GDK_DISPLAY_XDISPLAY (display), xatom); - atom_map->virtual_atom = gdk_atom_intern (xatom_string, FALSE); - XFree (xatom_string); - atom_display_list = g_new0 (GdkAtomDisplayList, 1); - atom_display_list->display = display; - atom_display_list->atom_list = g_slist_append (atom_display_list->atom_list, - atom_map); - display_atom_lists = g_slist_append (display_atom_lists, atom_display_list); - return atom_map->virtual_atom; - } + { + atom_map = g_new0 (GdkAtomMap, 1); + atom_map->x_atom = xatom; + xatom_string = XGetAtomName (GDK_DISPLAY_XDISPLAY (display), xatom); + atom_map->virtual_atom = gdk_atom_intern (xatom_string, FALSE); + XFree (xatom_string); + atom_display_list = g_new0 (GdkAtomDisplayList, 1); + atom_display_list->display = display; + atom_display_list->atom_list = + g_slist_append (atom_display_list->atom_list, atom_map); + display_atom_lists = + g_slist_append (display_atom_lists, atom_display_list); + return atom_map->virtual_atom; + } /* find atom map list for display */ tmp_atom_display_list = display_atom_lists; while (tmp_atom_display_list && !found) - { - if (((GdkAtomDisplayList*)tmp_atom_display_list->data)->display == display) - found = TRUE; - else - tmp_atom_display_list = tmp_atom_display_list->next; - } - if (found) - { - /* check is atom is already cached */ - tmp_atom_map_list = ((GdkAtomDisplayList *)tmp_atom_display_list->data)->atom_list; - atom_display_list = ((GdkAtomDisplayList *)tmp_atom_display_list->data); - while (tmp_atom_map_list) { - if (((GdkAtomMap *)tmp_atom_map_list->data)->x_atom == xatom) - { - return ((GdkAtomMap *)tmp_atom_map_list->data)->virtual_atom; - } - tmp_atom_map_list = tmp_atom_map_list->next; + if (((GdkAtomDisplayList *) tmp_atom_display_list->data)->display == + display) + found = TRUE; + else + tmp_atom_display_list = tmp_atom_display_list->next; } - /* not found get and add mapping */ - atom_map = g_new0 (GdkAtomMap, 1); - atom_map->x_atom = xatom; - xatom_string = XGetAtomName (GDK_DISPLAY_XDISPLAY (display), xatom); - atom_map->virtual_atom = gdk_atom_intern (xatom_string, FALSE); -/* g_print ("\nGet VIRTUAL (%d) string (%s) return virtual = %d\n", xatom, xatom_string, atom_map->virtual_atom);*/ - XFree (xatom_string); - atom_display_list->atom_list = g_slist_append (atom_display_list->atom_list, - atom_map); - return atom_map->virtual_atom; - } - /* new display list and new atom */ + if (found) + { + /* check is atom is already cached */ + tmp_atom_map_list = + ((GdkAtomDisplayList *) tmp_atom_display_list->data)->atom_list; + atom_display_list = + ((GdkAtomDisplayList *) tmp_atom_display_list->data); + while (tmp_atom_map_list) + { + if (((GdkAtomMap *) tmp_atom_map_list->data)->x_atom == xatom) + { + return ((GdkAtomMap *) tmp_atom_map_list->data)->virtual_atom; + } + tmp_atom_map_list = tmp_atom_map_list->next; + } + /* not found get and add mapping */ + atom_map = g_new0 (GdkAtomMap, 1); + atom_map->x_atom = xatom; + xatom_string = XGetAtomName (GDK_DISPLAY_XDISPLAY (display), xatom); + atom_map->virtual_atom = gdk_atom_intern (xatom_string, FALSE); + XFree (xatom_string); + atom_display_list->atom_list = + g_slist_append (atom_display_list->atom_list, atom_map); + return atom_map->virtual_atom; + } + /* new display list and new atom */ atom_map = g_new0 (GdkAtomMap, 1); atom_map->x_atom = xatom; xatom_string = XGetAtomName (GDK_DISPLAY_XDISPLAY (display), xatom); atom_map->virtual_atom = gdk_atom_intern (xatom_string, FALSE); -/*g_print ("\n!New Display! Get VIRTUAL (%d) string (%s) return virtual = %d\n", xatom, xatom_string, atom_map->virtual_atom);*/ - XFree (xatom_string); + XFree (xatom_string); atom_display_list = g_new0 (GdkAtomDisplayList, 1); atom_display_list->display = display; atom_display_list->atom_list = g_slist_append (atom_display_list->atom_list, - atom_map); + atom_map); display_atom_lists = g_slist_append (display_atom_lists, atom_display_list); - return atom_map->virtual_atom; + return atom_map->virtual_atom; } GdkAtom -gdk_x11_get_real_atom_by_name (GdkDisplay *display, const gchar *atom_name) +gdk_x11_get_real_atom_by_name (GdkDisplay * display, const gchar * atom_name) { -/* g_print("Get Real Atom by Name %s\n",atom_name);*/ - return gdk_x11_get_real_atom (display, gdk_atom_intern (atom_name, FALSE), FALSE); + return gdk_x11_get_real_atom (display, gdk_atom_intern (atom_name, FALSE), + FALSE); } -gchar* -gdk_x11_get_real_atom_name (GdkDisplay *display, GdkAtom xatom) +gchar * +gdk_x11_get_real_atom_name (GdkDisplay * display, GdkAtom xatom) { gchar *name, *tmp; tmp = XGetAtomName (GDK_DISPLAY_XDISPLAY (display), xatom); @@ -340,63 +333,61 @@ gdk_x11_get_real_atom_name (GdkDisplay *display, GdkAtom xatom) } GdkAtom -gdk_atom_intern (const gchar *atom_name, gboolean only_if_exists) +gdk_atom_intern (const gchar * atom_name, gboolean only_if_exists) { GdkAtom virtual_atom; g_return_val_if_fail (atom_name != NULL, GDK_NONE); if (!predefined_atom_cache_initialised) - { - int i; - for (i=0;i<68;i++) { - pac.list[i].virtual_atom = g_quark_from_string (XAtomsStrings[i]); - pac.list[i].x_atom = i+1; - /*g_print ("i (%d), virtual (%ld), xatom (%ld), Name (%s)\n", - i,pac.list[i].virtual_atom, pac.list[i].x_atom, - XAtomsStrings[i]);*/ + int i; + /* Mark such the predefined quarks are consecutives */ + G_LOCK (gdk_atom_predefined); + + for (i = 0; i < 68; i++) + { + GdkAtom virtual_tmp = g_quark_from_string (XAtomsStrings[i]); + if (i == 0) + min_predef_virtual_atom = virtual_tmp; + if (i == 67) + max_predef_virtual_atom = virtual_tmp; + } + predefined_atom_cache_initialised = TRUE; + G_UNLOCK (gdk_atom_predefined); } - pac.max = pac.list[67].virtual_atom; - pac.min = pac.list[0].virtual_atom; - /*g_print ("min is (%ld), max is (%ld)\n", - pac.min, - pac.max);*/ - predefined_atom_cache_initialised = TRUE; - } + virtual_atom = g_quark_from_string (atom_name); - if (virtual_atom < pac.max && virtual_atom > pac.min) - { - /*g_print ("predefined atom (%s) virtual %ld, X %ld\n", - atom_name, - virtual_atom, - pac.list[virtual_atom - pac.min].x_atom);*/ - /* I assume the quarks in pac.list are consecutives */ - virtual_atom = pac.list[virtual_atom - pac.min].x_atom; - return virtual_atom; - } + if (virtual_atom < max_predef_virtual_atom && + virtual_atom > min_predef_virtual_atom) + { + /* predefined atom numbers go from 1 to 67 so to get them + * first predefined virtual - current virtual gives the + * offset*/ + virtual_atom = (virtual_atom - min_predef_virtual_atom) + 1; + return virtual_atom; + } return virtual_atom; } -gchar* +gchar * gdk_atom_name (GdkAtom atom) { if (check_if_predefined_atom (atom)) - { - return gdk_x11_get_real_atom_name (gdk_get_default_display (), atom); - } + { + return gdk_x11_get_real_atom_name (gdk_get_default_display (), atom); + } return g_strdup (g_quark_to_string (atom)); } gboolean -gdk_property_get (GdkWindow *window, - GdkAtom property, - GdkAtom type, - gulong offset, - gulong length, - gint pdelete, - GdkAtom *actual_property_type, - gint *actual_format_type, - gint *actual_length, - guchar **data) +gdk_property_get (GdkWindow * window, + GdkAtom property, + GdkAtom type, + gulong offset, + gulong length, + gint pdelete, + GdkAtom * actual_property_type, + gint * actual_format_type, + gint * actual_length, guchar ** data) { GdkDisplay *display; Display *xdisplay; @@ -409,7 +400,7 @@ gdk_property_get (GdkWindow *window, guchar *ret_data; Atom xproperty; Atom xtype; - + g_return_val_if_fail (!window || GDK_IS_WINDOW (window), FALSE); @@ -423,8 +414,8 @@ gdk_property_get (GdkWindow *window, } else { - g_warning("gdk_property_get no GdkWindow defined\n"); - return FALSE; + g_warning ("gdk_property_get no GdkWindow defined\n"); + return FALSE; } ret_data = NULL; @@ -434,12 +425,12 @@ gdk_property_get (GdkWindow *window, XGetWindowProperty (xdisplay, xwindow, xproperty, offset, (length + 3) / 4, pdelete, xtype, &ret_prop_type, &ret_format, - &ret_nitems, &ret_bytes_after, - &ret_data); + &ret_nitems, &ret_bytes_after, &ret_data); - if ((ret_prop_type == None) && (ret_format == 0)) { - return FALSE; - } + if ((ret_prop_type == None) && (ret_format == 0)) + { + return FALSE; + } if (actual_property_type) *actual_property_type = gdk_x11_get_virtual_atom (display, ret_prop_type); @@ -451,12 +442,15 @@ gdk_property_get (GdkWindow *window, gchar *rn, *pn; XFree (ret_data); - rn = gdk_x11_get_real_atom_name (GDK_WINDOW_DISPLAY(window), ret_prop_type); + rn = + gdk_x11_get_real_atom_name (GDK_WINDOW_DISPLAY (window), + ret_prop_type); - pn = gdk_x11_get_real_atom_name (GDK_WINDOW_DISPLAY(window), type); + pn = gdk_x11_get_real_atom_name (GDK_WINDOW_DISPLAY (window), type); g_warning ("Couldn't match property type %s to %s\n", rn, pn); - g_free (rn); g_free (pn); + g_free (rn); + g_free (pn); return FALSE; } @@ -470,10 +464,10 @@ gdk_property_get (GdkWindow *window, ret_length = ret_nitems; break; case 16: - ret_length = sizeof(short) * ret_nitems; + ret_length = sizeof (short) * ret_nitems; break; case 32: - ret_length = sizeof(long) * ret_nitems; + ret_length = sizeof (long) * ret_nitems; break; default: g_warning ("unknown property return format: %d", ret_format); @@ -493,13 +487,11 @@ gdk_property_get (GdkWindow *window, } void -gdk_property_change (GdkWindow *window, - GdkAtom property, - GdkAtom type, - gint format, - GdkPropMode mode, - const guchar *data, - gint nelements) +gdk_property_change (GdkWindow * window, + GdkAtom property, + GdkAtom type, + gint format, + GdkPropMode mode, const guchar * data, gint nelements) { GdkDisplay *display; Display *xdisplay; @@ -519,19 +511,18 @@ gdk_property_change (GdkWindow *window, } else { - g_warning("gdk_property_change no GdkWindow defined\n"); + g_warning ("gdk_property_change no GdkWindow defined\n"); return; } display = GDK_WINDOW_DISPLAY (window); xproperty = gdk_x11_get_real_atom (display, property, FALSE); xtype = gdk_x11_get_real_atom (display, type, FALSE); XChangeProperty (xdisplay, xwindow, xproperty, xtype, - format, mode, (guchar *)data, nelements); + format, mode, (guchar *) data, nelements); } void -gdk_property_delete (GdkWindow *window, - GdkAtom property) +gdk_property_delete (GdkWindow * window, GdkAtom property) { Display *xdisplay; Window xwindow; @@ -545,11 +536,10 @@ gdk_property_delete (GdkWindow *window, xdisplay = GDK_WINDOW_XDISPLAY (window); xwindow = GDK_WINDOW_XID (window); - XDeleteProperty (xdisplay, + XDeleteProperty (xdisplay, xwindow, - gdk_x11_get_real_atom (GDK_WINDOW_DISPLAY (window), - property, - FALSE)); + gdk_x11_get_real_atom (GDK_WINDOW_DISPLAY (window), + property, FALSE)); } } diff --git a/gdk/x11/gdkscreen-x11.c b/gdk/x11/gdkscreen-x11.c index 3b9cc5788b..7b42d627c9 100644 --- a/gdk/x11/gdkscreen-x11.c +++ b/gdk/x11/gdkscreen-x11.c @@ -119,6 +119,7 @@ static GdkWindow * gdk_X11_screen_get_root_window (GdkScreen * screen) { GdkScreenImplX11 *scr_impl = GDK_SCREEN_IMPL_X11 (screen); + gdk_drawable_ref(GDK_DRAWABLE(scr_impl->root_window)); return scr_impl->root_window; } diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index 97e649b082..8284defb99 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -2036,14 +2036,18 @@ gdk_window_get_pointer (GdkWindow *window, unsigned int xmask = 0; gint xoffset, yoffset; - g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL); - if (!window) { GDK_NOTE (MULTIHEAD, g_message("window arg is need for multihead safe operation\n")); window = GDK_SCREEN_IMPL_X11 (gdk_get_default_screen())->root_window; } + if (!GDK_IS_WINDOW (window)) + { + g_print ("no a window\n"); + } + + g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL); _gdk_windowing_window_get_offsets (window, &xoffset, &yoffset); diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c index e44d8c4c1e..ad37fd3710 100644 --- a/gtk/gtkdnd.c +++ b/gtk/gtkdnd.c @@ -2798,7 +2798,7 @@ gtk_drag_end (GtkDragSourceInfo *info, guint32 time) { GdkEvent send_event; GtkWidget *source_widget = info->widget; - GdkWindow *root_window = gdk_screen_get_root_window (source_widget); + GdkWindow *root_window = gdk_screen_get_root_window (gtk_widget_get_screen (source_widget)); gdk_display_pointer_ungrab (gtk_widget_get_display (source_widget), time); diff --git a/gtk/gtkselection.c b/gtk/gtkselection.c index afea7262a6..411b2e4e8d 100644 --- a/gtk/gtkselection.c +++ b/gtk/gtkselection.c @@ -75,7 +75,7 @@ #include "gdkdisplay.h" #include "gdkscreen.h" -#define DEBUG_SELECTION +/*#define DEBUG_SELECTION */ /* Maximum size of a sent chunk, in bytes. Also the default size of our buffers */ diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index f1c8e686f7..282914382a 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -3048,7 +3048,11 @@ gtk_window_compute_reposition (GtkWindow *window, gint screen_width = gdk_screen_get_width (gtk_widget_get_screen (widget)); gint screen_height = gdk_screen_get_height (gtk_widget_get_screen (widget)); - gdk_window_get_pointer (window, x, y, NULL); + gdk_window_get_pointer ( + gdk_screen_get_root_window (gtk_widget_get_screen(widget)), + x, + y, + NULL); *x -= new_width / 2; *y -= new_height / 2; *x = CLAMP (*x, 0, screen_width - new_width);