Chromium Code Reviews| 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 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 903 } | 903 } |
| 904 | 904 |
| 905 void BrowserWindowGtk::Restore() { | 905 void BrowserWindowGtk::Restore() { |
| 906 if (IsMaximized()) | 906 if (IsMaximized()) |
| 907 UnMaximize(); | 907 UnMaximize(); |
| 908 else if (IsMinimized()) | 908 else if (IsMinimized()) |
| 909 gtk_window_deiconify(window_); | 909 gtk_window_deiconify(window_); |
| 910 } | 910 } |
| 911 | 911 |
| 912 bool BrowserWindowGtk::ShouldDrawContentDropShadow() { | 912 bool BrowserWindowGtk::ShouldDrawContentDropShadow() { |
| 913 return !IsMaximized() && UseCustomFrame(); | 913 return !IsMaximized() && !IsMinimized() && UseCustomFrame(); |
|
jennb
2012/04/27 18:36:13
Suggest overriding ShouldDrawContentDropShadow() i
jianli
2012/04/27 20:22:34
Done.
| |
| 914 } | 914 } |
| 915 | 915 |
| 916 void BrowserWindowGtk::EnterFullscreen( | 916 void BrowserWindowGtk::EnterFullscreen( |
| 917 const GURL& url, FullscreenExitBubbleType type) { | 917 const GURL& url, FullscreenExitBubbleType type) { |
| 918 // gtk_window_(un)fullscreen asks the window manager to toggle the EWMH | 918 // gtk_window_(un)fullscreen asks the window manager to toggle the EWMH |
| 919 // for fullscreen windows. Not all window managers support this. | 919 // for fullscreen windows. Not all window managers support this. |
| 920 gtk_window_fullscreen(window_); | 920 gtk_window_fullscreen(window_); |
| 921 fullscreen_exit_bubble_type_ = type; | 921 fullscreen_exit_bubble_type_ = type; |
| 922 } | 922 } |
| 923 | 923 |
| (...skipping 1520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2444 browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR); | 2444 browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR); |
| 2445 } | 2445 } |
| 2446 | 2446 |
| 2447 bool BrowserWindowGtk::IsBookmarkBarSupported() const { | 2447 bool BrowserWindowGtk::IsBookmarkBarSupported() const { |
| 2448 return browser_->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR); | 2448 return browser_->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR); |
| 2449 } | 2449 } |
| 2450 | 2450 |
| 2451 bool BrowserWindowGtk::UsingCustomPopupFrame() const { | 2451 bool BrowserWindowGtk::UsingCustomPopupFrame() const { |
| 2452 ThemeServiceGtk* theme_provider = ThemeServiceGtk::GetFrom( | 2452 ThemeServiceGtk* theme_provider = ThemeServiceGtk::GetFrom( |
| 2453 browser()->profile()); | 2453 browser()->profile()); |
| 2454 return !theme_provider->UsingNativeTheme() && | 2454 return !theme_provider->UsingNativeTheme() && browser()->is_type_popup(); |
| 2455 (browser()->is_type_popup() || browser()->is_type_panel()); | |
|
jennb
2012/04/27 18:36:13
FYI - (not for this patch) There are still other u
| |
| 2456 } | 2455 } |
| 2457 | 2456 |
| 2458 BrowserTitlebar* BrowserWindowGtk::CreateBrowserTitlebar() { | 2457 BrowserTitlebar* BrowserWindowGtk::CreateBrowserTitlebar() { |
| 2459 return new BrowserTitlebar(this, window_); | 2458 return new BrowserTitlebar(this, window_); |
| 2460 } | 2459 } |
| 2461 | 2460 |
| 2462 bool BrowserWindowGtk::GetWindowEdge(int x, int y, GdkWindowEdge* edge) { | 2461 bool BrowserWindowGtk::GetWindowEdge(int x, int y, GdkWindowEdge* edge) { |
| 2463 if (!UseCustomFrame()) | 2462 if (!UseCustomFrame()) |
| 2464 return false; | 2463 return false; |
| 2465 | 2464 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2551 GtkWidget* parent = gtk_widget_get_parent(bookmark_bar_->widget()); | 2550 GtkWidget* parent = gtk_widget_get_parent(bookmark_bar_->widget()); |
| 2552 if (parent != target_parent) { | 2551 if (parent != target_parent) { |
| 2553 if (parent) | 2552 if (parent) |
| 2554 gtk_container_remove(GTK_CONTAINER(parent), bookmark_bar_->widget()); | 2553 gtk_container_remove(GTK_CONTAINER(parent), bookmark_bar_->widget()); |
| 2555 | 2554 |
| 2556 gtk_box_pack_end(GTK_BOX(target_parent), bookmark_bar_->widget(), | 2555 gtk_box_pack_end(GTK_BOX(target_parent), bookmark_bar_->widget(), |
| 2557 FALSE, FALSE, 0); | 2556 FALSE, FALSE, 0); |
| 2558 } | 2557 } |
| 2559 } | 2558 } |
| 2560 | 2559 |
| 2561 BrowserWindowGtk::TitleDecoration BrowserWindowGtk::GetWindowTitle( | |
| 2562 std::string* title) const { | |
| 2563 *title = UTF16ToUTF8(browser()->GetWindowTitleForCurrentTab()); | |
| 2564 return PLAIN_TEXT; | |
| 2565 } | |
| 2566 | |
| 2567 // static | 2560 // static |
| 2568 bool BrowserWindowGtk::GetCustomFramePrefDefault() { | 2561 bool BrowserWindowGtk::GetCustomFramePrefDefault() { |
| 2569 // Ideally, we'd use the custom frame by default and just fall back on using | 2562 // Ideally, we'd use the custom frame by default and just fall back on using |
| 2570 // system decorations for the few (?) tiling window managers where the custom | 2563 // system decorations for the few (?) tiling window managers where the custom |
| 2571 // frame doesn't make sense (e.g. awesome, ion3, ratpoison, xmonad, etc.) or | 2564 // frame doesn't make sense (e.g. awesome, ion3, ratpoison, xmonad, etc.) or |
| 2572 // other WMs where it has issues (e.g. Fluxbox -- see issue 19130). The EWMH | 2565 // other WMs where it has issues (e.g. Fluxbox -- see issue 19130). The EWMH |
| 2573 // _NET_SUPPORTING_WM property makes it easy to look up a name for the current | 2566 // _NET_SUPPORTING_WM property makes it easy to look up a name for the current |
| 2574 // WM, but at least some of the WMs in the latter group don't set it. | 2567 // WM, but at least some of the WMs in the latter group don't set it. |
| 2575 // Instead, we default to using system decorations for all WMs and | 2568 // Instead, we default to using system decorations for all WMs and |
| 2576 // special-case the ones where the custom frame should be used. | 2569 // special-case the ones where the custom frame should be used. |
| 2577 ui::WindowManagerName wm_type = ui::GuessWindowManager(); | 2570 ui::WindowManagerName wm_type = ui::GuessWindowManager(); |
| 2578 return (wm_type == ui::WM_BLACKBOX || | 2571 return (wm_type == ui::WM_BLACKBOX || |
| 2579 wm_type == ui::WM_COMPIZ || | 2572 wm_type == ui::WM_COMPIZ || |
| 2580 wm_type == ui::WM_ENLIGHTENMENT || | 2573 wm_type == ui::WM_ENLIGHTENMENT || |
| 2581 wm_type == ui::WM_METACITY || | 2574 wm_type == ui::WM_METACITY || |
| 2582 wm_type == ui::WM_MUTTER || | 2575 wm_type == ui::WM_MUTTER || |
| 2583 wm_type == ui::WM_OPENBOX || | 2576 wm_type == ui::WM_OPENBOX || |
| 2584 wm_type == ui::WM_XFWM4); | 2577 wm_type == ui::WM_XFWM4); |
| 2585 } | 2578 } |
| 2586 | 2579 |
| 2587 // static | 2580 // static |
| 2588 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { | 2581 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { |
| 2589 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); | 2582 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); |
| 2590 browser_window_gtk->Init(); | 2583 browser_window_gtk->Init(); |
| 2591 return browser_window_gtk; | 2584 return browser_window_gtk; |
| 2592 } | 2585 } |
| OLD | NEW |