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 "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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 #include "ui/base/keycodes/keyboard_codes.h" | 51 #include "ui/base/keycodes/keyboard_codes.h" |
52 #include "ui/base/l10n/l10n_util.h" | 52 #include "ui/base/l10n/l10n_util.h" |
53 #include "ui/base/l10n/l10n_util_win.h" | 53 #include "ui/base/l10n/l10n_util_win.h" |
54 #include "ui/base/win/mouse_wheel_util.h" | 54 #include "ui/base/win/mouse_wheel_util.h" |
55 #include "ui/gfx/canvas.h" | 55 #include "ui/gfx/canvas.h" |
56 #include "ui/views/button_drag_utils.h" | 56 #include "ui/views/button_drag_utils.h" |
57 #include "ui/views/controls/menu/menu_2.h" | 57 #include "ui/views/controls/menu/menu_2.h" |
58 #include "ui/views/controls/textfield/native_textfield_win.h" | 58 #include "ui/views/controls/textfield/native_textfield_win.h" |
59 #include "ui/views/widget/widget.h" | 59 #include "ui/views/widget/widget.h" |
60 | 60 |
61 // TODO(tommi): Remove this when we update to a newer SDK. | |
Peter Kasting
2012/05/16 18:30:16
Just curious: Is there a bug or specific plan on u
tommi (sloooow) - chröme
2012/05/16 19:11:08
I don't know if there is a bug filed, but we're al
Peter Kasting
2012/05/16 19:12:34
That'd be fine. Whatever you think is best.
I mo
| |
62 #ifndef POINTER_MESSAGE_FLAG_FIRSTBUTTON | |
63 #define POINTER_MESSAGE_FLAG_FIRSTBUTTON 0x00000010 // Primary action | |
64 #define IS_POINTER_FLAG_SET_WPARAM(wParam, flag) \ | |
65 (((DWORD)HIWORD(wParam) & (flag)) == (flag)) | |
66 #define IS_POINTER_FIRSTBUTTON_WPARAM(wParam) \ | |
67 IS_POINTER_FLAG_SET_WPARAM(wParam, POINTER_MESSAGE_FLAG_FIRSTBUTTON) | |
68 #endif | |
69 | |
61 #pragma comment(lib, "oleacc.lib") // Needed for accessibility support. | 70 #pragma comment(lib, "oleacc.lib") // Needed for accessibility support. |
62 #pragma comment(lib, "riched20.lib") // Needed for the richedit control. | 71 #pragma comment(lib, "riched20.lib") // Needed for the richedit control. |
63 | 72 |
64 using content::UserMetricsAction; | 73 using content::UserMetricsAction; |
65 using content::WebContents; | 74 using content::WebContents; |
66 | 75 |
67 /////////////////////////////////////////////////////////////////////////////// | 76 /////////////////////////////////////////////////////////////////////////////// |
68 // AutocompleteEditModel | 77 // AutocompleteEditModel |
69 | 78 |
70 namespace { | 79 namespace { |
(...skipping 1369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1440 default: | 1449 default: |
1441 break; | 1450 break; |
1442 } | 1451 } |
1443 return DefWindowProc(message, wparam, lparam); | 1452 return DefWindowProc(message, wparam, lparam); |
1444 } | 1453 } |
1445 | 1454 |
1446 LRESULT OmniboxViewWin::OnPointerDown(UINT message, | 1455 LRESULT OmniboxViewWin::OnPointerDown(UINT message, |
1447 WPARAM wparam, | 1456 WPARAM wparam, |
1448 LPARAM lparam) { | 1457 LPARAM lparam) { |
1449 SetFocus(); | 1458 SetFocus(); |
1459 | |
1460 if (IS_POINTER_FIRSTBUTTON_WPARAM(wparam)) { | |
1461 TrackMousePosition(kLeft, CPoint(GET_X_LPARAM(lparam), | |
1462 GET_Y_LPARAM(lparam))); | |
1463 } | |
1464 | |
1450 // ITextInputPanel is not supported on all platforms. NULL is fine. | 1465 // ITextInputPanel is not supported on all platforms. NULL is fine. |
1451 if (keyboard_ != NULL) | 1466 if (keyboard_ != NULL) |
1452 keyboard_->SetInPlaceVisibility(true); | 1467 keyboard_->SetInPlaceVisibility(true); |
1453 return DefWindowProc(message, wparam, lparam); | 1468 return DefWindowProc(message, wparam, lparam); |
1454 } | 1469 } |
1455 | 1470 |
1456 void OmniboxViewWin::OnKeyDown(TCHAR key, | 1471 void OmniboxViewWin::OnKeyDown(TCHAR key, |
1457 UINT repeat_count, | 1472 UINT repeat_count, |
1458 UINT flags) { | 1473 UINT flags) { |
1459 delete_at_end_pressed_ = false; | 1474 delete_at_end_pressed_ = false; |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1656 // First, give other handlers a chance to handle the message to see if we are | 1671 // First, give other handlers a chance to handle the message to see if we are |
1657 // actually going to activate and gain focus. | 1672 // actually going to activate and gain focus. |
1658 LRESULT result = DefWindowProc(WM_MOUSEACTIVATE, | 1673 LRESULT result = DefWindowProc(WM_MOUSEACTIVATE, |
1659 reinterpret_cast<WPARAM>(window), | 1674 reinterpret_cast<WPARAM>(window), |
1660 MAKELPARAM(hit_test, mouse_message)); | 1675 MAKELPARAM(hit_test, mouse_message)); |
1661 // Check if we're getting focus from a click. We have to do this here rather | 1676 // Check if we're getting focus from a click. We have to do this here rather |
1662 // than in OnXButtonDown() since in many scenarios OnSetFocus() will be | 1677 // than in OnXButtonDown() since in many scenarios OnSetFocus() will be |
1663 // reached before OnXButtonDown(), preventing us from detecting this properly | 1678 // reached before OnXButtonDown(), preventing us from detecting this properly |
1664 // there. Also in those cases, we need to already know in OnSetFocus() that | 1679 // there. Also in those cases, we need to already know in OnSetFocus() that |
1665 // we should not restore the saved selection. | 1680 // we should not restore the saved selection. |
1666 if (!model_->has_focus() && | 1681 if (result == MA_ACTIVATE && |
Peter Kasting
2012/05/16 18:30:16
Nit: For consistency with the rest of this file, k
tommi (sloooow) - chröme
2012/05/16 19:11:08
Done
| |
1667 ((mouse_message == WM_LBUTTONDOWN || mouse_message == WM_RBUTTONDOWN)) && | 1682 (mouse_message == WM_LBUTTONDOWN || mouse_message == WM_RBUTTONDOWN || |
1668 (result == MA_ACTIVATE)) { | 1683 mouse_message == WM_POINTERDOWN) && |
1684 !model_->has_focus()) { | |
1669 DCHECK(!gaining_focus_.get()); | 1685 DCHECK(!gaining_focus_.get()); |
1670 gaining_focus_.reset(new ScopedFreeze(this, GetTextObjectModel())); | 1686 gaining_focus_.reset(new ScopedFreeze(this, GetTextObjectModel())); |
1671 // NOTE: Despite |mouse_message| being WM_XBUTTONDOWN here, we're not | 1687 // NOTE: Despite |mouse_message| being WM_XBUTTONDOWN here, we're not |
1672 // guaranteed to call OnXButtonDown() later! Specifically, if this is the | 1688 // guaranteed to call OnXButtonDown() later! Specifically, if this is the |
1673 // second click of a double click, we'll reach here but later call | 1689 // second click of a double click, we'll reach here but later call |
1674 // OnXButtonDblClk(). Make sure |gaining_focus_| gets reset both places, | 1690 // OnXButtonDblClk(). Make sure |gaining_focus_| gets reset both places, |
1675 // or we'll have visual glitchiness and then DCHECK failures. | 1691 // or we'll have visual glitchiness and then DCHECK failures. |
1676 | 1692 |
1677 // Don't restore saved selection, it will just screw up our interaction | 1693 // Don't restore saved selection, it will just screw up our interaction |
1678 // with this edit. | 1694 // with this edit. |
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2676 bool popup_window_mode, | 2692 bool popup_window_mode, |
2677 LocationBarView* location_bar) { | 2693 LocationBarView* location_bar) { |
2678 return new OmniboxViewWin(controller, | 2694 return new OmniboxViewWin(controller, |
2679 toolbar_model, | 2695 toolbar_model, |
2680 location_bar, | 2696 location_bar, |
2681 command_updater, | 2697 command_updater, |
2682 popup_window_mode, | 2698 popup_window_mode, |
2683 location_bar); | 2699 location_bar); |
2684 } | 2700 } |
2685 #endif | 2701 #endif |
OLD | NEW |