diff options
author | Matthias Clasen <mclasen@redhat.com> | 2010-12-15 01:39:30 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2010-12-21 12:06:59 -0500 |
commit | 2d7583c0e32168a89168a1fbc40155122db1bfe9 (patch) | |
tree | 9ac82c91881a44de2b2a72046f452781bf86588f | |
parent | 39a71b8831988f29da763ccc71f2a45e01a212ae (diff) | |
download | gtk+-2d7583c0e32168a89168a1fbc40155122db1bfe9.tar.gz |
Make gdk_window_{lookup,foreign_new}_for_display backend specific
At the same time, make GDK_IS_DISPLAY_X11 available in gdkx.h, and
add some exemplaric ifdefs to GTK+ code.
-rw-r--r-- | docs/reference/gdk/gdk3-sections.txt | 6 | ||||
-rw-r--r-- | docs/tools/shooter.c | 2 | ||||
-rw-r--r-- | gdk/gdk.symbols | 6 | ||||
-rw-r--r-- | gdk/gdkwindow.c | 37 | ||||
-rw-r--r-- | gdk/gdkwindow.h | 13 | ||||
-rw-r--r-- | gdk/x11/gdkdevice-core.c | 8 | ||||
-rw-r--r-- | gdk/x11/gdkdevice-xi2.c | 8 | ||||
-rw-r--r-- | gdk/x11/gdkdevicemanager-core.c | 6 | ||||
-rw-r--r-- | gdk/x11/gdkdevicemanager-xi.c | 4 | ||||
-rw-r--r-- | gdk/x11/gdkdevicemanager-xi2.c | 6 | ||||
-rw-r--r-- | gdk/x11/gdkdisplay-x11.c | 2 | ||||
-rw-r--r-- | gdk/x11/gdkdisplay-x11.h | 1 | ||||
-rw-r--r-- | gdk/x11/gdkdnd-x11.c | 18 | ||||
-rw-r--r-- | gdk/x11/gdkeventsource.c | 2 | ||||
-rw-r--r-- | gdk/x11/gdkscreen-x11.c | 12 | ||||
-rw-r--r-- | gdk/x11/gdkselection-x11.c | 2 | ||||
-rw-r--r-- | gdk/x11/gdkwindow-x11.c | 152 | ||||
-rw-r--r-- | gdk/x11/gdkx.h | 6 | ||||
-rw-r--r-- | gtk/gtkplug-x11.c | 4 | ||||
-rw-r--r-- | gtk/gtkplug.c | 17 | ||||
-rw-r--r-- | gtk/gtkselection.c | 20 | ||||
-rw-r--r-- | gtk/gtksocket.c | 52 | ||||
-rw-r--r-- | gtk/gtktrayicon-x11.c | 14 |
23 files changed, 185 insertions, 213 deletions
diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt index 1a1db3bf3f..02a3608ca0 100644 --- a/docs/reference/gdk/gdk3-sections.txt +++ b/docs/reference/gdk/gdk3-sections.txt @@ -954,12 +954,10 @@ GDK_SCREEN_XSCREEN GDK_CURSOR_XCURSOR GDK_CURSOR_XDISPLAY gdkx_visual_get -gdk_window_foreign_new -gdk_window_foreign_new_for_display +gdk_x11_window_foreign_new_for_display gdk_xid_table_lookup gdk_xid_table_lookup_for_display -gdk_window_lookup -gdk_window_lookup_for_display +gdk_x11_window_lookup_for_display gdk_x11_lookup_xdisplay gdk_x11_get_server_time gdk_net_wm_supports diff --git a/docs/tools/shooter.c b/docs/tools/shooter.c index f9492f62e1..fa7e8459c2 100644 --- a/docs/tools/shooter.c +++ b/docs/tools/shooter.c @@ -138,7 +138,7 @@ take_window_shot (Window child, else xid = child; - window = gdk_window_foreign_new (xid); + window = gdk_x11_window_foreign_new_for_display (gdk_display_get_default (), xid); width = gdk_window_get_width (window); height = gdk_window_get_height (window); diff --git a/gdk/gdk.symbols b/gdk/gdk.symbols index 6093cc44b6..ac826df829 100644 --- a/gdk/gdk.symbols +++ b/gdk/gdk.symbols @@ -403,8 +403,6 @@ gdk_window_end_paint gdk_window_ensure_native gdk_window_flush gdk_window_focus -gdk_window_foreign_new -gdk_window_foreign_new_for_display gdk_window_freeze_toplevel_updates_libgtk_only gdk_window_freeze_updates gdk_window_fullscreen @@ -463,8 +461,6 @@ gdk_window_is_input_only gdk_window_is_shaped gdk_window_is_viewable gdk_window_is_visible -gdk_window_lookup -gdk_window_lookup_for_display gdk_window_lower gdk_window_maximize gdk_window_merge_child_input_shapes @@ -569,6 +565,8 @@ gdk_x11_screen_supports_net_wm_hint gdk_x11_set_sm_client_id gdk_x11_ungrab_server gdk_x11_visual_get_xvisual +gdk_x11_window_foreign_new_for_display +gdk_x11_window_lookup_for_display gdk_x11_window_get_xid gdk_x11_window_move_to_current_desktop gdk_x11_window_set_user_time diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index 215bc5a80c..d0deb91f1a 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -5058,25 +5058,6 @@ gdk_get_default_root_window (void) return gdk_screen_get_root_window (gdk_screen_get_default ()); } -/** - * gdk_window_foreign_new: - * @anid: a native window handle. - * - * Wraps a native window for the default display in a #GdkWindow. - * This may fail if the window has been destroyed. - * - * For example in the X backend, a native window handle is an Xlib - * <type>XID</type>. - * - * Return value: (transfer full): the newly-created #GdkWindow wrapper - * for the native window, or %NULL if the window has been destroyed. - **/ -GdkWindow * -gdk_window_foreign_new (GdkNativeWindow anid) -{ - return gdk_window_foreign_new_for_display (gdk_display_get_default (), anid); -} - static void get_all_native_children (GdkWindow *window, GList **native) @@ -10745,21 +10726,3 @@ gdk_drag_begin_for_device (GdkWindow *window, { return GDK_WINDOW_IMPL_GET_CLASS (window->impl)->drag_begin (window, device, targets); } - -/** - * gdk_window_lookup: - * @anid: a native window handle - * - * Looks up the #GdkWindow that wraps the given native window handle. - * - * For example in the X backend, a native window handle is an Xlib - * <type>XID</type>. - * - * Return value: (transfer none): the #GdkWindow wrapper for the native - * window, or %NULL if there is none. - **/ -GdkWindow * -gdk_window_lookup (GdkNativeWindow anid) -{ - return gdk_window_lookup_for_display (gdk_display_get_default (), anid); -} diff --git a/gdk/gdkwindow.h b/gdk/gdkwindow.h index f7ac2a5ded..582a9bf6d5 100644 --- a/gdk/gdkwindow.h +++ b/gdk/gdkwindow.h @@ -642,18 +642,7 @@ GdkWindowState gdk_window_get_state (GdkWindow *window); * window gravity on all children. */ gboolean gdk_window_set_static_gravities (GdkWindow *window, - gboolean use_static); - -/* Functions to create/lookup windows from their native equivalents */ -#ifndef GDK_MULTIHEAD_SAFE -GdkWindow* gdk_window_foreign_new (GdkNativeWindow anid); -GdkWindow* gdk_window_lookup (GdkNativeWindow anid); -#endif -GdkWindow *gdk_window_foreign_new_for_display (GdkDisplay *display, - GdkNativeWindow anid); -GdkWindow* gdk_window_lookup_for_display (GdkDisplay *display, - GdkNativeWindow anid); - + gboolean use_static); /* GdkWindow */ diff --git a/gdk/x11/gdkdevice-core.c b/gdk/x11/gdkdevice-core.c index ff0d456e4c..7e4613b557 100644 --- a/gdk/x11/gdkdevice-core.c +++ b/gdk/x11/gdkdevice-core.c @@ -289,10 +289,10 @@ gdk_device_core_query_state (GdkDevice *device, } if (root_window) - *root_window = gdk_window_lookup_for_display (display, xroot_window); + *root_window = gdk_x11_window_lookup_for_display (display, xroot_window); if (child_window) - *child_window = gdk_window_lookup_for_display (display, xchild_window); + *child_window = gdk_x11_window_lookup_for_display (display, xchild_window); if (root_x) *root_x = xroot_x; @@ -529,7 +529,7 @@ gdk_device_core_window_at_position (GdkDevice *device, break; if (get_toplevel && last != root && - (window = gdk_window_lookup_for_display (display, last)) != NULL && + (window = gdk_x11_window_lookup_for_display (display, last)) != NULL && window->window_type != GDK_WINDOW_FOREIGN) { xwindow = last; @@ -539,7 +539,7 @@ gdk_device_core_window_at_position (GdkDevice *device, gdk_x11_display_ungrab (display); - window = gdk_window_lookup_for_display (display, last); + window = gdk_x11_window_lookup_for_display (display, last); if (win_x) *win_x = (window) ? xwin_x : -1; diff --git a/gdk/x11/gdkdevice-xi2.c b/gdk/x11/gdkdevice-xi2.c index 522eda90df..0af7a7edc0 100644 --- a/gdk/x11/gdkdevice-xi2.c +++ b/gdk/x11/gdkdevice-xi2.c @@ -357,10 +357,10 @@ gdk_device_xi2_query_state (GdkDevice *device, } if (root_window) - *root_window = gdk_window_lookup_for_display (display, xroot_window); + *root_window = gdk_x11_window_lookup_for_display (display, xroot_window); if (child_window) - *child_window = gdk_window_lookup_for_display (display, xchild_window); + *child_window = gdk_x11_window_lookup_for_display (display, xchild_window); if (root_x) *root_x = (gint) xroot_x; @@ -590,7 +590,7 @@ gdk_device_xi2_window_at_position (GdkDevice *device, break; if (get_toplevel && last != root && - (window = gdk_window_lookup_for_display (display, last)) != NULL && + (window = gdk_x11_window_lookup_for_display (display, last)) != NULL && GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN) { xwindow = last; @@ -600,7 +600,7 @@ gdk_device_xi2_window_at_position (GdkDevice *device, gdk_x11_display_ungrab (display); - window = gdk_window_lookup_for_display (display, last); + window = gdk_x11_window_lookup_for_display (display, last); if (win_x) *win_x = (window) ? (gint) xwin_x : -1; diff --git a/gdk/x11/gdkdevicemanager-core.c b/gdk/x11/gdkdevicemanager-core.c index 7163aa2a4e..b368614f26 100644 --- a/gdk/x11/gdkdevicemanager-core.c +++ b/gdk/x11/gdkdevicemanager-core.c @@ -384,7 +384,7 @@ get_event_window (GdkEventTranslator *translator, device_manager = GDK_DEVICE_MANAGER (translator); display = gdk_device_manager_get_display (device_manager); - window = gdk_window_lookup_for_display (display, xevent->xany.window); + window = gdk_x11_window_lookup_for_display (display, xevent->xany.window); /* Apply keyboard grabs to non-native windows */ if (xevent->type == KeyPress || xevent->type == KeyRelease) @@ -680,7 +680,7 @@ gdk_device_manager_core_translate_event (GdkEventTranslator *translator, * lookup the corresponding GdkWindow. */ if (xevent->xcrossing.subwindow != None) - event->crossing.subwindow = gdk_window_lookup_for_display (display, xevent->xcrossing.subwindow); + event->crossing.subwindow = gdk_x11_window_lookup_for_display (display, xevent->xcrossing.subwindow); else event->crossing.subwindow = NULL; @@ -724,7 +724,7 @@ gdk_device_manager_core_translate_event (GdkEventTranslator *translator, * lookup the corresponding GdkWindow. */ if (xevent->xcrossing.subwindow != None) - event->crossing.subwindow = gdk_window_lookup_for_display (display, xevent->xcrossing.subwindow); + event->crossing.subwindow = gdk_x11_window_lookup_for_display (display, xevent->xcrossing.subwindow); else event->crossing.subwindow = NULL; diff --git a/gdk/x11/gdkdevicemanager-xi.c b/gdk/x11/gdkdevicemanager-xi.c index 6d65725fad..9d8c5bcf6f 100644 --- a/gdk/x11/gdkdevicemanager-xi.c +++ b/gdk/x11/gdkdevicemanager-xi.c @@ -104,7 +104,7 @@ window_input_info_filter (GdkXEvent *xevent, xev = (XEvent *) xevent; display = gdk_device_manager_get_display (device_manager); - window = gdk_window_lookup_for_display (display, xev->xany.window); + window = gdk_x11_window_lookup_for_display (display, xev->xany.window); if (window && xev->type == ConfigureNotify) gdk_device_xi_update_window_info (window); @@ -421,7 +421,7 @@ gdk_device_manager_xi_translate_event (GdkEventTranslator *translator, if (!device) return FALSE; - window = gdk_window_lookup_for_display (display, xevent->xany.window); + window = gdk_x11_window_lookup_for_display (display, xevent->xany.window); if (!window) return FALSE; diff --git a/gdk/x11/gdkdevicemanager-xi2.c b/gdk/x11/gdkdevicemanager-xi2.c index f692ff5549..177926a7a5 100644 --- a/gdk/x11/gdkdevicemanager-xi2.c +++ b/gdk/x11/gdkdevicemanager-xi2.c @@ -894,7 +894,7 @@ get_event_window (GdkEventTranslator *translator, { XIDeviceEvent *xev = (XIDeviceEvent *) ev; - window = gdk_window_lookup_for_display (display, xev->event); + window = gdk_x11_window_lookup_for_display (display, xev->event); /* Apply keyboard grabs to non-native windows */ if (ev->evtype == XI_KeyPress || ev->evtype == XI_KeyRelease) @@ -926,7 +926,7 @@ get_event_window (GdkEventTranslator *translator, { XIEnterEvent *xev = (XIEnterEvent *) ev; - window = gdk_window_lookup_for_display (display, xev->event); + window = gdk_x11_window_lookup_for_display (display, xev->event); } break; } @@ -1188,7 +1188,7 @@ gdk_device_manager_xi2_translate_event (GdkEventTranslator *translator, event->crossing.focus = xev->focus; event->crossing.window = window; - event->crossing.subwindow = gdk_window_lookup_for_display (display, xev->child); + event->crossing.subwindow = gdk_x11_window_lookup_for_display (display, xev->child); device = g_hash_table_lookup (device_manager->id_table, GINT_TO_POINTER (xev->deviceid)); diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c index 113d61fe7a..8dfb40aaf4 100644 --- a/gdk/x11/gdkdisplay-x11.c +++ b/gdk/x11/gdkdisplay-x11.c @@ -368,7 +368,7 @@ get_event_window (GdkEventTranslator *translator, xwindow = xevent->xany.window; } - return gdk_window_lookup_for_display (display, xwindow); + return gdk_x11_window_lookup_for_display (display, xwindow); } static gboolean diff --git a/gdk/x11/gdkdisplay-x11.h b/gdk/x11/gdkdisplay-x11.h index 3f345de8dd..f682ca4830 100644 --- a/gdk/x11/gdkdisplay-x11.h +++ b/gdk/x11/gdkdisplay-x11.h @@ -41,7 +41,6 @@ typedef struct _GdkDisplayX11Class GdkDisplayX11Class; #define GDK_TYPE_DISPLAY_X11 (_gdk_display_x11_get_type()) #define GDK_DISPLAY_X11(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_DISPLAY_X11, GdkDisplayX11)) #define GDK_DISPLAY_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_DISPLAY_X11, GdkDisplayX11Class)) -#define GDK_IS_DISPLAY_X11(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_DISPLAY_X11)) #define GDK_IS_DISPLAY_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_DISPLAY_X11)) #define GDK_DISPLAY_X11_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_DISPLAY_X11, GdkDisplayX11Class)) diff --git a/gdk/x11/gdkdnd-x11.c b/gdk/x11/gdkdnd-x11.c index ae8d2b8e50..0cba36a2fd 100644 --- a/gdk/x11/gdkdnd-x11.c +++ b/gdk/x11/gdkdnd-x11.c @@ -988,8 +988,8 @@ motif_find_drag_window (GdkDisplay *display, */ if (display_x11->motif_drag_window) { - display_x11->motif_drag_gdk_window = - gdk_window_foreign_new_for_display (display, display_x11->motif_drag_window); + display_x11->motif_drag_gdk_window = + gdk_x11_window_foreign_new_for_display (display, display_x11->motif_drag_window); gdk_window_add_filter (display_x11->motif_drag_gdk_window, motif_drag_window_filter, NULL); @@ -1668,12 +1668,12 @@ motif_drag_context_new (GdkWindow *dest_window, context->protocol = GDK_DRAG_PROTO_MOTIF; context->is_source = FALSE; - context->source_window = gdk_window_lookup_for_display (display, source_window); + context->source_window = gdk_x11_window_lookup_for_display (display, source_window); if (context->source_window) g_object_ref (context->source_window); else { - context->source_window = gdk_window_foreign_new_for_display (display, source_window); + context->source_window = gdk_x11_window_foreign_new_for_display (display, source_window); if (!context->source_window) { g_object_unref (context_x11); @@ -2843,12 +2843,12 @@ xdnd_enter_filter (GdkXEvent *xev, device_manager = gdk_display_get_device_manager (display); gdk_drag_context_set_device (context, gdk_device_manager_get_client_pointer (device_manager)); - context->source_window = gdk_window_lookup_for_display (display, source_window); + context->source_window = gdk_x11_window_lookup_for_display (display, source_window); if (context->source_window) g_object_ref (context->source_window); else { - context->source_window = gdk_window_foreign_new_for_display (display, source_window); + context->source_window = gdk_x11_window_foreign_new_for_display (display, source_window); if (!context->source_window) { g_object_unref (context); @@ -3158,7 +3158,7 @@ _gdk_x11_display_get_drag_protocol (GdkDisplay *display, base_precache_atoms (display); /* Check for a local drag */ - window = gdk_window_lookup_for_display (display, xid); + window = gdk_x11_window_lookup_for_display (display, xid); if (window && gdk_window_get_window_type (window) != GDK_WINDOW_FOREIGN) { if (g_object_get_data (G_OBJECT (window), "gdk-dnd-registered") != NULL) @@ -3273,11 +3273,11 @@ gdk_drag_context_x11_find_window (GdkDragContext *context, if (recipient != None) { - dest_window = gdk_window_lookup_for_display (display, recipient); + dest_window = gdk_x11_window_lookup_for_display (display, recipient); if (dest_window) g_object_ref (dest_window); else - dest_window = gdk_window_foreign_new_for_display (display, recipient); + dest_window = gdk_x11_window_foreign_new_for_display (display, recipient); } else dest_window = NULL; diff --git a/gdk/x11/gdkeventsource.c b/gdk/x11/gdkeventsource.c index 21552dbc97..d21097ad16 100644 --- a/gdk/x11/gdkeventsource.c +++ b/gdk/x11/gdkeventsource.c @@ -101,7 +101,7 @@ gdk_event_source_get_filter_window (GdkEventSource *event_source, { GdkWindow *window; - window = gdk_window_lookup_for_display (event_source->display, + window = gdk_x11_window_lookup_for_display (event_source->display, xevent->xany.window); if (window && !GDK_IS_WINDOW (window)) diff --git a/gdk/x11/gdkscreen-x11.c b/gdk/x11/gdkscreen-x11.c index 95cfecbee9..8ff085960d 100644 --- a/gdk/x11/gdkscreen-x11.c +++ b/gdk/x11/gdkscreen-x11.c @@ -1023,8 +1023,8 @@ gdk_screen_x11_get_active_window (GdkScreen *screen) if (window != None) { - ret = gdk_window_foreign_new_for_display (screen_x11->display, - *(GdkNativeWindow *) data); + ret = gdk_x11_window_foreign_new_for_display (screen_x11->display, + *(Window *) data); } } } @@ -1071,8 +1071,8 @@ gdk_screen_x11_get_window_stack (GdkScreen *screen) for (i = 0; i < nitems_return; i++) { - win = gdk_window_foreign_new_for_display (screen_x11->display, - (GdkNativeWindow)stack[i]); + win = gdk_x11_window_foreign_new_for_display (screen_x11->display, + (Window)stack[i]); if (win != NULL) ret = g_list_append (ret, win); @@ -1507,7 +1507,7 @@ gdk_xsettings_watch_cb (Window window, GdkWindow *gdkwin; GdkScreen *screen = cb_data; - gdkwin = gdk_window_lookup_for_display (gdk_screen_get_display (screen), window); + gdkwin = gdk_x11_window_lookup_for_display (gdk_screen_get_display (screen), window); if (is_start) { @@ -1515,7 +1515,7 @@ gdk_xsettings_watch_cb (Window window, g_object_ref (gdkwin); else { - gdkwin = gdk_window_foreign_new_for_display (gdk_screen_get_display (screen), window); + gdkwin = gdk_x11_window_foreign_new_for_display (gdk_screen_get_display (screen), window); /* gdk_window_foreign_new_for_display() can fail and return NULL if the * window has already been destroyed. diff --git a/gdk/x11/gdkselection-x11.c b/gdk/x11/gdkselection-x11.c index 74d17c4f4d..49cdf3a018 100644 --- a/gdk/x11/gdkselection-x11.c +++ b/gdk/x11/gdkselection-x11.c @@ -221,7 +221,7 @@ gdk_selection_owner_get_for_display (GdkDisplay *display, if (xwindow == None) return NULL; - return gdk_window_lookup_for_display (display, xwindow); + return gdk_x11_window_lookup_for_display (display, xwindow); } void diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index 287a5bccfc..e7af2aa0ad 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -848,30 +848,28 @@ x_event_mask_to_gdk_event_mask (long mask) } /** - * gdk_window_foreign_new_for_display: + * gdk_x11_window_foreign_new_for_display: * @display: the #GdkDisplay where the window handle comes from. - * @anid: a native window handle. - * + * @window: an XLib <type>Window</type> + * * Wraps a native window in a #GdkWindow. + * * This may fail if the window has been destroyed. If the window - * was already known to GDK, a new reference to the existing + * was already known to GDK, a new reference to the existing * #GdkWindow is returned. * - * For example in the X backend, a native window handle is an Xlib - * <type>XID</type>. - * * Return value: (transfer full): a #GdkWindow wrapper for the native * window, or %NULL if the window has been destroyed. The wrapper * will be newly created, if one doesn't exist already. * - * Since: 2.2 - **/ + * Since: 3.0 + */ GdkWindow * -gdk_window_foreign_new_for_display (GdkDisplay *display, - GdkNativeWindow anid) +gdk_x11_window_foreign_new_for_display (GdkDisplay *display, + Window window) { GdkScreen *screen; - GdkWindow *window; + GdkWindow *win; GdkWindowImplX11 *impl; GdkDisplayX11 *display_x11; XWindowAttributes attrs; @@ -884,90 +882,88 @@ gdk_window_foreign_new_for_display (GdkDisplay *display, display_x11 = GDK_DISPLAY_X11 (display); - if ((window = gdk_xid_table_lookup_for_display (display, anid)) != NULL) - return g_object_ref (window); + if ((win = gdk_xid_table_lookup_for_display (display, window)) != NULL) + return g_object_ref (win); - gdk_error_trap_push (); - result = XGetWindowAttributes (display_x11->xdisplay, anid, &attrs); - if (gdk_error_trap_pop () || !result) + gdk_x11_display_error_trap_push (display); + result = XGetWindowAttributes (display_x11->xdisplay, window, &attrs); + if (gdk_x11_display_error_trap_pop (display) || !result) return NULL; - /* FIXME: This is pretty expensive. Maybe the caller should supply - * the parent */ - gdk_error_trap_push (); - result = XQueryTree (display_x11->xdisplay, anid, &root, &parent, &children, &nchildren); - if (gdk_error_trap_pop () || !result) + /* FIXME: This is pretty expensive. + * Maybe the caller should supply the parent + */ + gdk_x11_display_error_trap_push (display); + result = XQueryTree (display_x11->xdisplay, window, &root, &parent, &children, &nchildren); + if (gdk_x11_display_error_trap_pop (display) || !result) return NULL; if (children) XFree (children); - + screen = _gdk_x11_display_screen_for_xrootwin (display, root); - window = g_object_new (GDK_TYPE_WINDOW, NULL); + win = g_object_new (GDK_TYPE_WINDOW, NULL); + win->impl = g_object_new (GDK_TYPE_WINDOW_IMPL_X11, NULL); + win->impl_window = win; + win->visual = gdk_x11_screen_lookup_visual (screen, + XVisualIDFromVisual (attrs.visual)); - window->impl = g_object_new (GDK_TYPE_WINDOW_IMPL_X11, NULL); - window->impl_window = window; - window->visual = gdk_x11_screen_lookup_visual (screen, - XVisualIDFromVisual (attrs.visual)); + impl = GDK_WINDOW_IMPL_X11 (win->impl); + impl->wrapper = win; - impl = GDK_WINDOW_IMPL_X11 (window->impl); - impl->wrapper = window; - - window->parent = gdk_xid_table_lookup_for_display (display, parent); - - if (!window->parent || GDK_WINDOW_TYPE (window->parent) == GDK_WINDOW_FOREIGN) - window->parent = gdk_screen_get_root_window (screen); - - window->parent->children = g_list_prepend (window->parent->children, window); + win->parent = gdk_xid_table_lookup_for_display (display, parent); + + if (!win->parent || GDK_WINDOW_TYPE (win->parent) == GDK_WINDOW_FOREIGN) + win->parent = gdk_screen_get_root_window (screen); - impl->xid = anid; + win->parent->children = g_list_prepend (win->parent->children, win); - window->x = attrs.x; - window->y = attrs.y; - window->width = attrs.width; - window->height = attrs.height; - window->window_type = GDK_WINDOW_FOREIGN; - window->destroyed = FALSE; + impl->xid = window; - window->event_mask = x_event_mask_to_gdk_event_mask (attrs.your_event_mask); + win->x = attrs.x; + win->y = attrs.y; + win->width = attrs.width; + win->height = attrs.height; + win->window_type = GDK_WINDOW_FOREIGN; + win->destroyed = FALSE; + + win->event_mask = x_event_mask_to_gdk_event_mask (attrs.your_event_mask); if (attrs.map_state == IsUnmapped) - window->state = GDK_WINDOW_STATE_WITHDRAWN; + win->state = GDK_WINDOW_STATE_WITHDRAWN; else - window->state = 0; - window->viewable = TRUE; + win->state = 0; + win->viewable = TRUE; - window->depth = attrs.depth; - - g_object_ref (window); - _gdk_xid_table_insert (display, &GDK_WINDOW_XID (window), window); + win->depth = attrs.depth; + + g_object_ref (win); + _gdk_xid_table_insert (display, &GDK_WINDOW_XID (win), win); /* Update the clip region, etc */ - _gdk_window_update_size (window); + _gdk_window_update_size (win); - return window; + return win; } /** - * gdk_window_lookup_for_display: + * gdk_x11_window_lookup_for_display: * @display: the #GdkDisplay corresponding to the window handle - * @anid: a native window handle. + * @window: an XLib <type>Window</type> * * Looks up the #GdkWindow that wraps the given native window handle. * - * For example in the X backend, a native window handle is an Xlib - * <type>XID</type>. - * * Return value: (transfer none): the #GdkWindow wrapper for the native * window, or %NULL if there is none. * - * Since: 2.2 - **/ + * Since: 3.0 + */ GdkWindow * -gdk_window_lookup_for_display (GdkDisplay *display, GdkNativeWindow anid) +gdk_x11_window_lookup_for_display (GdkDisplay *display, + Window window) { - return (GdkWindow*) gdk_xid_table_lookup_for_display (display, anid); + return (GdkWindow*) gdk_xid_table_lookup_for_display (display, window); } static void @@ -1008,11 +1004,11 @@ gdk_x11_window_destroy (GdkWindow *window, { GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); GdkToplevelX11 *toplevel; - + g_return_if_fail (GDK_IS_WINDOW (window)); _gdk_selection_window_destroyed (window); - + toplevel = _gdk_x11_window_get_toplevel (window); if (toplevel) gdk_toplevel_x11_free_contents (GDK_WINDOW_DISPLAY (window), toplevel); @@ -1021,13 +1017,11 @@ gdk_x11_window_destroy (GdkWindow *window, { cairo_surface_finish (impl->cairo_surface); cairo_surface_set_user_data (impl->cairo_surface, &gdk_x11_cairo_key, - NULL, NULL); + NULL, NULL); } if (!recursing && !foreign_destroy) - { - XDestroyWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window)); - } + XDestroyWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window)); } static cairo_surface_t * @@ -1049,28 +1043,28 @@ gdk_x11_window_destroy_foreign (GdkWindow *window) * it a delete event, as if we were a WM */ XClientMessageEvent xclient; - - gdk_error_trap_push (); + GdkDisplay *display; + + display = GDK_WINDOW_DISPLAY (window); + gdk_x11_display_error_trap_push (display); gdk_window_hide (window); gdk_window_reparent (window, NULL, 0, 0); - + memset (&xclient, 0, sizeof (xclient)); xclient.type = ClientMessage; xclient.window = GDK_WINDOW_XID (window); - xclient.message_type = gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window), - "WM_PROTOCOLS"); + xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "WM_PROTOCOLS"); xclient.format = 32; - xclient.data.l[0] = gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window), - "WM_DELETE_WINDOW"); + xclient.data.l[0] = gdk_x11_get_xatom_by_name_for_display (display, "WM_DELETE_WINDOW"); xclient.data.l[1] = CurrentTime; xclient.data.l[2] = 0; xclient.data.l[3] = 0; xclient.data.l[4] = 0; XSendEvent (GDK_WINDOW_XDISPLAY (window), - GDK_WINDOW_XID (window), - False, 0, (XEvent *)&xclient); - gdk_error_trap_pop_ignored (); + GDK_WINDOW_XID (window), + False, 0, (XEvent *)&xclient); + gdk_x11_display_error_trap_pop_ignored (display); } static GdkWindow * diff --git a/gdk/x11/gdkx.h b/gdk/x11/gdkx.h index 7e5dd1b574..15b5e50d1e 100644 --- a/gdk/x11/gdkx.h +++ b/gdk/x11/gdkx.h @@ -95,6 +95,7 @@ gint gdk_x11_get_default_screen (void); */ #define GDK_CURSOR_XCURSOR(cursor) (gdk_x11_cursor_get_xcursor (cursor)) +#define GDK_IS_DISPLAY_X11(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), g_type_from_name ("GdkDisplayX11"))) #ifdef GDK_COMPILATION @@ -250,6 +251,11 @@ void gdk_x11_register_standard_event_type (GdkDisplay *display, void gdk_x11_set_sm_client_id (const gchar *sm_client_id); +GdkWindow *gdk_x11_window_foreign_new_for_display (GdkDisplay *display, + Window window); +GdkWindow *gdk_x11_window_lookup_for_display (GdkDisplay *display, + Window window); + G_END_DECLS #endif /* __GDK_X_H__ */ diff --git a/gtk/gtkplug-x11.c b/gtk/gtkplug-x11.c index 827474b50e..46b2b7cb48 100644 --- a/gtk/gtkplug-x11.c +++ b/gtk/gtkplug-x11.c @@ -316,7 +316,7 @@ _gtk_plug_windowing_filter_func (GdkXEvent *gdk_xevent, GTK_NOTE (PLUGSOCKET, g_message ("GtkPlug: start of embedding")); - priv->socket_window = gdk_window_lookup_for_display (display, xre->parent); + priv->socket_window = gdk_x11_window_lookup_for_display (display, xre->parent); if (priv->socket_window) { gpointer user_data = NULL; @@ -333,7 +333,7 @@ _gtk_plug_windowing_filter_func (GdkXEvent *gdk_xevent, } else { - priv->socket_window = gdk_window_foreign_new_for_display (display, xre->parent); + priv->socket_window = gdk_x11_window_foreign_new_for_display (display, xre->parent); if (!priv->socket_window) /* Already gone */ break; /* FIXME: shouldn't this unref the plug? i.e. "goto done;" instead */ } diff --git a/gtk/gtkplug.c b/gtk/gtkplug.c index 65326d97f6..4c0e8258bb 100644 --- a/gtk/gtkplug.c +++ b/gtk/gtkplug.c @@ -37,6 +37,10 @@ #include "gtkwidgetprivate.h" #include "gtkwindowprivate.h" +#ifdef GDK_WINDOWING_X11 +#include "x11/gdkx.h" +#endif + /** * SECTION:gtkplug * @Short_description: Toplevel for embedding into other processes @@ -513,7 +517,13 @@ gtk_plug_construct_for_display (GtkPlug *plug, { gpointer user_data = NULL; - priv->socket_window = gdk_window_lookup_for_display (display, socket_id); +#ifdef GDK_WINDOWING_X11 + if (GDK_IS_DISPLAY_X11 (display)) + priv->socket_window = gdk_x11_window_lookup_for_display (display, socket_id); + else +#endif + priv->socket_window = NULL; + if (priv->socket_window) { gdk_window_get_user_data (priv->socket_window, &user_data); @@ -532,7 +542,10 @@ gtk_plug_construct_for_display (GtkPlug *plug, g_object_ref (priv->socket_window); } else - priv->socket_window = gdk_window_foreign_new_for_display (display, socket_id); +#ifdef GDK_WINDOWING_X11 + if (GDK_IS_DISPLAY_X11 (display)) + priv->socket_window = gdk_x11_window_foreign_new_for_display (display, socket_id); +#endif if (priv->socket_window) { g_signal_emit (plug, plug_signals[EMBEDDED], 0); diff --git a/gtk/gtkselection.c b/gtk/gtkselection.c index 71520e448e..043d8ed71d 100644 --- a/gtk/gtkselection.c +++ b/gtk/gtkselection.c @@ -2266,20 +2266,20 @@ _gtk_selection_request (GtkWidget *widget, info = g_slice_new (GtkIncrInfo); g_object_ref (widget); - + info->selection = event->selection; info->num_incrs = 0; - + /* Create GdkWindow structure for the requestor */ - - info->requestor = gdk_window_lookup_for_display (display, - event->requestor); - if (!info->requestor) - info->requestor = gdk_window_foreign_new_for_display (display, - event->requestor); - + +#ifdef GDK_WINDOWING_X11 + if (GDK_IS_DISPLAY_X11 (display)) + info->requestor = gdk_x11_window_foreign_new_for_display (display, event->requestor); + else +#endif + info->requestor = NULL; + /* Determine conversions we need to perform */ - if (event->target == gtk_selection_atoms[MULTIPLE]) { GdkAtom type; diff --git a/gtk/gtksocket.c b/gtk/gtksocket.c index c8a8c58337..c362b64a2d 100644 --- a/gtk/gtksocket.c +++ b/gtk/gtksocket.c @@ -44,6 +44,10 @@ #include "gtkintl.h" #include "gtkwidgetprivate.h" +#ifdef GDK_WINDOWING_X11 +#include "x11/gdkx.h" +#endif + /** * SECTION:gtksocket @@ -869,8 +873,13 @@ _gtk_socket_add_window (GtkSocket *socket, GdkDisplay *display = gtk_widget_get_display (widget); gpointer user_data = NULL; GtkSocketPrivate *private = socket->priv; - - private->plug_window = gdk_window_lookup_for_display (display, xid); + +#ifdef GDK_WINDOWING_X11 + if (GDK_IS_DISPLAY_X11 (display)) + private->plug_window = gdk_x11_window_lookup_for_display (display, xid); + else +#endif + private->plug_window = NULL; if (private->plug_window) { @@ -878,22 +887,22 @@ _gtk_socket_add_window (GtkSocket *socket, gdk_window_get_user_data (private->plug_window, &user_data); } - if (user_data) /* A widget's window in this process */ + if (user_data) /* A widget's window in this process */ { GtkWidget *child_widget = user_data; if (!GTK_IS_PLUG (child_widget)) - { - g_warning (G_STRLOC ": Can't add non-GtkPlug to GtkSocket"); - private->plug_window = NULL; - gdk_error_trap_pop_ignored (); - - return; - } + { + g_warning (G_STRLOC ": Can't add non-GtkPlug to GtkSocket"); + private->plug_window = NULL; + gdk_error_trap_pop_ignored (); + + return; + } _gtk_plug_add_to_socket (GTK_PLUG (child_widget), socket); } - else /* A foreign window */ + else /* A foreign window */ { GtkWidget *toplevel; GdkDragProtocol protocol; @@ -901,15 +910,18 @@ _gtk_socket_add_window (GtkSocket *socket, gdk_error_trap_push (); if (!private->plug_window) - { - private->plug_window = gdk_window_foreign_new_for_display (display, xid); - if (!private->plug_window) /* was deleted before we could get it */ - { - gdk_error_trap_pop_ignored (); - return; - } - } - + { +#ifdef GDK_WINDOWING_X11 + if (GDK_IS_DISPLAY_X11 (display)) + private->plug_window = gdk_x11_window_foreign_new_for_display (display, xid); +#endif + if (!private->plug_window) /* was deleted before we could get it */ + { + gdk_error_trap_pop_ignored (); + return; + } + } + _gtk_socket_windowing_select_plug_window_input (socket); if (gdk_error_trap_pop ()) diff --git a/gtk/gtktrayicon-x11.c b/gtk/gtktrayicon-x11.c index 4689d3ca53..d814cf803f 100644 --- a/gtk/gtktrayicon-x11.c +++ b/gtk/gtktrayicon-x11.c @@ -254,8 +254,8 @@ gtk_tray_icon_clear_manager_window (GtkTrayIcon *icon) { GdkWindow *gdkwin; - gdkwin = gdk_window_lookup_for_display (display, - icon->priv->manager_window); + gdkwin = gdk_x11_window_lookup_for_display (display, + icon->priv->manager_window); gdk_window_remove_filter (gdkwin, gtk_tray_icon_manager_filter, icon); @@ -767,12 +767,12 @@ gtk_tray_icon_update_manager_window (GtkTrayIcon *icon) GdkWindow *gdkwin; GTK_NOTE (PLUGSOCKET, - g_print ("GtkStatusIcon %p: is being managed by window %lx\n", - icon, (gulong) icon->priv->manager_window)); + g_print ("GtkStatusIcon %p: is being managed by window %lx\n", + icon, (gulong) icon->priv->manager_window)); + + gdkwin = gdk_x11_window_lookup_for_display (display, + icon->priv->manager_window); - gdkwin = gdk_window_lookup_for_display (display, - icon->priv->manager_window); - gdk_window_add_filter (gdkwin, gtk_tray_icon_manager_filter, icon); gtk_tray_icon_get_orientation_property (icon); |