OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/gfx/gtk_preserve_window.h" | 5 #include "ui/gfx/gtk_preserve_window.h" |
6 | 6 |
7 #include <gdk/gdk.h> | 7 #include <gdk/gdk.h> |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 | 9 |
10 #include "ui/base/gtk/gtk_compat.h" | 10 #include "ui/base/gtk/gtk_compat.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 | 126 |
127 // This is the behavior from GtkWidget, inherited by GtkFixed. | 127 // This is the behavior from GtkWidget, inherited by GtkFixed. |
128 // It is unclear why we should not call the potentially overridden | 128 // It is unclear why we should not call the potentially overridden |
129 // unrealize method (via the callback), but doing so causes errors. | 129 // unrealize method (via the callback), but doing so causes errors. |
130 container_class->forall( | 130 container_class->forall( |
131 GTK_CONTAINER(widget), FALSE, | 131 GTK_CONTAINER(widget), FALSE, |
132 reinterpret_cast<GtkCallback>(gtk_widget_unrealize), NULL); | 132 reinterpret_cast<GtkCallback>(gtk_widget_unrealize), NULL); |
133 | 133 |
134 GdkWindow* gdk_window = gtk_widget_get_window(widget); | 134 GdkWindow* gdk_window = gtk_widget_get_window(widget); |
135 | 135 |
136 gtk_style_detach(widget->style); | 136 // TODO(erg): Almost all style handling will need to be overhauled in GTK3. |
| 137 gtk_style_detach(gtk_widget_get_style(widget)); |
137 gdk_window_reparent(gdk_window, gdk_get_default_root_window(), 0, 0); | 138 gdk_window_reparent(gdk_window, gdk_get_default_root_window(), 0, 0); |
138 gtk_selection_remove_all(widget); | 139 gtk_selection_remove_all(widget); |
139 gdk_window_set_user_data(gdk_window, NULL); | 140 gdk_window_set_user_data(gdk_window, NULL); |
140 | 141 |
141 gtk_widget_set_realized(widget, FALSE); | 142 gtk_widget_set_realized(widget, FALSE); |
142 } else { | 143 } else { |
143 GTK_WIDGET_CLASS(gtk_preserve_window_parent_class)->unrealize(widget); | 144 GTK_WIDGET_CLASS(gtk_preserve_window_parent_class)->unrealize(widget); |
144 } | 145 } |
145 } | 146 } |
146 | 147 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 if (priv->delegate_resize) { | 201 if (priv->delegate_resize) { |
201 gdk_window_move(gdk_window, allocation->x, allocation->y); | 202 gdk_window_move(gdk_window, allocation->x, allocation->y); |
202 } else { | 203 } else { |
203 gdk_window_move_resize( | 204 gdk_window_move_resize( |
204 gdk_window, allocation->x, allocation->y, | 205 gdk_window, allocation->x, allocation->y, |
205 allocation->width, allocation->height); | 206 allocation->width, allocation->height); |
206 } | 207 } |
207 } | 208 } |
208 | 209 |
209 // Propagate resize to children | 210 // Propagate resize to children |
210 guint16 border_width = GTK_CONTAINER(widget)->border_width; | 211 guint16 border_width = gtk_container_get_border_width(GTK_CONTAINER(widget)); |
211 GList *children = GTK_FIXED(widget)->children; | 212 GList *children = GTK_FIXED(widget)->children; |
212 while (children) { | 213 while (children) { |
213 GtkFixedChild *child = reinterpret_cast<GtkFixedChild*>(children->data); | 214 GtkFixedChild *child = reinterpret_cast<GtkFixedChild*>(children->data); |
214 if (gtk_widget_get_visible(child->widget)) { | 215 if (gtk_widget_get_visible(child->widget)) { |
215 GtkRequisition child_requisition; | 216 GtkRequisition child_requisition; |
216 gtk_widget_get_child_requisition(child->widget, &child_requisition); | 217 gtk_widget_get_child_requisition(child->widget, &child_requisition); |
217 | 218 |
218 GtkAllocation child_allocation; | 219 GtkAllocation child_allocation; |
219 child_allocation.x = child->x + border_width; | 220 child_allocation.x = child->x + border_width; |
220 child_allocation.y = child->y + border_width; | 221 child_allocation.y = child->y + border_width; |
221 child_allocation.width = child_requisition.width; | 222 child_allocation.width = child_requisition.width; |
222 child_allocation.height = child_requisition.height; | 223 child_allocation.height = child_requisition.height; |
223 | 224 |
224 gtk_widget_size_allocate(child->widget, &child_allocation); | 225 gtk_widget_size_allocate(child->widget, &child_allocation); |
225 } | 226 } |
226 children = children->next; | 227 children = children->next; |
227 } | 228 } |
228 } | 229 } |
229 | 230 |
230 void gtk_preserve_window_delegate_resize(GtkPreserveWindow* widget, | 231 void gtk_preserve_window_delegate_resize(GtkPreserveWindow* widget, |
231 gboolean delegate) { | 232 gboolean delegate) { |
232 GtkPreserveWindowPrivate* priv = GTK_PRESERVE_WINDOW_GET_PRIVATE(widget); | 233 GtkPreserveWindowPrivate* priv = GTK_PRESERVE_WINDOW_GET_PRIVATE(widget); |
233 priv->delegate_resize = delegate; | 234 priv->delegate_resize = delegate; |
234 } | 235 } |
235 | 236 |
236 G_END_DECLS | 237 G_END_DECLS |
OLD | NEW |