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

Side by Side Diff: ui/base/win/hwnd_util.cc

Issue 11110004: Make gfx::Rect class operations consistently mutate the class they are called on. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: cc/ fixes Created 8 years, 2 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
« no previous file with comments | « ui/base/native_theme/native_theme_base.cc ('k') | ui/gfx/blit.cc » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/base/win/hwnd_util.h" 5 #include "ui/base/win/hwnd_util.h"
6 6
7 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/win/metro.h" 9 #include "base/win/metro.h"
10 #include "ui/gfx/rect.h" 10 #include "ui/gfx/rect.h"
11 #include "ui/gfx/size.h" 11 #include "ui/gfx/size.h"
12 12
13 namespace ui { 13 namespace ui {
14 14
15 namespace { 15 namespace {
16 16
17 // Adjust the window to fit. 17 // Adjust the window to fit.
18 void AdjustWindowToFit(HWND hwnd, const RECT& bounds, bool fit_to_monitor) { 18 void AdjustWindowToFit(HWND hwnd, const RECT& bounds, bool fit_to_monitor) {
19 if (fit_to_monitor) { 19 if (fit_to_monitor) {
20 // Get the monitor. 20 // Get the monitor.
21 HMONITOR hmon = MonitorFromRect(&bounds, MONITOR_DEFAULTTONEAREST); 21 HMONITOR hmon = MonitorFromRect(&bounds, MONITOR_DEFAULTTONEAREST);
22 if (hmon) { 22 if (hmon) {
23 MONITORINFO mi; 23 MONITORINFO mi;
24 mi.cbSize = sizeof(mi); 24 mi.cbSize = sizeof(mi);
25 GetMonitorInfo(hmon, &mi); 25 GetMonitorInfo(hmon, &mi);
26 gfx::Rect window_rect(bounds); 26 gfx::Rect window_rect(bounds);
27 gfx::Rect monitor_rect(mi.rcWork); 27 gfx::Rect monitor_rect(mi.rcWork);
28 gfx::Rect new_window_rect = window_rect.AdjustToFit(monitor_rect); 28 gfx::Rect new_window_rect = window_rect;
29 new_window_rect.AdjustToFit(monitor_rect);
29 if (new_window_rect != window_rect) { 30 if (new_window_rect != window_rect) {
30 // Window doesn't fit on monitor, move and possibly resize. 31 // Window doesn't fit on monitor, move and possibly resize.
31 SetWindowPos(hwnd, 0, new_window_rect.x(), new_window_rect.y(), 32 SetWindowPos(hwnd, 0, new_window_rect.x(), new_window_rect.y(),
32 new_window_rect.width(), new_window_rect.height(), 33 new_window_rect.width(), new_window_rect.height(),
33 SWP_NOACTIVATE | SWP_NOZORDER); 34 SWP_NOACTIVATE | SWP_NOZORDER);
34 return; 35 return;
35 } 36 }
36 // Else fall through. 37 // Else fall through.
37 } else { 38 } else {
38 NOTREACHED() << "Unable to find default monitor"; 39 NOTREACHED() << "Unable to find default monitor";
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 HMODULE metro = base::win::GetMetroModule(); 194 HMODULE metro = base::win::GetMetroModule();
194 if (!metro) 195 if (!metro)
195 return get_real_hwnd ? ::GetDesktopWindow() : HWND_DESKTOP; 196 return get_real_hwnd ? ::GetDesktopWindow() : HWND_DESKTOP;
196 // In windows 8 metro-mode the root window is not the desktop. 197 // In windows 8 metro-mode the root window is not the desktop.
197 RootWindow root_window = 198 RootWindow root_window =
198 reinterpret_cast<RootWindow>(::GetProcAddress(metro, "GetRootWindow")); 199 reinterpret_cast<RootWindow>(::GetProcAddress(metro, "GetRootWindow"));
199 return root_window(); 200 return root_window();
200 } 201 }
201 202
202 } // namespace ui 203 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/native_theme/native_theme_base.cc ('k') | ui/gfx/blit.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698