| 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 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 if (exterior) { | 681 if (exterior) { |
| 682 SetWindowSize(window_, gfx::Size(width, height)); | 682 SetWindowSize(window_, gfx::Size(width, height)); |
| 683 } else { | 683 } else { |
| 684 gtk_widget_set_size_request(contents_container_->widget(), | 684 gtk_widget_set_size_request(contents_container_->widget(), |
| 685 width, height); | 685 width, height); |
| 686 } | 686 } |
| 687 } | 687 } |
| 688 | 688 |
| 689 void BrowserWindowGtk::SetBounds(const gfx::Rect& bounds) { | 689 void BrowserWindowGtk::SetBounds(const gfx::Rect& bounds) { |
| 690 if (IsFullscreen()) | 690 if (IsFullscreen()) |
| 691 SetFullscreen(false); | 691 ExitFullscreen(); |
| 692 SetBoundsImpl(bounds, true, true); | 692 SetBoundsImpl(bounds, true, true); |
| 693 } | 693 } |
| 694 | 694 |
| 695 void BrowserWindowGtk::Close() { | 695 void BrowserWindowGtk::Close() { |
| 696 // We're already closing. Do nothing. | 696 // We're already closing. Do nothing. |
| 697 if (!window_) | 697 if (!window_) |
| 698 return; | 698 return; |
| 699 | 699 |
| 700 if (!CanClose()) | 700 if (!CanClose()) |
| 701 return; | 701 return; |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 } | 843 } |
| 844 | 844 |
| 845 bool BrowserWindowGtk::IsMinimized() const { | 845 bool BrowserWindowGtk::IsMinimized() const { |
| 846 return (state_ & GDK_WINDOW_STATE_ICONIFIED); | 846 return (state_ & GDK_WINDOW_STATE_ICONIFIED); |
| 847 } | 847 } |
| 848 | 848 |
| 849 bool BrowserWindowGtk::ShouldDrawContentDropShadow() { | 849 bool BrowserWindowGtk::ShouldDrawContentDropShadow() { |
| 850 return !IsMaximized() && UseCustomFrame(); | 850 return !IsMaximized() && UseCustomFrame(); |
| 851 } | 851 } |
| 852 | 852 |
| 853 void BrowserWindowGtk::SetFullscreen(bool fullscreen) { | 853 void BrowserWindowGtk::EnterFullscreen(const GURL& url, bool ask_permission) { |
| 854 // gtk_window_(un)fullscreen asks the window manager to toggle the EWMH | 854 // gtk_window_(un)fullscreen asks the window manager to toggle the EWMH |
| 855 // for fullscreen windows. Not all window managers support this. | 855 // for fullscreen windows. Not all window managers support this. |
| 856 if (fullscreen) { | 856 gtk_window_fullscreen(window_); |
| 857 gtk_window_fullscreen(window_); | 857 bool is_kiosk = |
| 858 } else { | 858 CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode); |
| 859 // Work around a bug where if we try to unfullscreen, metacity immediately | 859 if (!is_kiosk) { |
| 860 // fullscreens us again. This is a little flickery and not necessary if | 860 fullscreen_exit_bubble_.reset(new FullscreenExitBubbleGtk( |
| 861 // there's a gnome-panel, but it's not easy to detect whether there's a | 861 GTK_FLOATING_CONTAINER(render_area_floating_container_), |
| 862 // panel or not. | 862 browser(), |
| 863 std::string wm_name; | 863 url, |
| 864 bool unmaximize_before_unfullscreen = IsMaximized() && | 864 ask_permission)); |
| 865 ui::GetWindowManagerName(&wm_name) && wm_name == "Metacity"; | 865 } |
| 866 if (unmaximize_before_unfullscreen) | 866 } |
| 867 UnMaximize(); | |
| 868 | 867 |
| 869 gtk_window_unfullscreen(window_); | 868 void BrowserWindowGtk::ExitFullscreen() { |
| 869 // Work around a bug where if we try to unfullscreen, metacity immediately |
| 870 // fullscreens us again. This is a little flickery and not necessary if |
| 871 // there's a gnome-panel, but it's not easy to detect whether there's a |
| 872 // panel or not. |
| 873 std::string wm_name; |
| 874 bool unmaximize_before_unfullscreen = IsMaximized() && |
| 875 ui::GetWindowManagerName(&wm_name) && wm_name == "Metacity"; |
| 876 if (unmaximize_before_unfullscreen) |
| 877 UnMaximize(); |
| 870 | 878 |
| 871 if (unmaximize_before_unfullscreen) | 879 gtk_window_unfullscreen(window_); |
| 872 gtk_window_maximize(window_); | 880 |
| 873 } | 881 if (unmaximize_before_unfullscreen) |
| 882 gtk_window_maximize(window_); |
| 874 } | 883 } |
| 875 | 884 |
| 876 bool BrowserWindowGtk::IsFullscreen() const { | 885 bool BrowserWindowGtk::IsFullscreen() const { |
| 877 return (state_ & GDK_WINDOW_STATE_FULLSCREEN); | 886 return (state_ & GDK_WINDOW_STATE_FULLSCREEN); |
| 878 } | 887 } |
| 879 | 888 |
| 880 bool BrowserWindowGtk::IsFullscreenBubbleVisible() const { | 889 bool BrowserWindowGtk::IsFullscreenBubbleVisible() const { |
| 881 return fullscreen_exit_bubble_.get() ? true : false; | 890 return fullscreen_exit_bubble_.get() ? true : false; |
| 882 } | 891 } |
| 883 | 892 |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1424 if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN) { | 1433 if (event->changed_mask & GDK_WINDOW_STATE_FULLSCREEN) { |
| 1425 browser_->WindowFullscreenStateChanged(); | 1434 browser_->WindowFullscreenStateChanged(); |
| 1426 if (state_ & GDK_WINDOW_STATE_FULLSCREEN) { | 1435 if (state_ & GDK_WINDOW_STATE_FULLSCREEN) { |
| 1427 UpdateCustomFrame(); | 1436 UpdateCustomFrame(); |
| 1428 toolbar_->Hide(); | 1437 toolbar_->Hide(); |
| 1429 tabstrip_->Hide(); | 1438 tabstrip_->Hide(); |
| 1430 if (bookmark_bar_.get()) | 1439 if (bookmark_bar_.get()) |
| 1431 gtk_widget_hide(bookmark_bar_->widget()); | 1440 gtk_widget_hide(bookmark_bar_->widget()); |
| 1432 bool is_kiosk = | 1441 bool is_kiosk = |
| 1433 CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode); | 1442 CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode); |
| 1434 if (!is_kiosk) { | 1443 if (!is_kiosk && !fullscreen_exit_bubble_.get()) { |
| 1435 fullscreen_exit_bubble_.reset(new FullscreenExitBubbleGtk( | 1444 fullscreen_exit_bubble_.reset(new FullscreenExitBubbleGtk( |
| 1436 GTK_FLOATING_CONTAINER(render_area_floating_container_), | 1445 GTK_FLOATING_CONTAINER(render_area_floating_container_), |
| 1437 browser())); | 1446 browser(), |
| 1447 GURL(), |
| 1448 false)); |
| 1438 } | 1449 } |
| 1439 gtk_widget_hide(toolbar_border_); | 1450 gtk_widget_hide(toolbar_border_); |
| 1440 } else { | 1451 } else { |
| 1441 fullscreen_exit_bubble_.reset(); | 1452 fullscreen_exit_bubble_.reset(); |
| 1442 UpdateCustomFrame(); | 1453 UpdateCustomFrame(); |
| 1443 ShowSupportedWindowFeatures(); | 1454 ShowSupportedWindowFeatures(); |
| 1444 } | 1455 } |
| 1445 } | 1456 } |
| 1446 | 1457 |
| 1447 titlebar_->UpdateCustomFrame(UseCustomFrame() && !IsFullscreen()); | 1458 titlebar_->UpdateCustomFrame(UseCustomFrame() && !IsFullscreen()); |
| (...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2388 wm_name == "Openbox" || | 2399 wm_name == "Openbox" || |
| 2389 wm_name == "Xfwm4"); | 2400 wm_name == "Xfwm4"); |
| 2390 } | 2401 } |
| 2391 | 2402 |
| 2392 // static | 2403 // static |
| 2393 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { | 2404 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { |
| 2394 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); | 2405 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); |
| 2395 browser_window_gtk->Init(); | 2406 browser_window_gtk->Init(); |
| 2396 return browser_window_gtk; | 2407 return browser_window_gtk; |
| 2397 } | 2408 } |
| OLD | NEW |