| OLD | NEW |
| 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 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 | 430 |
| 431 // Setting _GTK_HIDE_TITLEBAR_WHEN_MAXIMIZED tells gnome-shell to not force | 431 // Setting _GTK_HIDE_TITLEBAR_WHEN_MAXIMIZED tells gnome-shell to not force |
| 432 // fullscreen on the window when it matches the desktop size. | 432 // fullscreen on the window when it matches the desktop size. |
| 433 ui::SetHideTitlebarWhenMaximizedProperty( | 433 ui::SetHideTitlebarWhenMaximizedProperty( |
| 434 ui::GetX11WindowFromGtkWidget(GTK_WIDGET(window_))); | 434 ui::GetX11WindowFromGtkWidget(GTK_WIDGET(window_))); |
| 435 } | 435 } |
| 436 | 436 |
| 437 gboolean BrowserWindowGtk::OnCustomFrameExpose(GtkWidget* widget, | 437 gboolean BrowserWindowGtk::OnCustomFrameExpose(GtkWidget* widget, |
| 438 GdkEventExpose* event) { | 438 GdkEventExpose* event) { |
| 439 TRACE_EVENT0("ui::gtk", "BrowserWindowGtk::OnCustomFrameExpose"); | 439 TRACE_EVENT0("ui::gtk", "BrowserWindowGtk::OnCustomFrameExpose"); |
| 440 DrawFrame(widget, event); |
| 441 return FALSE; // Allow subwidgets to paint. |
| 442 } |
| 440 | 443 |
| 444 void BrowserWindowGtk::DrawFrame(GtkWidget* widget, GdkEventExpose* event) { |
| 441 // Draw the default background. | 445 // Draw the default background. |
| 442 cairo_t* cr = gdk_cairo_create(gtk_widget_get_window(widget)); | 446 cairo_t* cr = gdk_cairo_create(gtk_widget_get_window(widget)); |
| 443 gdk_cairo_rectangle(cr, &event->area); | 447 gdk_cairo_rectangle(cr, &event->area); |
| 444 cairo_clip(cr); | 448 cairo_clip(cr); |
| 445 | 449 |
| 446 if (UsingCustomPopupFrame()) { | 450 if (UsingCustomPopupFrame()) { |
| 447 DrawPopupFrame(cr, widget, event); | 451 DrawPopupFrame(cr, widget, event); |
| 448 } else { | 452 } else { |
| 449 DrawCustomFrame(cr, widget, event); | 453 DrawCustomFrame(cr, widget, event); |
| 450 } | 454 } |
| 451 | 455 |
| 452 DrawContentShadow(cr); | 456 DrawContentShadow(cr); |
| 453 | 457 |
| 454 cairo_destroy(cr); | 458 cairo_destroy(cr); |
| 455 | 459 |
| 456 if (UseCustomFrame() && !IsMaximized()) | 460 if (UseCustomFrame() && !IsMaximized()) |
| 457 DrawCustomFrameBorder(widget); | 461 DrawCustomFrameBorder(widget); |
| 458 | |
| 459 return FALSE; // Allow subwidgets to paint. | |
| 460 } | 462 } |
| 461 | 463 |
| 462 void BrowserWindowGtk::DrawCustomFrameBorder(GtkWidget* widget) { | 464 void BrowserWindowGtk::DrawCustomFrameBorder(GtkWidget* widget) { |
| 463 static NineBox* custom_frame_border = NULL; | 465 static NineBox* custom_frame_border = NULL; |
| 464 if (!custom_frame_border) { | 466 if (!custom_frame_border) { |
| 465 custom_frame_border = new NineBox(IDR_WINDOW_TOP_LEFT_CORNER, | 467 custom_frame_border = new NineBox(IDR_WINDOW_TOP_LEFT_CORNER, |
| 466 IDR_WINDOW_TOP_CENTER, | 468 IDR_WINDOW_TOP_CENTER, |
| 467 IDR_WINDOW_TOP_RIGHT_CORNER, | 469 IDR_WINDOW_TOP_RIGHT_CORNER, |
| 468 IDR_WINDOW_LEFT_SIDE, | 470 IDR_WINDOW_LEFT_SIDE, |
| 469 0, | 471 0, |
| (...skipping 2002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2472 bool BrowserWindowGtk::IsBookmarkBarSupported() const { | 2474 bool BrowserWindowGtk::IsBookmarkBarSupported() const { |
| 2473 return browser_->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR); | 2475 return browser_->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR); |
| 2474 } | 2476 } |
| 2475 | 2477 |
| 2476 bool BrowserWindowGtk::UsingCustomPopupFrame() const { | 2478 bool BrowserWindowGtk::UsingCustomPopupFrame() const { |
| 2477 GtkThemeService* theme_provider = GtkThemeService::GetFrom( | 2479 GtkThemeService* theme_provider = GtkThemeService::GetFrom( |
| 2478 browser()->profile()); | 2480 browser()->profile()); |
| 2479 return !theme_provider->UsingNativeTheme() && browser()->is_type_popup(); | 2481 return !theme_provider->UsingNativeTheme() && browser()->is_type_popup(); |
| 2480 } | 2482 } |
| 2481 | 2483 |
| 2482 BrowserTitlebar* BrowserWindowGtk::CreateBrowserTitlebar() { | 2484 BrowserTitlebarBase* BrowserWindowGtk::CreateBrowserTitlebar() { |
| 2483 return new BrowserTitlebar(this, window_); | 2485 return new BrowserTitlebar(this, window_); |
| 2484 } | 2486 } |
| 2485 | 2487 |
| 2486 bool BrowserWindowGtk::GetWindowEdge(int x, int y, GdkWindowEdge* edge) { | 2488 bool BrowserWindowGtk::GetWindowEdge(int x, int y, GdkWindowEdge* edge) { |
| 2487 if (!UseCustomFrame()) | 2489 if (!UseCustomFrame()) |
| 2488 return false; | 2490 return false; |
| 2489 | 2491 |
| 2490 if (IsMaximized() || IsFullscreen()) | 2492 if (IsMaximized() || IsFullscreen()) |
| 2491 return false; | 2493 return false; |
| 2492 | 2494 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2601 wm_type == ui::WM_OPENBOX || | 2603 wm_type == ui::WM_OPENBOX || |
| 2602 wm_type == ui::WM_XFWM4); | 2604 wm_type == ui::WM_XFWM4); |
| 2603 } | 2605 } |
| 2604 | 2606 |
| 2605 // static | 2607 // static |
| 2606 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { | 2608 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { |
| 2607 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); | 2609 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); |
| 2608 browser_window_gtk->Init(); | 2610 browser_window_gtk->Init(); |
| 2609 return browser_window_gtk; | 2611 return browser_window_gtk; |
| 2610 } | 2612 } |
| OLD | NEW |