| 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/tracked_objects.h" |
| 9 #include "base/win/metro.h" | 10 #include "base/win/metro.h" |
| 10 #include "base/win/win_util.h" | 11 #include "base/win/win_util.h" |
| 11 #include "ui/gfx/point.h" | 12 #include "ui/gfx/point.h" |
| 12 #include "ui/gfx/rect.h" | 13 #include "ui/gfx/rect.h" |
| 13 #include "ui/gfx/size.h" | 14 #include "ui/gfx/size.h" |
| 14 | 15 |
| 15 namespace gfx { | 16 namespace gfx { |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 } | 216 } |
| 216 | 217 |
| 217 void ShowSystemMenuAtPoint(HWND window, const Point& point) { | 218 void ShowSystemMenuAtPoint(HWND window, const Point& point) { |
| 218 // In the Metro process, we never want to show the system menu. | 219 // In the Metro process, we never want to show the system menu. |
| 219 if (base::win::IsMetroProcess()) | 220 if (base::win::IsMetroProcess()) |
| 220 return; | 221 return; |
| 221 UINT flags = TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_RETURNCMD; | 222 UINT flags = TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_RETURNCMD; |
| 222 if (base::i18n::IsRTL()) | 223 if (base::i18n::IsRTL()) |
| 223 flags |= TPM_RIGHTALIGN; | 224 flags |= TPM_RIGHTALIGN; |
| 224 HMENU menu = GetSystemMenu(window, FALSE); | 225 HMENU menu = GetSystemMenu(window, FALSE); |
| 226 |
| 227 // Use task stopwatch to exclude the time while the context menu is open from |
| 228 // the current task, if any. |
| 229 tracked_objects::TaskStopwatch stopwatch; |
| 230 stopwatch.Start(); |
| 225 const int command = | 231 const int command = |
| 226 TrackPopupMenu(menu, flags, point.x(), point.y(), 0, window, NULL); | 232 TrackPopupMenu(menu, flags, point.x(), point.y(), 0, window, NULL); |
| 233 stopwatch.Stop(); |
| 234 |
| 227 if (command) | 235 if (command) |
| 228 SendMessage(window, WM_SYSCOMMAND, command, 0); | 236 SendMessage(window, WM_SYSCOMMAND, command, 0); |
| 229 } | 237 } |
| 230 | 238 |
| 231 extern "C" { | 239 extern "C" { |
| 232 typedef HWND (*RootWindow)(); | 240 typedef HWND (*RootWindow)(); |
| 233 } | 241 } |
| 234 | 242 |
| 235 HWND GetWindowToParentTo(bool get_real_hwnd) { | 243 HWND GetWindowToParentTo(bool get_real_hwnd) { |
| 236 HMODULE metro = base::win::GetMetroModule(); | 244 HMODULE metro = base::win::GetMetroModule(); |
| 237 if (!metro) | 245 if (!metro) |
| 238 return get_real_hwnd ? ::GetDesktopWindow() : HWND_DESKTOP; | 246 return get_real_hwnd ? ::GetDesktopWindow() : HWND_DESKTOP; |
| 239 // In windows 8 metro-mode the root window is not the desktop. | 247 // In windows 8 metro-mode the root window is not the desktop. |
| 240 RootWindow root_window = | 248 RootWindow root_window = |
| 241 reinterpret_cast<RootWindow>(::GetProcAddress(metro, "GetRootWindow")); | 249 reinterpret_cast<RootWindow>(::GetProcAddress(metro, "GetRootWindow")); |
| 242 return root_window(); | 250 return root_window(); |
| 243 } | 251 } |
| 244 | 252 |
| 245 } // namespace gfx | 253 } // namespace gfx |
| OLD | NEW |