Chromium Code Reviews| 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" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
| 14 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
| 15 #include "base/string_split.h" | 15 #include "base/string_split.h" |
| 16 #include "ui/aura/aura_switches.h" | 16 #include "ui/aura/aura_switches.h" |
| 17 #include "ui/aura/client/stacking_client.h" | 17 #include "ui/aura/client/stacking_client.h" |
| 18 #include "ui/aura/desktop_host.h" | 18 #include "ui/aura/desktop_host.h" |
| 19 #include "ui/aura/desktop_observer.h" | 19 #include "ui/aura/desktop_observer.h" |
| 20 #include "ui/aura/event.h" | 20 #include "ui/aura/event.h" |
| 21 #include "ui/aura/event_filter.h" | 21 #include "ui/aura/event_filter.h" |
| 22 #include "ui/aura/focus_manager.h" | 22 #include "ui/aura/focus_manager.h" |
| 23 #include "ui/aura/screen_aura.h" | 23 #include "ui/aura/screen_aura.h" |
| 24 #include "ui/aura/window.h" | 24 #include "ui/aura/window.h" |
| 25 #include "ui/aura/window_delegate.h" | 25 #include "ui/aura/window_delegate.h" |
| 26 #include "ui/base/hit_test.h" | 26 #include "ui/base/hit_test.h" |
| 27 #include "ui/gfx/compositor/compositor.h" | 27 #include "ui/gfx/compositor/compositor.h" |
| 28 #include "ui/gfx/compositor/debug_utils.h" | |
| 28 #include "ui/gfx/compositor/layer.h" | 29 #include "ui/gfx/compositor/layer.h" |
| 29 #include "ui/gfx/compositor/layer_animation_sequence.h" | 30 #include "ui/gfx/compositor/layer_animation_sequence.h" |
| 30 #include "ui/gfx/compositor/layer_animator.h" | 31 #include "ui/gfx/compositor/layer_animator.h" |
| 31 #include "ui/gfx/compositor/screen_rotation.h" | 32 #include "ui/gfx/compositor/screen_rotation.h" |
| 32 #include "ui/gfx/interpolated_transform.h" | 33 #include "ui/gfx/interpolated_transform.h" |
| 33 | 34 |
| 34 using std::string; | 35 using std::string; |
| 35 using std::vector; | 36 using std::vector; |
| 36 | 37 |
| 37 namespace aura { | 38 namespace aura { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); | 131 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); |
| 131 scoped_ptr<ui::LayerAnimationSequence> screen_rotation( | 132 scoped_ptr<ui::LayerAnimationSequence> screen_rotation( |
| 132 new ui::LayerAnimationSequence(new ui::ScreenRotation(delta))); | 133 new ui::LayerAnimationSequence(new ui::ScreenRotation(delta))); |
| 133 screen_rotation->AddObserver(desktop); | 134 screen_rotation->AddObserver(desktop); |
| 134 desktop->layer()->GetAnimator()->ScheduleAnimation( | 135 desktop->layer()->GetAnimator()->ScheduleAnimation( |
| 135 screen_rotation.release()); | 136 screen_rotation.release()); |
| 136 return true; | 137 return true; |
| 137 } | 138 } |
| 138 return false; | 139 return false; |
| 139 } | 140 } |
| 141 | |
| 142 bool MaybePrintDebug(Desktop* desktop, KeyEvent* event) { | |
|
Ben Goodger (Google)
2011/11/17 21:03:17
Can you wait until mazda lands his keyboard stuff?
| |
| 143 if ((event->flags() & ui::EF_ALT_DOWN) && | |
| 144 event->key_code() == ui::VKEY_L) { | |
| 145 ui::PrintLayerHierarchy(desktop->layer()); | |
| 146 return true; | |
| 147 } | |
| 148 return false; | |
| 149 } | |
| 140 #endif | 150 #endif |
| 141 | 151 |
| 142 } // namespace | 152 } // namespace |
| 143 | 153 |
| 144 Desktop* Desktop::instance_ = NULL; | 154 Desktop* Desktop::instance_ = NULL; |
| 145 bool Desktop::use_fullscreen_host_window_ = false; | 155 bool Desktop::use_fullscreen_host_window_ = false; |
| 146 | 156 |
| 147 Desktop::Desktop() | 157 Desktop::Desktop() |
| 148 : Window(NULL), | 158 : Window(NULL), |
| 149 host_(aura::DesktopHost::Create(GetInitialHostWindowBounds())), | 159 host_(aura::DesktopHost::Create(GetInitialHostWindowBounds())), |
| 150 ALLOW_THIS_IN_INITIALIZER_LIST( | 160 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 151 stacking_client_(new DefaultStackingClient(this))), | 161 stacking_client_(new DefaultStackingClient(this))), |
| 152 ALLOW_THIS_IN_INITIALIZER_LIST(schedule_paint_factory_(this)), | 162 ALLOW_THIS_IN_INITIALIZER_LIST(schedule_paint_factory_(this)), |
| 153 active_window_(NULL), | 163 active_window_(NULL), |
| 154 mouse_button_flags_(0), | 164 mouse_button_flags_(0), |
| 155 last_cursor_(kCursorNull), | 165 last_cursor_(kCursorNull), |
| 156 in_destructor_(false), | 166 in_destructor_(false), |
| 157 screen_(new ScreenAura), | 167 screen_(new ScreenAura), |
| 158 capture_window_(NULL), | 168 capture_window_(NULL), |
| 159 mouse_pressed_handler_(NULL), | 169 mouse_pressed_handler_(NULL), |
| 160 mouse_moved_handler_(NULL), | 170 mouse_moved_handler_(NULL), |
| 161 focused_window_(NULL), | 171 focused_window_(NULL), |
| 162 touch_event_handler_(NULL) { | 172 touch_event_handler_(NULL) { |
| 163 set_name("RootWindow"); | 173 SetName("RootWindow"); |
| 164 gfx::Screen::SetInstance(screen_); | 174 gfx::Screen::SetInstance(screen_); |
| 165 host_->SetDesktop(this); | 175 host_->SetDesktop(this); |
| 166 last_mouse_location_ = host_->QueryMouseLocation(); | 176 last_mouse_location_ = host_->QueryMouseLocation(); |
| 167 | 177 |
| 168 if (ui::Compositor::compositor_factory()) { | 178 if (ui::Compositor::compositor_factory()) { |
| 169 compositor_ = (*ui::Compositor::compositor_factory())(this); | 179 compositor_ = (*ui::Compositor::compositor_factory())(this); |
| 170 } else { | 180 } else { |
| 171 compositor_ = ui::Compositor::Create(this, host_->GetAcceleratedWidget(), | 181 compositor_ = ui::Compositor::Create(this, host_->GetAcceleratedWidget(), |
| 172 host_->GetSize()); | 182 host_->GetSize()); |
| 173 } | 183 } |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 273 return false; | 283 return false; |
| 274 } | 284 } |
| 275 | 285 |
| 276 bool Desktop::DispatchKeyEvent(KeyEvent* event) { | 286 bool Desktop::DispatchKeyEvent(KeyEvent* event) { |
| 277 #if !defined(NDEBUG) | 287 #if !defined(NDEBUG) |
| 278 // TODO(beng): replace this hack with global keyboard event handlers. | 288 // TODO(beng): replace this hack with global keyboard event handlers. |
| 279 if (event->type() == ui::ET_KEY_PRESSED) { | 289 if (event->type() == ui::ET_KEY_PRESSED) { |
| 280 if (MaybeFullScreen(host_.get(), event) || MaybeRotate(this, event)) | 290 if (MaybeFullScreen(host_.get(), event) || MaybeRotate(this, event)) |
| 281 return true; | 291 return true; |
| 282 } | 292 } |
| 293 | |
| 294 if (event->type() == ui::ET_KEY_RELEASED && MaybePrintDebug(this, event)) | |
| 295 return true; | |
| 283 #endif | 296 #endif |
| 284 | 297 |
| 285 if (focused_window_) { | 298 if (focused_window_) { |
| 286 KeyEvent translated_event(*event); | 299 KeyEvent translated_event(*event); |
| 287 return ProcessKeyEvent(focused_window_, &translated_event); | 300 return ProcessKeyEvent(focused_window_, &translated_event); |
| 288 } | 301 } |
| 289 return false; | 302 return false; |
| 290 } | 303 } |
| 291 | 304 |
| 292 bool Desktop::DispatchTouchEvent(TouchEvent* event) { | 305 bool Desktop::DispatchTouchEvent(TouchEvent* event) { |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 606 base::StringToInt(parts[1], &parsed_height) && parsed_height > 0) { | 619 base::StringToInt(parts[1], &parsed_height) && parsed_height > 0) { |
| 607 bounds.set_size(gfx::Size(parsed_width, parsed_height)); | 620 bounds.set_size(gfx::Size(parsed_width, parsed_height)); |
| 608 } else if (use_fullscreen_host_window_) { | 621 } else if (use_fullscreen_host_window_) { |
| 609 bounds = gfx::Rect(DesktopHost::GetNativeDisplaySize()); | 622 bounds = gfx::Rect(DesktopHost::GetNativeDisplaySize()); |
| 610 } | 623 } |
| 611 | 624 |
| 612 return bounds; | 625 return bounds; |
| 613 } | 626 } |
| 614 | 627 |
| 615 } // namespace aura | 628 } // namespace aura |
| OLD | NEW |