diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-17 23:58:44 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-17 23:58:44 +0000 |
commit | 7321e58f2c6c308e7ff117443acad9a73b5b7592 (patch) | |
tree | 3430879bd44d891d643f947e19a5983366b8b6ed /chrome/views | |
parent | f340e881d7059db7284d07ab4cd19d82739212c3 (diff) | |
download | chromium_src-7321e58f2c6c308e7ff117443acad9a73b5b7592.zip chromium_src-7321e58f2c6c308e7ff117443acad9a73b5b7592.tar.gz chromium_src-7321e58f2c6c308e7ff117443acad9a73b5b7592.tar.bz2 |
Allow middle click on the only tab with one window open.
http://crbug.com/3466
Review URL: http://codereview.chromium.org/7506
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3580 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/views')
-rw-r--r-- | chrome/views/container_win.cc | 12 | ||||
-rw-r--r-- | chrome/views/container_win.h | 6 | ||||
-rw-r--r-- | chrome/views/custom_frame_window.cc | 37 | ||||
-rw-r--r-- | chrome/views/custom_frame_window.h | 8 |
4 files changed, 53 insertions, 10 deletions
diff --git a/chrome/views/container_win.cc b/chrome/views/container_win.cc index 59e1199..b20e8a9 100644 --- a/chrome/views/container_win.cc +++ b/chrome/views/container_win.cc @@ -565,6 +565,18 @@ void ContainerWin::OnNCLButtonUp(UINT flags, const CPoint& point) { SetMsgHandled(FALSE); } +void ContainerWin::OnNCMButtonDblClk(UINT flags, const CPoint& point) { + SetMsgHandled(FALSE); +} + +void ContainerWin::OnNCMButtonDown(UINT flags, const CPoint& point) { + SetMsgHandled(FALSE); +} + +void ContainerWin::OnNCMButtonUp(UINT flags, const CPoint& point) { + SetMsgHandled(FALSE); +} + LRESULT ContainerWin::OnNCMouseLeave(UINT uMsg, WPARAM w_param, LPARAM l_param) { ProcessMouseExited(); diff --git a/chrome/views/container_win.h b/chrome/views/container_win.h index a5f55f8..d1d1272 100644 --- a/chrome/views/container_win.h +++ b/chrome/views/container_win.h @@ -216,6 +216,9 @@ class ContainerWin : public Container, MSG_WM_NCLBUTTONDBLCLK(OnNCLButtonDblClk) MSG_WM_NCLBUTTONDOWN(OnNCLButtonDown) MSG_WM_NCLBUTTONUP(OnNCLButtonUp) + MSG_WM_NCMBUTTONDBLCLK(OnNCMButtonDblClk) + MSG_WM_NCMBUTTONDOWN(OnNCMButtonDown) + MSG_WM_NCMBUTTONUP(OnNCMButtonUp) MSG_WM_NCPAINT(OnNCPaint) MSG_WM_NCRBUTTONDBLCLK(OnNCRButtonDblClk) MSG_WM_NCRBUTTONDOWN(OnNCRButtonDown) @@ -389,6 +392,9 @@ class ContainerWin : public Container, virtual void OnNCLButtonDblClk(UINT flags, const CPoint& point); virtual void OnNCLButtonDown(UINT flags, const CPoint& point); virtual void OnNCLButtonUp(UINT flags, const CPoint& point); + virtual void OnNCMButtonDblClk(UINT flags, const CPoint& point); + virtual void OnNCMButtonDown(UINT flags, const CPoint& point); + virtual void OnNCMButtonUp(UINT flags, const CPoint& point); virtual LRESULT OnNCMouseLeave(UINT uMsg, WPARAM w_param, LPARAM l_param); virtual LRESULT OnNCMouseMove(UINT flags, const CPoint& point); virtual void OnNCPaint(HRGN rgn) { SetMsgHandled(FALSE); } diff --git a/chrome/views/custom_frame_window.cc b/chrome/views/custom_frame_window.cc index 472a9bb..0febe17 100644 --- a/chrome/views/custom_frame_window.cc +++ b/chrome/views/custom_frame_window.cc @@ -1189,16 +1189,7 @@ void CustomFrameWindow::OnNCLButtonDown(UINT ht_component, // view! Ick! By handling this message we prevent Windows from doing this // undesirable thing, but that means we need to roll the sys-command // handling ourselves. - CPoint temp = point; - MapWindowPoints(HWND_DESKTOP, GetHWND(), &temp, 1); - UINT flags = 0; - if ((GetKeyState(VK_CONTROL) & 0x80) == 0x80) - flags |= MK_CONTROL; - if ((GetKeyState(VK_SHIFT) & 0x80) == 0x80) - flags |= MK_SHIFT; - flags |= MK_LBUTTON; - ProcessMousePressed(temp, flags, false); - SetMsgHandled(TRUE); + ProcessNCMousePress(point, MK_LBUTTON); return; } default: @@ -1207,6 +1198,20 @@ void CustomFrameWindow::OnNCLButtonDown(UINT ht_component, } } +void CustomFrameWindow::OnNCMButtonDown(UINT ht_component, + const CPoint& point) { + if (ht_component == HTCAPTION) { + // When there's only one window and only one tab, the tab area is reported + // to be part of the caption area of the window. However users should still + // be able to middle click that tab to close it so we need to make sure + // these messages reach the View system. + ProcessNCMousePress(point, MK_MBUTTON); + SetMsgHandled(FALSE); + return; + } + ContainerWin::OnNCMButtonDown(ht_component, point); +} + LRESULT CustomFrameWindow::OnNCUAHDrawCaption(UINT msg, WPARAM w_param, LPARAM l_param) { // See comment in hwnd_view_container.h at the definition of @@ -1318,5 +1323,17 @@ void CustomFrameWindow::ResetWindowRegion() { DeleteObject(current_rgn); } +void CustomFrameWindow::ProcessNCMousePress(const CPoint& point, int flags) { + CPoint temp = point; + MapWindowPoints(HWND_DESKTOP, GetHWND(), &temp, 1); + UINT message_flags = 0; + if ((GetKeyState(VK_CONTROL) & 0x80) == 0x80) + message_flags |= MK_CONTROL; + if ((GetKeyState(VK_SHIFT) & 0x80) == 0x80) + message_flags |= MK_SHIFT; + message_flags |= flags; + ProcessMousePressed(temp, message_flags, false); +} + } // namespace views diff --git a/chrome/views/custom_frame_window.h b/chrome/views/custom_frame_window.h index 3f3b3b1..ed03230 100644 --- a/chrome/views/custom_frame_window.h +++ b/chrome/views/custom_frame_window.h @@ -56,6 +56,7 @@ class CustomFrameWindow : public Window { virtual LRESULT OnNCHitTest(const CPoint& point); virtual void OnNCPaint(HRGN rgn); virtual void OnNCLButtonDown(UINT ht_component, const CPoint& point); + virtual void OnNCMButtonDown(UINT ht_component, const CPoint& point); virtual LRESULT OnNCUAHDrawCaption(UINT msg, WPARAM w_param, LPARAM l_param); virtual LRESULT OnNCUAHDrawFrame(UINT msg, WPARAM w_param, LPARAM l_param); virtual LRESULT OnSetCursor(HWND window, UINT hittest_code, UINT message); @@ -67,6 +68,13 @@ class CustomFrameWindow : public Window { // Resets the window region. void ResetWindowRegion(); + // Converts a non-client mouse down message to a regular ChromeViews event + // and handle it. |point| is the mouse position of the message in screen + // coords. |flags| are flags that would be passed with a WM_L/M/RBUTTON* + // message and relate to things like which button was pressed. These are + // combined with flags relating to the current key state. + void ProcessNCMousePress(const CPoint& point, int flags); + // True if this window is the active top level window. bool is_active_; |