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 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 if (exterior) { | 680 if (exterior) { |
681 SetWindowSize(window_, gfx::Size(width, height)); | 681 SetWindowSize(window_, gfx::Size(width, height)); |
682 } else { | 682 } else { |
683 gtk_widget_set_size_request(contents_container_->widget(), | 683 gtk_widget_set_size_request(contents_container_->widget(), |
684 width, height); | 684 width, height); |
685 } | 685 } |
686 } | 686 } |
687 | 687 |
688 void BrowserWindowGtk::SetBounds(const gfx::Rect& bounds) { | 688 void BrowserWindowGtk::SetBounds(const gfx::Rect& bounds) { |
689 if (IsFullscreen()) | 689 if (IsFullscreen()) |
690 SetFullscreen(false); | 690 ExitFullscreen(); |
691 SetBoundsImpl(bounds, true, true); | 691 SetBoundsImpl(bounds, true, true); |
692 } | 692 } |
693 | 693 |
694 void BrowserWindowGtk::Close() { | 694 void BrowserWindowGtk::Close() { |
695 // We're already closing. Do nothing. | 695 // We're already closing. Do nothing. |
696 if (!window_) | 696 if (!window_) |
697 return; | 697 return; |
698 | 698 |
699 if (!CanClose()) | 699 if (!CanClose()) |
700 return; | 700 return; |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
842 } | 842 } |
843 | 843 |
844 bool BrowserWindowGtk::IsMinimized() const { | 844 bool BrowserWindowGtk::IsMinimized() const { |
845 return (state_ & GDK_WINDOW_STATE_ICONIFIED); | 845 return (state_ & GDK_WINDOW_STATE_ICONIFIED); |
846 } | 846 } |
847 | 847 |
848 bool BrowserWindowGtk::ShouldDrawContentDropShadow() { | 848 bool BrowserWindowGtk::ShouldDrawContentDropShadow() { |
849 return !IsMaximized() && UseCustomFrame(); | 849 return !IsMaximized() && UseCustomFrame(); |
850 } | 850 } |
851 | 851 |
852 void BrowserWindowGtk::SetFullscreen(bool fullscreen) { | 852 void BrowserWindowGtk::EnterFullscreen(const GURL& url, bool ask_permission) { |
853 // gtk_window_(un)fullscreen asks the window manager to toggle the EWMH | 853 // gtk_window_(un)fullscreen asks the window manager to toggle the EWMH |
854 // for fullscreen windows. Not all window managers support this. | 854 // for fullscreen windows. Not all window managers support this. |
855 if (fullscreen) { | 855 gtk_window_fullscreen(window_); |
856 gtk_window_fullscreen(window_); | 856 bool is_kiosk = |
857 } else { | 857 CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode); |
858 // Work around a bug where if we try to unfullscreen, metacity immediately | 858 if (!is_kiosk) { |
859 // fullscreens us again. This is a little flickery and not necessary if | 859 fullscreen_exit_bubble_.reset(new FullscreenExitBubbleGtk( |
860 // there's a gnome-panel, but it's not easy to detect whether there's a | 860 GTK_FLOATING_CONTAINER(render_area_floating_container_), |
861 // panel or not. | 861 browser(), |
862 std::string wm_name; | 862 url, |
863 bool unmaximize_before_unfullscreen = IsMaximized() && | 863 ask_permission)); |
864 ui::GetWindowManagerName(&wm_name) && wm_name == "Metacity"; | 864 } |
865 if (unmaximize_before_unfullscreen) | 865 } |
866 UnMaximize(); | |
867 | 866 |
868 gtk_window_unfullscreen(window_); | 867 void BrowserWindowGtk::ExitFullscreen() { |
| 868 // Work around a bug where if we try to unfullscreen, metacity immediately |
| 869 // fullscreens us again. This is a little flickery and not necessary if |
| 870 // there's a gnome-panel, but it's not easy to detect whether there's a |
| 871 // panel or not. |
| 872 std::string wm_name; |
| 873 bool unmaximize_before_unfullscreen = IsMaximized() && |
| 874 ui::GetWindowManagerName(&wm_name) && wm_name == "Metacity"; |
| 875 if (unmaximize_before_unfullscreen) |
| 876 UnMaximize(); |
869 | 877 |
870 if (unmaximize_before_unfullscreen) | 878 gtk_window_unfullscreen(window_); |
871 gtk_window_maximize(window_); | 879 |
872 } | 880 if (unmaximize_before_unfullscreen) |
| 881 gtk_window_maximize(window_); |
873 } | 882 } |
874 | 883 |
875 bool BrowserWindowGtk::IsFullscreen() const { | 884 bool BrowserWindowGtk::IsFullscreen() const { |
876 return (state_ & GDK_WINDOW_STATE_FULLSCREEN); | 885 return (state_ & GDK_WINDOW_STATE_FULLSCREEN); |
877 } | 886 } |
878 | 887 |
879 bool BrowserWindowGtk::IsFullscreenBubbleVisible() const { | 888 bool BrowserWindowGtk::IsFullscreenBubbleVisible() const { |
880 return fullscreen_exit_bubble_.get() ? true : false; | 889 return fullscreen_exit_bubble_.get() ? true : false; |
881 } | 890 } |
882 | 891 |
(...skipping 1497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2380 wm_name == "Openbox" || | 2389 wm_name == "Openbox" || |
2381 wm_name == "Xfwm4"); | 2390 wm_name == "Xfwm4"); |
2382 } | 2391 } |
2383 | 2392 |
2384 // static | 2393 // static |
2385 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { | 2394 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { |
2386 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); | 2395 BrowserWindowGtk* browser_window_gtk = new BrowserWindowGtk(browser); |
2387 browser_window_gtk->Init(); | 2396 browser_window_gtk->Init(); |
2388 return browser_window_gtk; | 2397 return browser_window_gtk; |
2389 } | 2398 } |
OLD | NEW |