| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/gtk/browser_window_gtk.h" | 5 #include "chrome/browser/gtk/browser_window_gtk.h" |
| 6 | 6 |
| 7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
| 8 #include <X11/XF86keysym.h> | 8 #include <X11/XF86keysym.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 #if defined(OS_CHROMEOS) | 480 #if defined(OS_CHROMEOS) |
| 481 drag_active_(false), | 481 drag_active_(false), |
| 482 panel_controller_(NULL), | 482 panel_controller_(NULL), |
| 483 compact_navigation_bar_(NULL), | 483 compact_navigation_bar_(NULL), |
| 484 status_area_(NULL), | 484 status_area_(NULL), |
| 485 #endif | 485 #endif |
| 486 frame_cursor_(NULL), | 486 frame_cursor_(NULL), |
| 487 is_active_(true), | 487 is_active_(true), |
| 488 last_click_time_(0), | 488 last_click_time_(0), |
| 489 maximize_after_show_(false), | 489 maximize_after_show_(false), |
| 490 accel_group_(NULL) { | 490 accel_group_(NULL), |
| 491 set_fullscreen_(false), |
| 492 fullscreen_(false) { |
| 491 use_custom_frame_.Init(prefs::kUseCustomChromeFrame, | 493 use_custom_frame_.Init(prefs::kUseCustomChromeFrame, |
| 492 browser_->profile()->GetPrefs(), this); | 494 browser_->profile()->GetPrefs(), this); |
| 493 | 495 |
| 494 window_ = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); | 496 window_ = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); |
| 495 g_object_set_data(G_OBJECT(window_), kBrowserWindowKey, this); | 497 g_object_set_data(G_OBJECT(window_), kBrowserWindowKey, this); |
| 496 gtk_widget_add_events(GTK_WIDGET(window_), GDK_BUTTON_PRESS_MASK | | 498 gtk_widget_add_events(GTK_WIDGET(window_), GDK_BUTTON_PRESS_MASK | |
| 497 GDK_POINTER_MOTION_MASK); | 499 GDK_POINTER_MOTION_MASK); |
| 498 | 500 |
| 499 // Add this window to its own unique window group to allow for | 501 // Add this window to its own unique window group to allow for |
| 500 // window-to-parent modality. | 502 // window-to-parent modality. |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 | 888 |
| 887 gfx::Rect BrowserWindowGtk::GetRestoredBounds() const { | 889 gfx::Rect BrowserWindowGtk::GetRestoredBounds() const { |
| 888 return restored_bounds_; | 890 return restored_bounds_; |
| 889 } | 891 } |
| 890 | 892 |
| 891 bool BrowserWindowGtk::IsMaximized() const { | 893 bool BrowserWindowGtk::IsMaximized() const { |
| 892 return (state_ & GDK_WINDOW_STATE_MAXIMIZED); | 894 return (state_ & GDK_WINDOW_STATE_MAXIMIZED); |
| 893 } | 895 } |
| 894 | 896 |
| 895 void BrowserWindowGtk::SetFullscreen(bool fullscreen) { | 897 void BrowserWindowGtk::SetFullscreen(bool fullscreen) { |
| 898 set_fullscreen_ = fullscreen; |
| 896 // gtk_window_(un)fullscreen asks the window manager to toggle the EWMH | 899 // gtk_window_(un)fullscreen asks the window manager to toggle the EWMH |
| 897 // for fullscreen windows. Not all window managers support this. | 900 // for fullscreen windows. Not all window managers support this. |
| 898 if (fullscreen) { | 901 if (fullscreen) { |
| 899 gtk_window_fullscreen(window_); | 902 gtk_window_fullscreen(window_); |
| 900 } else { | 903 } else { |
| 901 gtk_window_unfullscreen(window_); | 904 gtk_window_unfullscreen(window_); |
| 902 } | 905 } |
| 903 } | 906 } |
| 904 | 907 |
| 905 bool BrowserWindowGtk::IsFullscreen() const { | 908 bool BrowserWindowGtk::IsFullscreen() const { |
| 906 return (state_ & GDK_WINDOW_STATE_FULLSCREEN); | 909 return fullscreen_; |
| 907 } | 910 } |
| 908 | 911 |
| 909 LocationBar* BrowserWindowGtk::GetLocationBar() const { | 912 LocationBar* BrowserWindowGtk::GetLocationBar() const { |
| 910 return toolbar_->GetLocationBar(); | 913 return toolbar_->GetLocationBar(); |
| 911 } | 914 } |
| 912 | 915 |
| 913 void BrowserWindowGtk::SetFocusToLocationBar() { | 916 void BrowserWindowGtk::SetFocusToLocationBar() { |
| 914 if (!IsFullscreen()) | 917 if (!IsFullscreen()) |
| 915 GetLocationBar()->FocusLocation(); | 918 GetLocationBar()->FocusLocation(); |
| 916 } | 919 } |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1211 | 1214 |
| 1212 void BrowserWindowGtk::UpdateUIForContents(TabContents* contents) { | 1215 void BrowserWindowGtk::UpdateUIForContents(TabContents* contents) { |
| 1213 MaybeShowBookmarkBar(contents, false); | 1216 MaybeShowBookmarkBar(contents, false); |
| 1214 } | 1217 } |
| 1215 | 1218 |
| 1216 void BrowserWindowGtk::DestroyBrowser() { | 1219 void BrowserWindowGtk::DestroyBrowser() { |
| 1217 browser_.reset(); | 1220 browser_.reset(); |
| 1218 } | 1221 } |
| 1219 | 1222 |
| 1220 void BrowserWindowGtk::OnBoundsChanged(const gfx::Rect& bounds) { | 1223 void BrowserWindowGtk::OnBoundsChanged(const gfx::Rect& bounds) { |
| 1224 if (bounds_ == bounds) |
| 1225 return; |
| 1226 |
| 1221 GetLocationBar()->location_entry()->ClosePopup(); | 1227 GetLocationBar()->location_entry()->ClosePopup(); |
| 1222 | 1228 |
| 1223 if (bounds_.size() != bounds.size()) | 1229 if (bounds_.size() != bounds.size()) |
| 1224 OnSizeChanged(bounds.width(), bounds.height()); | 1230 OnSizeChanged(bounds.width(), bounds.height()); |
| 1225 | 1231 |
| 1226 bounds_ = bounds; | 1232 bounds_ = bounds; |
| 1227 if (!IsFullscreen() && !IsMaximized()) | 1233 if (!IsFullscreen() && !IsMaximized()) |
| 1228 restored_bounds_ = bounds; | 1234 restored_bounds_ = bounds; |
| 1229 SaveWindowPosition(); | 1235 SaveWindowPosition(); |
| 1230 } | 1236 } |
| 1231 | 1237 |
| 1232 void BrowserWindowGtk::OnStateChanged(GdkWindowState state, | 1238 void BrowserWindowGtk::OnStateChanged(GdkWindowState state, |
| 1233 GdkWindowState changed_mask) { | 1239 GdkWindowState changed_mask) { |
| 1240 bool fullscreen_state = (state & GDK_WINDOW_STATE_FULLSCREEN); |
| 1241 bool fullscreen_state_changed = (changed_mask & GDK_WINDOW_STATE_FULLSCREEN); |
| 1242 bool is_fullscreen = set_fullscreen_ && fullscreen_state; |
| 1243 |
| 1234 state_ = state; | 1244 state_ = state; |
| 1235 | 1245 |
| 1236 if (changed_mask & GDK_WINDOW_STATE_FULLSCREEN) { | 1246 // If Window Manager turns our window into fullscreen automatically |
| 1237 bool is_fullscreen = state & GDK_WINDOW_STATE_FULLSCREEN; | 1247 // without our request, then we need to turn it back, because we do not |
| 1248 // really want to be in fullscreen mode. |
| 1249 if (fullscreen_state_changed && fullscreen_state && !set_fullscreen_) { |
| 1250 gtk_window_unfullscreen(window_); |
| 1251 return; |
| 1252 } |
| 1253 |
| 1254 if (fullscreen_ != is_fullscreen) { |
| 1255 fullscreen_ = is_fullscreen; |
| 1238 browser_->UpdateCommandsForFullscreenMode(is_fullscreen); | 1256 browser_->UpdateCommandsForFullscreenMode(is_fullscreen); |
| 1239 if (is_fullscreen) { | 1257 if (is_fullscreen) { |
| 1240 UpdateCustomFrame(); | 1258 UpdateCustomFrame(); |
| 1241 toolbar_->Hide(); | 1259 toolbar_->Hide(); |
| 1242 tabstrip_->Hide(); | 1260 tabstrip_->Hide(); |
| 1243 bookmark_bar_->Hide(false); | 1261 bookmark_bar_->Hide(false); |
| 1244 if (extension_shelf_.get()) | 1262 if (extension_shelf_.get()) |
| 1245 extension_shelf_->Hide(); | 1263 extension_shelf_->Hide(); |
| 1246 } else { | 1264 } else { |
| 1247 UpdateCustomFrame(); | 1265 UpdateCustomFrame(); |
| 1248 ShowSupportedWindowFeatures(); | 1266 ShowSupportedWindowFeatures(); |
| 1249 } | 1267 } |
| 1250 } | 1268 } |
| 1251 | |
| 1252 UpdateWindowShape(bounds_.width(), bounds_.height()); | |
| 1253 SaveWindowPosition(); | |
| 1254 } | 1269 } |
| 1255 | 1270 |
| 1256 bool BrowserWindowGtk::CanClose() const { | 1271 bool BrowserWindowGtk::CanClose() const { |
| 1257 #if defined(OS_CHROMEOS) | 1272 #if defined(OS_CHROMEOS) |
| 1258 if (drag_active_) | 1273 if (drag_active_) |
| 1259 return false; | 1274 return false; |
| 1260 #endif | 1275 #endif |
| 1261 | 1276 |
| 1262 // You cannot close a frame for which there is an active originating drag | 1277 // You cannot close a frame for which there is an active originating drag |
| 1263 // session. | 1278 // session. |
| (...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2037 // special-case the ones where the custom frame should be used. These names | 2052 // special-case the ones where the custom frame should be used. These names |
| 2038 // are taken from the WMs' source code. | 2053 // are taken from the WMs' source code. |
| 2039 return (wm_name == "Blackbox" || | 2054 return (wm_name == "Blackbox" || |
| 2040 wm_name == "compiz" || | 2055 wm_name == "compiz" || |
| 2041 wm_name == "e16" || // Enlightenment DR16 | 2056 wm_name == "e16" || // Enlightenment DR16 |
| 2042 wm_name == "KWin" || | 2057 wm_name == "KWin" || |
| 2043 wm_name == "Metacity" || | 2058 wm_name == "Metacity" || |
| 2044 wm_name == "Openbox" || | 2059 wm_name == "Openbox" || |
| 2045 wm_name == "Xfwm4"); | 2060 wm_name == "Xfwm4"); |
| 2046 } | 2061 } |
| OLD | NEW |