Avi Drissman | 3e1a26c | 2022-09-15 20:26:03 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors |
[email protected] | 6bc684df | 2014-02-20 20:29:35 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef UI_BASE_WIN_WINDOW_EVENT_TARGET_H_ |
| 6 | #define UI_BASE_WIN_WINDOW_EVENT_TARGET_H_ |
| 7 | |
| 8 | #include <windows.h> |
| 9 | |
Henrique Ferreiro | 376c765 | 2020-05-22 09:00:04 | [diff] [blame] | 10 | #include "base/component_export.h" |
[email protected] | 6bc684df | 2014-02-20 20:29:35 | [diff] [blame] | 11 | |
| 12 | namespace ui { |
| 13 | |
| 14 | // This interface is implemented by classes who get input events forwarded to |
| 15 | // them from others. E.g. would be a win32 parent child relationship where the |
| 16 | // child forwards input events to the parent after doing minimal processing. |
Henrique Ferreiro | 376c765 | 2020-05-22 09:00:04 | [diff] [blame] | 17 | class COMPONENT_EXPORT(UI_BASE) WindowEventTarget { |
[email protected] | 6bc684df | 2014-02-20 20:29:35 | [diff] [blame] | 18 | public: |
| 19 | static const char kWin32InputEventTarget[]; |
| 20 | |
| 21 | // Handles mouse events like WM_MOUSEMOVE, WM_LBUTTONDOWN, etc. |
| 22 | // The |message| parameter identifies the message. |
| 23 | // The |w_param| and |l_param| values are dependent on the type of the |
| 24 | // message. |
[email protected] | 76c1a2b | 2014-06-24 01:58:19 | [diff] [blame] | 25 | // The |handled| parameter is an output parameter which when set to false |
| 26 | // indicates that the message should be DefProc'ed. |
[email protected] | 6bc684df | 2014-02-20 20:29:35 | [diff] [blame] | 27 | // Returns the result of processing the message. |
| 28 | virtual LRESULT HandleMouseMessage(unsigned int message, |
| 29 | WPARAM w_param, |
[email protected] | 76c1a2b | 2014-06-24 01:58:19 | [diff] [blame] | 30 | LPARAM l_param, |
| 31 | bool* handled) = 0; |
[email protected] | 6bc684df | 2014-02-20 20:29:35 | [diff] [blame] | 32 | |
lanwei | 499bc4f | 2017-03-29 20:30:29 | [diff] [blame] | 33 | // Handles pointer events like WM_POINTERUP, WM_POINTERDOWN, WM_POINTERUPDATE |
| 34 | // events. |
| 35 | // The |message| parameter identifies the message. |
| 36 | // The |w_param| and |l_param| values are as per MSDN docs. |
| 37 | // The |handled| parameter is an output parameter which when set to false |
| 38 | // indicates that the message should be DefProc'ed. |
| 39 | // Returns the result of processing the message. |
| 40 | virtual LRESULT HandlePointerMessage(unsigned int message, |
| 41 | WPARAM w_param, |
| 42 | LPARAM l_param, |
| 43 | bool* handled) = 0; |
| 44 | |
[email protected] | 6bc684df | 2014-02-20 20:29:35 | [diff] [blame] | 45 | // Handles keyboard events like WM_KEYDOWN/WM_KEYUP, etc. |
| 46 | // The |message| parameter identifies the message. |
| 47 | // The |w_param| and |l_param| values are dependent on the type of the |
| 48 | // message. |
[email protected] | 76c1a2b | 2014-06-24 01:58:19 | [diff] [blame] | 49 | // The |handled| parameter is an output parameter which when set to false |
| 50 | // indicates that the message should be DefProc'ed. |
[email protected] | 6bc684df | 2014-02-20 20:29:35 | [diff] [blame] | 51 | // Returns the result of processing the message. |
| 52 | virtual LRESULT HandleKeyboardMessage(unsigned int message, |
| 53 | WPARAM w_param, |
[email protected] | 76c1a2b | 2014-06-24 01:58:19 | [diff] [blame] | 54 | LPARAM l_param, |
| 55 | bool* handled) = 0; |
[email protected] | 6bc684df | 2014-02-20 20:29:35 | [diff] [blame] | 56 | |
| 57 | // Handles WM_TOUCH events. |
| 58 | // The |message| parameter identifies the message. |
| 59 | // The |w_param| and |l_param| values are as per MSDN docs. |
[email protected] | 76c1a2b | 2014-06-24 01:58:19 | [diff] [blame] | 60 | // The |handled| parameter is an output parameter which when set to false |
| 61 | // indicates that the message should be DefProc'ed. |
[email protected] | 6bc684df | 2014-02-20 20:29:35 | [diff] [blame] | 62 | // Returns the result of processing the message. |
| 63 | virtual LRESULT HandleTouchMessage(unsigned int message, |
| 64 | WPARAM w_param, |
[email protected] | 76c1a2b | 2014-06-24 01:58:19 | [diff] [blame] | 65 | LPARAM l_param, |
| 66 | bool* handled) = 0; |
[email protected] | 6bc684df | 2014-02-20 20:29:35 | [diff] [blame] | 67 | |
Ella Ge | dd3c80b4 | 2019-09-25 01:17:57 | [diff] [blame] | 68 | // Handles WM_INPUT events. |
| 69 | // The |message| parameter identifies the message. |
| 70 | // The |w_param| and |l_param| values are as per MSDN docs. |
| 71 | // The |handled| parameter is an output parameter which when set to false |
| 72 | // indicates that the message should be DefProc'ed. |
| 73 | // Returns the result of processing the message. |
| 74 | virtual LRESULT HandleInputMessage(unsigned int message, |
| 75 | WPARAM w_param, |
| 76 | LPARAM l_param, |
| 77 | bool* handled) = 0; |
| 78 | |
[email protected] | 6bc684df | 2014-02-20 20:29:35 | [diff] [blame] | 79 | // Handles scroll messages like WM_VSCROLL and WM_HSCROLL. |
| 80 | // The |message| parameter identifies the scroll message. |
| 81 | // The |w_param| and |l_param| values are dependent on the type of scroll. |
[email protected] | 76c1a2b | 2014-06-24 01:58:19 | [diff] [blame] | 82 | // The |handled| parameter is an output parameter which when set to false |
| 83 | // indicates that the message should be DefProc'ed. |
[email protected] | 6bc684df | 2014-02-20 20:29:35 | [diff] [blame] | 84 | virtual LRESULT HandleScrollMessage(unsigned int message, |
| 85 | WPARAM w_param, |
[email protected] | 76c1a2b | 2014-06-24 01:58:19 | [diff] [blame] | 86 | LPARAM l_param, |
| 87 | bool* handled) = 0; |
[email protected] | 6bc684df | 2014-02-20 20:29:35 | [diff] [blame] | 88 | |
| 89 | // Handles the WM_NCHITTEST message |
| 90 | // The |message| parameter identifies the message. |
| 91 | // The |w_param| and |l_param| values are as per MSDN docs. |
[email protected] | 76c1a2b | 2014-06-24 01:58:19 | [diff] [blame] | 92 | // The |handled| parameter is an output parameter which when set to false |
| 93 | // indicates that the message should be DefProc'ed. |
[email protected] | 6bc684df | 2014-02-20 20:29:35 | [diff] [blame] | 94 | // Returns the result of processing the message. |
| 95 | virtual LRESULT HandleNcHitTestMessage(unsigned int message, |
| 96 | WPARAM w_param, |
[email protected] | 76c1a2b | 2014-06-24 01:58:19 | [diff] [blame] | 97 | LPARAM l_param, |
| 98 | bool* handled) = 0; |
ananta | 6bdd5d5 | 2015-06-03 19:08:24 | [diff] [blame] | 99 | |
chaopeng | 04fd930 | 2018-03-02 21:43:06 | [diff] [blame] | 100 | // Apply the transform from Direct Manipulation API. |
chaopeng | 77ff930c | 2018-03-13 03:35:03 | [diff] [blame] | 101 | |
| 102 | // Calls ApplyPinchZoomScale() for pinch-zoom gesture. scale is the scale |
| 103 | // factor. |
chaopeng | 04fd930 | 2018-03-02 21:43:06 | [diff] [blame] | 104 | virtual void ApplyPinchZoomScale(float scale) = 0; |
chaopeng | 77ff930c | 2018-03-13 03:35:03 | [diff] [blame] | 105 | |
| 106 | // Pinch gesture phase. The sequencing expected of these events. |
| 107 | // The sequence of calls is ApplyPinchZoomBegin(), any number of calls to |
| 108 | // ApplyPinchZoomScale() and finally ApplyPinchZoomEnd(). |
| 109 | virtual void ApplyPinchZoomBegin() = 0; |
| 110 | virtual void ApplyPinchZoomEnd() = 0; |
| 111 | |
| 112 | // Calls ApplyPanGestureScroll() for pan gesture, scroll_x and scroll_y are |
| 113 | // pixel precison scroll offset. |
chaopeng | 04fd930 | 2018-03-02 21:43:06 | [diff] [blame] | 114 | virtual void ApplyPanGestureScroll(int scroll_x, int scroll_y) = 0; |
| 115 | |
chaopeng | e8f2c03 | 2018-04-05 03:11:59 | [diff] [blame] | 116 | // Calls ApplyPanGestureFling() for pan inertia gesture, scroll_x and scroll_y |
| 117 | // are pixel precison scroll offset. |
| 118 | virtual void ApplyPanGestureFling(int scroll_x, int scroll_y) = 0; |
| 119 | |
| 120 | // Pan gesture phase. The sequencing expected of these events. |
| 121 | // The sequence of calls is ApplyPanGestureScrollBegin(), any number of calls |
| 122 | // to ApplyPanGestureScroll(), ApplyPanGestureScrollEnd(), |
| 123 | // ApplyPanGestureFlingBegin(), any number of calls to ApplyPanGestureFling(), |
| 124 | // and finally ApplyPanGestureFlingEnd(). |
Mario Bianucci | 4da9f93b | 2019-08-26 19:54:38 | [diff] [blame] | 125 | // |transition_to_pinch| is a hint to know if the scroll end will be followed |
| 126 | // by a pinch begin or not, so that momentum_phase can be set to Blocked if |
| 127 | // a momentum scroll/fling will not be happening next. |
chaopeng | e8f2c03 | 2018-04-05 03:11:59 | [diff] [blame] | 128 | virtual void ApplyPanGestureScrollBegin(int scroll_x, int scroll_y) = 0; |
Mario Bianucci | 4da9f93b | 2019-08-26 19:54:38 | [diff] [blame] | 129 | virtual void ApplyPanGestureScrollEnd(bool transition_to_pinch) = 0; |
chaopeng | e8f2c03 | 2018-04-05 03:11:59 | [diff] [blame] | 130 | virtual void ApplyPanGestureFlingBegin() = 0; |
| 131 | virtual void ApplyPanGestureFlingEnd() = 0; |
| 132 | |
[email protected] | 6bc684df | 2014-02-20 20:29:35 | [diff] [blame] | 133 | protected: |
| 134 | WindowEventTarget(); |
| 135 | virtual ~WindowEventTarget(); |
| 136 | }; |
| 137 | |
| 138 | } // namespace ui |
| 139 | |
| 140 | #endif // UI_BASE_WIN_WINDOW_EVENT_TARGET_H_ |
| 141 | |
| 142 | |