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

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

Issue 285403003: Re-land: Store and restore view focus in OnWindowFocused. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Disable ConstrainedWindowViewTest.ClosesOnEscape on Win XP. Created 6 years, 7 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
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/foreground_helper.h" 5 #include "ui/base/win/foreground_helper.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ui/gfx/win/window_impl.h" 8 #include "ui/gfx/win/window_impl.h"
9 9
10 namespace ui { 10 namespace ui {
(...skipping 25 matching lines...) Expand all
36 // If the calling thread is not yet a UI thread, call PeekMessage 36 // If the calling thread is not yet a UI thread, call PeekMessage
37 // to ensure creation of its message queue. 37 // to ensure creation of its message queue.
38 MSG msg = {0}; 38 MSG msg = {0};
39 PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE); 39 PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
40 40
41 // Send the Hotkey. 41 // Send the Hotkey.
42 INPUT hotkey = {0}; 42 INPUT hotkey = {0};
43 hotkey.type = INPUT_KEYBOARD; 43 hotkey.type = INPUT_KEYBOARD;
44 hotkey.ki.wVk = VK_F22; 44 hotkey.ki.wVk = VK_F22;
45 if (1 != SendInput(1, &hotkey, sizeof(hotkey))) { 45 if (1 != SendInput(1, &hotkey, sizeof(hotkey))) {
46 LOG(WARNING) << "Failed to send input"; 46 LOG(WARNING) << "Failed to send input; GetLastError(): " << GetLastError();
47 return E_FAIL; 47 return E_FAIL;
48 } 48 }
49 49
50 // There are scenarios where the WM_HOTKEY is not dispatched by the 50 // There are scenarios where the WM_HOTKEY is not dispatched by the
51 // the corresponding foreground thread. To prevent us from indefinitely 51 // the corresponding foreground thread. To prevent us from indefinitely
52 // waiting for the hotkey, we set a timer and exit the loop. 52 // waiting for the hotkey, we set a timer and exit the loop.
53 SetTimer(hwnd(), kHotKeyId, kHotKeyWaitTimeout, NULL); 53 SetTimer(hwnd(), kHotKeyId, kHotKeyWaitTimeout, NULL);
54 54
55 // Loop until we get the key or the timer fires. 55 // Loop until we get the key or the timer fires.
56 while (GetMessage(&msg, NULL, 0, 0)) { 56 while (GetMessage(&msg, NULL, 0, 0)) {
(...skipping 14 matching lines...) Expand all
71 71
72 return S_OK; 72 return S_OK;
73 } 73 }
74 74
75 // Handle the registered Hotkey being pressed. 75 // Handle the registered Hotkey being pressed.
76 void ForegroundHelper::OnHotKey(int id, UINT vcode, UINT modifiers) { 76 void ForegroundHelper::OnHotKey(int id, UINT vcode, UINT modifiers) {
77 SetForegroundWindow(window_); 77 SetForegroundWindow(window_);
78 } 78 }
79 79
80 } // namespace ui 80 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698