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

Side by Side Diff: ui/views/widget/widget.cc

Issue 6756043: Consolidate Widget Event code, other cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync and merge. Created 9 years, 8 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 | « ui/views/widget/native_widget_win.cc ('k') | views/controls/menu/menu_host_gtk.h » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "ui/views/widget/widget.h" 5 #include "ui/views/widget/widget.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "ui/views/focus/focus_manager.h" 9 #include "ui/views/focus/focus_manager.h"
10 #include "ui/views/view.h" 10 #include "ui/views/view.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 152
153 void Widget::OnMouseCaptureLost() { 153 void Widget::OnMouseCaptureLost() {
154 if (native_widget_->HasMouseCapture()) { 154 if (native_widget_->HasMouseCapture()) {
155 if (is_mouse_button_pressed_) 155 if (is_mouse_button_pressed_)
156 root_view_->OnMouseCaptureLost(); 156 root_view_->OnMouseCaptureLost();
157 is_mouse_button_pressed_ = false; 157 is_mouse_button_pressed_ = false;
158 } 158 }
159 } 159 }
160 160
161 bool Widget::OnMouseEvent(const MouseEvent& event) { 161 bool Widget::OnMouseEvent(const MouseEvent& event) {
162 last_mouse_event_was_move_ = false;
163 switch (event.type()) { 162 switch (event.type()) {
164 case ui::Event::ET_MOUSE_PRESSED: 163 case ui::Event::ET_MOUSE_PRESSED:
164 last_mouse_event_was_move_ = false;
165 if (root_view_->OnMousePressed(event)) { 165 if (root_view_->OnMousePressed(event)) {
166 is_mouse_button_pressed_ = true; 166 is_mouse_button_pressed_ = true;
167 if (!native_widget_->HasMouseCapture()) 167 if (!native_widget_->HasMouseCapture())
168 native_widget_->SetMouseCapture(); 168 native_widget_->SetMouseCapture();
169 return true; 169 return true;
170 } 170 }
171 return false; 171 return false;
172 case ui::Event::ET_MOUSE_RELEASED: 172 case ui::Event::ET_MOUSE_RELEASED:
173 // TODO(beng): NativeWidgetGtk should not call this function if drag data 173 // TODO(beng): NativeWidgetGtk should not call this function if drag data
174 // exists, see comment in this function in WidgetGtk. 174 // exists, see comment in this function in WidgetGtk.
175 // Release the capture first, that way we don't get confused if 175 // Release the capture first, that way we don't get confused if
176 // OnMouseReleased blocks. 176 // OnMouseReleased blocks.
177 if (native_widget_->HasMouseCapture() && 177 if (native_widget_->HasMouseCapture() &&
178 native_widget_->ShouldReleaseCaptureOnMouseReleased()) { 178 native_widget_->ShouldReleaseCaptureOnMouseReleased()) {
179 native_widget_->ReleaseMouseCapture(); 179 native_widget_->ReleaseMouseCapture();
180 } 180 }
181 last_mouse_event_was_move_ = false;
181 is_mouse_button_pressed_ = false; 182 is_mouse_button_pressed_ = false;
182 root_view_->OnMouseReleased(event); 183 root_view_->OnMouseReleased(event);
183 return true; 184 return true;
184 case ui::Event::ET_MOUSE_MOVED: 185 case ui::Event::ET_MOUSE_MOVED:
185 if (native_widget_->HasMouseCapture() && is_mouse_button_pressed_) { 186 if (native_widget_->HasMouseCapture() && is_mouse_button_pressed_) {
186 last_mouse_event_was_move_ = false; 187 last_mouse_event_was_move_ = false;
187 root_view_->OnMouseDragged(event); 188 root_view_->OnMouseDragged(event);
188 } else { 189 } else {
189 gfx::Point screen_loc(event.location()); 190 gfx::Point screen_loc(event.location());
190 View::ConvertPointToScreen(*root_view_, &screen_loc); 191 View::ConvertPointToScreen(*root_view_, &screen_loc);
191 if (last_mouse_event_was_move_ && 192 if (last_mouse_event_was_move_ &&
192 last_mouse_event_position_ == screen_loc) { 193 last_mouse_event_position_ == screen_loc) {
193 // Don't generate a mouse event for the same location as the last. 194 // Don't generate a mouse event for the same location as the last.
194 return true; 195 return true;
195 } 196 }
196 last_mouse_event_position_ = screen_loc; 197 last_mouse_event_position_ = screen_loc;
197 last_mouse_event_was_move_ = true; 198 last_mouse_event_was_move_ = true;
198 root_view_->OnMouseMoved(event); 199 root_view_->OnMouseMoved(event);
199 } 200 }
200 break; 201 break;
201 case ui::Event::ET_MOUSE_EXITED: 202 case ui::Event::ET_MOUSE_EXITED:
203 last_mouse_event_was_move_ = false;
202 root_view_->OnMouseExited(event); 204 root_view_->OnMouseExited(event);
203 return true; 205 return true;
204 } 206 }
205 return true; 207 return true;
206 } 208 }
207 209
208 bool Widget::OnMouseWheelEvent(const MouseWheelEvent& event) { 210 bool Widget::OnMouseWheelEvent(const MouseWheelEvent& event) {
209 return root_view_->OnMouseWheel(event); 211 return root_view_->OnMouseWheel(event);
210 } 212 }
211 213
(...skipping 30 matching lines...) Expand all
242 244
243 //////////////////////////////////////////////////////////////////////////////// 245 ////////////////////////////////////////////////////////////////////////////////
244 // Widget, private: 246 // Widget, private:
245 247
246 void Widget::CloseNow() { 248 void Widget::CloseNow() {
247 native_widget_->Close(); 249 native_widget_->Close();
248 } 250 }
249 251
250 } // namespace ui 252 } // namespace ui
251 253
OLDNEW
« no previous file with comments | « ui/views/widget/native_widget_win.cc ('k') | views/controls/menu/menu_host_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698