| 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 "chrome/browser/ui/gtk/rounded_window.h" | 5 #include "chrome/browser/ui/gtk/rounded_window.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 #include <math.h> | 8 #include <math.h> |
| 9 | 9 |
| 10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 return points; | 198 return points; |
| 199 } | 199 } |
| 200 | 200 |
| 201 // Set the window shape in needed, lets our owner do some drawing (if it wants | 201 // Set the window shape in needed, lets our owner do some drawing (if it wants |
| 202 // to), and finally draw the border. | 202 // to), and finally draw the border. |
| 203 gboolean OnRoundedWindowExpose(GtkWidget* widget, | 203 gboolean OnRoundedWindowExpose(GtkWidget* widget, |
| 204 GdkEventExpose* event) { | 204 GdkEventExpose* event) { |
| 205 RoundedWindowData* data = static_cast<RoundedWindowData*>( | 205 RoundedWindowData* data = static_cast<RoundedWindowData*>( |
| 206 g_object_get_data(G_OBJECT(widget), kRoundedData)); | 206 g_object_get_data(G_OBJECT(widget), kRoundedData)); |
| 207 | 207 |
| 208 if (data->expected_width != widget->allocation.width || | 208 GtkAllocation allocation; |
| 209 data->expected_height != widget->allocation.height) { | 209 gtk_widget_get_allocation(widget, &allocation); |
| 210 data->expected_width = widget->allocation.width; | 210 |
| 211 data->expected_height = widget->allocation.height; | 211 if (data->expected_width != allocation.width || |
| 212 data->expected_height != allocation.height) { |
| 213 data->expected_width = allocation.width; |
| 214 data->expected_height = allocation.height; |
| 212 | 215 |
| 213 // We need to update the shape of the status bubble whenever our GDK | 216 // We need to update the shape of the status bubble whenever our GDK |
| 214 // window changes shape. | 217 // window changes shape. |
| 215 std::vector<GdkPoint> mask_points = MakeFramePolygonPoints( | 218 std::vector<GdkPoint> mask_points = MakeFramePolygonPoints( |
| 216 data, FRAME_MASK); | 219 data, FRAME_MASK); |
| 217 GdkRegion* mask_region = gdk_region_polygon(&mask_points[0], | 220 GdkRegion* mask_region = gdk_region_polygon(&mask_points[0], |
| 218 mask_points.size(), | 221 mask_points.size(), |
| 219 GDK_EVEN_ODD_RULE); | 222 GDK_EVEN_ODD_RULE); |
| 220 gdk_window_shape_combine_region(widget->window, mask_region, 0, 0); | 223 gdk_window_shape_combine_region(gtk_widget_get_window(widget), |
| 224 mask_region, 0, 0); |
| 221 gdk_region_destroy(mask_region); | 225 gdk_region_destroy(mask_region); |
| 222 } | 226 } |
| 223 | 227 |
| 224 GdkDrawable* drawable = GDK_DRAWABLE(event->window); | 228 GdkDrawable* drawable = GDK_DRAWABLE(event->window); |
| 225 GdkGC* gc = gdk_gc_new(drawable); | 229 GdkGC* gc = gdk_gc_new(drawable); |
| 226 gdk_gc_set_clip_rectangle(gc, &event->area); | 230 gdk_gc_set_clip_rectangle(gc, &event->area); |
| 227 gdk_gc_set_rgb_fg_color(gc, &data->border_color); | 231 gdk_gc_set_rgb_fg_color(gc, &data->border_color); |
| 228 | 232 |
| 229 // Stroke the frame border. | 233 // Stroke the frame border. |
| 230 std::vector<GdkPoint> points = MakeFramePolygonPoints( | 234 std::vector<GdkPoint> points = MakeFramePolygonPoints( |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 | 317 |
| 314 void SetRoundedWindowBorderColor(GtkWidget* widget, GdkColor color) { | 318 void SetRoundedWindowBorderColor(GtkWidget* widget, GdkColor color) { |
| 315 DCHECK(widget); | 319 DCHECK(widget); |
| 316 RoundedWindowData* data = static_cast<RoundedWindowData*>( | 320 RoundedWindowData* data = static_cast<RoundedWindowData*>( |
| 317 g_object_get_data(G_OBJECT(widget), kRoundedData)); | 321 g_object_get_data(G_OBJECT(widget), kRoundedData)); |
| 318 DCHECK(data); | 322 DCHECK(data); |
| 319 data->border_color = color; | 323 data->border_color = color; |
| 320 } | 324 } |
| 321 | 325 |
| 322 } // namespace gtk_util | 326 } // namespace gtk_util |
| OLD | NEW |