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

Side by Side Diff: views/widget/native_widget_win.cc

Issue 7748036: Restoring a session should restore window minimization state on Windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 9 years, 3 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 | « views/widget/native_widget_win.h ('k') | views/widget/widget.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 "views/widget/native_widget_win.h" 5 #include "views/widget/native_widget_win.h"
6 6
7 #include <dwmapi.h> 7 #include <dwmapi.h>
8 #include <shellapi.h> 8 #include <shellapi.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 return NULL; 620 return NULL;
621 } 621 }
622 622
623 void NativeWidgetWin::CenterWindow(const gfx::Size& size) { 623 void NativeWidgetWin::CenterWindow(const gfx::Size& size) {
624 HWND parent = GetParent(); 624 HWND parent = GetParent();
625 if (!IsWindow()) 625 if (!IsWindow())
626 parent = ::GetWindow(GetNativeView(), GW_OWNER); 626 parent = ::GetWindow(GetNativeView(), GW_OWNER);
627 ui::CenterAndSizeWindow(parent, GetNativeView(), size, false); 627 ui::CenterAndSizeWindow(parent, GetNativeView(), size, false);
628 } 628 }
629 629
630 void NativeWidgetWin::GetWindowBoundsAndMaximizedState(gfx::Rect* bounds, 630 void NativeWidgetWin::GetWindowPlacement(
631 bool* maximized) const { 631 gfx::Rect* bounds,
632 ui::WindowShowState* show_state) const {
632 WINDOWPLACEMENT wp; 633 WINDOWPLACEMENT wp;
633 wp.length = sizeof(wp); 634 wp.length = sizeof(wp);
634 const bool succeeded = !!GetWindowPlacement(GetNativeView(), &wp); 635 const bool succeeded = !!::GetWindowPlacement(GetNativeView(), &wp);
635 DCHECK(succeeded); 636 DCHECK(succeeded);
636 637
637 if (bounds != NULL) { 638 if (bounds != NULL) {
638 MONITORINFO mi; 639 MONITORINFO mi;
639 mi.cbSize = sizeof(mi); 640 mi.cbSize = sizeof(mi);
640 const bool succeeded = !!GetMonitorInfo( 641 const bool succeeded = !!GetMonitorInfo(
641 MonitorFromWindow(GetNativeView(), MONITOR_DEFAULTTONEAREST), &mi); 642 MonitorFromWindow(GetNativeView(), MONITOR_DEFAULTTONEAREST), &mi);
642 DCHECK(succeeded); 643 DCHECK(succeeded);
643 *bounds = gfx::Rect(wp.rcNormalPosition); 644 *bounds = gfx::Rect(wp.rcNormalPosition);
644 // Convert normal position from workarea coordinates to screen coordinates. 645 // Convert normal position from workarea coordinates to screen coordinates.
645 bounds->Offset(mi.rcWork.left - mi.rcMonitor.left, 646 bounds->Offset(mi.rcWork.left - mi.rcMonitor.left,
646 mi.rcWork.top - mi.rcMonitor.top); 647 mi.rcWork.top - mi.rcMonitor.top);
647 } 648 }
648 649
649 if (maximized != NULL) 650 if (show_state != NULL) {
650 *maximized = (wp.showCmd == SW_SHOWMAXIMIZED); 651 if (wp.showCmd == SW_SHOWMAXIMIZED)
652 *show_state = ui::SHOW_STATE_MAXIMIZED;
653 else if (wp.showCmd == SW_SHOWMINIMIZED)
654 *show_state = ui::SHOW_STATE_MINIMIZED;
655 else
656 *show_state = ui::SHOW_STATE_NORMAL;
657 }
651 } 658 }
652 659
653 void NativeWidgetWin::SetWindowTitle(const std::wstring& title) { 660 void NativeWidgetWin::SetWindowTitle(const std::wstring& title) {
654 SetWindowText(GetNativeView(), title.c_str()); 661 SetWindowText(GetNativeView(), title.c_str());
655 SetAccessibleName(title); 662 SetAccessibleName(title);
656 } 663 }
657 664
658 void NativeWidgetWin::SetWindowIcons(const SkBitmap& window_icon, 665 void NativeWidgetWin::SetWindowIcons(const SkBitmap& window_icon,
659 const SkBitmap& app_icon) { 666 const SkBitmap& app_icon) {
660 if (!window_icon.isNull()) { 667 if (!window_icon.isNull()) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 return gfx::Rect(point.x, point.y, r.right - r.left, r.bottom - r.top); 749 return gfx::Rect(point.x, point.y, r.right - r.left, r.bottom - r.top);
743 } 750 }
744 751
745 gfx::Rect NativeWidgetWin::GetRestoredBounds() const { 752 gfx::Rect NativeWidgetWin::GetRestoredBounds() const {
746 // If we're in fullscreen mode, we've changed the normal bounds to the monitor 753 // If we're in fullscreen mode, we've changed the normal bounds to the monitor
747 // rect, so return the saved bounds instead. 754 // rect, so return the saved bounds instead.
748 if (IsFullscreen()) 755 if (IsFullscreen())
749 return gfx::Rect(saved_window_info_.window_rect); 756 return gfx::Rect(saved_window_info_.window_rect);
750 757
751 gfx::Rect bounds; 758 gfx::Rect bounds;
752 GetWindowBoundsAndMaximizedState(&bounds, NULL); 759 GetWindowPlacement(&bounds, NULL);
753 return bounds; 760 return bounds;
754 } 761 }
755 762
756 void NativeWidgetWin::SetBounds(const gfx::Rect& bounds) { 763 void NativeWidgetWin::SetBounds(const gfx::Rect& bounds) {
757 LONG style = GetWindowLong(GWL_STYLE); 764 LONG style = GetWindowLong(GWL_STYLE);
758 if (style & WS_MAXIMIZE) 765 if (style & WS_MAXIMIZE)
759 SetWindowLong(GWL_STYLE, style & ~WS_MAXIMIZE); 766 SetWindowLong(GWL_STYLE, style & ~WS_MAXIMIZE);
760 SetWindowPos(NULL, bounds.x(), bounds.y(), bounds.width(), bounds.height(), 767 SetWindowPos(NULL, bounds.x(), bounds.y(), bounds.width(), bounds.height(),
761 SWP_NOACTIVATE | SWP_NOZORDER); 768 SWP_NOACTIVATE | SWP_NOZORDER);
762 } 769 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 865
859 void NativeWidgetWin::ShowMaximizedWithBounds( 866 void NativeWidgetWin::ShowMaximizedWithBounds(
860 const gfx::Rect& restored_bounds) { 867 const gfx::Rect& restored_bounds) {
861 WINDOWPLACEMENT placement = { 0 }; 868 WINDOWPLACEMENT placement = { 0 };
862 placement.length = sizeof(WINDOWPLACEMENT); 869 placement.length = sizeof(WINDOWPLACEMENT);
863 placement.showCmd = SW_SHOWMAXIMIZED; 870 placement.showCmd = SW_SHOWMAXIMIZED;
864 placement.rcNormalPosition = restored_bounds.ToRECT(); 871 placement.rcNormalPosition = restored_bounds.ToRECT();
865 SetWindowPlacement(hwnd(), &placement); 872 SetWindowPlacement(hwnd(), &placement);
866 } 873 }
867 874
868 void NativeWidgetWin::ShowWithState(ShowState state) { 875 void NativeWidgetWin::ShowWithWindowState(ui::WindowShowState show_state) {
869 DWORD native_show_state; 876 DWORD native_show_state;
870 switch (state) { 877 switch (show_state) {
871 case SHOW_INACTIVE: 878 case ui::SHOW_STATE_INACTIVE:
872 native_show_state = SW_SHOWNOACTIVATE; 879 native_show_state = SW_SHOWNOACTIVATE;
873 break; 880 break;
874 case SHOW_MAXIMIZED: 881 case ui::SHOW_STATE_MAXIMIZED:
875 native_show_state = SW_SHOWMAXIMIZED; 882 native_show_state = SW_SHOWMAXIMIZED;
876 break; 883 break;
884 case ui::SHOW_STATE_MINIMIZED:
885 native_show_state = SW_SHOWMINIMIZED;
886 break;
877 default: 887 default:
878 native_show_state = GetShowState(); 888 native_show_state = GetShowState();
879 break; 889 break;
880 } 890 }
881 Show(native_show_state); 891 Show(native_show_state);
882 } 892 }
883 893
884 bool NativeWidgetWin::IsVisible() const { 894 bool NativeWidgetWin::IsVisible() const {
885 return !!::IsWindowVisible(hwnd()); 895 return !!::IsWindowVisible(hwnd());
886 } 896 }
(...skipping 1270 matching lines...) Expand 10 before | Expand all | Expand 10 after
2157 // Set non-style attributes. 2167 // Set non-style attributes.
2158 ownership_ = params.ownership; 2168 ownership_ = params.ownership;
2159 2169
2160 DWORD style = WS_CLIPCHILDREN | WS_CLIPSIBLINGS; 2170 DWORD style = WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
2161 DWORD ex_style = 0; 2171 DWORD ex_style = 0;
2162 DWORD class_style = CS_DBLCLKS; 2172 DWORD class_style = CS_DBLCLKS;
2163 2173
2164 // Set type-independent style attributes. 2174 // Set type-independent style attributes.
2165 if (params.child) 2175 if (params.child)
2166 style |= WS_CHILD | WS_VISIBLE; 2176 style |= WS_CHILD | WS_VISIBLE;
2167 if (params.maximize) 2177 if (params.show_state == ui::SHOW_STATE_MAXIMIZED)
2168 style |= WS_MAXIMIZE; 2178 style |= WS_MAXIMIZE;
2179 if (params.show_state == ui::SHOW_STATE_MINIMIZED)
2180 style |= WS_MINIMIZE;
2169 if (!params.accept_events) 2181 if (!params.accept_events)
2170 ex_style |= WS_EX_TRANSPARENT; 2182 ex_style |= WS_EX_TRANSPARENT;
2171 if (!params.can_activate) 2183 if (!params.can_activate)
2172 ex_style |= WS_EX_NOACTIVATE; 2184 ex_style |= WS_EX_NOACTIVATE;
2173 if (params.keep_on_top) 2185 if (params.keep_on_top)
2174 ex_style |= WS_EX_TOPMOST; 2186 ex_style |= WS_EX_TOPMOST;
2175 if (params.mirror_origin_in_rtl) 2187 if (params.mirror_origin_in_rtl)
2176 ex_style |= l10n_util::GetExtendedTooltipStyles(); 2188 ex_style |= l10n_util::GetExtendedTooltipStyles();
2177 if (params.transparent) 2189 if (params.transparent)
2178 ex_style |= WS_EX_LAYERED; 2190 ex_style |= WS_EX_LAYERED;
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
2521 return (GetKeyState(VK_LBUTTON) & 0x80) || 2533 return (GetKeyState(VK_LBUTTON) & 0x80) ||
2522 (GetKeyState(VK_RBUTTON) & 0x80) || 2534 (GetKeyState(VK_RBUTTON) & 0x80) ||
2523 (GetKeyState(VK_MBUTTON) & 0x80) || 2535 (GetKeyState(VK_MBUTTON) & 0x80) ||
2524 (GetKeyState(VK_XBUTTON1) & 0x80) || 2536 (GetKeyState(VK_XBUTTON1) & 0x80) ||
2525 (GetKeyState(VK_XBUTTON2) & 0x80); 2537 (GetKeyState(VK_XBUTTON2) & 0x80);
2526 } 2538 }
2527 2539
2528 } // namespace internal 2540 } // namespace internal
2529 2541
2530 } // namespace views 2542 } // namespace views
OLDNEW
« no previous file with comments | « views/widget/native_widget_win.h ('k') | views/widget/widget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698