OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 widget->window = NULL; | 71 widget->window = NULL; |
72 } | 72 } |
73 | 73 |
74 GTK_OBJECT_CLASS(gtk_preserve_window_parent_class)->destroy(object); | 74 GTK_OBJECT_CLASS(gtk_preserve_window_parent_class)->destroy(object); |
75 } | 75 } |
76 | 76 |
77 static void gtk_preserve_window_realize(GtkWidget* widget) { | 77 static void gtk_preserve_window_realize(GtkWidget* widget) { |
78 g_return_if_fail(GTK_IS_PRESERVE_WINDOW(widget)); | 78 g_return_if_fail(GTK_IS_PRESERVE_WINDOW(widget)); |
79 | 79 |
80 if (widget->window) { | 80 if (widget->window) { |
| 81 GtkAllocation allocation; |
| 82 gtk_widget_get_allocation(widget, &allocation); |
| 83 |
81 gdk_window_reparent(widget->window, | 84 gdk_window_reparent(widget->window, |
82 gtk_widget_get_parent_window(widget), | 85 gtk_widget_get_parent_window(widget), |
83 widget->allocation.x, | 86 allocation.x, |
84 widget->allocation.y); | 87 allocation.y); |
85 GtkPreserveWindowPrivate* priv = GTK_PRESERVE_WINDOW_GET_PRIVATE(widget); | 88 GtkPreserveWindowPrivate* priv = GTK_PRESERVE_WINDOW_GET_PRIVATE(widget); |
86 if (!priv->delegate_resize) { | 89 if (!priv->delegate_resize) { |
87 gdk_window_resize(widget->window, | 90 gdk_window_resize(gtk_widget_get_window(widget), |
88 widget->allocation.width, | 91 allocation.width, |
89 widget->allocation.height); | 92 allocation.height); |
90 } | 93 } |
91 widget->style = gtk_style_attach(widget->style, widget->window); | 94 widget->style = gtk_style_attach(widget->style, widget->window); |
92 gtk_style_set_background(widget->style, widget->window, GTK_STATE_NORMAL); | 95 gtk_style_set_background(widget->style, widget->window, GTK_STATE_NORMAL); |
93 | 96 |
94 gint event_mask = gtk_widget_get_events(widget); | 97 gint event_mask = gtk_widget_get_events(widget); |
95 event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK; | 98 event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK; |
96 gdk_window_set_events(widget->window, (GdkEventMask) event_mask); | 99 gdk_window_set_events(widget->window, (GdkEventMask) event_mask); |
97 gdk_window_set_user_data(widget->window, widget); | 100 gdk_window_set_user_data(widget->window, widget); |
98 | 101 |
99 // Deprecated as of GTK 2.22. Used for compatibility. | 102 // Deprecated as of GTK 2.22. Used for compatibility. |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 } | 221 } |
219 } | 222 } |
220 | 223 |
221 void gtk_preserve_window_delegate_resize(GtkPreserveWindow* widget, | 224 void gtk_preserve_window_delegate_resize(GtkPreserveWindow* widget, |
222 gboolean delegate) { | 225 gboolean delegate) { |
223 GtkPreserveWindowPrivate* priv = GTK_PRESERVE_WINDOW_GET_PRIVATE(widget); | 226 GtkPreserveWindowPrivate* priv = GTK_PRESERVE_WINDOW_GET_PRIVATE(widget); |
224 priv->delegate_resize = delegate; | 227 priv->delegate_resize = delegate; |
225 } | 228 } |
226 | 229 |
227 G_END_DECLS | 230 G_END_DECLS |
OLD | NEW |