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

Side by Side Diff: ui/views/win/hwnd_message_handler.cc

Issue 1615073005: Revert of Makes sure the keyboard typing isn't blocked when InputMethod::OnFocus() is not correctly (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
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/views/win/hwnd_message_handler.h" 5 #include "ui/views/win/hwnd_message_handler.h"
6 6
7 #include <dwmapi.h> 7 #include <dwmapi.h>
8 #include <oleacc.h> 8 #include <oleacc.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 #include <tchar.h> 10 #include <tchar.h>
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 if (!ref || !::IsWindow(window)) 921 if (!ref || !::IsWindow(window))
922 return result; 922 return result;
923 } 923 }
924 924
925 if (delegate_) { 925 if (delegate_) {
926 delegate_->PostHandleMSG(message, w_param, l_param); 926 delegate_->PostHandleMSG(message, w_param, l_param);
927 if (message == WM_NCDESTROY) 927 if (message == WM_NCDESTROY)
928 delegate_->HandleDestroyed(); 928 delegate_->HandleDestroyed();
929 } 929 }
930 930
931 if (message == WM_ACTIVATE) { 931 if (message == WM_ACTIVATE && IsTopLevelWindow(window))
932 if (IsTopLevelWindow(window)) 932 PostProcessActivateMessage(LOWORD(w_param), !!HIWORD(w_param));
933 PostProcessActivateMessage(LOWORD(w_param), !!HIWORD(w_param));
934 else
935 delegate_->AddStringLog("WM_ACTIVATE on non-top-level window.");
936 }
937 return result; 933 return result;
938 } 934 }
939 935
940 LRESULT HWNDMessageHandler::HandleMouseMessage(unsigned int message, 936 LRESULT HWNDMessageHandler::HandleMouseMessage(unsigned int message,
941 WPARAM w_param, 937 WPARAM w_param,
942 LPARAM l_param, 938 LPARAM l_param,
943 bool* handled) { 939 bool* handled) {
944 // Don't track forwarded mouse messages. We expect the caller to track the 940 // Don't track forwarded mouse messages. We expect the caller to track the
945 // mouse. 941 // mouse.
946 base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); 942 base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr());
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 SetFocus(hwnd()); 1026 SetFocus(hwnd());
1031 } 1027 }
1032 } 1028 }
1033 1029
1034 void HWNDMessageHandler::PostProcessActivateMessage(int activation_state, 1030 void HWNDMessageHandler::PostProcessActivateMessage(int activation_state,
1035 bool minimized) { 1031 bool minimized) {
1036 DCHECK(IsTopLevelWindow(hwnd())); 1032 DCHECK(IsTopLevelWindow(hwnd()));
1037 const bool active = activation_state != WA_INACTIVE && !minimized; 1033 const bool active = activation_state != WA_INACTIVE && !minimized;
1038 if (delegate_->CanActivate()) 1034 if (delegate_->CanActivate())
1039 delegate_->HandleActivationChanged(active); 1035 delegate_->HandleActivationChanged(active);
1040 else
1041 delegate_->AddStringLog("Missing call to HandleActivationChanged.");
1042 } 1036 }
1043 1037
1044 void HWNDMessageHandler::RestoreEnabledIfNecessary() { 1038 void HWNDMessageHandler::RestoreEnabledIfNecessary() {
1045 if (delegate_->IsModal() && !restored_enabled_) { 1039 if (delegate_->IsModal() && !restored_enabled_) {
1046 restored_enabled_ = true; 1040 restored_enabled_ = true;
1047 // If we were run modally, we need to undo the disabled-ness we inflicted on 1041 // If we were run modally, we need to undo the disabled-ness we inflicted on
1048 // the owner's parent hierarchy. 1042 // the owner's parent hierarchy.
1049 HWND start = ::GetWindow(hwnd(), GW_OWNER); 1043 HWND start = ::GetWindow(hwnd(), GW_OWNER);
1050 while (start) { 1044 while (start) {
1051 ::EnableWindow(start, TRUE); 1045 ::EnableWindow(start, TRUE);
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1230 attempts), 1224 attempts),
1231 base::TimeDelta::FromMilliseconds(500)); 1225 base::TimeDelta::FromMilliseconds(500));
1232 return; 1226 return;
1233 } 1227 }
1234 InvalidateRect(hwnd(), NULL, FALSE); 1228 InvalidateRect(hwnd(), NULL, FALSE);
1235 } 1229 }
1236 1230
1237 // Message handlers ------------------------------------------------------------ 1231 // Message handlers ------------------------------------------------------------
1238 1232
1239 void HWNDMessageHandler::OnActivateApp(BOOL active, DWORD thread_id) { 1233 void HWNDMessageHandler::OnActivateApp(BOOL active, DWORD thread_id) {
1240 delegate_->AddStringLog("WM_ACTIVATEAPP: ");
1241 delegate_->AddBooleanLog(active ? true : false);
1242 if (delegate_->IsWidgetWindow() && !active && 1234 if (delegate_->IsWidgetWindow() && !active &&
1243 thread_id != GetCurrentThreadId()) { 1235 thread_id != GetCurrentThreadId()) {
1244 delegate_->HandleAppDeactivated(); 1236 delegate_->HandleAppDeactivated();
1245 // Also update the native frame if it is rendering the non-client area. 1237 // Also update the native frame if it is rendering the non-client area.
1246 if (!remove_standard_frame_ && !delegate_->IsUsingCustomFrame()) 1238 if (!remove_standard_frame_ && !delegate_->IsUsingCustomFrame())
1247 DefWindowProcWithRedrawLock(WM_NCACTIVATE, FALSE, 0); 1239 DefWindowProcWithRedrawLock(WM_NCACTIVATE, FALSE, 0);
1248 } 1240 }
1249 } 1241 }
1250 1242
1251 BOOL HWNDMessageHandler::OnAppCommand(HWND window, 1243 BOOL HWNDMessageHandler::OnAppCommand(HWND window,
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
1487 } 1479 }
1488 1480
1489 void HWNDMessageHandler::OnInputLangChange(DWORD character_set, 1481 void HWNDMessageHandler::OnInputLangChange(DWORD character_set,
1490 HKL input_language_id) { 1482 HKL input_language_id) {
1491 delegate_->HandleInputLanguageChange(character_set, input_language_id); 1483 delegate_->HandleInputLanguageChange(character_set, input_language_id);
1492 } 1484 }
1493 1485
1494 LRESULT HWNDMessageHandler::OnKeyEvent(UINT message, 1486 LRESULT HWNDMessageHandler::OnKeyEvent(UINT message,
1495 WPARAM w_param, 1487 WPARAM w_param,
1496 LPARAM l_param) { 1488 LPARAM l_param) {
1497 if (message == WM_KEYDOWN || message == WM_SYSKEYDOWN)
1498 delegate_->AddStringLog("WM_KEYDOWN || WM_SYSKEYDOWN");
1499 MSG msg = { 1489 MSG msg = {
1500 hwnd(), message, w_param, l_param, static_cast<DWORD>(GetMessageTime())}; 1490 hwnd(), message, w_param, l_param, static_cast<DWORD>(GetMessageTime())};
1501 ui::KeyEvent key(msg); 1491 ui::KeyEvent key(msg);
1502 delegate_->HandleKeyEvent(&key); 1492 delegate_->HandleKeyEvent(&key);
1503 if (!key.handled()) 1493 if (!key.handled())
1504 SetMsgHandled(FALSE); 1494 SetMsgHandled(FALSE);
1505 return 0; 1495 return 0;
1506 } 1496 }
1507 1497
1508 void HWNDMessageHandler::OnKillFocus(HWND focused_window) { 1498 void HWNDMessageHandler::OnKillFocus(HWND focused_window) {
1509 delegate_->HandleNativeBlur(focused_window); 1499 delegate_->HandleNativeBlur(focused_window);
1510 SetMsgHandled(FALSE); 1500 SetMsgHandled(FALSE);
1511 } 1501 }
1512 1502
1513 LRESULT HWNDMessageHandler::OnMouseActivate(UINT message, 1503 LRESULT HWNDMessageHandler::OnMouseActivate(UINT message,
1514 WPARAM w_param, 1504 WPARAM w_param,
1515 LPARAM l_param) { 1505 LPARAM l_param) {
1516 delegate_->AddStringLog("WM_MOUSEACTIVATE");
1517 // Please refer to the comments in the header for the touch_down_contexts_ 1506 // Please refer to the comments in the header for the touch_down_contexts_
1518 // member for the if statement below. 1507 // member for the if statement below.
1519 if (touch_down_contexts_) 1508 if (touch_down_contexts_)
1520 return MA_NOACTIVATE; 1509 return MA_NOACTIVATE;
1521 1510
1522 // On Windows, if we select the menu item by touch and if the window at the 1511 // On Windows, if we select the menu item by touch and if the window at the
1523 // location is another window on the same thread, that window gets a 1512 // location is another window on the same thread, that window gets a
1524 // WM_MOUSEACTIVATE message and ends up activating itself, which is not 1513 // WM_MOUSEACTIVATE message and ends up activating itself, which is not
1525 // correct. We workaround this by setting a property on the window at the 1514 // correct. We workaround this by setting a property on the window at the
1526 // current cursor location. We check for this property in our 1515 // current cursor location. We check for this property in our
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1571 SetMsgHandled(FALSE); 1560 SetMsgHandled(FALSE);
1572 } 1561 }
1573 1562
1574 void HWNDMessageHandler::OnMoving(UINT param, const RECT* new_bounds) { 1563 void HWNDMessageHandler::OnMoving(UINT param, const RECT* new_bounds) {
1575 delegate_->HandleMove(); 1564 delegate_->HandleMove();
1576 } 1565 }
1577 1566
1578 LRESULT HWNDMessageHandler::OnNCActivate(UINT message, 1567 LRESULT HWNDMessageHandler::OnNCActivate(UINT message,
1579 WPARAM w_param, 1568 WPARAM w_param,
1580 LPARAM l_param) { 1569 LPARAM l_param) {
1581 delegate_->AddStringLog("WM_NCACTIVATE: ");
1582 delegate_->AddBooleanLog(w_param ? true : false);
1583 // Per MSDN, w_param is either TRUE or FALSE. However, MSDN also hints that: 1570 // Per MSDN, w_param is either TRUE or FALSE. However, MSDN also hints that:
1584 // "If the window is minimized when this message is received, the application 1571 // "If the window is minimized when this message is received, the application
1585 // should pass the message to the DefWindowProc function." 1572 // should pass the message to the DefWindowProc function."
1586 // It is found out that the high word of w_param might be set when the window 1573 // It is found out that the high word of w_param might be set when the window
1587 // is minimized or restored. To handle this, w_param's high word should be 1574 // is minimized or restored. To handle this, w_param's high word should be
1588 // cleared before it is converted to BOOL. 1575 // cleared before it is converted to BOOL.
1589 BOOL active = static_cast<BOOL>(LOWORD(w_param)); 1576 BOOL active = static_cast<BOOL>(LOWORD(w_param));
1590 1577
1591 bool inactive_rendering_disabled = delegate_->IsInactiveRenderingDisabled(); 1578 bool inactive_rendering_disabled = delegate_->IsInactiveRenderingDisabled();
1592 1579
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after
2585 2572
2586 default: 2573 default:
2587 left_button_down_on_caption_ = false; 2574 left_button_down_on_caption_ = false;
2588 break; 2575 break;
2589 } 2576 }
2590 return handled; 2577 return handled;
2591 } 2578 }
2592 2579
2593 2580
2594 } // namespace views 2581 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc ('k') | ui/views/win/hwnd_message_handler_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698