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

Side by Side Diff: ui/views/widget/native_widget_win.cc

Issue 10802085: Correct behaviour of touch wrt mouse capture. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Moved IsMouseEventFromTouch from base/win to ui/base/win Created 8 years, 4 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
« no previous file with comments | « ui/base/win/events_win.cc ('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 "ui/views/widget/native_widget_win.h" 5 #include "ui/views/widget/native_widget_win.h"
6 6
7 #include <dwmapi.h> 7 #include <dwmapi.h>
8 #include <shellapi.h> 8 #include <shellapi.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #include "ui/views/widget/widget_hwnd_utils.h" 51 #include "ui/views/widget/widget_hwnd_utils.h"
52 #include "ui/views/window/native_frame_view.h" 52 #include "ui/views/window/native_frame_view.h"
53 53
54 #if !defined(USE_AURA) 54 #if !defined(USE_AURA)
55 #include "base/command_line.h" 55 #include "base/command_line.h"
56 #include "ui/base/ui_base_switches.h" 56 #include "ui/base/ui_base_switches.h"
57 #endif 57 #endif
58 58
59 #pragma comment(lib, "dwmapi.lib") 59 #pragma comment(lib, "dwmapi.lib")
60 60
61 // From msdn:
62 #define MOUSEEVENTF_FROMTOUCH 0xFF515700
63
64 using ui::ViewProp; 61 using ui::ViewProp;
65 62
66 namespace views { 63 namespace views {
67 64
68 namespace { 65 namespace {
69 66
70 // MoveLoopMouseWatcher is used to determine if the user canceled or completed a 67 // MoveLoopMouseWatcher is used to determine if the user canceled or completed a
71 // move. win32 doesn't appear to offer a way to determine the result of a move, 68 // move. win32 doesn't appear to offer a way to determine the result of a move,
72 // so we install hooks to determine if we got a mouse up and assume the move 69 // so we install hooks to determine if we got a mouse up and assume the move
73 // completed. 70 // completed.
(...skipping 1550 matching lines...) Expand 10 before | Expand all | Expand 10 after
1624 is_right_mouse_pressed_on_caption_ = true; 1621 is_right_mouse_pressed_on_caption_ = true;
1625 // We SetCapture() to ensure we only show the menu when the button 1622 // We SetCapture() to ensure we only show the menu when the button
1626 // down and up are both on the caption. Note: this causes the button up to 1623 // down and up are both on the caption. Note: this causes the button up to
1627 // be WM_RBUTTONUP instead of WM_NCRBUTTONUP. 1624 // be WM_RBUTTONUP instead of WM_NCRBUTTONUP.
1628 SetCapture(); 1625 SetCapture();
1629 } 1626 }
1630 1627
1631 MSG msg = { hwnd(), message, w_param, l_param, 0, 1628 MSG msg = { hwnd(), message, w_param, l_param, 0,
1632 { GET_X_LPARAM(l_param), GET_Y_LPARAM(l_param) } }; 1629 { GET_X_LPARAM(l_param), GET_Y_LPARAM(l_param) } };
1633 MouseEvent event(msg); 1630 MouseEvent event(msg);
1634 // Only button up/down have MOUSEEVENTF_FROMTOUCH set. 1631 if (!touch_ids_.empty() || ui::IsMouseEventFromTouch(message))
1635 if (!touch_ids_.empty() ||
1636 ((message == WM_LBUTTONDOWN || message == WM_LBUTTONUP ||
1637 message == WM_RBUTTONDOWN || message == WM_RBUTTONUP) &&
1638 (GetMessageExtraInfo() & MOUSEEVENTF_FROMTOUCH) ==
1639 MOUSEEVENTF_FROMTOUCH)) {
1640 event.set_flags(event.flags() | ui::EF_FROM_TOUCH); 1632 event.set_flags(event.flags() | ui::EF_FROM_TOUCH);
1641 }
1642 1633
1643 if (!(event.flags() & ui::EF_IS_NON_CLIENT)) 1634 if (!(event.flags() & ui::EF_IS_NON_CLIENT))
1644 if (tooltip_manager_.get()) 1635 if (tooltip_manager_.get())
1645 tooltip_manager_->OnMouse(message, w_param, l_param); 1636 tooltip_manager_->OnMouse(message, w_param, l_param);
1646 1637
1647 if (event.type() == ui::ET_MOUSE_MOVED && !HasCapture()) { 1638 if (event.type() == ui::ET_MOUSE_MOVED && !HasCapture()) {
1648 // Windows only fires WM_MOUSELEAVE events if the application begins 1639 // Windows only fires WM_MOUSELEAVE events if the application begins
1649 // "tracking" mouse events for a given HWND during WM_MOUSEMOVE events. 1640 // "tracking" mouse events for a given HWND during WM_MOUSEMOVE events.
1650 // We need to call |TrackMouseEvents| to listen for WM_MOUSELEAVE. 1641 // We need to call |TrackMouseEvents| to listen for WM_MOUSELEAVE.
1651 TrackMouseEvents((message == WM_NCMOUSEMOVE) ? 1642 TrackMouseEvents((message == WM_NCMOUSEMOVE) ?
(...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after
2767 // static 2758 // static
2768 bool NativeWidgetPrivate::IsTouchDown() { 2759 bool NativeWidgetPrivate::IsTouchDown() {
2769 // This currently isn't necessary because we're not generating touch events on 2760 // This currently isn't necessary because we're not generating touch events on
2770 // windows. When we do, this will need to be updated. 2761 // windows. When we do, this will need to be updated.
2771 return false; 2762 return false;
2772 } 2763 }
2773 2764
2774 } // namespace internal 2765 } // namespace internal
2775 2766
2776 } // namespace views 2767 } // namespace views
OLDNEW
« no previous file with comments | « ui/base/win/events_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698