diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-20 20:29:35 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-20 20:29:35 +0000 |
commit | 6bc684df3bf7141d2145626c05aa653a65aa40bc (patch) | |
tree | c3199cc4e5b76dfc909daedf8b43f83006a4138f /ui/base/win | |
parent | 4413d87abb4483aecd867cac1e07af85c67d3242 (diff) | |
download | chromium_src-6bc684df3bf7141d2145626c05aa653a65aa40bc.zip chromium_src-6bc684df3bf7141d2145626c05aa653a65aa40bc.tar.gz chromium_src-6bc684df3bf7141d2145626c05aa653a65aa40bc.tar.bz2 |
Create an interface WindowEventTarget to enable a class to receive
Windows input events.
This interface is defined in the newly added ui\base\window_event_target.cc/.h files.
It is implemented by the HWNDMessageHandler class. The class sets the interface as
window property on the HWND. The LegacyRenderWidgetHostHWND class retrieves this interface
via the window property and invokes the corresponding methods.
This is much cleaner than the current method of forwarding input messages from the
LegacyRenderWidgetHostHWND class via SendMessage and also avoids mucking with the
WPARAM of WM_MOUSEMOVE messages to ensure that the parent does not track those messages.
BUG=342323
R=sky@chromium.org
TBR=cpu
Review URL: https://codereview.chromium.org/165753002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@252365 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base/win')
-rw-r--r-- | ui/base/win/window_event_target.cc | 16 | ||||
-rw-r--r-- | ui/base/win/window_event_target.h | 71 |
2 files changed, 87 insertions, 0 deletions
diff --git a/ui/base/win/window_event_target.cc b/ui/base/win/window_event_target.cc new file mode 100644 index 0000000..555cd5a --- /dev/null +++ b/ui/base/win/window_event_target.cc @@ -0,0 +1,16 @@ +// Copyright (c) 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ui/base/win/window_event_target.h" + +namespace ui { + +const char WindowEventTarget::kWin32InputEventTarget[] + = "Win32_InputEventTarget"; + +WindowEventTarget::WindowEventTarget() {} + +WindowEventTarget::~WindowEventTarget() {} + +} // namespace ui diff --git a/ui/base/win/window_event_target.h b/ui/base/win/window_event_target.h new file mode 100644 index 0000000..c7bb670 --- /dev/null +++ b/ui/base/win/window_event_target.h @@ -0,0 +1,71 @@ +// Copyright (c) 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_BASE_WIN_WINDOW_EVENT_TARGET_H_ +#define UI_BASE_WIN_WINDOW_EVENT_TARGET_H_ + +#include <windows.h> + +#include "base/basictypes.h" +#include "ui/base/ui_base_export.h" + +namespace ui { + +// This interface is implemented by classes who get input events forwarded to +// them from others. E.g. would be a win32 parent child relationship where the +// child forwards input events to the parent after doing minimal processing. +class UI_BASE_EXPORT WindowEventTarget { + public: + static const char kWin32InputEventTarget[]; + + // Handles mouse events like WM_MOUSEMOVE, WM_LBUTTONDOWN, etc. + // The |message| parameter identifies the message. + // The |w_param| and |l_param| values are dependent on the type of the + // message. + // Returns the result of processing the message. + virtual LRESULT HandleMouseMessage(unsigned int message, + WPARAM w_param, + LPARAM l_param) = 0; + + // Handles keyboard events like WM_KEYDOWN/WM_KEYUP, etc. + // The |message| parameter identifies the message. + // The |w_param| and |l_param| values are dependent on the type of the + // message. + // Returns the result of processing the message. + virtual LRESULT HandleKeyboardMessage(unsigned int message, + WPARAM w_param, + LPARAM l_param) = 0; + + // Handles WM_TOUCH events. + // The |message| parameter identifies the message. + // The |w_param| and |l_param| values are as per MSDN docs. + // Returns the result of processing the message. + virtual LRESULT HandleTouchMessage(unsigned int message, + WPARAM w_param, + LPARAM l_param) = 0; + + // Handles scroll messages like WM_VSCROLL and WM_HSCROLL. + // The |message| parameter identifies the scroll message. + // The |w_param| and |l_param| values are dependent on the type of scroll. + virtual LRESULT HandleScrollMessage(unsigned int message, + WPARAM w_param, + LPARAM l_param) = 0; + + // Handles the WM_NCHITTEST message + // The |message| parameter identifies the message. + // The |w_param| and |l_param| values are as per MSDN docs. + // Returns the result of processing the message. + virtual LRESULT HandleNcHitTestMessage(unsigned int message, + WPARAM w_param, + LPARAM l_param) = 0; + protected: + WindowEventTarget(); + virtual ~WindowEventTarget(); +}; + +} // namespace ui + +#endif // UI_BASE_WIN_WINDOW_EVENT_TARGET_H_ + + |