summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-11 21:41:59 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-11 21:41:59 +0000
commit6a3e3081b35adfdc055a32d7d7d2a91b5e31d09c (patch)
treec14023f65fd9c0962b500a211a9837679c4f8796 /views
parent81895a4622ac7e84d7ecb1ff93678a8aa29f9ad7 (diff)
downloadchromium_src-6a3e3081b35adfdc055a32d7d7d2a91b5e31d09c.zip
chromium_src-6a3e3081b35adfdc055a32d7d7d2a91b5e31d09c.tar.gz
chromium_src-6a3e3081b35adfdc055a32d7d7d2a91b5e31d09c.tar.bz2
Landing georgey CL.
See http://codereview.chromium.org/384012 Review URL: http://codereview.chromium.org/387028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31717 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/window/window_win.cc44
-rw-r--r--views/window/window_win.h7
2 files changed, 46 insertions, 5 deletions
diff --git a/views/window/window_win.cc b/views/window/window_win.cc
index 84a09b6..6689a5b 100644
--- a/views/window/window_win.cc
+++ b/views/window/window_win.cc
@@ -499,9 +499,8 @@ WindowWin::WindowWin(WindowDelegate* window_delegate)
ignore_pos_changes_factory_(this),
force_hidden_count_(0),
is_right_mouse_pressed_on_caption_(false),
- last_monitor_(NULL),
- drag_frame_saved_window_style_(0),
- drag_frame_saved_window_ex_style_(false) {
+ last_time_system_menu_clicked_(0),
+ last_monitor_(NULL) {
is_window_ = true;
InitClass();
DCHECK(window_delegate_);
@@ -590,6 +589,8 @@ void WindowWin::RunSystemMenu(const gfx::Point& point) {
int id = ::TrackPopupMenu(system_menu, flags,
point.x(), point.y(), 0, GetNativeView(), NULL);
ExecuteSystemMenuCommand(id);
+ if (id) // something was selected
+ last_time_system_menu_clicked_ = 0;
}
///////////////////////////////////////////////////////////////////////////////
@@ -966,10 +967,18 @@ void WindowWin::OnNCLButtonDown(UINT ht_component, const CPoint& point) {
// From my initial research, it looks like DefWindowProc tries
// to run it but fails before sending the initial WM_MENUSELECT
// for the sysmenu.
- if (ht_component == HTSYSMENU)
+ // TODO(georgey): Remove the fix for double click when we figure out why
+ // system menu does not open automatically and pass it to
+ // default processing.
+ if (ht_component == HTSYSMENU) {
+ // We use 0 as a special value. If user is "lucky" and double clicks on
+ // system icon exactly 49.7x days after PC was started we ignore that
+ // click.
+ last_time_system_menu_clicked_ = GetTickCount();
RunSystemMenu(non_client_view_->GetSystemMenuPoint());
- else
+ } else {
WidgetWin::OnNCLButtonDown(ht_component, point);
+ }
/* TODO(beng): Fix the standard non-client over-painting bug. This code
doesn't work but identifies the problem.
@@ -987,6 +996,31 @@ void WindowWin::OnNCLButtonDown(UINT ht_component, const CPoint& point) {
*/
}
+void WindowWin::OnNCLButtonUp(UINT ht_component, const CPoint& point) {
+ // georgey : fix for double click on system icon not working
+ // As we do track on system menu, the following sequence occurs, when user
+ // double clicks:
+ // 1. Window gets WM_NCLBUTTONDOWN with ht_component == HTSYSMENU
+ // 2. We call TrackPopupMenu, that captures the mouse
+ // 3. Menu, not window, gets WM_NCLBUTTONUP
+ // 4. Menu gets WM_NCLBUTTONDOWN and closes returning 0 (canceled) from
+ // TrackPopupMenu.
+ // 5. Window gets WM_NCLBUTTONUP with ht_component == HTSYSMENU
+ if (ht_component == HTSYSMENU) {
+ if (last_time_system_menu_clicked_) {
+ if ((GetTickCount() - last_time_system_menu_clicked_) <=
+ GetDoubleClickTime()) {
+ // User double clicked left mouse button on system menu - close
+ // window
+ ExecuteSystemMenuCommand(SC_CLOSE);
+ }
+ last_time_system_menu_clicked_ = 0;
+ }
+ }
+
+ WidgetWin::OnNCLButtonUp(ht_component, point);
+}
+
void WindowWin::OnNCRButtonDown(UINT ht_component, const CPoint& point) {
if (ht_component == HTCAPTION || ht_component == HTSYSMENU) {
is_right_mouse_pressed_on_caption_ = true;
diff --git a/views/window/window_win.h b/views/window/window_win.h
index c9c19cf..e9625c2 100644
--- a/views/window/window_win.h
+++ b/views/window/window_win.h
@@ -129,6 +129,7 @@ class WindowWin : public WidgetWin,
virtual LRESULT OnNCHitTest(const CPoint& point);
virtual void OnNCPaint(HRGN rgn);
virtual void OnNCLButtonDown(UINT ht_component, const CPoint& point);
+ virtual void OnNCLButtonUp(UINT ht_component, const CPoint& point);
virtual void OnNCRButtonDown(UINT ht_component, const CPoint& point);
virtual void OnNCRButtonUp(UINT ht_component, const CPoint& point);
virtual void OnRButtonUp(UINT ht_component, const CPoint& point);
@@ -293,6 +294,12 @@ class WindowWin : public WidgetWin,
// area. We need this so we can correctly show the context menu on mouse-up.
bool is_right_mouse_pressed_on_caption_;
+ // With our current behavior when we track popup menu we capture the mouse
+ // so doubleclick does not work. If user doubleclicks on the system icon
+ // the menu will be canceled and user will receive WM_NCLBUTTONUP.
+ // So we store the last time system menu was opened and canceled
+ DWORD last_time_system_menu_clicked_;
+
// The last-seen monitor containing us, and its rect and work area. These are
// used to catch updates to the rect and work area and react accordingly.
HMONITOR last_monitor_;