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

Unified Diff: views/window/window_win.cc

Issue 18095: In chromium, context menu is displayed when right mouse button is released.... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 6 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
===================================================================
--- views/window/window_win.cc (revision 18057)
+++ views/window/window_win.cc (working copy)
@@ -513,6 +513,7 @@
ignore_window_pos_changes_(false),
ignore_pos_changes_factory_(this),
force_hidden_count_(0),
+ is_right_mouse_pressed_on_caption_(false),
last_monitor_(NULL) {
is_window_ = true;
InitClass();
@@ -946,12 +947,43 @@
}
void WindowWin::OnNCRButtonDown(UINT ht_component, const CPoint& point) {
- if (ht_component == HTCAPTION || ht_component == HTSYSMENU)
- RunSystemMenu(gfx::Point(point));
- else
- WidgetWin::OnNCRButtonDown(ht_component, point);
+ if (ht_component == HTCAPTION || ht_component == HTSYSMENU) {
+ is_right_mouse_pressed_on_caption_ = true;
+ // Using SetCapture() here matches Windows native behavior for right-clicks
+ // on the title bar. It's not obvious why Windows does this.
+ SetCapture();
+ }
+
+ WidgetWin::OnNCRButtonDown(ht_component, point);
}
+void WindowWin::OnNCRButtonUp(UINT ht_component, const CPoint& point) {
+ if (is_right_mouse_pressed_on_caption_)
+ is_right_mouse_pressed_on_caption_ = false;
+
+ WidgetWin::OnNCRButtonUp(ht_component, point);
+}
+
+void WindowWin::OnRButtonUp(UINT ht_component, const CPoint& point) {
+ // We handle running the system menu on mouseup here because calling
+ // SetCapture() on mousedown makes the mouseup generate WM_RBUTTONUP instead
+ // of WM_NCRBUTTONUP.
+ CPoint pt = point;
+ MapWindowPoints(GetNativeView(), HWND_DESKTOP, &pt, 1);
+ if (is_right_mouse_pressed_on_caption_) {
+ is_right_mouse_pressed_on_caption_ = false;
+ ReleaseCapture();
+ ht_component =
+ ::SendMessage(GetNativeView(), WM_NCHITTEST, 0, MAKELPARAM(pt.x, pt.y));
+ if (ht_component == HTCAPTION || ht_component == HTSYSMENU) {
+ RunSystemMenu(gfx::Point(pt));
+ return;
+ }
+ }
+
+ WidgetWin::OnRButtonUp(ht_component, point);
+}
+
LRESULT WindowWin::OnNCUAHDrawCaption(UINT msg, WPARAM w_param,
LPARAM l_param) {
// See comment in widget_win.h at the definition of WM_NCUAHDRAWCAPTION for
« 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