Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: chrome/browser/ui/gtk/browser_window_gtk.cc

Issue 7621061: Restoring a session should restore window minimization state (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressing Mark's comments. Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/gtk/browser_window_gtk.h ('k') | chrome/browser/ui/panels/panel.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 render_area_vbox_(NULL), 317 render_area_vbox_(NULL),
318 render_area_floating_container_(NULL), 318 render_area_floating_container_(NULL),
319 render_area_event_box_(NULL), 319 render_area_event_box_(NULL),
320 toolbar_border_(NULL), 320 toolbar_border_(NULL),
321 browser_(browser), 321 browser_(browser),
322 state_(GDK_WINDOW_STATE_WITHDRAWN), 322 state_(GDK_WINDOW_STATE_WITHDRAWN),
323 contents_split_(NULL), 323 contents_split_(NULL),
324 frame_cursor_(NULL), 324 frame_cursor_(NULL),
325 is_active_(!ui::ActiveWindowWatcherX::WMSupportsActivation()), 325 is_active_(!ui::ActiveWindowWatcherX::WMSupportsActivation()),
326 last_click_time_(0), 326 last_click_time_(0),
327 maximize_after_show_(false), 327 show_state_after_show_(ui::SHOW_STATE_DEFAULT),
328 suppress_window_raise_(false), 328 suppress_window_raise_(false),
329 accel_group_(NULL), 329 accel_group_(NULL),
330 debounce_timer_disabled_(false) { 330 debounce_timer_disabled_(false) {
331 } 331 }
332 332
333 BrowserWindowGtk::~BrowserWindowGtk() { 333 BrowserWindowGtk::~BrowserWindowGtk() {
334 ui::ActiveWindowWatcherX::RemoveObserver(this); 334 ui::ActiveWindowWatcherX::RemoveObserver(this);
335 335
336 browser_->tabstrip_model()->RemoveObserver(this); 336 browser_->tabstrip_model()->RemoveObserver(this);
337 } 337 }
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 void BrowserWindowGtk::Show() { 638 void BrowserWindowGtk::Show() {
639 // The Browser associated with this browser window must become the active 639 // The Browser associated with this browser window must become the active
640 // browser at the time Show() is called. This is the natural behaviour under 640 // browser at the time Show() is called. This is the natural behaviour under
641 // Windows, but gtk_widget_show won't show the widget (and therefore won't 641 // Windows, but gtk_widget_show won't show the widget (and therefore won't
642 // call OnFocusIn()) until we return to the runloop. Therefore any calls to 642 // call OnFocusIn()) until we return to the runloop. Therefore any calls to
643 // BrowserList::GetLastActive() (for example, in bookmark_util), will return 643 // BrowserList::GetLastActive() (for example, in bookmark_util), will return
644 // the previous browser instead if we don't explicitly set it here. 644 // the previous browser instead if we don't explicitly set it here.
645 BrowserList::SetLastActive(browser()); 645 BrowserList::SetLastActive(browser());
646 646
647 gtk_window_present(window_); 647 gtk_window_present(window_);
648 if (maximize_after_show_) { 648 if (show_state_after_show_ == ui::SHOW_STATE_MAXIMIZED) {
649 gtk_window_maximize(window_); 649 gtk_window_maximize(window_);
650 maximize_after_show_ = false; 650 show_state_after_show_ = ui::SHOW_STATE_NORMAL;
651 } else if (show_state_after_show_ == ui::SHOW_STATE_MINIMIZED) {
652 gtk_window_iconify(window_);
653 show_state_after_show_ = ui::SHOW_STATE_NORMAL;
651 } 654 }
652 655
653 // If we have sized the window by setting a size request for the render 656 // If we have sized the window by setting a size request for the render
654 // area, then undo it so that the render view can later adjust its own 657 // area, then undo it so that the render view can later adjust its own
655 // size. 658 // size.
656 gtk_widget_set_size_request(contents_container_->widget(), -1, -1); 659 gtk_widget_set_size_request(contents_container_->widget(), -1, -1);
657 } 660 }
658 661
659 void BrowserWindowGtk::ShowInactive() { 662 void BrowserWindowGtk::ShowInactive() {
660 gtk_window_set_focus_on_map(window_, false); 663 gtk_window_set_focus_on_map(window_, false);
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 } 832 }
830 833
831 gfx::Rect BrowserWindowGtk::GetBounds() const { 834 gfx::Rect BrowserWindowGtk::GetBounds() const {
832 return bounds_; 835 return bounds_;
833 } 836 }
834 837
835 bool BrowserWindowGtk::IsMaximized() const { 838 bool BrowserWindowGtk::IsMaximized() const {
836 return (state_ & GDK_WINDOW_STATE_MAXIMIZED); 839 return (state_ & GDK_WINDOW_STATE_MAXIMIZED);
837 } 840 }
838 841
842 bool BrowserWindowGtk::IsMinimized() const {
843 return (state_ & GDK_WINDOW_STATE_ICONIFIED);
844 }
845
839 bool BrowserWindowGtk::ShouldDrawContentDropShadow() { 846 bool BrowserWindowGtk::ShouldDrawContentDropShadow() {
840 return !IsMaximized() && UseCustomFrame(); 847 return !IsMaximized() && UseCustomFrame();
841 } 848 }
842 849
843 void BrowserWindowGtk::SetFullscreen(bool fullscreen) { 850 void BrowserWindowGtk::SetFullscreen(bool fullscreen) {
844 // gtk_window_(un)fullscreen asks the window manager to toggle the EWMH 851 // gtk_window_(un)fullscreen asks the window manager to toggle the EWMH
845 // for fullscreen windows. Not all window managers support this. 852 // for fullscreen windows. Not all window managers support this.
846 if (fullscreen) { 853 if (fullscreen) {
847 gtk_window_fullscreen(window_); 854 gtk_window_fullscreen(window_);
848 } else { 855 } else {
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after
1594 1601
1595 void BrowserWindowGtk::QueueToolbarRedraw() { 1602 void BrowserWindowGtk::QueueToolbarRedraw() {
1596 gtk_widget_queue_draw(toolbar_->widget()); 1603 gtk_widget_queue_draw(toolbar_->widget());
1597 } 1604 }
1598 1605
1599 void BrowserWindowGtk::SetGeometryHints() { 1606 void BrowserWindowGtk::SetGeometryHints() {
1600 // If we call gtk_window_maximize followed by gtk_window_present, compiz gets 1607 // If we call gtk_window_maximize followed by gtk_window_present, compiz gets
1601 // confused and maximizes the window, but doesn't set the 1608 // confused and maximizes the window, but doesn't set the
1602 // GDK_WINDOW_STATE_MAXIMIZED bit. So instead, we keep track of whether to 1609 // GDK_WINDOW_STATE_MAXIMIZED bit. So instead, we keep track of whether to
1603 // maximize and call it after gtk_window_present. 1610 // maximize and call it after gtk_window_present.
1604 maximize_after_show_ = browser_->GetSavedMaximizedState(); 1611 show_state_after_show_ = browser_->GetSavedWindowShowState();
1605 1612
1606 gfx::Rect bounds = browser_->GetSavedWindowBounds(); 1613 gfx::Rect bounds = browser_->GetSavedWindowBounds();
1607 // We don't blindly call SetBounds here: that sets a forced position 1614 // We don't blindly call SetBounds here: that sets a forced position
1608 // on the window and we intentionally *don't* do that for normal 1615 // on the window and we intentionally *don't* do that for normal
1609 // windows. Most programs do not restore their window position on 1616 // windows. Most programs do not restore their window position on
1610 // Linux, instead letting the window manager choose a position. 1617 // Linux, instead letting the window manager choose a position.
1611 // 1618 //
1612 // However, in cases like dropping a tab where the bounds are 1619 // However, in cases like dropping a tab where the bounds are
1613 // specifically set, we do want to position explicitly. We also 1620 // specifically set, we do want to position explicitly. We also
1614 // force the position as part of session restore, as applications 1621 // force the position as part of session restore, as applications
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
1883 } 1890 }
1884 1891
1885 void BrowserWindowGtk::UpdateCustomFrame() { 1892 void BrowserWindowGtk::UpdateCustomFrame() {
1886 gtk_window_set_decorated(window_, !UseCustomFrame()); 1893 gtk_window_set_decorated(window_, !UseCustomFrame());
1887 titlebar_->UpdateCustomFrame(UseCustomFrame() && !IsFullscreen()); 1894 titlebar_->UpdateCustomFrame(UseCustomFrame() && !IsFullscreen());
1888 UpdateWindowShape(bounds_.width(), bounds_.height()); 1895 UpdateWindowShape(bounds_.width(), bounds_.height());
1889 } 1896 }
1890 1897
1891 void BrowserWindowGtk::SaveWindowPosition() { 1898 void BrowserWindowGtk::SaveWindowPosition() {
1892 // Browser::SaveWindowPlacement is used for session restore. 1899 // Browser::SaveWindowPlacement is used for session restore.
1900 ui::WindowShowState show_state = ui::SHOW_STATE_NORMAL;
1901 if (IsMaximized())
1902 show_state = ui::SHOW_STATE_MAXIMIZED;
1903 else if (IsMinimized())
1904 show_state = ui::SHOW_STATE_MINIMIZED;
1905
1893 if (browser_->ShouldSaveWindowPlacement()) 1906 if (browser_->ShouldSaveWindowPlacement())
1894 browser_->SaveWindowPlacement(restored_bounds_, IsMaximized()); 1907 browser_->SaveWindowPlacement(restored_bounds_, show_state);
1895 1908
1896 // We also need to save the placement for startup. 1909 // We also need to save the placement for startup.
1897 // This is a web of calls between views and delegates on Windows, but the 1910 // This is a web of calls between views and delegates on Windows, but the
1898 // crux of the logic follows. See also cocoa/browser_window_controller.mm. 1911 // crux of the logic follows. See also cocoa/browser_window_controller.mm.
1899 if (!browser_->profile()->GetPrefs()) 1912 if (!browser_->profile()->GetPrefs())
1900 return; 1913 return;
1901 1914
1902 std::string window_name = browser_->GetWindowPlacementKey(); 1915 std::string window_name = browser_->GetWindowPlacementKey();
1903 DictionaryPrefUpdate update(browser_->profile()->GetPrefs(), 1916 DictionaryPrefUpdate update(browser_->profile()->GetPrefs(),
1904 window_name.c_str()); 1917 window_name.c_str());
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
2373 // are taken from the WMs' source code. 2386 // are taken from the WMs' source code.
2374 return (wm_name == "Blackbox" || 2387 return (wm_name == "Blackbox" ||
2375 wm_name == "compiz" || 2388 wm_name == "compiz" ||
2376 wm_name == "Compiz" || 2389 wm_name == "Compiz" ||
2377 wm_name == "e16" || // Enlightenment DR16 2390 wm_name == "e16" || // Enlightenment DR16
2378 wm_name == "Metacity" || 2391 wm_name == "Metacity" ||
2379 wm_name == "Mutter" || 2392 wm_name == "Mutter" ||
2380 wm_name == "Openbox" || 2393 wm_name == "Openbox" ||
2381 wm_name == "Xfwm4"); 2394 wm_name == "Xfwm4");
2382 } 2395 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/browser_window_gtk.h ('k') | chrome/browser/ui/panels/panel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698