| 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/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> |
| 11 | 11 |
| 12 #include "ui/base/gtk/gtk_compat.h" |
| 13 |
| 12 G_BEGIN_DECLS | 14 G_BEGIN_DECLS |
| 13 | 15 |
| 14 #define GTK_PRESERVE_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \ | 16 #define GTK_PRESERVE_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \ |
| 15 GTK_TYPE_PRESERVE_WINDOW, \ | 17 GTK_TYPE_PRESERVE_WINDOW, \ |
| 16 GtkPreserveWindowPrivate)) | 18 GtkPreserveWindowPrivate)) |
| 17 | 19 |
| 18 typedef struct _GtkPreserveWindowPrivate GtkPreserveWindowPrivate; | 20 typedef struct _GtkPreserveWindowPrivate GtkPreserveWindowPrivate; |
| 19 | 21 |
| 20 struct _GtkPreserveWindowPrivate { | 22 struct _GtkPreserveWindowPrivate { |
| 21 // If true, don't create/destroy windows on realize/unrealize. | 23 // If true, don't create/destroy windows on realize/unrealize. |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 | 175 |
| 174 attributes.visual = gtk_widget_get_visual(widget); | 176 attributes.visual = gtk_widget_get_visual(widget); |
| 175 attributes.colormap = gtk_widget_get_colormap(widget); | 177 attributes.colormap = gtk_widget_get_colormap(widget); |
| 176 | 178 |
| 177 attributes.event_mask = gtk_widget_get_events(widget); | 179 attributes.event_mask = gtk_widget_get_events(widget); |
| 178 attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK; | 180 attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK; |
| 179 | 181 |
| 180 attributes_mask = GDK_WA_VISUAL | GDK_WA_COLORMAP | GDK_WA_NOREDIR; | 182 attributes_mask = GDK_WA_VISUAL | GDK_WA_COLORMAP | GDK_WA_NOREDIR; |
| 181 widget->window = gdk_window_new( | 183 widget->window = gdk_window_new( |
| 182 gdk_get_default_root_window(), &attributes, attributes_mask); | 184 gdk_get_default_root_window(), &attributes, attributes_mask); |
| 183 } else if (!value && widget->window && !GTK_WIDGET_REALIZED(widget)) { | 185 } else if (!value && widget->window && !gtk_widget_get_realized(widget)) { |
| 184 gdk_window_destroy(widget->window); | 186 gdk_window_destroy(widget->window); |
| 185 widget->window = NULL; | 187 widget->window = NULL; |
| 186 } | 188 } |
| 187 } | 189 } |
| 188 | 190 |
| 189 void gtk_preserve_window_size_allocate(GtkWidget* widget, | 191 void gtk_preserve_window_size_allocate(GtkWidget* widget, |
| 190 GtkAllocation* allocation) { | 192 GtkAllocation* allocation) { |
| 191 g_return_if_fail(GTK_IS_PRESERVE_WINDOW(widget)); | 193 g_return_if_fail(GTK_IS_PRESERVE_WINDOW(widget)); |
| 192 | 194 |
| 193 widget->allocation = *allocation; | 195 widget->allocation = *allocation; |
| 194 | 196 |
| 195 if (GTK_WIDGET_REALIZED(widget)) { | 197 if (gtk_widget_get_realized(widget)) { |
| 196 GtkPreserveWindowPrivate* priv = GTK_PRESERVE_WINDOW_GET_PRIVATE(widget); | 198 GtkPreserveWindowPrivate* priv = GTK_PRESERVE_WINDOW_GET_PRIVATE(widget); |
| 197 if (priv->delegate_resize) { | 199 if (priv->delegate_resize) { |
| 198 gdk_window_move(widget->window, allocation->x, allocation->y); | 200 gdk_window_move(widget->window, allocation->x, allocation->y); |
| 199 } else { | 201 } else { |
| 200 gdk_window_move_resize( | 202 gdk_window_move_resize( |
| 201 widget->window, allocation->x, allocation->y, | 203 widget->window, allocation->x, allocation->y, |
| 202 allocation->width, allocation->height); | 204 allocation->width, allocation->height); |
| 203 } | 205 } |
| 204 } | 206 } |
| 205 | 207 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 224 } | 226 } |
| 225 } | 227 } |
| 226 | 228 |
| 227 void gtk_preserve_window_delegate_resize(GtkPreserveWindow* widget, | 229 void gtk_preserve_window_delegate_resize(GtkPreserveWindow* widget, |
| 228 gboolean delegate) { | 230 gboolean delegate) { |
| 229 GtkPreserveWindowPrivate* priv = GTK_PRESERVE_WINDOW_GET_PRIVATE(widget); | 231 GtkPreserveWindowPrivate* priv = GTK_PRESERVE_WINDOW_GET_PRIVATE(widget); |
| 230 priv->delegate_resize = delegate; | 232 priv->delegate_resize = delegate; |
| 231 } | 233 } |
| 232 | 234 |
| 233 G_END_DECLS | 235 G_END_DECLS |
| OLD | NEW |