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

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);
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 // There is a bug in Windows 8 where in the generated mouse messages
1463 // after touch go to the window which previously had focus. This means that
1464 // if a user taps the omnibox to give it focus, we don't get the simulated
1465 // WM_LBUTTONDOWN, and thus don't properly select all the text. To ensure
1466 // that we get this message, we capture the mouse when the user is doing a
Peter Kasting 2012/10/12 00:19:59 Nit: Extra space
ananta 2012/10/12 00:37:18 Done.
1467 // single-point tap on an unfocused model.
1468 if (wparam == 1 && !model()->has_focus()) {
Peter Kasting 2012/10/12 00:19:59 Nit: Rest of this code puts parens around all bina
ananta 2012/10/12 00:37:18 Do you mean to parenthesize point.dwFlags & TOUCHE
1469 TOUCHINPUT point = {0};
1470 if (GetTouchInputInfo(reinterpret_cast<HTOUCHINPUT>(lparam), 1,
1471 &point, sizeof(TOUCHINPUT))) {
1472 if (point.dwFlags & TOUCHEVENTF_DOWN) {
1473 SetFocus();
1474 SetCapture();
1475 } else if (point.dwFlags & TOUCHEVENTF_UP) {
1476 ReleaseCapture();
1477 }
1478 }
1479 }
1480 SetMsgHandled(false);
1481 return 0;
1482 }
1483
1449 LRESULT OmniboxViewWin::OnPointerDown(UINT message, 1484 LRESULT OmniboxViewWin::OnPointerDown(UINT message,
1450 WPARAM wparam, 1485 WPARAM wparam,
1451 LPARAM lparam) { 1486 LPARAM lparam) {
1452 if (!model()->has_focus())
1453 SetFocus();
1454
1455 if (IS_POINTER_FIRSTBUTTON_WPARAM(wparam)) { 1487 if (IS_POINTER_FIRSTBUTTON_WPARAM(wparam)) {
1456 TrackMousePosition(kLeft, CPoint(GET_X_LPARAM(lparam), 1488 TrackMousePosition(kLeft, CPoint(GET_X_LPARAM(lparam),
1457 GET_Y_LPARAM(lparam))); 1489 GET_Y_LPARAM(lparam)));
1458 } 1490 }
1459
1460 SetMsgHandled(false); 1491 SetMsgHandled(false);
1461
1462 return 0;
1463 }
1464
1465 LRESULT OmniboxViewWin::OnPointerUp(UINT message, WPARAM wparam,
1466 LPARAM lparam) {
1467 SetMsgHandled(false);
1468
1469 return 0; 1492 return 0;
1470 } 1493 }
1471 1494
1472 void OmniboxViewWin::OnKeyDown(TCHAR key, 1495 void OmniboxViewWin::OnKeyDown(TCHAR key,
1473 UINT repeat_count, 1496 UINT repeat_count,
1474 UINT flags) { 1497 UINT flags) {
1475 delete_at_end_pressed_ = false; 1498 delete_at_end_pressed_ = false;
1476 1499
1477 if (OnKeyDownAllModes(key, repeat_count, flags)) 1500 if (OnKeyDownAllModes(key, repeat_count, flags))
1478 return; 1501 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); 2702 return (rect.left - client_rect.left) + (client_rect.right - rect.right);
2680 } 2703 }
2681 2704
2682 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const { 2705 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const {
2683 // Use font_.GetStringWidth() instead of 2706 // Use font_.GetStringWidth() instead of
2684 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is 2707 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is
2685 // apparently buggy. In both LTR UI and RTL UI with left-to-right layout, 2708 // 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. 2709 // PosFromChar(i) might return 0 when i is greater than 1.
2687 return font_.GetStringWidth(text) + GetHorizontalMargin(); 2710 return font_.GetStringWidth(text) + GetHorizontalMargin();
2688 } 2711 }
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