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

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

Issue 8602003: Revert 110637 - Add ShellAcceleratorController that manages global keyboard accelerators. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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_shell/aura_shell.gyp » ('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"
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/layer.h" 28 #include "ui/gfx/compositor/layer.h"
29 #include "ui/gfx/compositor/layer_animation_sequence.h"
29 #include "ui/gfx/compositor/layer_animator.h" 30 #include "ui/gfx/compositor/layer_animator.h"
31 #include "ui/gfx/compositor/screen_rotation.h"
32 #include "ui/gfx/interpolated_transform.h"
30 33
31 using std::string; 34 using std::string;
32 using std::vector; 35 using std::vector;
33 36
34 namespace aura { 37 namespace aura {
35 38
36 namespace { 39 namespace {
37 40
38 // Default bounds for the host window. 41 // Default bounds for the host window.
39 static const int kDefaultHostWindowX = 200; 42 static const int kDefaultHostWindowX = 200;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 88
86 void GetEventFiltersToNotify(Window* target, EventFilters* filters) { 89 void GetEventFiltersToNotify(Window* target, EventFilters* filters) {
87 Window* window = target->parent(); 90 Window* window = target->parent();
88 while (window) { 91 while (window) {
89 if (window->event_filter()) 92 if (window->event_filter())
90 filters->push_back(window->event_filter()); 93 filters->push_back(window->event_filter());
91 window = window->parent(); 94 window = window->parent();
92 } 95 }
93 } 96 }
94 97
98 #if !defined(NDEBUG)
99 bool MaybeFullScreen(DesktopHost* host, KeyEvent* event) {
100 if (event->key_code() == ui::VKEY_F11) {
101 host->ToggleFullScreen();
102 return true;
103 }
104 return false;
105 }
106
107 bool MaybeRotate(Desktop* desktop, KeyEvent* event) {
108 if ((event->flags() & ui::EF_CONTROL_DOWN) &&
109 event->key_code() == ui::VKEY_HOME) {
110 static int i = 0;
111 int delta = 0;
112 switch (i) {
113 case 0: delta = 90; break;
114 case 1: delta = 90; break;
115 case 2: delta = 90; break;
116 case 3: delta = 90; break;
117 case 4: delta = -90; break;
118 case 5: delta = -90; break;
119 case 6: delta = -90; break;
120 case 7: delta = -90; break;
121 case 8: delta = -90; break;
122 case 9: delta = 180; break;
123 case 10: delta = 180; break;
124 case 11: delta = 90; break;
125 case 12: delta = 180; break;
126 case 13: delta = 180; break;
127 }
128 i = (i + 1) % 14;
129 desktop->layer()->GetAnimator()->set_preemption_strategy(
130 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
131 scoped_ptr<ui::LayerAnimationSequence> screen_rotation(
132 new ui::LayerAnimationSequence(new ui::ScreenRotation(delta)));
133 screen_rotation->AddObserver(desktop);
134 desktop->layer()->GetAnimator()->ScheduleAnimation(
135 screen_rotation.release());
136 return true;
137 }
138 return false;
139 }
140 #endif
141
95 } // namespace 142 } // namespace
96 143
97 Desktop* Desktop::instance_ = NULL; 144 Desktop* Desktop::instance_ = NULL;
98 bool Desktop::use_fullscreen_host_window_ = false; 145 bool Desktop::use_fullscreen_host_window_ = false;
99 146
100 Desktop::Desktop() 147 Desktop::Desktop()
101 : Window(NULL), 148 : Window(NULL),
102 host_(aura::DesktopHost::Create(GetInitialHostWindowBounds())), 149 host_(aura::DesktopHost::Create(GetInitialHostWindowBounds())),
103 ALLOW_THIS_IN_INITIALIZER_LIST( 150 ALLOW_THIS_IN_INITIALIZER_LIST(
104 stacking_client_(new DefaultStackingClient(this))), 151 stacking_client_(new DefaultStackingClient(this))),
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 Window::ConvertPointToWindow(this, target, &location_in_window); 267 Window::ConvertPointToWindow(this, target, &location_in_window);
221 if (IsNonClientLocation(target, location_in_window)) 268 if (IsNonClientLocation(target, location_in_window))
222 flags |= ui::EF_IS_NON_CLIENT; 269 flags |= ui::EF_IS_NON_CLIENT;
223 MouseEvent translated_event(*event, this, target, event->type(), flags); 270 MouseEvent translated_event(*event, this, target, event->type(), flags);
224 return ProcessMouseEvent(target, &translated_event); 271 return ProcessMouseEvent(target, &translated_event);
225 } 272 }
226 return false; 273 return false;
227 } 274 }
228 275
229 bool Desktop::DispatchKeyEvent(KeyEvent* event) { 276 bool Desktop::DispatchKeyEvent(KeyEvent* event) {
277 #if !defined(NDEBUG)
278 // TODO(beng): replace this hack with global keyboard event handlers.
279 if (event->type() == ui::ET_KEY_PRESSED) {
280 if (MaybeFullScreen(host_.get(), event) || MaybeRotate(this, event))
281 return true;
282 }
283 #endif
284
230 if (focused_window_) { 285 if (focused_window_) {
231 KeyEvent translated_event(*event); 286 KeyEvent translated_event(*event);
232 return ProcessKeyEvent(focused_window_, &translated_event); 287 return ProcessKeyEvent(focused_window_, &translated_event);
233 } 288 }
234 return false; 289 return false;
235 } 290 }
236 291
237 bool Desktop::DispatchTouchEvent(TouchEvent* event) { 292 bool Desktop::DispatchTouchEvent(TouchEvent* event) {
238 event->UpdateForTransform(layer()->transform()); 293 event->UpdateForTransform(layer()->transform());
239 bool handled = false; 294 bool handled = false;
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 444
390 void Desktop::SetTransform(const ui::Transform& transform) { 445 void Desktop::SetTransform(const ui::Transform& transform) {
391 Window::SetTransform(transform); 446 Window::SetTransform(transform);
392 447
393 // If the layer is not animating, then we need to update the host size 448 // If the layer is not animating, then we need to update the host size
394 // immediately. 449 // immediately.
395 if (!layer()->GetAnimator()->is_animating()) 450 if (!layer()->GetAnimator()->is_animating())
396 OnHostResized(host_->GetSize()); 451 OnHostResized(host_->GetSize());
397 } 452 }
398 453
399 #if !defined(NDEBUG)
400 void Desktop::ToggleFullScreen() {
401 host_->ToggleFullScreen();
402 }
403 #endif
404
405 void Desktop::HandleMouseMoved(const MouseEvent& event, Window* target) { 454 void Desktop::HandleMouseMoved(const MouseEvent& event, Window* target) {
406 if (target == mouse_moved_handler_) 455 if (target == mouse_moved_handler_)
407 return; 456 return;
408 457
409 // Send an exited event. 458 // Send an exited event.
410 if (mouse_moved_handler_ && mouse_moved_handler_->delegate()) { 459 if (mouse_moved_handler_ && mouse_moved_handler_->delegate()) {
411 MouseEvent translated_event(event, this, mouse_moved_handler_, 460 MouseEvent translated_event(event, this, mouse_moved_handler_,
412 ui::ET_MOUSE_EXITED, event.flags()); 461 ui::ET_MOUSE_EXITED, event.flags());
413 ProcessMouseEvent(mouse_moved_handler_, &translated_event); 462 ProcessMouseEvent(mouse_moved_handler_, &translated_event);
414 } 463 }
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 base::StringToInt(parts[1], &parsed_height) && parsed_height > 0) { 610 base::StringToInt(parts[1], &parsed_height) && parsed_height > 0) {
562 bounds.set_size(gfx::Size(parsed_width, parsed_height)); 611 bounds.set_size(gfx::Size(parsed_width, parsed_height));
563 } else if (use_fullscreen_host_window_) { 612 } else if (use_fullscreen_host_window_) {
564 bounds = gfx::Rect(DesktopHost::GetNativeDisplaySize()); 613 bounds = gfx::Rect(DesktopHost::GetNativeDisplaySize());
565 } 614 }
566 615
567 return bounds; 616 return bounds;
568 } 617 }
569 618
570 } // namespace aura 619 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/desktop.h ('k') | ui/aura_shell/aura_shell.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698