From a83f0f2a4ae1be9d70e9d6930bd6b3a8f6036fd8 Mon Sep 17 00:00:00 2001 From: "ben@chromium.org" Date: Tue, 23 Aug 2011 15:39:15 +0000 Subject: Wire mouseevent through to Window. BUG=none TEST=none TBR=sky Review URL: http://codereview.chromium.org/7685031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97864 0039d316-1c4b-4281-b951-d872f2087c98 --- aura/desktop.cc | 4 ++++ aura/desktop.h | 4 ++++ aura/desktop_host_win.cc | 10 ++++++++++ aura/desktop_host_win.h | 5 +++++ aura/window.cc | 4 ++++ aura/window.h | 4 ++++ 6 files changed, 31 insertions(+) (limited to 'aura') diff --git a/aura/desktop.cc b/aura/desktop.cc index 0055450..00b130f 100644 --- a/aura/desktop.cc +++ b/aura/desktop.cc @@ -26,4 +26,8 @@ void Desktop::Draw() { compositor_->NotifyEnd(); } +bool Desktop::OnMouseEvent(const MouseEvent& event) { + return window_->OnMouseEvent(event); +} + } // namespace aura diff --git a/aura/desktop.h b/aura/desktop.h index 4df3742..1eb89ca 100644 --- a/aura/desktop.h +++ b/aura/desktop.h @@ -21,6 +21,7 @@ class Compositor; namespace aura { +class MouseEvent; class Window; // Desktop is responsible for hosting a set of windows. @@ -32,6 +33,9 @@ class Desktop { // Draws the necessary set of windows. void Draw(); + // Handles a mouse event. Returns true if handled. + bool OnMouseEvent(const MouseEvent& event); + // Compositor we're drawing to. ui::Compositor* compositor() { return compositor_.get(); } diff --git a/aura/desktop_host_win.cc b/aura/desktop_host_win.cc index 080b84a..e581b7d 100644 --- a/aura/desktop_host_win.cc +++ b/aura/desktop_host_win.cc @@ -5,6 +5,7 @@ #include "aura/desktop_host_win.h" #include "aura/desktop.h" +#include "aura/event.h" #include "base/message_loop.h" namespace aura { @@ -51,6 +52,15 @@ void DesktopHostWin::OnClose() { MessageLoopForUI::current()->Quit(); } +LRESULT DesktopHostWin::OnMouseRange(UINT message, + WPARAM w_param, + LPARAM l_param) { + MSG msg = { hwnd(), message, w_param, l_param, 0, + { GET_X_LPARAM(l_param), GET_Y_LPARAM(l_param) } }; + SetMsgHandled(desktop_->OnMouseEvent(MouseEvent(msg))); + return 0; +} + void DesktopHostWin::OnPaint(HDC dc) { if (desktop_) desktop_->Draw(); diff --git a/aura/desktop_host_win.h b/aura/desktop_host_win.h index 0f0d68f..6a8165b 100644 --- a/aura/desktop_host_win.h +++ b/aura/desktop_host_win.h @@ -28,11 +28,16 @@ class DesktopHostWin : public DesktopHost, public ui::WindowImpl { private: BEGIN_MSG_MAP_EX(DesktopHostWin) + // Range handlers must go first! + MESSAGE_RANGE_HANDLER_EX(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseRange) + MESSAGE_RANGE_HANDLER_EX(WM_NCMOUSEMOVE, WM_NCXBUTTONDBLCLK, OnMouseRange) + MSG_WM_CLOSE(OnClose) MSG_WM_PAINT(OnPaint) END_MSG_MAP() void OnClose(); + LRESULT OnMouseRange(UINT message, WPARAM w_param, LPARAM l_param); void OnPaint(HDC dc); Desktop* desktop_; diff --git a/aura/window.cc b/aura/window.cc index 2d63d80..11e9b31 100644 --- a/aura/window.cc +++ b/aura/window.cc @@ -82,6 +82,10 @@ void Window::RemoveChild(Window* child) { children_.erase(i); } +bool Window::OnMouseEvent(const MouseEvent& event) { + return true; +} + void Window::UpdateLayerCanvas() { if (needs_paint_all_) { needs_paint_all_ = false; diff --git a/aura/window.h b/aura/window.h index b4611c4..f72b2b6 100644 --- a/aura/window.h +++ b/aura/window.h @@ -23,6 +23,7 @@ class Layer; namespace aura { class Desktop; +class MouseEvent; class WindowDelegate; // Aura window implementation. Interesting events are sent to the @@ -73,6 +74,9 @@ class Window { void RemoveChild(Window* child); Window* parent() { return parent_; } + // Handles a mouse event. Returns true if handled. + bool OnMouseEvent(const MouseEvent& event); + private: typedef std::vector Windows; -- cgit v1.1