OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/controls/menu/menu_host_win.h" | 5 #include "views/controls/menu/menu_host_win.h" |
6 | 6 |
7 #include "base/win_util.h" | 7 #include "base/win_util.h" |
8 #include "views/controls/menu/menu_controller.h" | 8 #include "views/controls/menu/menu_controller.h" |
9 #include "views/controls/menu/menu_host_root_view.h" | 9 #include "views/controls/menu/menu_host_root_view.h" |
10 #include "views/controls/menu/menu_item_view.h" | 10 #include "views/controls/menu/menu_item_view.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 set_window_ex_style(WS_EX_TOPMOST | WS_EX_NOACTIVATE); | 30 set_window_ex_style(WS_EX_TOPMOST | WS_EX_NOACTIVATE); |
31 } | 31 } |
32 | 32 |
33 void MenuHost::Init(HWND parent, | 33 void MenuHost::Init(HWND parent, |
34 const gfx::Rect& bounds, | 34 const gfx::Rect& bounds, |
35 View* contents_view, | 35 View* contents_view, |
36 bool do_capture) { | 36 bool do_capture) { |
37 WidgetWin::Init(parent, bounds); | 37 WidgetWin::Init(parent, bounds); |
38 SetContentsView(contents_view); | 38 SetContentsView(contents_view); |
39 Show(); | 39 Show(); |
40 owns_capture_ = do_capture; | 40 if (do_capture) |
41 if (do_capture) { | 41 DoCapture(); |
42 SetCapture(); | |
43 has_capture_ = true; | |
44 #ifdef DEBUG_MENU | |
45 DLOG(INFO) << "Doing capture"; | |
46 #endif | |
47 } | |
48 } | 42 } |
49 | 43 |
50 void MenuHost::Show() { | 44 void MenuHost::Show() { |
51 // We don't want to take focus away from the hosting window. | 45 // We don't want to take focus away from the hosting window. |
52 ShowWindow(SW_SHOWNA); | 46 ShowWindow(SW_SHOWNA); |
53 } | 47 } |
54 | 48 |
55 void MenuHost::Hide() { | 49 void MenuHost::Hide() { |
56 if (closed_) { | 50 if (closed_) { |
57 // We're already closed, nothing to do. | 51 // We're already closed, nothing to do. |
(...skipping 17 matching lines...) Expand all Loading... |
75 } | 69 } |
76 | 70 |
77 void MenuHost::OnCaptureChanged(HWND hwnd) { | 71 void MenuHost::OnCaptureChanged(HWND hwnd) { |
78 WidgetWin::OnCaptureChanged(hwnd); | 72 WidgetWin::OnCaptureChanged(hwnd); |
79 owns_capture_ = false; | 73 owns_capture_ = false; |
80 #ifdef DEBUG_MENU | 74 #ifdef DEBUG_MENU |
81 DLOG(INFO) << "Capture changed"; | 75 DLOG(INFO) << "Capture changed"; |
82 #endif | 76 #endif |
83 } | 77 } |
84 | 78 |
| 79 void MenuHost::DoCapture() { |
| 80 owns_capture_ = true; |
| 81 SetCapture(); |
| 82 has_capture_ = true; |
| 83 #ifdef DEBUG_MENU |
| 84 DLOG(INFO) << "Doing capture"; |
| 85 #endif |
| 86 } |
| 87 |
85 void MenuHost::ReleaseCapture() { | 88 void MenuHost::ReleaseCapture() { |
86 if (owns_capture_) { | 89 if (owns_capture_) { |
87 #ifdef DEBUG_MENU | 90 #ifdef DEBUG_MENU |
88 DLOG(INFO) << "released capture"; | 91 DLOG(INFO) << "released capture"; |
89 #endif | 92 #endif |
90 owns_capture_ = false; | 93 owns_capture_ = false; |
91 ::ReleaseCapture(); | 94 ::ReleaseCapture(); |
92 } | 95 } |
93 } | 96 } |
94 | 97 |
(...skipping 10 matching lines...) Expand all Loading... |
105 } | 108 } |
106 } | 109 } |
107 | 110 |
108 // Overriden to return false, we do NOT want to release capture on mouse | 111 // Overriden to return false, we do NOT want to release capture on mouse |
109 // release. | 112 // release. |
110 bool MenuHost::ReleaseCaptureOnMouseReleased() { | 113 bool MenuHost::ReleaseCaptureOnMouseReleased() { |
111 return false; | 114 return false; |
112 } | 115 } |
113 | 116 |
114 } // namespace views | 117 } // namespace views |
OLD | NEW |