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

Unified Diff: views/window/window_win.cc

Issue 6591120: Update MouseEvent (initial pass). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 9 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « views/window/window_win.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/window/window_win.cc
diff --git a/views/window/window_win.cc b/views/window/window_win.cc
index 3122a942cf43574ab5f1a97b966b2df31b1cc7f2..30e98ec191aba2861696075b432bab06af679b25 100644
--- a/views/window/window_win.cc
+++ b/views/window/window_win.cc
@@ -640,7 +640,7 @@ WindowWin::WindowWin(WindowDelegate* window_delegate)
set_window_ex_style(0);
}
-void WindowWin::Init(HWND parent, const gfx::Rect& bounds) {
+void WindowWin::Init(gfx::NativeView parent, const gfx::Rect& bounds) {
// We need to save the parent window, since later calls to GetParent() will
// return NULL.
owning_hwnd_ = parent;
@@ -807,12 +807,12 @@ void WindowWin::OnInitMenu(HMENU menu) {
!is_minimized);
}
-void WindowWin::OnMouseLeave() {
+LRESULT WindowWin::OnMouseLeave(UINT message, WPARAM w_param, LPARAM l_param) {
// We only need to manually track WM_MOUSELEAVE messages between the client
// and non-client area when we're not using the native frame.
if (GetWindow()->non_client_view()->UseNativeFrame()) {
SetMsgHandled(FALSE);
- return;
+ return 0;
}
bool process_mouse_exited = true;
@@ -832,8 +832,38 @@ void WindowWin::OnMouseLeave() {
if (process_mouse_exited)
ProcessMouseExited();
+ return 0;
+}
+
+LRESULT WindowWin::OnMouseRange(UINT message, WPARAM w_param, LPARAM l_param) {
+ if (message == WM_RBUTTONUP) {
+ if (is_right_mouse_pressed_on_caption_) {
+ is_right_mouse_pressed_on_caption_ = false;
+ ReleaseCapture();
+ // |point| is in window coordinates, but WM_NCHITTEST and TrackPopupMenu()
+ // expect screen coordinates.
+ CPoint screen_point(l_param);
+ MapWindowPoints(GetNativeView(), HWND_DESKTOP, &screen_point, 1);
+ w_param = SendMessage(GetNativeView(), WM_NCHITTEST, 0,
+ MAKELPARAM(screen_point.x, screen_point.y));
+ if (w_param == HTCAPTION || w_param == HTSYSMENU) {
+ UINT flags = TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_RETURNCMD;
+ if (base::i18n::IsRTL())
+ flags |= TPM_RIGHTALIGN;
+ HMENU system_menu = GetSystemMenu(GetNativeView(), FALSE);
+ int id = TrackPopupMenu(system_menu, flags, screen_point.x,
+ screen_point.y, 0, GetNativeView(), NULL);
+ ExecuteSystemMenuCommand(id);
+ return 0;
+ }
+ }
+ }
+
+ WidgetWin::OnMouseRange(message, w_param, l_param);
+ return 0;
}
+
LRESULT WindowWin::OnNCActivate(BOOL active) {
is_active_ = !!active;
@@ -953,17 +983,14 @@ LRESULT WindowWin::OnNCHitTest(const CPoint& point) {
return WidgetWin::OnNCHitTest(point);
}
-void WindowWin::OnNCPaint(HRGN rgn) {
- // When using a custom frame, we want to avoid calling DefWindowProc() since
- // that may render artifacts.
- SetMsgHandled(!GetWindow()->non_client_view()->UseNativeFrame());
-}
-
-void WindowWin::OnNCLButtonDown(UINT ht_component, const CPoint& point) {
+LRESULT WindowWin::OnNCMouseRange(UINT message,
+ WPARAM w_param,
+ LPARAM l_param) {
// When we're using a native frame, window controls work without us
// interfering.
- if (!GetWindow()->non_client_view()->UseNativeFrame()) {
- switch (ht_component) {
+ if (message == WM_NCLBUTTONDOWN &&
+ !GetWindow()->non_client_view()->UseNativeFrame()) {
+ switch (w_param) {
case HTCLOSE:
case HTMINBUTTON:
case HTMAXBUTTON: {
@@ -979,65 +1006,45 @@ void WindowWin::OnNCLButtonDown(UINT ht_component, const CPoint& point) {
// our 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.
- ProcessNCMousePress(point, MK_LBUTTON);
- return;
+ // Combine |w_param| with common key state message flags.
+ w_param |= ((GetKeyState(VK_CONTROL) & 0x80) == 0x80)? MK_CONTROL : 0;
+ w_param |= ((GetKeyState(VK_SHIFT) & 0x80) == 0x80)? MK_SHIFT : 0;
+ ProcessMousePressed(message, w_param, l_param);
+ return 0;
}
}
+ } else if (message == WM_NCRBUTTONDOWN &&
+ (w_param == HTCAPTION || w_param == HTSYSMENU)) {
+ is_right_mouse_pressed_on_caption_ = true;
+ // We SetCapture() to ensure we only show the menu when the button down and
+ // up are both on the caption. Note: this causes the button up to be
+ // WM_RBUTTONUP instead of WM_NCRBUTTONUP.
+ SetCapture();
}
- WidgetWin::OnNCLButtonDown(ht_component, point);
+ WidgetWin::OnNCMouseRange(message, w_param, l_param);
/* TODO(beng): Fix the standard non-client over-painting bug. This code
doesn't work but identifies the problem.
- if (!IsMsgHandled()) {
+ if (message == WM_NCLBUTTONDOWN && !IsMsgHandled()) {
// WindowWin::OnNCLButtonDown set the message as unhandled. This normally
// means WidgetWin::ProcessWindowMessage will pass it to
// DefWindowProc. Sadly, DefWindowProc for WM_NCLBUTTONDOWN does weird
// non-client painting, so we need to call it directly here inside a
// scoped update lock.
ScopedRedrawLock lock(this);
- DefWindowProc(GetNativeView(), WM_NCLBUTTONDOWN, ht_component,
- MAKELPARAM(point.x, point.y));
+ DefWindowProc(GetNativeView(), WM_NCLBUTTONDOWN, w_param, l_param);
SetMsgHandled(TRUE);
}
*/
-}
-void WindowWin::OnNCRButtonDown(UINT ht_component, const CPoint& point) {
- if (ht_component == HTCAPTION || ht_component == HTSYSMENU) {
- is_right_mouse_pressed_on_caption_ = true;
- // We SetCapture() to ensure we only show the menu when the button down and
- // up are both on the caption. Note: this causes the button up to be
- // WM_RBUTTONUP instead of WM_NCRBUTTONUP.
- SetCapture();
- }
-
- WidgetWin::OnNCRButtonDown(ht_component, point);
-}
-
-void WindowWin::OnRButtonUp(UINT ht_component, const CPoint& point) {
- if (is_right_mouse_pressed_on_caption_) {
- is_right_mouse_pressed_on_caption_ = false;
- ReleaseCapture();
- // |point| is in window coordinates, but WM_NCHITTEST and TrackPopupMenu()
- // expect screen coordinates.
- CPoint screen_point(point);
- MapWindowPoints(GetNativeView(), HWND_DESKTOP, &screen_point, 1);
- ht_component = SendMessage(GetNativeView(), WM_NCHITTEST, 0,
- MAKELPARAM(screen_point.x, screen_point.y));
- if (ht_component == HTCAPTION || ht_component == HTSYSMENU) {
- UINT flags = TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_RETURNCMD;
- if (base::i18n::IsRTL())
- flags |= TPM_RIGHTALIGN;
- HMENU system_menu = GetSystemMenu(GetNativeView(), FALSE);
- int id = TrackPopupMenu(system_menu, flags, screen_point.x,
- screen_point.y, 0, GetNativeView(), NULL);
- ExecuteSystemMenuCommand(id);
- return;
- }
- }
+ return 0;
+}
- WidgetWin::OnRButtonUp(ht_component, point);
+void WindowWin::OnNCPaint(HRGN rgn) {
+ // When using a custom frame, we want to avoid calling DefWindowProc() since
+ // that may render artifacts.
+ SetMsgHandled(!GetWindow()->non_client_view()->UseNativeFrame());
}
LRESULT WindowWin::OnNCUAHDrawCaption(UINT msg, WPARAM w_param,
@@ -1447,18 +1454,6 @@ void WindowWin::UpdateAccessibleState() {
}
}
-void WindowWin::ProcessNCMousePress(const CPoint& point, int flags) {
- CPoint temp = point;
- MapWindowPoints(HWND_DESKTOP, GetNativeView(), &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, false);
-}
-
LRESULT WindowWin::CallDefaultNCActivateHandler(BOOL active) {
// The DefWindowProc handling for WM_NCACTIVATE renders the classic-look
// window title bar directly, so we need to use a redraw lock here to prevent
« no previous file with comments | « views/window/window_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698