| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/gtk/browser_window_gtk.h" | 5 #include "chrome/browser/gtk/browser_window_gtk.h" |
| 6 | 6 |
| 7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
| 8 #include <X11/XF86keysym.h> | 8 #include <X11/XF86keysym.h> |
| 9 | 9 |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 ThemeProvider* theme_provider = | 408 ThemeProvider* theme_provider = |
| 409 window->browser()->profile()->GetThemeProvider(); | 409 window->browser()->profile()->GetThemeProvider(); |
| 410 if (!default_background) { | 410 if (!default_background) { |
| 411 default_background = new NineBox(theme_provider, | 411 default_background = new NineBox(theme_provider, |
| 412 0, IDR_THEME_FRAME, 0, 0, 0, 0, 0, 0, 0); | 412 0, IDR_THEME_FRAME, 0, 0, 0, 0, 0, 0, 0); |
| 413 default_background_otr = new NineBox(theme_provider, | 413 default_background_otr = new NineBox(theme_provider, |
| 414 0, IDR_THEME_FRAME_INCOGNITO, 0, 0, 0, 0, 0, 0, 0); | 414 0, IDR_THEME_FRAME_INCOGNITO, 0, 0, 0, 0, 0, 0, 0); |
| 415 } | 415 } |
| 416 | 416 |
| 417 // Draw the default background. | 417 // Draw the default background. |
| 418 // TODO(tc): Handle maximized windows. | |
| 419 cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(widget->window)); | 418 cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(widget->window)); |
| 420 cairo_rectangle(cr, event->area.x, event->area.y, event->area.width, | 419 cairo_rectangle(cr, event->area.x, event->area.y, event->area.width, |
| 421 event->area.height); | 420 event->area.height); |
| 422 cairo_clip(cr); | 421 cairo_clip(cr); |
| 423 NineBox* image = window->browser()->profile()->IsOffTheRecord() | 422 NineBox* image = window->browser()->profile()->IsOffTheRecord() |
| 424 ? default_background_otr : default_background; | 423 ? default_background_otr : default_background; |
| 425 image->RenderTopCenterStrip(cr, 0, 0, widget->allocation.width); | 424 image->RenderTopCenterStrip(cr, 0, 0, widget->allocation.width); |
| 426 cairo_destroy(cr); | 425 cairo_destroy(cr); |
| 427 | 426 |
| 428 // TODO(tc): Draw the theme overlay. The windows code is below. | 427 // TODO(tc): Draw the theme overlay. The windows code is below. |
| 429 // if (theme_provider->HasCustomImage(IDR_THEME_FRAME_OVERLAY)) { | 428 // if (theme_provider->HasCustomImage(IDR_THEME_FRAME_OVERLAY)) { |
| 430 // SkBitmap* theme_overlay = theme_provider->GetBitmapNamed( | 429 // SkBitmap* theme_overlay = theme_provider->GetBitmapNamed( |
| 431 // IDR_THEME_FRAME_OVERLAY); | 430 // IDR_THEME_FRAME_OVERLAY); |
| 432 // canvas->DrawBitmapInt(*theme_overlay, 0, 0); | 431 // canvas->DrawBitmapInt(*theme_overlay, 0, 0); |
| 433 // } | 432 // } |
| 434 | 433 |
| 435 if (window->use_custom_frame_.GetValue()) { | 434 if (window->use_custom_frame_.GetValue() && !window->IsMaximized()) { |
| 436 if (!custom_frame_border) { | 435 if (!custom_frame_border) { |
| 437 custom_frame_border = new NineBox( | 436 custom_frame_border = new NineBox( |
| 438 theme_provider, | 437 theme_provider, |
| 439 IDR_WINDOW_TOP_LEFT_CORNER, | 438 IDR_WINDOW_TOP_LEFT_CORNER, |
| 440 IDR_WINDOW_TOP_CENTER, | 439 IDR_WINDOW_TOP_CENTER, |
| 441 IDR_WINDOW_TOP_RIGHT_CORNER, | 440 IDR_WINDOW_TOP_RIGHT_CORNER, |
| 442 IDR_WINDOW_LEFT_SIDE, | 441 IDR_WINDOW_LEFT_SIDE, |
| 443 NULL, | 442 NULL, |
| 444 IDR_WINDOW_RIGHT_SIDE, | 443 IDR_WINDOW_RIGHT_SIDE, |
| 445 IDR_WINDOW_BOTTOM_LEFT_CORNER, | 444 IDR_WINDOW_BOTTOM_LEFT_CORNER, |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1061 // Make the top corners rounded. We set a mask that includes most of the | 1060 // Make the top corners rounded. We set a mask that includes most of the |
| 1062 // window except for a few pixels in the top two corners. | 1061 // window except for a few pixels in the top two corners. |
| 1063 GdkRectangle top_rect = { 3, 0, width - 6, 1 }; | 1062 GdkRectangle top_rect = { 3, 0, width - 6, 1 }; |
| 1064 GdkRectangle mid_rect = { 1, 1, width - 2, 2 }; | 1063 GdkRectangle mid_rect = { 1, 1, width - 2, 2 }; |
| 1065 GdkRectangle bot_rect = { 0, 3, width, height - 3 }; | 1064 GdkRectangle bot_rect = { 0, 3, width, height - 3 }; |
| 1066 GdkRegion* mask = gdk_region_rectangle(&top_rect); | 1065 GdkRegion* mask = gdk_region_rectangle(&top_rect); |
| 1067 gdk_region_union_with_rect(mask, &mid_rect); | 1066 gdk_region_union_with_rect(mask, &mid_rect); |
| 1068 gdk_region_union_with_rect(mask, &bot_rect); | 1067 gdk_region_union_with_rect(mask, &bot_rect); |
| 1069 gdk_window_shape_combine_region(GTK_WIDGET(window_)->window, mask, 0, 0); | 1068 gdk_window_shape_combine_region(GTK_WIDGET(window_)->window, mask, 0, 0); |
| 1070 gdk_region_destroy(mask); | 1069 gdk_region_destroy(mask); |
| 1070 gtk_alignment_set_padding(GTK_ALIGNMENT(window_container_), 1, |
| 1071 kFrameBorderThickness, kFrameBorderThickness, kFrameBorderThickness); |
| 1071 } else { | 1072 } else { |
| 1072 // Disable rounded corners. | 1073 // Disable rounded corners. |
| 1073 gdk_window_shape_combine_region(GTK_WIDGET(window_)->window, NULL, 0, 0); | 1074 gdk_window_shape_combine_region(GTK_WIDGET(window_)->window, NULL, 0, 0); |
| 1075 gtk_alignment_set_padding(GTK_ALIGNMENT(window_container_), 0, 0, 0, 0); |
| 1074 } | 1076 } |
| 1075 } | 1077 } |
| 1076 | 1078 |
| 1077 void BrowserWindowGtk::ConnectAccelerators() { | 1079 void BrowserWindowGtk::ConnectAccelerators() { |
| 1078 GtkAccelGroup* accel_group = gtk_accel_group_new(); | 1080 GtkAccelGroup* accel_group = gtk_accel_group_new(); |
| 1079 gtk_window_add_accel_group(window_, accel_group); | 1081 gtk_window_add_accel_group(window_, accel_group); |
| 1080 // Drop the initial ref on |accel_group| so |window_| will own it. | 1082 // Drop the initial ref on |accel_group| so |window_| will own it. |
| 1081 g_object_unref(accel_group); | 1083 g_object_unref(accel_group); |
| 1082 | 1084 |
| 1083 for (size_t i = 0; i < arraysize(kAcceleratorMap); ++i) { | 1085 for (size_t i = 0; i < arraysize(kAcceleratorMap); ++i) { |
| 1084 gtk_accel_group_connect( | 1086 gtk_accel_group_connect( |
| 1085 accel_group, | 1087 accel_group, |
| 1086 kAcceleratorMap[i].keyval, | 1088 kAcceleratorMap[i].keyval, |
| 1087 kAcceleratorMap[i].modifier_type, | 1089 kAcceleratorMap[i].modifier_type, |
| 1088 GtkAccelFlags(0), | 1090 GtkAccelFlags(0), |
| 1089 g_cclosure_new(G_CALLBACK(OnGtkAccelerator), this, NULL)); | 1091 g_cclosure_new(G_CALLBACK(OnGtkAccelerator), this, NULL)); |
| 1090 } | 1092 } |
| 1091 } | 1093 } |
| 1092 | 1094 |
| 1093 void BrowserWindowGtk::UpdateCustomFrame() { | 1095 void BrowserWindowGtk::UpdateCustomFrame() { |
| 1094 bool enable = use_custom_frame_.GetValue() && !full_screen_; | 1096 bool enable = use_custom_frame_.GetValue() && !full_screen_; |
| 1095 gtk_window_set_decorated(window_, !enable); | 1097 gtk_window_set_decorated(window_, !enable); |
| 1096 titlebar_->UpdateCustomFrame(enable); | 1098 titlebar_->UpdateCustomFrame(enable); |
| 1097 UpdateWindowShape(bounds_.width(), bounds_.height()); | 1099 UpdateWindowShape(bounds_.width(), bounds_.height()); |
| 1098 if (enable) { | |
| 1099 gtk_alignment_set_padding(GTK_ALIGNMENT(window_container_), 1, | |
| 1100 kFrameBorderThickness, kFrameBorderThickness, kFrameBorderThickness); | |
| 1101 } else { | |
| 1102 gtk_alignment_set_padding(GTK_ALIGNMENT(window_container_), 0, 0, 0, 0); | |
| 1103 } | |
| 1104 } | 1100 } |
| 1105 | 1101 |
| 1106 void BrowserWindowGtk::SaveWindowPosition() { | 1102 void BrowserWindowGtk::SaveWindowPosition() { |
| 1107 // Browser::SaveWindowPlacement is used for session restore. | 1103 // Browser::SaveWindowPlacement is used for session restore. |
| 1108 if (browser_->ShouldSaveWindowPlacement()) | 1104 if (browser_->ShouldSaveWindowPlacement()) |
| 1109 browser_->SaveWindowPlacement(bounds_, IsMaximized()); | 1105 browser_->SaveWindowPlacement(bounds_, IsMaximized()); |
| 1110 | 1106 |
| 1111 // We also need to save the placement for startup. | 1107 // We also need to save the placement for startup. |
| 1112 // This is a web of calls between views and delegates on Windows, but the | 1108 // This is a web of calls between views and delegates on Windows, but the |
| 1113 // crux of the logic follows. See also cocoa/browser_window_controller.mm. | 1109 // crux of the logic follows. See also cocoa/browser_window_controller.mm. |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1337 *edge = GDK_WINDOW_EDGE_NORTH_EAST; | 1333 *edge = GDK_WINDOW_EDGE_NORTH_EAST; |
| 1338 } else if (y < bounds_.height() - kResizeAreaCornerSize) { | 1334 } else if (y < bounds_.height() - kResizeAreaCornerSize) { |
| 1339 *edge = GDK_WINDOW_EDGE_EAST; | 1335 *edge = GDK_WINDOW_EDGE_EAST; |
| 1340 } else { | 1336 } else { |
| 1341 *edge = GDK_WINDOW_EDGE_SOUTH_EAST; | 1337 *edge = GDK_WINDOW_EDGE_SOUTH_EAST; |
| 1342 } | 1338 } |
| 1343 return true; | 1339 return true; |
| 1344 } | 1340 } |
| 1345 NOTREACHED(); | 1341 NOTREACHED(); |
| 1346 } | 1342 } |
| OLD | NEW |