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/browser_window_gtk.h" | 5 #include "chrome/browser/ui/gtk/browser_window_gtk.h" |
6 | 6 |
7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
8 | 8 |
9 #include <dlfcn.h> | 9 #include <dlfcn.h> |
10 #include <string> | 10 #include <string> |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 return FALSE; // Allow subwidgets to paint. | 447 return FALSE; // Allow subwidgets to paint. |
448 } | 448 } |
449 | 449 |
450 void BrowserWindowGtk::DrawContentShadow(cairo_t* cr) { | 450 void BrowserWindowGtk::DrawContentShadow(cairo_t* cr) { |
451 // Draw the shadow above the toolbar. Tabs on the tabstrip will draw over us. | 451 // Draw the shadow above the toolbar. Tabs on the tabstrip will draw over us. |
452 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 452 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
453 int left_x, top_y; | 453 int left_x, top_y; |
454 gtk_widget_translate_coordinates(toolbar_->widget(), | 454 gtk_widget_translate_coordinates(toolbar_->widget(), |
455 GTK_WIDGET(window_), 0, 0, &left_x, | 455 GTK_WIDGET(window_), 0, 0, &left_x, |
456 &top_y); | 456 &top_y); |
457 int center_width = window_vbox_->allocation.width; | 457 |
| 458 GtkAllocation window_vbox_allocation; |
| 459 gtk_widget_get_allocation(window_vbox_, &window_vbox_allocation); |
| 460 int center_width = window_vbox_allocation.width; |
458 | 461 |
459 gfx::CairoCachedSurface* top_center = | 462 gfx::CairoCachedSurface* top_center = |
460 rb.GetNativeImageNamed(IDR_CONTENT_TOP_CENTER).ToCairo(); | 463 rb.GetNativeImageNamed(IDR_CONTENT_TOP_CENTER).ToCairo(); |
461 gfx::CairoCachedSurface* top_right = | 464 gfx::CairoCachedSurface* top_right = |
462 rb.GetNativeImageNamed(IDR_CONTENT_TOP_RIGHT_CORNER).ToCairo(); | 465 rb.GetNativeImageNamed(IDR_CONTENT_TOP_RIGHT_CORNER).ToCairo(); |
463 gfx::CairoCachedSurface* top_left = | 466 gfx::CairoCachedSurface* top_left = |
464 rb.GetNativeImageNamed(IDR_CONTENT_TOP_LEFT_CORNER).ToCairo(); | 467 rb.GetNativeImageNamed(IDR_CONTENT_TOP_LEFT_CORNER).ToCairo(); |
465 | 468 |
466 int center_left_x = left_x; | 469 int center_left_x = left_x; |
467 if (ShouldDrawContentDropShadow()) { | 470 if (ShouldDrawContentDropShadow()) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 right_x, | 509 right_x, |
507 top_y - kContentShadowThickness, | 510 top_y - kContentShadowThickness, |
508 top_right->Width(), | 511 top_right->Width(), |
509 top_right->Height()); | 512 top_right->Height()); |
510 cairo_fill(cr); | 513 cairo_fill(cr); |
511 | 514 |
512 // Fill in the sides. As above, we only draw 2 of the 3 columns on Linux. | 515 // Fill in the sides. As above, we only draw 2 of the 3 columns on Linux. |
513 int bottom_y; | 516 int bottom_y; |
514 gtk_widget_translate_coordinates(window_vbox_, | 517 gtk_widget_translate_coordinates(window_vbox_, |
515 GTK_WIDGET(window_), | 518 GTK_WIDGET(window_), |
516 0, window_vbox_->allocation.height, | 519 0, window_vbox_allocation.height, |
517 NULL, &bottom_y); | 520 NULL, &bottom_y); |
518 // |side_y| is where to start drawing the side shadows. The top corners draw | 521 // |side_y| is where to start drawing the side shadows. The top corners draw |
519 // the sides down to the bottom of the toolbar. | 522 // the sides down to the bottom of the toolbar. |
520 int side_y = top_y - kContentShadowThickness + top_right->Height(); | 523 int side_y = top_y - kContentShadowThickness + top_right->Height(); |
521 // |side_height| is how many pixels to draw for the side borders. We do one | 524 // |side_height| is how many pixels to draw for the side borders. We do one |
522 // pixel before the bottom of the web contents because that extra pixel is | 525 // pixel before the bottom of the web contents because that extra pixel is |
523 // drawn by the bottom corners. | 526 // drawn by the bottom corners. |
524 int side_height = bottom_y - side_y - 1; | 527 int side_height = bottom_y - side_y - 1; |
525 if (side_height > 0) { | 528 if (side_height > 0) { |
526 gfx::CairoCachedSurface* left = | 529 gfx::CairoCachedSurface* left = |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 | 567 |
565 // Finally, draw the bottom row. Since we don't overlap the contents, we clip | 568 // Finally, draw the bottom row. Since we don't overlap the contents, we clip |
566 // the top row of pixels. | 569 // the top row of pixels. |
567 gfx::CairoCachedSurface* bottom = | 570 gfx::CairoCachedSurface* bottom = |
568 rb.GetNativeImageNamed(IDR_CONTENT_BOTTOM_CENTER).ToCairo(); | 571 rb.GetNativeImageNamed(IDR_CONTENT_BOTTOM_CENTER).ToCairo(); |
569 bottom->SetSource(cr, GTK_WIDGET(window_), left_x + 1, bottom_y - 1); | 572 bottom->SetSource(cr, GTK_WIDGET(window_), left_x + 1, bottom_y - 1); |
570 cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT); | 573 cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT); |
571 cairo_rectangle(cr, | 574 cairo_rectangle(cr, |
572 left_x + 1, | 575 left_x + 1, |
573 bottom_y, | 576 bottom_y, |
574 window_vbox_->allocation.width - 2, | 577 window_vbox_allocation.width - 2, |
575 kContentShadowThickness); | 578 kContentShadowThickness); |
576 cairo_fill(cr); | 579 cairo_fill(cr); |
577 } | 580 } |
578 | 581 |
579 void BrowserWindowGtk::DrawPopupFrame(cairo_t* cr, | 582 void BrowserWindowGtk::DrawPopupFrame(cairo_t* cr, |
580 GtkWidget* widget, | 583 GtkWidget* widget, |
581 GdkEventExpose* event) { | 584 GdkEventExpose* event) { |
582 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 585 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
583 | 586 |
584 // Like DrawCustomFrame(), except that we use the unthemed resources to draw | 587 // Like DrawCustomFrame(), except that we use the unthemed resources to draw |
(...skipping 1335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1920 } | 1923 } |
1921 | 1924 |
1922 void BrowserWindowGtk::UpdateCustomFrame() { | 1925 void BrowserWindowGtk::UpdateCustomFrame() { |
1923 gtk_window_set_decorated( | 1926 gtk_window_set_decorated( |
1924 window_, !UseCustomFrame() && browser_->type() != Browser::TYPE_SHELL); | 1927 window_, !UseCustomFrame() && browser_->type() != Browser::TYPE_SHELL); |
1925 titlebar_->UpdateCustomFrame(UseCustomFrame() && !IsFullscreen()); | 1928 titlebar_->UpdateCustomFrame(UseCustomFrame() && !IsFullscreen()); |
1926 UpdateWindowShape(bounds_.width(), bounds_.height()); | 1929 UpdateWindowShape(bounds_.width(), bounds_.height()); |
1927 } | 1930 } |
1928 | 1931 |
1929 gfx::Size BrowserWindowGtk::GetNonClientFrameSize() const { | 1932 gfx::Size BrowserWindowGtk::GetNonClientFrameSize() const { |
1930 return gfx::Size(window_container_->allocation.width - | 1933 GtkAllocation window_container_allocation; |
1931 render_area_floating_container_->allocation.width, | 1934 gtk_widget_get_allocation(window_container_, &window_container_allocation); |
1932 window_container_->allocation.height - | 1935 GtkAllocation render_area_floating_container_allocation; |
1933 render_area_floating_container_->allocation.height); | 1936 gtk_widget_get_allocation(render_area_floating_container_, |
| 1937 &render_area_floating_container_allocation); |
| 1938 return gfx::Size(window_container_allocation.width - |
| 1939 render_area_floating_container_allocation.width, |
| 1940 window_container_allocation.height - |
| 1941 render_area_floating_container_allocation.height); |
1934 } | 1942 } |
1935 | 1943 |
1936 void BrowserWindowGtk::InvalidateWindow() { | 1944 void BrowserWindowGtk::InvalidateWindow() { |
1937 gdk_window_invalidate_rect(gtk_widget_get_window(GTK_WIDGET(window_)), | 1945 gdk_window_invalidate_rect(gtk_widget_get_window(GTK_WIDGET(window_)), |
1938 >K_WIDGET(window_)->allocation, TRUE); | 1946 >K_WIDGET(window_)->allocation, TRUE); |
1939 } | 1947 } |
1940 | 1948 |
1941 void BrowserWindowGtk::SaveWindowPosition() { | 1949 void BrowserWindowGtk::SaveWindowPosition() { |
1942 // Browser::SaveWindowPlacement is used for session restore. | 1950 // Browser::SaveWindowPlacement is used for session restore. |
1943 ui::WindowShowState show_state = ui::SHOW_STATE_NORMAL; | 1951 ui::WindowShowState show_state = ui::SHOW_STATE_NORMAL; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1981 gtk_widget_queue_draw(toolbar_->widget()); | 1989 gtk_widget_queue_draw(toolbar_->widget()); |
1982 if (bookmark_bar_.get() && | 1990 if (bookmark_bar_.get() && |
1983 browser_->bookmark_bar_state() != BookmarkBar::DETACHED) { | 1991 browser_->bookmark_bar_state() != BookmarkBar::DETACHED) { |
1984 gtk_widget_queue_draw(bookmark_bar_->widget()); | 1992 gtk_widget_queue_draw(bookmark_bar_->widget()); |
1985 } | 1993 } |
1986 } | 1994 } |
1987 | 1995 |
1988 int BrowserWindowGtk::GetXPositionOfLocationIcon(GtkWidget* relative_to) { | 1996 int BrowserWindowGtk::GetXPositionOfLocationIcon(GtkWidget* relative_to) { |
1989 GtkWidget* location_icon = toolbar_->GetLocationBarView()-> | 1997 GtkWidget* location_icon = toolbar_->GetLocationBarView()-> |
1990 location_icon_widget(); | 1998 location_icon_widget(); |
| 1999 |
| 2000 GtkAllocation location_icon_allocation; |
| 2001 gtk_widget_get_allocation(location_icon, &location_icon_allocation); |
| 2002 |
1991 int x = 0; | 2003 int x = 0; |
1992 gtk_widget_translate_coordinates( | 2004 gtk_widget_translate_coordinates( |
1993 location_icon, relative_to, | 2005 location_icon, relative_to, |
1994 (location_icon->allocation.width + 1) / 2, | 2006 (location_icon_allocation.width + 1) / 2, |
1995 0, &x, NULL); | 2007 0, &x, NULL); |
1996 | 2008 |
1997 if (!gtk_widget_get_has_window(relative_to)) { | 2009 if (!gtk_widget_get_has_window(relative_to)) { |
1998 GtkAllocation allocation; | 2010 GtkAllocation allocation; |
1999 gtk_widget_get_allocation(relative_to, &allocation); | 2011 gtk_widget_get_allocation(relative_to, &allocation); |
2000 x += allocation.x; | 2012 x += allocation.x; |
2001 } | 2013 } |
2002 | 2014 |
2003 return x; | 2015 return x; |
2004 } | 2016 } |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2444 wm_type == ui::WM_OPENBOX || | 2456 wm_type == ui::WM_OPENBOX || |
2445 wm_type == ui::WM_XFWM4); | 2457 wm_type == ui::WM_XFWM4); |
2446 } | 2458 } |
2447 | 2459 |
2448 // static | 2460 // static |
2449 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { | 2461 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { |
2450 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); | 2462 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); |
2451 browser_window_gtk->Init(); | 2463 browser_window_gtk->Init(); |
2452 return browser_window_gtk; | 2464 return browser_window_gtk; |
2453 } | 2465 } |
OLD | NEW |