diff options
author | Alexander Larsson <alexl@redhat.com> | 2016-12-16 12:35:03 +0100 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2016-12-16 12:35:03 +0100 |
commit | 330c7feaa2cae359f43e6cb7372dba812ff7dfd2 (patch) | |
tree | 333ad18e48bb9e9fd6d43820c20f4c978034553f /gdk/gdkwindow.c | |
parent | 5bf28a386937847a171435bf55be16769565e402 (diff) | |
download | gtk+-wip/alexl/simplify-gdkwindow.tar.gz |
gdk: Drop gdk_window_reparentwip/alexl/simplify-gdkwindow
We're not currently using this, and dropping it allows us to loose
a bunch of code which leads us towards the goal of having GdkWindow
only for toplevels (and reparenting makes not sense for toplevels).
Diffstat (limited to 'gdk/gdkwindow.c')
-rw-r--r-- | gdk/gdkwindow.c | 221 |
1 files changed, 0 insertions, 221 deletions
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index 356fb87baa..8c72268711 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -1288,227 +1288,6 @@ gdk_window_new_input (GdkWindow *parent, return gdk_window_new (parent, &attr); } -static gboolean -is_parent_of (GdkWindow *parent, - GdkWindow *child) -{ - GdkWindow *w; - - w = child; - while (w != NULL) - { - if (w == parent) - return TRUE; - - w = gdk_window_get_parent (w); - } - - return FALSE; -} - -static void -change_impl (GdkWindow *private, - GdkWindow *impl_window, - GdkWindowImpl *new) -{ - GList *l; - GdkWindow *child; - GdkWindowImpl *old_impl; - GdkWindow *old_impl_window; - - old_impl = private->impl; - old_impl_window = private->impl_window; - if (private != impl_window) - private->impl_window = g_object_ref (impl_window); - else - private->impl_window = private; - private->impl = g_object_ref (new); - if (old_impl_window != private) - g_object_unref (old_impl_window); - g_object_unref (old_impl); - - for (l = private->children; l != NULL; l = l->next) - { - child = l->data; - - g_assert (child->impl == old_impl); /* All children should be the same impl */ - - change_impl (child, impl_window, new); - } -} - -/** - * gdk_window_reparent: - * @window: a #GdkWindow - * @new_parent: new parent to move @window into - * @x: X location inside the new parent - * @y: Y location inside the new parent - * - * Reparents @window into the given @new_parent. The window being - * reparented will be unmapped as a side effect. - * - **/ -void -gdk_window_reparent (GdkWindow *window, - GdkWindow *new_parent, - gint x, - gint y) -{ - GdkWindow *old_parent; - GdkScreen *screen; - gboolean show, was_mapped; - GdkEventMask old_native_event_mask; - GdkWindowImplClass *impl_class; - - g_return_if_fail (GDK_IS_WINDOW (window)); - g_return_if_fail (new_parent == NULL || GDK_IS_WINDOW (new_parent)); - g_return_if_fail (GDK_WINDOW_TYPE (window) != GDK_WINDOW_ROOT); - - if (GDK_WINDOW_DESTROYED (window) || - (new_parent && GDK_WINDOW_DESTROYED (new_parent))) - return; - - screen = gdk_window_get_screen (window); - if (!new_parent) - new_parent = gdk_screen_get_root_window (screen); - - /* Don't allow reparenting to/from toplevel status */ - if (!gdk_window_is_toplevel (window) && (new_parent->window_type == GDK_WINDOW_ROOT || - new_parent->window_type == GDK_WINDOW_FOREIGN)) - { - g_warning ("Can't reparent to toplevel"); - return; - } - - if (gdk_window_is_toplevel (window) && (new_parent->window_type != GDK_WINDOW_ROOT || - new_parent->window_type != GDK_WINDOW_FOREIGN)) - { - g_warning ("Can't reparent from toplevel"); - return; - } - - /* No input-output children of input-only windows */ - if (new_parent->input_only && !window->input_only) - return; - - /* Don't create loops in hierarchy */ - if (is_parent_of (window, new_parent)) - return; - - impl_class = GDK_WINDOW_IMPL_GET_CLASS (window->impl); - old_parent = window->parent; - - was_mapped = GDK_WINDOW_IS_MAPPED (window); - - old_native_event_mask = 0; - if (gdk_window_has_impl (window)) - { - /* This shouldn't happen, check anyway to see if that ever fails */ - g_assert (new_parent->window_type == GDK_WINDOW_ROOT || - new_parent->window_type == GDK_WINDOW_FOREIGN); - - old_native_event_mask = get_native_event_mask (window); - /* Native window */ - show = impl_class->reparent (window, new_parent, x, y); - } - else - { - /* This shouldn't happen, check anyway to see if that ever fails */ - g_assert (new_parent->window_type != GDK_WINDOW_ROOT && - new_parent->window_type != GDK_WINDOW_FOREIGN); - - show = was_mapped; - gdk_window_hide (window); - - change_impl (window, - new_parent->impl_window, - new_parent->impl); - } - - /* From here on, we treat parents of type GDK_WINDOW_FOREIGN like - * the root window - */ - if (GDK_WINDOW_TYPE (new_parent) == GDK_WINDOW_FOREIGN) - { - new_parent = gdk_screen_get_root_window (screen); - } - - if (old_parent) - old_parent->children = g_list_remove_link (old_parent->children, &window->children_list_node); - - window->parent = new_parent; - window->x = x; - window->y = y; - - new_parent->children = g_list_concat (&window->children_list_node, new_parent->children); - - /* Switch the window type as appropriate */ - - switch (GDK_WINDOW_TYPE (new_parent)) - { - case GDK_WINDOW_ROOT: - case GDK_WINDOW_FOREIGN: - if (window->toplevel_window_type != -1) - GDK_WINDOW_TYPE (window) = window->toplevel_window_type; - else if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD) - GDK_WINDOW_TYPE (window) = GDK_WINDOW_TOPLEVEL; - break; - case GDK_WINDOW_TOPLEVEL: - case GDK_WINDOW_CHILD: - case GDK_WINDOW_TEMP: - if (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD && \ - GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN) - { - /* Save the original window type so we can restore it if the - * window is reparented back to be a toplevel - */ - window->toplevel_window_type = GDK_WINDOW_TYPE (window); - GDK_WINDOW_TYPE (window) = GDK_WINDOW_CHILD; - } - } - - /* If we changed the window type, we might have to set or - * unset the frame clock on the window - */ - if (GDK_WINDOW_TYPE (new_parent) == GDK_WINDOW_ROOT && - GDK_WINDOW_TYPE (window) != GDK_WINDOW_FOREIGN) - { - if (window->frame_clock == NULL) - { - GdkFrameClock *frame_clock = g_object_new (GDK_TYPE_FRAME_CLOCK_IDLE, NULL); - gdk_window_set_frame_clock (window, frame_clock); - g_object_unref (frame_clock); - } - } - else - { - if (window->frame_clock != NULL) - { - g_object_run_dispose (G_OBJECT (window->frame_clock)); - gdk_window_set_frame_clock (window, NULL); - } - } - - /* We might have changed window type for a native windows, so we - need to change the event mask too. */ - if (gdk_window_has_impl (window)) - { - GdkEventMask native_event_mask = get_native_event_mask (window); - - if (native_event_mask != old_native_event_mask) - impl_class->set_events (window, native_event_mask); - } - - _gdk_window_update_viewable (window); - - recompute_visible_regions (window, FALSE); - - if (show) - gdk_window_show_unraised (window); - else - _gdk_synthesize_crossing_events_for_geometry_change (window); -} - /** * _gdk_event_filter_unref: * @window: (allow-none): A #GdkWindow, or %NULL to be the global window |