| OLD | NEW |
| 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 Desktop* Desktop::instance_ = NULL; | 142 Desktop* Desktop::instance_ = NULL; |
| 143 bool Desktop::use_fullscreen_host_window_ = false; | 143 bool Desktop::use_fullscreen_host_window_ = false; |
| 144 | 144 |
| 145 Desktop::Desktop() | 145 Desktop::Desktop() |
| 146 : Window(NULL), | 146 : Window(NULL), |
| 147 host_(aura::DesktopHost::Create(GetInitialHostWindowBounds())), | 147 host_(aura::DesktopHost::Create(GetInitialHostWindowBounds())), |
| 148 ALLOW_THIS_IN_INITIALIZER_LIST( | 148 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 149 stacking_client_(new DefaultStackingClient(this))), | 149 stacking_client_(new DefaultStackingClient(this))), |
| 150 ALLOW_THIS_IN_INITIALIZER_LIST(schedule_paint_factory_(this)), | 150 ALLOW_THIS_IN_INITIALIZER_LIST(schedule_paint_factory_(this)), |
| 151 active_window_(NULL), | 151 active_window_(NULL), |
| 152 mouse_button_flags_(0), |
| 152 last_cursor_(kCursorNull), | 153 last_cursor_(kCursorNull), |
| 153 in_destructor_(false), | 154 in_destructor_(false), |
| 154 screen_(new ScreenAura), | 155 screen_(new ScreenAura), |
| 155 capture_window_(NULL), | 156 capture_window_(NULL), |
| 156 mouse_pressed_handler_(NULL), | 157 mouse_pressed_handler_(NULL), |
| 157 mouse_moved_handler_(NULL), | 158 mouse_moved_handler_(NULL), |
| 158 focused_window_(NULL), | 159 focused_window_(NULL), |
| 159 touch_event_handler_(NULL) { | 160 touch_event_handler_(NULL) { |
| 160 set_name("RootWindow"); | 161 set_name("RootWindow"); |
| 161 gfx::Screen::SetInstance(screen_); | 162 gfx::Screen::SetInstance(screen_); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 void Desktop::Run() { | 223 void Desktop::Run() { |
| 223 ShowDesktop(); | 224 ShowDesktop(); |
| 224 MessageLoopForUI::current()->RunWithDispatcher(host_.get()); | 225 MessageLoopForUI::current()->RunWithDispatcher(host_.get()); |
| 225 } | 226 } |
| 226 | 227 |
| 227 void Desktop::Draw() { | 228 void Desktop::Draw() { |
| 228 compositor_->Draw(false); | 229 compositor_->Draw(false); |
| 229 } | 230 } |
| 230 | 231 |
| 231 bool Desktop::DispatchMouseEvent(MouseEvent* event) { | 232 bool Desktop::DispatchMouseEvent(MouseEvent* event) { |
| 233 static const int kMouseButtonFlagMask = |
| 234 ui::EF_LEFT_BUTTON_DOWN | |
| 235 ui::EF_MIDDLE_BUTTON_DOWN | |
| 236 ui::EF_RIGHT_BUTTON_DOWN; |
| 237 |
| 232 event->UpdateForTransform(layer()->transform()); | 238 event->UpdateForTransform(layer()->transform()); |
| 233 | 239 |
| 234 last_mouse_location_ = event->location(); | 240 last_mouse_location_ = event->location(); |
| 235 | 241 |
| 236 Window* target = | 242 Window* target = |
| 237 mouse_pressed_handler_ ? mouse_pressed_handler_ : capture_window_; | 243 mouse_pressed_handler_ ? mouse_pressed_handler_ : capture_window_; |
| 238 if (!target) | 244 if (!target) |
| 239 target = GetEventHandlerForPoint(event->location()); | 245 target = GetEventHandlerForPoint(event->location()); |
| 240 switch (event->type()) { | 246 switch (event->type()) { |
| 241 case ui::ET_MOUSE_MOVED: | 247 case ui::ET_MOUSE_MOVED: |
| 242 HandleMouseMoved(*event, target); | 248 HandleMouseMoved(*event, target); |
| 243 break; | 249 break; |
| 244 case ui::ET_MOUSE_PRESSED: | 250 case ui::ET_MOUSE_PRESSED: |
| 245 if (!mouse_pressed_handler_) | 251 if (!mouse_pressed_handler_) |
| 246 mouse_pressed_handler_ = target; | 252 mouse_pressed_handler_ = target; |
| 253 mouse_button_flags_ = event->flags() & kMouseButtonFlagMask; |
| 247 break; | 254 break; |
| 248 case ui::ET_MOUSE_RELEASED: | 255 case ui::ET_MOUSE_RELEASED: |
| 249 mouse_pressed_handler_ = NULL; | 256 mouse_pressed_handler_ = NULL; |
| 257 mouse_button_flags_ = event->flags() & kMouseButtonFlagMask; |
| 250 break; | 258 break; |
| 251 default: | 259 default: |
| 252 break; | 260 break; |
| 253 } | 261 } |
| 254 if (target && target->delegate()) { | 262 if (target && target->delegate()) { |
| 255 int flags = event->flags(); | 263 int flags = event->flags(); |
| 256 if (IsNonClientLocation(target, event->location())) | 264 if (IsNonClientLocation(target, event->location())) |
| 257 flags |= ui::EF_IS_NON_CLIENT; | 265 flags |= ui::EF_IS_NON_CLIENT; |
| 258 MouseEvent translated_event(*event, this, target, event->type(), flags); | 266 MouseEvent translated_event(*event, this, target, event->type(), flags); |
| 259 return ProcessMouseEvent(target, &translated_event); | 267 return ProcessMouseEvent(target, &translated_event); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 } | 396 } |
| 389 | 397 |
| 390 void Desktop::AddObserver(DesktopObserver* observer) { | 398 void Desktop::AddObserver(DesktopObserver* observer) { |
| 391 observers_.AddObserver(observer); | 399 observers_.AddObserver(observer); |
| 392 } | 400 } |
| 393 | 401 |
| 394 void Desktop::RemoveObserver(DesktopObserver* observer) { | 402 void Desktop::RemoveObserver(DesktopObserver* observer) { |
| 395 observers_.RemoveObserver(observer); | 403 observers_.RemoveObserver(observer); |
| 396 } | 404 } |
| 397 | 405 |
| 406 bool Desktop::IsMouseButtonDown() const { |
| 407 return mouse_button_flags_; |
| 408 } |
| 409 |
| 398 void Desktop::SetCapture(Window* window) { | 410 void Desktop::SetCapture(Window* window) { |
| 399 if (capture_window_ == window) | 411 if (capture_window_ == window) |
| 400 return; | 412 return; |
| 401 | 413 |
| 402 if (capture_window_ && capture_window_->delegate()) | 414 if (capture_window_ && capture_window_->delegate()) |
| 403 capture_window_->delegate()->OnCaptureLost(); | 415 capture_window_->delegate()->OnCaptureLost(); |
| 404 capture_window_ = window; | 416 capture_window_ = window; |
| 405 | 417 |
| 406 if (capture_window_) { | 418 if (capture_window_) { |
| 407 // Make all subsequent mouse events and touch go to the capture window. We | 419 // 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 Loading... |
| 588 base::StringToInt(parts[1], &parsed_height) && parsed_height > 0) { | 600 base::StringToInt(parts[1], &parsed_height) && parsed_height > 0) { |
| 589 bounds.set_size(gfx::Size(parsed_width, parsed_height)); | 601 bounds.set_size(gfx::Size(parsed_width, parsed_height)); |
| 590 } else if (use_fullscreen_host_window_) { | 602 } else if (use_fullscreen_host_window_) { |
| 591 bounds = gfx::Rect(DesktopHost::GetNativeDisplaySize()); | 603 bounds = gfx::Rect(DesktopHost::GetNativeDisplaySize()); |
| 592 } | 604 } |
| 593 | 605 |
| 594 return bounds; | 606 return bounds; |
| 595 } | 607 } |
| 596 | 608 |
| 597 } // namespace aura | 609 } // namespace aura |
| OLD | NEW |