| OLD | NEW |
| 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.AdjustToFit(monitor_rect); |
| 29 if (!new_window_rect.Equals(window_rect)) { | 29 if (new_window_rect != window_rect) { |
| 30 // Window doesn't fit on monitor, move and possibly resize. | 30 // Window doesn't fit on monitor, move and possibly resize. |
| 31 SetWindowPos(hwnd, 0, new_window_rect.x(), new_window_rect.y(), | 31 SetWindowPos(hwnd, 0, new_window_rect.x(), new_window_rect.y(), |
| 32 new_window_rect.width(), new_window_rect.height(), | 32 new_window_rect.width(), new_window_rect.height(), |
| 33 SWP_NOACTIVATE | SWP_NOZORDER); | 33 SWP_NOACTIVATE | SWP_NOZORDER); |
| 34 return; | 34 return; |
| 35 } | 35 } |
| 36 // Else fall through. | 36 // Else fall through. |
| 37 } else { | 37 } else { |
| 38 NOTREACHED() << "Unable to find default monitor"; | 38 NOTREACHED() << "Unable to find default monitor"; |
| 39 // Fall through. | 39 // Fall through. |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 HMODULE metro = base::win::GetMetroModule(); | 193 HMODULE metro = base::win::GetMetroModule(); |
| 194 if (!metro) | 194 if (!metro) |
| 195 return get_real_hwnd ? ::GetDesktopWindow() : HWND_DESKTOP; | 195 return get_real_hwnd ? ::GetDesktopWindow() : HWND_DESKTOP; |
| 196 // In windows 8 metro-mode the root window is not the desktop. | 196 // In windows 8 metro-mode the root window is not the desktop. |
| 197 RootWindow root_window = | 197 RootWindow root_window = |
| 198 reinterpret_cast<RootWindow>(::GetProcAddress(metro, "GetRootWindow")); | 198 reinterpret_cast<RootWindow>(::GetProcAddress(metro, "GetRootWindow")); |
| 199 return root_window(); | 199 return root_window(); |
| 200 } | 200 } |
| 201 | 201 |
| 202 } // namespace ui | 202 } // namespace ui |
| OLD | NEW |