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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/window/window_win.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "views/window/window_win.h" 5 #include "views/window/window_win.h"
6 6
7 #include <shellapi.h> 7 #include <shellapi.h>
8 8
9 #include "app/gfx/canvas.h" 9 #include "app/gfx/canvas.h"
10 #include "app/gfx/font.h" 10 #include "app/gfx/font.h"
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 fullscreen_(false), 506 fullscreen_(false),
507 window_closed_(false), 507 window_closed_(false),
508 disable_inactive_rendering_(false), 508 disable_inactive_rendering_(false),
509 is_active_(false), 509 is_active_(false),
510 lock_updates_(false), 510 lock_updates_(false),
511 saved_window_style_(0), 511 saved_window_style_(0),
512 saved_maximized_state_(0), 512 saved_maximized_state_(0),
513 ignore_window_pos_changes_(false), 513 ignore_window_pos_changes_(false),
514 ignore_pos_changes_factory_(this), 514 ignore_pos_changes_factory_(this),
515 force_hidden_count_(0), 515 force_hidden_count_(0),
516 is_right_mouse_pressed_on_caption_(false),
516 last_monitor_(NULL) { 517 last_monitor_(NULL) {
517 is_window_ = true; 518 is_window_ = true;
518 InitClass(); 519 InitClass();
519 DCHECK(window_delegate_); 520 DCHECK(window_delegate_);
520 window_delegate_->window_.reset(this); 521 window_delegate_->window_.reset(this);
521 // Initialize these values to 0 so that subclasses can override the default 522 // Initialize these values to 0 so that subclasses can override the default
522 // behavior before calling Init. 523 // behavior before calling Init.
523 set_window_style(0); 524 set_window_style(0);
524 set_window_ex_style(0); 525 set_window_ex_style(0);
525 } 526 }
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 // scoped update lock. 940 // scoped update lock.
940 ScopedRedrawLock lock(this); 941 ScopedRedrawLock lock(this);
941 DefWindowProc(GetNativeView(), WM_NCLBUTTONDOWN, ht_component, 942 DefWindowProc(GetNativeView(), WM_NCLBUTTONDOWN, ht_component,
942 MAKELPARAM(point.x, point.y)); 943 MAKELPARAM(point.x, point.y));
943 SetMsgHandled(TRUE); 944 SetMsgHandled(TRUE);
944 } 945 }
945 */ 946 */
946 } 947 }
947 948
948 void WindowWin::OnNCRButtonDown(UINT ht_component, const CPoint& point) { 949 void WindowWin::OnNCRButtonDown(UINT ht_component, const CPoint& point) {
949 if (ht_component == HTCAPTION || ht_component == HTSYSMENU) 950 if (ht_component == HTCAPTION || ht_component == HTSYSMENU) {
950 RunSystemMenu(gfx::Point(point)); 951 is_right_mouse_pressed_on_caption_ = true;
951 else 952 // Using SetCapture() here matches Windows native behavior for right-clicks
952 WidgetWin::OnNCRButtonDown(ht_component, point); 953 // on the title bar. It's not obvious why Windows does this.
954 SetCapture();
955 }
956
957 WidgetWin::OnNCRButtonDown(ht_component, point);
958 }
959
960 void WindowWin::OnNCRButtonUp(UINT ht_component, const CPoint& point) {
961 if (is_right_mouse_pressed_on_caption_)
962 is_right_mouse_pressed_on_caption_ = false;
963
964 WidgetWin::OnNCRButtonUp(ht_component, point);
965 }
966
967 void WindowWin::OnRButtonUp(UINT ht_component, const CPoint& point) {
968 // We handle running the system menu on mouseup here because calling
969 // SetCapture() on mousedown makes the mouseup generate WM_RBUTTONUP instead
970 // of WM_NCRBUTTONUP.
971 CPoint pt = point;
972 MapWindowPoints(GetNativeView(), HWND_DESKTOP, &pt, 1);
973 if (is_right_mouse_pressed_on_caption_) {
974 is_right_mouse_pressed_on_caption_ = false;
975 ReleaseCapture();
976 ht_component =
977 ::SendMessage(GetNativeView(), WM_NCHITTEST, 0, MAKELPARAM(pt.x, pt.y));
978 if (ht_component == HTCAPTION || ht_component == HTSYSMENU) {
979 RunSystemMenu(gfx::Point(pt));
980 return;
981 }
982 }
983
984 WidgetWin::OnRButtonUp(ht_component, point);
953 } 985 }
954 986
955 LRESULT WindowWin::OnNCUAHDrawCaption(UINT msg, WPARAM w_param, 987 LRESULT WindowWin::OnNCUAHDrawCaption(UINT msg, WPARAM w_param,
956 LPARAM l_param) { 988 LPARAM l_param) {
957 // See comment in widget_win.h at the definition of WM_NCUAHDRAWCAPTION for 989 // See comment in widget_win.h at the definition of WM_NCUAHDRAWCAPTION for
958 // an explanation about why we need to handle this message. 990 // an explanation about why we need to handle this message.
959 SetMsgHandled(!non_client_view_->UseNativeFrame()); 991 SetMsgHandled(!non_client_view_->UseNativeFrame());
960 return 0; 992 return 0;
961 } 993 }
962 994
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
1395 } 1427 }
1396 return TRUE; 1428 return TRUE;
1397 } 1429 }
1398 } // namespace 1430 } // namespace
1399 1431
1400 void Window::CloseAllSecondaryWindows() { 1432 void Window::CloseAllSecondaryWindows() {
1401 EnumThreadWindows(GetCurrentThreadId(), WindowCallbackProc, 0); 1433 EnumThreadWindows(GetCurrentThreadId(), WindowCallbackProc, 0);
1402 } 1434 }
1403 1435
1404 } // namespace views 1436 } // namespace views
OLDNEW
« 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