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

Unified Diff: views/window/window_win.cc

Issue 6756043: Consolidate Widget Event code, other cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Consolidate Widget Event code, other cleanup. 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
« views/widget/widget_win.cc ('K') | « 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 375bf31b404e7466b8b8be4f78f58eb7e8745a13..1d635559f63f7eb12be47c2a98570b0f3efedc55 100644
--- a/views/window/window_win.cc
+++ b/views/window/window_win.cc
@@ -472,28 +472,71 @@ LRESULT WindowWin::OnMouseActivate(UINT message, WPARAM w_param,
}
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);
+ if (message == WM_RBUTTONUP && 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;
+ }
+ } else if (message == WM_NCLBUTTONDOWN && !delegate_->IsUsingNativeFrame()) {
+ switch (w_param) {
+ case HTCLOSE:
+ case HTMINBUTTON:
+ case HTMAXBUTTON: {
+ // When the mouse is pressed down in these specific non-client areas,
+ // we need to tell the RootView to send the mouse pressed event (which
+ // sets capture, allowing subsequent WM_LBUTTONUP (note, _not_
+ // WM_NCLBUTTONUP) to fire so that the appropriate WM_SYSCOMMAND can be
+ // sent by the applicable button's ButtonListener. We _have_ to do this
+ // way rather than letting Windows just send the syscommand itself (as
+ // would happen if we never did this dance) because for some insane
+ // reason DefWindowProc for WM_NCLBUTTONDOWN also renders the pressed
+ // window control button appearance, in the Windows classic style, over
+ // 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.
+ // 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;
+ WidgetWin::OnMouseRange(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 SetMouseCapture() 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.
+ SetMouseCapture();
+ }
+
+ /* TODO(beng): Fix the standard non-client over-painting bug. This code
+ doesn't work but identifies the problem.
+ 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, w_param, l_param);
+ SetMsgHandled(TRUE);
}
+ */
WidgetWin::OnMouseRange(message, w_param, l_param);
return 0;
@@ -626,63 +669,6 @@ LRESULT WindowWin::OnNCHitTest(const CPoint& point) {
return WidgetWin::OnNCHitTest(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 (message == WM_NCLBUTTONDOWN && !delegate_->IsUsingNativeFrame()) {
- switch (w_param) {
- case HTCLOSE:
- case HTMINBUTTON:
- case HTMAXBUTTON: {
- // When the mouse is pressed down in these specific non-client areas,
- // we need to tell the RootView to send the mouse pressed event (which
- // sets capture, allowing subsequent WM_LBUTTONUP (note, _not_
- // WM_NCLBUTTONUP) to fire so that the appropriate WM_SYSCOMMAND can be
- // sent by the applicable button's ButtonListener. We _have_ to do this
- // way rather than letting Windows just send the syscommand itself (as
- // would happen if we never did this dance) because for some insane
- // reason DefWindowProc for WM_NCLBUTTONDOWN also renders the pressed
- // window control button appearance, in the Windows classic style, over
- // 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.
- // 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.
- SetNativeCapture();
- }
-
- 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 (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, w_param, l_param);
- SetMsgHandled(TRUE);
- }
- */
-
- return 0;
-}
-
void WindowWin::OnNCPaint(HRGN rgn) {
// When using a custom frame, we want to avoid calling DefWindowProc() since
// that may render artifacts.
« views/widget/widget_win.cc ('K') | « views/window/window_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698