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

Side by Side Diff: chrome/browser/ui/views/omnibox/omnibox_view_win.cc

Issue 11098077: Grab mouse capture in the WM_POINTERDOWN message handler in the omnibox. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 2 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
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_view_win.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/ui/views/omnibox/omnibox_view_win.h" 5 #include "chrome/browser/ui/views/omnibox/omnibox_view_win.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <locale> 8 #include <locale>
9 #include <string> 9 #include <string>
10 10
(...skipping 1353 matching lines...) Expand 10 before | Expand all | Expand 10 after
1364 // the smaller value. 1364 // the smaller value.
1365 model()->AdjustTextForCopy(sel.cpMin, IsSelectAll(), &text, &url, &write_url); 1365 model()->AdjustTextForCopy(sel.cpMin, IsSelectAll(), &text, &url, &write_url);
1366 DoCopy(text, write_url ? &url : NULL); 1366 DoCopy(text, write_url ? &url : NULL);
1367 } 1367 }
1368 1368
1369 LRESULT OmniboxViewWin::OnCreate(const CREATESTRUCTW* /*create_struct*/) { 1369 LRESULT OmniboxViewWin::OnCreate(const CREATESTRUCTW* /*create_struct*/) {
1370 if (base::win::IsTsfAwareRequired()) { 1370 if (base::win::IsTsfAwareRequired()) {
1371 // Enable TSF support of RichEdit. 1371 // Enable TSF support of RichEdit.
1372 SetEditStyle(SES_USECTF, SES_USECTF); 1372 SetEditStyle(SES_USECTF, SES_USECTF);
1373 } 1373 }
1374
1375 if (base::win::GetVersion() >= base::win::VERSION_WIN8) {
1376 bool touch_mode = RegisterTouchWindow(m_hWnd, TWF_WANTPALM) == TRUE;
Peter Kasting 2012/10/11 23:13:34 Nit: Just auto-convert to bool, don't explicitly c
ananta 2012/10/11 23:48:41 Replaced with !! as auto conversion gets a compile
Peter Kasting 2012/10/12 00:19:59 Suck. In that case, maybe it'd be even better to
1377 DCHECK(touch_mode);
1378 }
1374 SetMsgHandled(FALSE); 1379 SetMsgHandled(FALSE);
1375 return 0; 1380 return 0;
1376 } 1381 }
1377 1382
1378 void OmniboxViewWin::OnCut() { 1383 void OmniboxViewWin::OnCut() {
1379 OnCopy(); 1384 OnCopy();
1380 1385
1381 // This replace selection will have no effect (even on the undo stack) if the 1386 // This replace selection will have no effect (even on the undo stack) if the
1382 // current selection is empty. 1387 // current selection is empty.
1383 ReplaceSel(L"", true); 1388 ReplaceSel(L"", true);
1384 } 1389 }
1385 1390
1386 LRESULT OmniboxViewWin::OnGetObject(UINT message, 1391 LRESULT OmniboxViewWin::OnGetObject(UINT message,
1387 WPARAM wparam, 1392 WPARAM wparam,
1388 LPARAM lparam) { 1393 LPARAM lparam) {
1389 // This is a request for the native accessibility object. 1394 // This is a request for the native accessibility object.
1390 if (lparam == OBJID_CLIENT) { 1395 if (lparam == OBJID_CLIENT) {
1391 return LresultFromObject(IID_IAccessible, wparam, 1396 return LresultFromObject(IID_IAccessible, wparam,
1392 native_view_host_->GetNativeViewAccessible()); 1397 native_view_host_->GetNativeViewAccessible());
1393 } 1398 }
1394 return 0; 1399 return 0;
1395 } 1400 }
1396 1401
1402 void OmniboxViewWin::OnDestroy() {
1403 if (base::win::GetVersion() >= base::win::VERSION_WIN8)
1404 UnregisterTouchWindow(m_hWnd);
1405 }
1406
1397 LRESULT OmniboxViewWin::OnImeComposition(UINT message, 1407 LRESULT OmniboxViewWin::OnImeComposition(UINT message,
1398 WPARAM wparam, 1408 WPARAM wparam,
1399 LPARAM lparam) { 1409 LPARAM lparam) {
1400 if (ignore_ime_messages_) { 1410 if (ignore_ime_messages_) {
1401 // This message was sent while we're in the middle of meddling with the 1411 // This message was sent while we're in the middle of meddling with the
1402 // underlying edit control. If we handle it below, OnAfterPossibleChange() 1412 // underlying edit control. If we handle it below, OnAfterPossibleChange()
1403 // can get bogus text for the edit, and rerun autocomplete, destructively 1413 // can get bogus text for the edit, and rerun autocomplete, destructively
1404 // modifying the result set that we're in the midst of using. For example, 1414 // modifying the result set that we're in the midst of using. For example,
1405 // if SetWindowTextAndCaretPos() was called due to the user clicking an 1415 // if SetWindowTextAndCaretPos() was called due to the user clicking an
1406 // entry in the popup, we're in the middle of executing SetSelectedLine(), 1416 // entry in the popup, we're in the middle of executing SetSelectedLine(),
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 if (model()->user_input_in_progress()) 1449 if (model()->user_input_in_progress())
1440 UpdatePopup(); 1450 UpdatePopup();
1441 1451
1442 break; 1452 break;
1443 default: 1453 default:
1444 break; 1454 break;
1445 } 1455 }
1446 return DefWindowProc(message, wparam, lparam); 1456 return DefWindowProc(message, wparam, lparam);
1447 } 1457 }
1448 1458
1459 LRESULT OmniboxViewWin::OnTouchEvent(UINT message,
1460 WPARAM wparam,
1461 LPARAM lparam) {
1462 if (wparam == 1) {
Peter Kasting 2012/10/11 23:13:34 Shouldn't this also check "&& !model()->has_focus(
ananta 2012/10/11 23:48:41 We can't do that as the WM_POINTERDOWN handler whi
ananta 2012/10/11 23:53:11 I moved the SetFocus call from OnPointerDown to th
1463 TOUCHINPUT point = {0};
1464 if (GetTouchInputInfo(reinterpret_cast<HTOUCHINPUT>(lparam), 1,
1465 &point, sizeof(TOUCHINPUT))) {
1466 // There is a bug in Windows 8 where in the generated mouse messages
1467 // after touch go to the window which previously had focus. We set
1468 // capture here to ensure that the generated mouse messages come to us.
Peter Kasting 2012/10/11 23:13:34 Nit: If you move this comment to be at the beginni
ananta 2012/10/11 23:48:41 Done.
1469 if (point.dwFlags & TOUCHEVENTF_DOWN)
1470 SetCapture();
1471 else if (point.dwFlags & TOUCHEVENTF_UP)
1472 ReleaseCapture();
1473 }
1474 }
1475 SetMsgHandled(false);
1476 return 0;
1477 }
1478
1449 LRESULT OmniboxViewWin::OnPointerDown(UINT message, 1479 LRESULT OmniboxViewWin::OnPointerDown(UINT message,
1450 WPARAM wparam, 1480 WPARAM wparam,
1451 LPARAM lparam) { 1481 LPARAM lparam) {
1452 if (!model()->has_focus()) 1482 if (!model()->has_focus())
1453 SetFocus(); 1483 SetFocus();
1454 1484
1455 if (IS_POINTER_FIRSTBUTTON_WPARAM(wparam)) { 1485 if (IS_POINTER_FIRSTBUTTON_WPARAM(wparam)) {
1456 TrackMousePosition(kLeft, CPoint(GET_X_LPARAM(lparam), 1486 TrackMousePosition(kLeft, CPoint(GET_X_LPARAM(lparam),
1457 GET_Y_LPARAM(lparam))); 1487 GET_Y_LPARAM(lparam)));
1458 } 1488 }
1459
1460 SetMsgHandled(false); 1489 SetMsgHandled(false);
1461
1462 return 0; 1490 return 0;
1463 } 1491 }
1464 1492
1465 LRESULT OmniboxViewWin::OnPointerUp(UINT message, WPARAM wparam, 1493 LRESULT OmniboxViewWin::OnPointerUp(UINT message, WPARAM wparam,
1466 LPARAM lparam) { 1494 LPARAM lparam) {
1467 SetMsgHandled(false); 1495 SetMsgHandled(false);
Peter Kasting 2012/10/11 23:13:34 Nit: If this is all this function does, can't we j
ananta 2012/10/11 23:48:41 Done.
1468
1469 return 0; 1496 return 0;
1470 } 1497 }
1471 1498
1472 void OmniboxViewWin::OnKeyDown(TCHAR key, 1499 void OmniboxViewWin::OnKeyDown(TCHAR key,
1473 UINT repeat_count, 1500 UINT repeat_count,
1474 UINT flags) { 1501 UINT flags) {
1475 delete_at_end_pressed_ = false; 1502 delete_at_end_pressed_ = false;
1476 1503
1477 if (OnKeyDownAllModes(key, repeat_count, flags)) 1504 if (OnKeyDownAllModes(key, repeat_count, flags))
1478 return; 1505 return;
(...skipping 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after
2679 return (rect.left - client_rect.left) + (client_rect.right - rect.right); 2706 return (rect.left - client_rect.left) + (client_rect.right - rect.right);
2680 } 2707 }
2681 2708
2682 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const { 2709 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const {
2683 // Use font_.GetStringWidth() instead of 2710 // Use font_.GetStringWidth() instead of
2684 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is 2711 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is
2685 // apparently buggy. In both LTR UI and RTL UI with left-to-right layout, 2712 // apparently buggy. In both LTR UI and RTL UI with left-to-right layout,
2686 // PosFromChar(i) might return 0 when i is greater than 1. 2713 // PosFromChar(i) might return 0 when i is greater than 1.
2687 return font_.GetStringWidth(text) + GetHorizontalMargin(); 2714 return font_.GetStringWidth(text) + GetHorizontalMargin();
2688 } 2715 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_view_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698