OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "gfx/gtk_preserve_window.h" | 5 #include "gfx/gtk_preserve_window.h" |
6 | 6 |
7 #include <gdk/gdkwindow.h> | 7 #include <gdk/gdkwindow.h> |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 #include <gtk/gtkwidget.h> | 9 #include <gtk/gtkwidget.h> |
10 #include <gtk/gtkfixed.h> | 10 #include <gtk/gtkfixed.h> |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 // These widgets always have their own window. | 54 // These widgets always have their own window. |
55 gtk_fixed_set_has_window(GTK_FIXED(widget), TRUE); | 55 gtk_fixed_set_has_window(GTK_FIXED(widget), TRUE); |
56 } | 56 } |
57 | 57 |
58 GtkWidget* gtk_preserve_window_new() { | 58 GtkWidget* gtk_preserve_window_new() { |
59 return GTK_WIDGET(g_object_new(GTK_TYPE_PRESERVE_WINDOW, NULL)); | 59 return GTK_WIDGET(g_object_new(GTK_TYPE_PRESERVE_WINDOW, NULL)); |
60 } | 60 } |
61 | 61 |
62 static void gtk_preserve_window_destroy(GtkObject* object) { | 62 static void gtk_preserve_window_destroy(GtkObject* object) { |
63 GtkWidget* widget = reinterpret_cast<GtkWidget*>(object); | 63 GtkWidget* widget = reinterpret_cast<GtkWidget*>(object); |
| 64 GtkPreserveWindowPrivate* priv = GTK_PRESERVE_WINDOW_GET_PRIVATE(widget); |
64 | 65 |
65 if (widget->window) { | 66 if (widget->window) { |
66 gdk_window_set_user_data(widget->window, NULL); | 67 gdk_window_set_user_data(widget->window, NULL); |
67 gdk_window_destroy(widget->window); | 68 // If the window is preserved, someone else must destroy it. |
| 69 if (!priv->preserve_window) |
| 70 gdk_window_destroy(widget->window); |
68 widget->window = NULL; | 71 widget->window = NULL; |
69 } | 72 } |
70 | 73 |
71 GTK_OBJECT_CLASS(gtk_preserve_window_parent_class)->destroy(object); | 74 GTK_OBJECT_CLASS(gtk_preserve_window_parent_class)->destroy(object); |
72 } | 75 } |
73 | 76 |
74 static void gtk_preserve_window_realize(GtkWidget* widget) { | 77 static void gtk_preserve_window_realize(GtkWidget* widget) { |
75 g_return_if_fail(GTK_IS_PRESERVE_WINDOW(widget)); | 78 g_return_if_fail(GTK_IS_PRESERVE_WINDOW(widget)); |
76 | 79 |
77 if (widget->window) { | 80 if (widget->window) { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 } | 188 } |
186 } | 189 } |
187 | 190 |
188 void gtk_preserve_window_delegate_resize(GtkPreserveWindow* widget, | 191 void gtk_preserve_window_delegate_resize(GtkPreserveWindow* widget, |
189 gboolean delegate) { | 192 gboolean delegate) { |
190 GtkPreserveWindowPrivate* priv = GTK_PRESERVE_WINDOW_GET_PRIVATE(widget); | 193 GtkPreserveWindowPrivate* priv = GTK_PRESERVE_WINDOW_GET_PRIVATE(widget); |
191 priv->delegate_resize = delegate; | 194 priv->delegate_resize = delegate; |
192 } | 195 } |
193 | 196 |
194 G_END_DECLS | 197 G_END_DECLS |
OLD | NEW |