Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: chrome/browser/ui/gtk/browser_window_gtk.cc

Issue 10262025: Make bottom corners of panels not rounded on GTK. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Patch to land Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser_window_gtk.h" 5 #include "chrome/browser/ui/gtk/browser_window_gtk.h"
6 6
7 #include <dlfcn.h> 7 #include <dlfcn.h>
8 #include <gdk/gdkkeysyms.h> 8 #include <gdk/gdkkeysyms.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 if (UsingCustomPopupFrame()) { 441 if (UsingCustomPopupFrame()) {
442 DrawPopupFrame(cr, widget, event); 442 DrawPopupFrame(cr, widget, event);
443 } else { 443 } else {
444 DrawCustomFrame(cr, widget, event); 444 DrawCustomFrame(cr, widget, event);
445 } 445 }
446 446
447 DrawContentShadow(cr); 447 DrawContentShadow(cr);
448 448
449 cairo_destroy(cr); 449 cairo_destroy(cr);
450 450
451 if (UseCustomFrame() && !IsMaximized()) { 451 if (UseCustomFrame() && !IsMaximized())
452 static NineBox* custom_frame_border = NULL; 452 DrawCustomFrameBorder(widget);
453 if (!custom_frame_border) {
454 custom_frame_border = new NineBox(IDR_WINDOW_TOP_LEFT_CORNER,
455 IDR_WINDOW_TOP_CENTER,
456 IDR_WINDOW_TOP_RIGHT_CORNER,
457 IDR_WINDOW_LEFT_SIDE,
458 0,
459 IDR_WINDOW_RIGHT_SIDE,
460 IDR_WINDOW_BOTTOM_LEFT_CORNER,
461 IDR_WINDOW_BOTTOM_CENTER,
462 IDR_WINDOW_BOTTOM_RIGHT_CORNER);
463 }
464 custom_frame_border->RenderToWidget(widget);
465 }
466 453
467 return FALSE; // Allow subwidgets to paint. 454 return FALSE; // Allow subwidgets to paint.
468 } 455 }
469 456
457 void BrowserWindowGtk::DrawCustomFrameBorder(GtkWidget* widget) {
458 static NineBox* custom_frame_border = NULL;
459 if (!custom_frame_border) {
460 custom_frame_border = new NineBox(IDR_WINDOW_TOP_LEFT_CORNER,
461 IDR_WINDOW_TOP_CENTER,
462 IDR_WINDOW_TOP_RIGHT_CORNER,
463 IDR_WINDOW_LEFT_SIDE,
464 0,
465 IDR_WINDOW_RIGHT_SIDE,
466 IDR_WINDOW_BOTTOM_LEFT_CORNER,
467 IDR_WINDOW_BOTTOM_CENTER,
468 IDR_WINDOW_BOTTOM_RIGHT_CORNER);
469 }
470 custom_frame_border->RenderToWidget(widget);
471 }
472
470 void BrowserWindowGtk::DrawContentShadow(cairo_t* cr) { 473 void BrowserWindowGtk::DrawContentShadow(cairo_t* cr) {
471 // Draw the shadow above the toolbar. Tabs on the tabstrip will draw over us. 474 // Draw the shadow above the toolbar. Tabs on the tabstrip will draw over us.
472 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 475 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
473 int left_x, top_y; 476 int left_x, top_y;
474 gtk_widget_translate_coordinates(toolbar_->widget(), 477 gtk_widget_translate_coordinates(toolbar_->widget(),
475 GTK_WIDGET(window_), 0, 0, &left_x, 478 GTK_WIDGET(window_), 0, 0, &left_x,
476 &top_y); 479 &top_y);
477 480
478 GtkAllocation window_vbox_allocation; 481 GtkAllocation window_vbox_allocation;
479 gtk_widget_get_allocation(window_vbox_, &window_vbox_allocation); 482 gtk_widget_get_allocation(window_vbox_, &window_vbox_allocation);
(...skipping 1496 matching lines...) Expand 10 before | Expand all | Expand 10 after
1976 1979
1977 GdkColor border_color = theme_provider->GetBorderColor(); 1980 GdkColor border_color = theme_provider->GetBorderColor();
1978 gtk_widget_modify_bg(toolbar_border_, GTK_STATE_NORMAL, &border_color); 1981 gtk_widget_modify_bg(toolbar_border_, GTK_STATE_NORMAL, &border_color);
1979 } 1982 }
1980 1983
1981 void BrowserWindowGtk::OnSizeChanged(int width, int height) { 1984 void BrowserWindowGtk::OnSizeChanged(int width, int height) {
1982 UpdateWindowShape(width, height); 1985 UpdateWindowShape(width, height);
1983 } 1986 }
1984 1987
1985 void BrowserWindowGtk::UpdateWindowShape(int width, int height) { 1988 void BrowserWindowGtk::UpdateWindowShape(int width, int height) {
1989 GdkRegion* mask = GetWindowShape(width, height);
1990 gdk_window_shape_combine_region(
1991 gtk_widget_get_window(GTK_WIDGET(window_)), mask, 0, 0);
1992 if (mask)
1993 gdk_region_destroy(mask);
1994
1995 if (UseCustomFrame() && !IsFullscreen() && !IsMaximized()) {
1996 gtk_alignment_set_padding(GTK_ALIGNMENT(window_container_), 1,
1997 kFrameBorderThickness, kFrameBorderThickness, kFrameBorderThickness);
1998 } else {
1999 gtk_alignment_set_padding(GTK_ALIGNMENT(window_container_), 0, 0, 0, 0);
2000 }
2001 }
2002
2003 GdkRegion* BrowserWindowGtk::GetWindowShape(int width, int height) const {
1986 if (UseCustomFrame() && !IsFullscreen() && !IsMaximized()) { 2004 if (UseCustomFrame() && !IsFullscreen() && !IsMaximized()) {
1987 // Make the corners rounded. We set a mask that includes most of the 2005 // Make the corners rounded. We set a mask that includes most of the
1988 // window except for a few pixels in each corner. 2006 // window except for a few pixels in each corner.
1989 GdkRectangle top_top_rect = { 3, 0, width - 6, 1 }; 2007 GdkRectangle top_top_rect = { 3, 0, width - 6, 1 };
1990 GdkRectangle top_mid_rect = { 1, 1, width - 2, 2 }; 2008 GdkRectangle top_mid_rect = { 1, 1, width - 2, 2 };
1991 GdkRectangle mid_rect = { 0, 3, width, height - 6 }; 2009 GdkRectangle mid_rect = { 0, 3, width, height - 6 };
1992 // The bottom two rects are mirror images of the top two rects. 2010 // The bottom two rects are mirror images of the top two rects.
1993 GdkRectangle bot_mid_rect = top_mid_rect; 2011 GdkRectangle bot_mid_rect = top_mid_rect;
1994 bot_mid_rect.y = height - 3; 2012 bot_mid_rect.y = height - 3;
1995 GdkRectangle bot_bot_rect = top_top_rect; 2013 GdkRectangle bot_bot_rect = top_top_rect;
1996 bot_bot_rect.y = height - 1; 2014 bot_bot_rect.y = height - 1;
1997 GdkRegion* mask = gdk_region_rectangle(&top_top_rect); 2015 GdkRegion* mask = gdk_region_rectangle(&top_top_rect);
1998 gdk_region_union_with_rect(mask, &top_mid_rect); 2016 gdk_region_union_with_rect(mask, &top_mid_rect);
1999 gdk_region_union_with_rect(mask, &mid_rect); 2017 gdk_region_union_with_rect(mask, &mid_rect);
2000 gdk_region_union_with_rect(mask, &bot_mid_rect); 2018 gdk_region_union_with_rect(mask, &bot_mid_rect);
2001 gdk_region_union_with_rect(mask, &bot_bot_rect); 2019 gdk_region_union_with_rect(mask, &bot_bot_rect);
2002 gdk_window_shape_combine_region(gtk_widget_get_window(GTK_WIDGET(window_)), 2020 return mask;
2003 mask, 0, 0); 2021 } else if (UseCustomFrame()) {
2004 gdk_region_destroy(mask); 2022 // Disable rounded corners. Simply passing in a NULL region doesn't
2005 gtk_alignment_set_padding(GTK_ALIGNMENT(window_container_), 1, 2023 // seem to work on KWin, so manually set the shape to the whole window.
2006 kFrameBorderThickness, kFrameBorderThickness, kFrameBorderThickness); 2024 GdkRectangle rect = { 0, 0, width, height };
2025 GdkRegion* mask = gdk_region_rectangle(&rect);
2026 return mask;
2007 } else { 2027 } else {
2008 // XFCE disables the system decorations if there's an xshape set. 2028 // XFCE disables the system decorations if there's an xshape set. Do not
2009 if (UseCustomFrame()) { 2029 // use the KWin hack when the custom frame is not enabled.
2010 // Disable rounded corners. Simply passing in a NULL region doesn't 2030 return NULL;
2011 // seem to work on KWin, so manually set the shape to the whole window.
2012 GdkRectangle rect = { 0, 0, width, height };
2013 GdkRegion* mask = gdk_region_rectangle(&rect);
2014 gdk_window_shape_combine_region(
2015 gtk_widget_get_window(GTK_WIDGET(window_)), mask, 0, 0);
2016 gdk_region_destroy(mask);
2017 } else {
2018 gdk_window_shape_combine_region(
2019 gtk_widget_get_window(GTK_WIDGET(window_)), NULL, 0, 0);
2020 }
2021 gtk_alignment_set_padding(GTK_ALIGNMENT(window_container_), 0, 0, 0, 0);
2022 } 2031 }
2023 } 2032 }
2024 2033
2025 void BrowserWindowGtk::ConnectAccelerators() { 2034 void BrowserWindowGtk::ConnectAccelerators() {
2026 accel_group_ = gtk_accel_group_new(); 2035 accel_group_ = gtk_accel_group_new();
2027 gtk_window_add_accel_group(window_, accel_group_); 2036 gtk_window_add_accel_group(window_, accel_group_);
2028 2037
2029 AcceleratorsGtk* accelerators = AcceleratorsGtk::GetInstance(); 2038 AcceleratorsGtk* accelerators = AcceleratorsGtk::GetInstance();
2030 for (AcceleratorsGtk::const_iterator iter = accelerators->begin(); 2039 for (AcceleratorsGtk::const_iterator iter = accelerators->begin();
2031 iter != accelerators->end(); ++iter) { 2040 iter != accelerators->end(); ++iter) {
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
2576 wm_type == ui::WM_OPENBOX || 2585 wm_type == ui::WM_OPENBOX ||
2577 wm_type == ui::WM_XFWM4); 2586 wm_type == ui::WM_XFWM4);
2578 } 2587 }
2579 2588
2580 // static 2589 // static
2581 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { 2590 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) {
2582 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); 2591 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser);
2583 browser_window_gtk->Init(); 2592 browser_window_gtk->Init();
2584 return browser_window_gtk; 2593 return browser_window_gtk;
2585 } 2594 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/browser_window_gtk.h ('k') | chrome/browser/ui/panels/panel_browser_window_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698