[gtk+/toplevel-embedding] Still not rendering properly, more precautions taken when embedding toplevels.
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/toplevel-embedding] Still not rendering properly, more precautions taken when embedding toplevels.
- Date: Thu, 23 Dec 2010 09:44:46 +0000 (UTC)
commit ff998c73de38069ac3c4093352cd8022dd1e7e72
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Thu Dec 23 18:50:36 2010 +0900
Still not rendering properly, more precautions taken when embedding toplevels.
gtk/gtkwidget.c | 10 ++-
gtk/gtkwindow.c | 240 ++++++++++++++++++++++++++++++++++++-------------------
2 files changed, 164 insertions(+), 86 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 740562e..3993fdc 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -8629,7 +8629,9 @@ gtk_widget_get_default_style (void)
return gtk_default_style;
}
-#ifdef G_ENABLE_DEBUG
+#if 0
+/* #ifdef G_ENABLE_DEBUG */
+
/* Verify invariants, see docs/widget_system.txt for notes on much of
* this. Invariants may be temporarily broken while we're in the
* process of updating state, of course, so you can only
@@ -9079,7 +9081,11 @@ gtk_widget_set_parent_window (GtkWidget *widget,
* this is the primary entry point to allow toplevels to be
* embeddable.
*/
- _gtk_widget_set_is_toplevel (widget, FALSE);
+ if (GTK_IS_WINDOW (widget))
+ {
+ _gtk_window_set_is_toplevel (GTK_WINDOW (widget), FALSE);
+ gtk_container_set_resize_mode (GTK_CONTAINER (widget), GTK_RESIZE_PARENT);
+ }
}
}
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 7958e9b..43cf43b 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -4621,6 +4621,12 @@ gtk_window_show (GtkWidget *widget)
GtkContainer *container = GTK_CONTAINER (window);
gboolean need_resize;
+ if (!gtk_widget_is_toplevel (GTK_WIDGET (widget)))
+ {
+ GTK_WIDGET_CLASS (gtk_window_parent_class)->show (widget);
+ return;
+ }
+
_gtk_widget_set_visible_flag (widget, TRUE);
need_resize = _gtk_container_get_need_resize (container) || !gtk_widget_get_realized (widget);
@@ -4698,6 +4704,12 @@ gtk_window_hide (GtkWidget *widget)
GtkWindow *window = GTK_WINDOW (widget);
GtkWindowPrivate *priv = window->priv;
+ if (!gtk_widget_is_toplevel (GTK_WIDGET (widget)))
+ {
+ GTK_WIDGET_CLASS (gtk_window_parent_class)->hide (widget);
+ return;
+ }
+
_gtk_widget_set_visible_flag (widget, FALSE);
gtk_widget_unmap (widget);
@@ -4717,6 +4729,12 @@ gtk_window_map (GtkWidget *widget)
gdk_window = gtk_widget_get_window (widget);
+ if (!gtk_widget_is_toplevel (GTK_WIDGET (widget)))
+ {
+ GTK_WIDGET_CLASS (gtk_window_parent_class)->map (widget);
+ return;
+ }
+
gtk_widget_set_mapped (widget, TRUE);
child = gtk_bin_get_child (&(window->bin));
@@ -4833,6 +4851,12 @@ gtk_window_unmap (GtkWidget *widget)
GdkWindow *gdk_window;
GdkWindowState state;
+ if (!gtk_widget_is_toplevel (GTK_WIDGET (widget)))
+ {
+ GTK_WIDGET_CLASS (gtk_window_parent_class)->unmap (widget);
+ return;
+ }
+
gdk_window = gtk_widget_get_window (widget);
gtk_widget_set_mapped (widget, FALSE);
@@ -4875,19 +4899,50 @@ gtk_window_realize (GtkWidget *widget)
GtkAllocation allocation;
GtkWindow *window;
GdkWindow *parent_window;
- GdkWindow *parent_parent_window;
GdkWindow *gdk_window;
GdkWindowAttr attributes;
gint attributes_mask;
GtkWindowPrivate *priv;
GtkStyleContext *context;
- gboolean embedded_window = FALSE;
window = GTK_WINDOW (widget);
priv = window->priv;
gtk_widget_get_allocation (widget, &allocation);
+ if (gtk_widget_get_parent_window (widget))
+ {
+
+#if 0
+ gtk_widget_set_has_window (widget, FALSE);
+ GTK_WIDGET_CLASS (gtk_window_parent_class)->realize (widget);
+#endif
+
+ gtk_widget_set_realized (widget, TRUE);
+
+ attributes.x = allocation.x;
+ attributes.y = allocation.y;
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
+ attributes.window_type = GDK_WINDOW_CHILD;
+
+ attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK;
+
+ attributes.visual = gtk_widget_get_visual (widget);
+ attributes.wclass = GDK_INPUT_OUTPUT;
+
+ attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
+
+ gdk_window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ &attributes, attributes_mask);
+ gtk_widget_set_window (widget, gdk_window);
+ gdk_window_set_user_data (gdk_window, widget);
+
+ gtk_widget_style_attach (widget);
+ gtk_style_set_background (gtk_widget_get_style (widget), gdk_window, GTK_STATE_NORMAL);
+ return;
+ }
+
/* ensure widget tree is properly size allocated */
if (allocation.x == -1 &&
allocation.y == -1 &&
@@ -4937,18 +4992,7 @@ gtk_window_realize (GtkWidget *widget)
attributes.visual = gtk_widget_get_visual (widget);
attributes_mask = 0;
- if (gtk_widget_get_parent_window (widget))
- {
- parent_parent_window = gtk_widget_get_parent_window (widget);
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes_mask = GDK_WA_X | GDK_WA_Y;
- embedded_window = TRUE;
- }
- else
- parent_parent_window = gtk_widget_get_root_window (widget);
-
- /* Only real windows can possibly have a frame */
- if (!gtk_widget_get_parent_window (widget) && priv->has_frame)
+ if (priv->has_frame)
{
gtk_widget_get_allocation (widget, &allocation);
attributes.width = allocation.width + priv->frame_left + priv->frame_right;
@@ -4966,7 +5010,7 @@ gtk_window_realize (GtkWidget *widget)
attributes_mask = GDK_WA_VISUAL;
- priv->frame = gdk_window_new (parent_parent_window,
+ priv->frame = gdk_window_new (gtk_widget_get_root_window (widget),
&attributes, attributes_mask);
if (priv->opacity_set)
@@ -4988,7 +5032,10 @@ gtk_window_realize (GtkWidget *widget)
NULL);
}
else
- parent_window = parent_parent_window;
+ {
+ attributes_mask = 0;
+ parent_window = gtk_widget_get_root_window (widget);
+ }
gtk_widget_get_allocation (widget, &allocation);
attributes.width = allocation.width;
@@ -5013,8 +5060,7 @@ gtk_window_realize (GtkWidget *widget)
if (!priv->has_frame && priv->opacity_set)
gdk_window_set_opacity (gdk_window, priv->opacity);
- if (!embedded_window)
- gdk_window_enable_synchronized_configure (gdk_window);
+ gdk_window_enable_synchronized_configure (gdk_window);
gdk_window_set_user_data (gdk_window, window);
@@ -5031,55 +5077,52 @@ gtk_window_realize (GtkWidget *widget)
gdk_window_set_transient_for (gdk_window,
gtk_widget_get_window (GTK_WIDGET (priv->transient_parent)));
- if (!embedded_window)
+ if (priv->wm_role)
+ gdk_window_set_role (gdk_window, priv->wm_role);
+
+ if (!priv->decorated)
+ gdk_window_set_decorations (gdk_window, 0);
+
+ if (!priv->deletable)
+ gdk_window_set_functions (gdk_window, GDK_FUNC_ALL | GDK_FUNC_CLOSE);
+
+ if (gtk_window_get_skip_pager_hint (window))
+ gdk_window_set_skip_pager_hint (gdk_window, TRUE);
+
+ if (gtk_window_get_skip_taskbar_hint (window))
+ gdk_window_set_skip_taskbar_hint (gdk_window, TRUE);
+
+ if (gtk_window_get_accept_focus (window))
+ gdk_window_set_accept_focus (gdk_window, TRUE);
+ else
+ gdk_window_set_accept_focus (gdk_window, FALSE);
+
+ if (gtk_window_get_focus_on_map (window))
+ gdk_window_set_focus_on_map (gdk_window, TRUE);
+ else
+ gdk_window_set_focus_on_map (gdk_window, FALSE);
+
+ if (priv->modal)
+ gdk_window_set_modal_hint (gdk_window, TRUE);
+ else
+ gdk_window_set_modal_hint (gdk_window, FALSE);
+
+ if (priv->startup_id)
{
- if (priv->wm_role)
- gdk_window_set_role (gdk_window, priv->wm_role);
-
- if (!priv->decorated)
- gdk_window_set_decorations (gdk_window, 0);
-
- if (!priv->deletable)
- gdk_window_set_functions (gdk_window, GDK_FUNC_ALL | GDK_FUNC_CLOSE);
-
- if (gtk_window_get_skip_pager_hint (window))
- gdk_window_set_skip_pager_hint (gdk_window, TRUE);
-
- if (gtk_window_get_skip_taskbar_hint (window))
- gdk_window_set_skip_taskbar_hint (gdk_window, TRUE);
-
- if (gtk_window_get_accept_focus (window))
- gdk_window_set_accept_focus (gdk_window, TRUE);
- else
- gdk_window_set_accept_focus (gdk_window, FALSE);
-
- if (gtk_window_get_focus_on_map (window))
- gdk_window_set_focus_on_map (gdk_window, TRUE);
- else
- gdk_window_set_focus_on_map (gdk_window, FALSE);
-
- if (priv->modal)
- gdk_window_set_modal_hint (gdk_window, TRUE);
- else
- gdk_window_set_modal_hint (gdk_window, FALSE);
-
- if (priv->startup_id)
- {
#ifdef GDK_WINDOWING_X11
- guint32 timestamp = extract_time_from_startup_id (priv->startup_id);
- if (timestamp != GDK_CURRENT_TIME)
- gdk_x11_window_set_user_time (gdk_window, timestamp);
+ guint32 timestamp = extract_time_from_startup_id (priv->startup_id);
+ if (timestamp != GDK_CURRENT_TIME)
+ gdk_x11_window_set_user_time (gdk_window, timestamp);
#endif
- if (!startup_id_is_fake (priv->startup_id))
- gdk_window_set_startup_id (gdk_window, priv->startup_id);
- }
-
- /* Icons */
- gtk_window_realize_icon (window);
-
- if (priv->has_resize_grip)
- resize_grip_create_window (window);
+ if (!startup_id_is_fake (priv->startup_id))
+ gdk_window_set_startup_id (gdk_window, priv->startup_id);
}
+
+ /* Icons */
+ gtk_window_realize_icon (window);
+
+ if (priv->has_resize_grip)
+ resize_grip_create_window (window);
}
static void
@@ -5294,20 +5337,6 @@ gtk_window_size_allocate (GtkWidget *widget,
gtk_widget_set_allocation (widget, allocation);
- child = gtk_bin_get_child (&(window->bin));
- if (child && gtk_widget_get_visible (child))
- {
- border_width = gtk_container_get_border_width (GTK_CONTAINER (window));
- child_allocation.x = border_width;
- child_allocation.y = border_width;
- child_allocation.width =
- MAX (1, (gint)allocation->width - child_allocation.x * 2);
- child_allocation.height =
- MAX (1, (gint)allocation->height - child_allocation.y * 2);
-
- gtk_widget_size_allocate (child, &child_allocation);
- }
-
if (gtk_widget_get_realized (widget))
{
/* If it's not a toplevel we're embedded, we need to resize the window's
@@ -5330,6 +5359,20 @@ gtk_window_size_allocate (GtkWidget *widget,
set_grip_position (window);
}
}
+
+ child = gtk_bin_get_child (&(window->bin));
+ if (child && gtk_widget_get_visible (child))
+ {
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (window));
+ child_allocation.x = border_width;
+ child_allocation.y = border_width;
+ child_allocation.width =
+ MAX (1, (gint)allocation->width - child_allocation.x * 2);
+ child_allocation.height =
+ MAX (1, (gint)allocation->height - child_allocation.y * 2);
+
+ gtk_widget_size_allocate (child, &child_allocation);
+ }
}
static gint
@@ -5400,6 +5443,14 @@ gtk_window_configure_event (GtkWidget *widget,
GtkWindowPrivate *priv = window->priv;
gboolean expected_reply = priv->configure_request_count > 0;
+ if (!gtk_widget_is_toplevel (GTK_WIDGET (widget)))
+ {
+ if (GTK_WIDGET_CLASS (gtk_window_parent_class)->configure_event)
+ return GTK_WIDGET_CLASS (gtk_window_parent_class)->configure_event (widget, event);
+
+ return FALSE;
+ }
+
/* priv->configure_request_count incremented for each
* configure request, and decremented to a min of 0 for
* each configure notify.
@@ -5461,7 +5512,8 @@ static gboolean
gtk_window_state_event (GtkWidget *widget,
GdkEventWindowState *event)
{
- update_grip_visibility (GTK_WINDOW (widget));
+ if (gtk_widget_is_toplevel (GTK_WIDGET (widget)))
+ update_grip_visibility (GTK_WINDOW (widget));
return FALSE;
}
@@ -5472,9 +5524,12 @@ gtk_window_direction_changed (GtkWidget *widget,
{
GtkWindow *window = GTK_WINDOW (widget);
- set_grip_cursor (window);
- set_grip_position (window);
- set_grip_shape (window);
+ if (gtk_widget_is_toplevel (GTK_WIDGET (widget)))
+ {
+ set_grip_cursor (window);
+ set_grip_position (window);
+ set_grip_shape (window);
+ }
}
static void
@@ -5483,7 +5538,8 @@ gtk_window_state_changed (GtkWidget *widget,
{
GtkWindow *window = GTK_WINDOW (widget);
- update_grip_visibility (window);
+ if (gtk_widget_is_toplevel (GTK_WIDGET (widget)))
+ update_grip_visibility (window);
}
static void
@@ -5584,7 +5640,8 @@ gtk_window_set_has_resize_grip (GtkWindow *window,
priv->has_resize_grip = value;
gtk_widget_queue_draw (widget);
- if (gtk_widget_get_realized (widget))
+ if (gtk_widget_get_realized (widget) &&
+ gtk_widget_is_toplevel (GTK_WIDGET (widget)))
{
if (priv->has_resize_grip && priv->grip_window == NULL)
resize_grip_create_window (window);
@@ -5653,6 +5710,9 @@ gtk_window_resize_grip_is_visible (GtkWindow *window)
if (!priv->resizable)
return FALSE;
+ if (!gtk_widget_is_toplevel (GTK_WIDGET (widget)))
+ return FALSE;
+
if (gtk_widget_get_realized (widget))
{
GdkWindowState state;
@@ -7466,7 +7526,19 @@ gtk_window_draw (GtkWidget *widget,
/* If the window is not toplevel anymore than it's embedded somewhere,
* so just chain up and paint the children */
if (!gtk_widget_is_toplevel (widget))
- return GTK_WIDGET_CLASS (gtk_window_parent_class)->draw (widget, cr);
+ {
+ if (!gtk_widget_get_app_paintable (widget))
+ gtk_paint_flat_box (gtk_widget_get_style (widget),
+ cr,
+ gtk_widget_get_state (widget),
+ GTK_SHADOW_NONE,
+ widget, "window",
+ 0, 0,
+ gtk_widget_get_allocated_width (widget),
+ gtk_widget_get_allocated_height (widget));
+
+ return GTK_WIDGET_CLASS (gtk_window_parent_class)->draw (widget, cr);
+ }
context = gtk_widget_get_style_context (widget);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]