| 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/gfx/win/hwnd_util.h" | 5 #include "ui/gfx/win/hwnd_util.h" |
| 6 | 6 |
| 7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/win/metro.h" | 9 #include "base/win/metro.h" |
| 10 #include "base/win/win_util.h" | 10 #include "base/win/win_util.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 // as is, or we have no monitor info; reset the bounds. | 47 // as is, or we have no monitor info; reset the bounds. |
| 48 ::SetWindowPos(hwnd, 0, bounds.left, bounds.top, | 48 ::SetWindowPos(hwnd, 0, bounds.left, bounds.top, |
| 49 bounds.right - bounds.left, bounds.bottom - bounds.top, | 49 bounds.right - bounds.left, bounds.bottom - bounds.top, |
| 50 SWP_NOACTIVATE | SWP_NOZORDER); | 50 SWP_NOACTIVATE | SWP_NOZORDER); |
| 51 } | 51 } |
| 52 | 52 |
| 53 // Turn off optimizations for these functions so they show up in crash reports. | 53 // Turn off optimizations for these functions so they show up in crash reports. |
| 54 MSVC_DISABLE_OPTIMIZE(); | 54 MSVC_DISABLE_OPTIMIZE(); |
| 55 | 55 |
| 56 void CrashOutOfMemory() { | 56 void CrashOutOfMemory() { |
| 57 LOG_GETLASTERROR(FATAL); | 57 PLOG(FATAL); |
| 58 } | 58 } |
| 59 | 59 |
| 60 void CrashAccessDenied() { | 60 void CrashAccessDenied() { |
| 61 LOG_GETLASTERROR(FATAL); | 61 PLOG(FATAL); |
| 62 } | 62 } |
| 63 | 63 |
| 64 // Crash isn't one of the ones we commonly see. | 64 // Crash isn't one of the ones we commonly see. |
| 65 void CrashOther() { | 65 void CrashOther() { |
| 66 LOG_GETLASTERROR(FATAL); | 66 PLOG(FATAL); |
| 67 } | 67 } |
| 68 | 68 |
| 69 MSVC_ENABLE_OPTIMIZE(); | 69 MSVC_ENABLE_OPTIMIZE(); |
| 70 | 70 |
| 71 } // namespace | 71 } // namespace |
| 72 | 72 |
| 73 base::string16 GetClassName(HWND window) { | 73 base::string16 GetClassName(HWND window) { |
| 74 // GetClassNameW will return a truncated result (properly null terminated) if | 74 // GetClassNameW will return a truncated result (properly null terminated) if |
| 75 // the given buffer is not large enough. So, it is not possible to determine | 75 // the given buffer is not large enough. So, it is not possible to determine |
| 76 // that we got the entire class name if the result is exactly equal to the | 76 // that we got the entire class name if the result is exactly equal to the |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 case ERROR_NOT_ENOUGH_MEMORY: | 193 case ERROR_NOT_ENOUGH_MEMORY: |
| 194 CrashOutOfMemory(); | 194 CrashOutOfMemory(); |
| 195 break; | 195 break; |
| 196 case ERROR_ACCESS_DENIED: | 196 case ERROR_ACCESS_DENIED: |
| 197 CrashAccessDenied(); | 197 CrashAccessDenied(); |
| 198 break; | 198 break; |
| 199 default: | 199 default: |
| 200 CrashOther(); | 200 CrashOther(); |
| 201 break; | 201 break; |
| 202 } | 202 } |
| 203 LOG_GETLASTERROR(FATAL); | 203 PLOG(FATAL); |
| 204 } | 204 } |
| 205 } | 205 } |
| 206 | 206 |
| 207 void ShowSystemMenu(HWND window) { | 207 void ShowSystemMenu(HWND window) { |
| 208 RECT rect; | 208 RECT rect; |
| 209 GetWindowRect(window, &rect); | 209 GetWindowRect(window, &rect); |
| 210 Point point = Point(base::i18n::IsRTL() ? rect.right : rect.left, rect.top); | 210 Point point = Point(base::i18n::IsRTL() ? rect.right : rect.left, rect.top); |
| 211 static const int kSystemMenuOffset = 10; | 211 static const int kSystemMenuOffset = 10; |
| 212 point.Offset(base::i18n::IsRTL() ? -kSystemMenuOffset : kSystemMenuOffset, | 212 point.Offset(base::i18n::IsRTL() ? -kSystemMenuOffset : kSystemMenuOffset, |
| 213 kSystemMenuOffset); | 213 kSystemMenuOffset); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 236 HMODULE metro = base::win::GetMetroModule(); | 236 HMODULE metro = base::win::GetMetroModule(); |
| 237 if (!metro) | 237 if (!metro) |
| 238 return get_real_hwnd ? ::GetDesktopWindow() : HWND_DESKTOP; | 238 return get_real_hwnd ? ::GetDesktopWindow() : HWND_DESKTOP; |
| 239 // In windows 8 metro-mode the root window is not the desktop. | 239 // In windows 8 metro-mode the root window is not the desktop. |
| 240 RootWindow root_window = | 240 RootWindow root_window = |
| 241 reinterpret_cast<RootWindow>(::GetProcAddress(metro, "GetRootWindow")); | 241 reinterpret_cast<RootWindow>(::GetProcAddress(metro, "GetRootWindow")); |
| 242 return root_window(); | 242 return root_window(); |
| 243 } | 243 } |
| 244 | 244 |
| 245 } // namespace gfx | 245 } // namespace gfx |
| OLD | NEW |