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

Side by Side Diff: ui/aura/desktop.cc

Issue 8526020: aura: Track mouse button state. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 9 years, 1 month 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/aura/desktop.h ('k') | ui/aura/desktop_unittest.cc » ('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/aura/desktop.h" 5 #include "ui/aura/desktop.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 Desktop* Desktop::instance_ = NULL; 144 Desktop* Desktop::instance_ = NULL;
145 bool Desktop::use_fullscreen_host_window_ = false; 145 bool Desktop::use_fullscreen_host_window_ = false;
146 146
147 Desktop::Desktop() 147 Desktop::Desktop()
148 : Window(NULL), 148 : Window(NULL),
149 host_(aura::DesktopHost::Create(GetInitialHostWindowBounds())), 149 host_(aura::DesktopHost::Create(GetInitialHostWindowBounds())),
150 ALLOW_THIS_IN_INITIALIZER_LIST( 150 ALLOW_THIS_IN_INITIALIZER_LIST(
151 stacking_client_(new DefaultStackingClient(this))), 151 stacking_client_(new DefaultStackingClient(this))),
152 ALLOW_THIS_IN_INITIALIZER_LIST(schedule_paint_factory_(this)), 152 ALLOW_THIS_IN_INITIALIZER_LIST(schedule_paint_factory_(this)),
153 active_window_(NULL), 153 active_window_(NULL),
154 mouse_button_flags_(0),
154 last_cursor_(kCursorNull), 155 last_cursor_(kCursorNull),
155 in_destructor_(false), 156 in_destructor_(false),
156 screen_(new ScreenAura), 157 screen_(new ScreenAura),
157 capture_window_(NULL), 158 capture_window_(NULL),
158 mouse_pressed_handler_(NULL), 159 mouse_pressed_handler_(NULL),
159 mouse_moved_handler_(NULL), 160 mouse_moved_handler_(NULL),
160 focused_window_(NULL), 161 focused_window_(NULL),
161 touch_event_handler_(NULL) { 162 touch_event_handler_(NULL) {
162 set_name("RootWindow"); 163 set_name("RootWindow");
163 gfx::Screen::SetInstance(screen_); 164 gfx::Screen::SetInstance(screen_);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 void Desktop::Run() { 225 void Desktop::Run() {
225 ShowDesktop(); 226 ShowDesktop();
226 MessageLoopForUI::current()->RunWithDispatcher(host_.get()); 227 MessageLoopForUI::current()->RunWithDispatcher(host_.get());
227 } 228 }
228 229
229 void Desktop::Draw() { 230 void Desktop::Draw() {
230 compositor_->Draw(false); 231 compositor_->Draw(false);
231 } 232 }
232 233
233 bool Desktop::DispatchMouseEvent(MouseEvent* event) { 234 bool Desktop::DispatchMouseEvent(MouseEvent* event) {
235 static const int kMouseButtonFlagMask =
236 ui::EF_LEFT_BUTTON_DOWN |
237 ui::EF_MIDDLE_BUTTON_DOWN |
238 ui::EF_RIGHT_BUTTON_DOWN;
239
234 event->UpdateForTransform(layer()->transform()); 240 event->UpdateForTransform(layer()->transform());
235 241
236 last_mouse_location_ = event->location(); 242 last_mouse_location_ = event->location();
237 243
238 Window* target = 244 Window* target =
239 mouse_pressed_handler_ ? mouse_pressed_handler_ : capture_window_; 245 mouse_pressed_handler_ ? mouse_pressed_handler_ : capture_window_;
240 if (!target) 246 if (!target)
241 target = GetEventHandlerForPoint(event->location()); 247 target = GetEventHandlerForPoint(event->location());
242 switch (event->type()) { 248 switch (event->type()) {
243 case ui::ET_MOUSE_MOVED: 249 case ui::ET_MOUSE_MOVED:
244 HandleMouseMoved(*event, target); 250 HandleMouseMoved(*event, target);
245 break; 251 break;
246 case ui::ET_MOUSE_PRESSED: 252 case ui::ET_MOUSE_PRESSED:
247 if (!mouse_pressed_handler_) 253 if (!mouse_pressed_handler_)
248 mouse_pressed_handler_ = target; 254 mouse_pressed_handler_ = target;
255 mouse_button_flags_ = event->flags() & kMouseButtonFlagMask;
249 break; 256 break;
250 case ui::ET_MOUSE_RELEASED: 257 case ui::ET_MOUSE_RELEASED:
251 mouse_pressed_handler_ = NULL; 258 mouse_pressed_handler_ = NULL;
259 mouse_button_flags_ = event->flags() & kMouseButtonFlagMask;
252 break; 260 break;
253 default: 261 default:
254 break; 262 break;
255 } 263 }
256 if (target && target->delegate()) { 264 if (target && target->delegate()) {
257 int flags = event->flags(); 265 int flags = event->flags();
258 gfx::Point location_in_window = event->location(); 266 gfx::Point location_in_window = event->location();
259 Window::ConvertPointToWindow(this, target, &location_in_window); 267 Window::ConvertPointToWindow(this, target, &location_in_window);
260 if (IsNonClientLocation(target, location_in_window)) 268 if (IsNonClientLocation(target, location_in_window))
261 flags |= ui::EF_IS_NON_CLIENT; 269 flags |= ui::EF_IS_NON_CLIENT;
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 } 400 }
393 401
394 void Desktop::AddObserver(DesktopObserver* observer) { 402 void Desktop::AddObserver(DesktopObserver* observer) {
395 observers_.AddObserver(observer); 403 observers_.AddObserver(observer);
396 } 404 }
397 405
398 void Desktop::RemoveObserver(DesktopObserver* observer) { 406 void Desktop::RemoveObserver(DesktopObserver* observer) {
399 observers_.RemoveObserver(observer); 407 observers_.RemoveObserver(observer);
400 } 408 }
401 409
410 bool Desktop::IsMouseButtonDown() const {
411 return mouse_button_flags_ != 0;
412 }
413
402 void Desktop::SetCapture(Window* window) { 414 void Desktop::SetCapture(Window* window) {
403 if (capture_window_ == window) 415 if (capture_window_ == window)
404 return; 416 return;
405 417
406 if (capture_window_ && capture_window_->delegate()) 418 if (capture_window_ && capture_window_->delegate())
407 capture_window_->delegate()->OnCaptureLost(); 419 capture_window_->delegate()->OnCaptureLost();
408 capture_window_ = window; 420 capture_window_ = window;
409 421
410 if (capture_window_) { 422 if (capture_window_) {
411 // Make all subsequent mouse events and touch go to the capture window. We 423 // Make all subsequent mouse events and touch go to the capture window. We
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 base::StringToInt(parts[1], &parsed_height) && parsed_height > 0) { 604 base::StringToInt(parts[1], &parsed_height) && parsed_height > 0) {
593 bounds.set_size(gfx::Size(parsed_width, parsed_height)); 605 bounds.set_size(gfx::Size(parsed_width, parsed_height));
594 } else if (use_fullscreen_host_window_) { 606 } else if (use_fullscreen_host_window_) {
595 bounds = gfx::Rect(DesktopHost::GetNativeDisplaySize()); 607 bounds = gfx::Rect(DesktopHost::GetNativeDisplaySize());
596 } 608 }
597 609
598 return bounds; 610 return bounds;
599 } 611 }
600 612
601 } // namespace aura 613 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/desktop.h ('k') | ui/aura/desktop_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698