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

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

Issue 8465021: Add ShellAcceleratorController that managers global keyboard accelerators. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Move AcceleratorPressed to Shell from Desktop 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
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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 88
89 void GetEventFiltersToNotify(Window* target, EventFilters* filters) { 89 void GetEventFiltersToNotify(Window* target, EventFilters* filters) {
90 Window* window = target->parent(); 90 Window* window = target->parent();
91 while (window) { 91 while (window) {
92 if (window->event_filter()) 92 if (window->event_filter())
93 filters->push_back(window->event_filter()); 93 filters->push_back(window->event_filter());
94 window = window->parent(); 94 window = window->parent();
95 } 95 }
96 } 96 }
97 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
142 } // namespace 98 } // namespace
143 99
144 Desktop* Desktop::instance_ = NULL; 100 Desktop* Desktop::instance_ = NULL;
145 bool Desktop::use_fullscreen_host_window_ = false; 101 bool Desktop::use_fullscreen_host_window_ = false;
146 102
147 Desktop::Desktop() 103 Desktop::Desktop()
148 : Window(NULL), 104 : Window(NULL),
149 host_(aura::DesktopHost::Create(GetInitialHostWindowBounds())), 105 host_(aura::DesktopHost::Create(GetInitialHostWindowBounds())),
150 ALLOW_THIS_IN_INITIALIZER_LIST( 106 ALLOW_THIS_IN_INITIALIZER_LIST(
151 stacking_client_(new DefaultStackingClient(this))), 107 stacking_client_(new DefaultStackingClient(this))),
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 Window::ConvertPointToWindow(this, target, &location_in_window); 223 Window::ConvertPointToWindow(this, target, &location_in_window);
268 if (IsNonClientLocation(target, location_in_window)) 224 if (IsNonClientLocation(target, location_in_window))
269 flags |= ui::EF_IS_NON_CLIENT; 225 flags |= ui::EF_IS_NON_CLIENT;
270 MouseEvent translated_event(*event, this, target, event->type(), flags); 226 MouseEvent translated_event(*event, this, target, event->type(), flags);
271 return ProcessMouseEvent(target, &translated_event); 227 return ProcessMouseEvent(target, &translated_event);
272 } 228 }
273 return false; 229 return false;
274 } 230 }
275 231
276 bool Desktop::DispatchKeyEvent(KeyEvent* event) { 232 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
285 if (focused_window_) { 233 if (focused_window_) {
286 KeyEvent translated_event(*event); 234 KeyEvent translated_event(*event);
287 return ProcessKeyEvent(focused_window_, &translated_event); 235 return ProcessKeyEvent(focused_window_, &translated_event);
288 } 236 }
289 return false; 237 return false;
290 } 238 }
291 239
292 bool Desktop::DispatchTouchEvent(TouchEvent* event) { 240 bool Desktop::DispatchTouchEvent(TouchEvent* event) {
293 event->UpdateForTransform(layer()->transform()); 241 event->UpdateForTransform(layer()->transform());
294 bool handled = false; 242 bool handled = false;
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 388
441 void Desktop::SetTransform(const ui::Transform& transform) { 389 void Desktop::SetTransform(const ui::Transform& transform) {
442 Window::SetTransform(transform); 390 Window::SetTransform(transform);
443 391
444 // If the layer is not animating, then we need to update the host size 392 // If the layer is not animating, then we need to update the host size
445 // immediately. 393 // immediately.
446 if (!layer()->GetAnimator()->is_animating()) 394 if (!layer()->GetAnimator()->is_animating())
447 OnHostResized(host_->GetSize()); 395 OnHostResized(host_->GetSize());
448 } 396 }
449 397
398 #if !defined(NDEBUG)
399 void Desktop::ToggleFullScreen() {
400 host_->ToggleFullScreen();
401 }
402
403 void Desktop::Rotate() {
404 static int i = 0;
405 int delta = 0;
406 switch (i) {
407 case 0: delta = 90; break;
408 case 1: delta = 90; break;
409 case 2: delta = 90; break;
410 case 3: delta = 90; break;
411 case 4: delta = -90; break;
412 case 5: delta = -90; break;
413 case 6: delta = -90; break;
414 case 7: delta = -90; break;
415 case 8: delta = -90; break;
416 case 9: delta = 180; break;
417 case 10: delta = 180; break;
418 case 11: delta = 90; break;
419 case 12: delta = 180; break;
420 case 13: delta = 180; break;
421 }
422 i = (i + 1) % 14;
423 layer()->GetAnimator()->set_preemption_strategy(
424 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
425 scoped_ptr<ui::LayerAnimationSequence> screen_rotation(
426 new ui::LayerAnimationSequence(new ui::ScreenRotation(delta)));
427 screen_rotation->AddObserver(this);
428 layer()->GetAnimator()->ScheduleAnimation(screen_rotation.release());
429 }
430 #endif
431
450 void Desktop::HandleMouseMoved(const MouseEvent& event, Window* target) { 432 void Desktop::HandleMouseMoved(const MouseEvent& event, Window* target) {
451 if (target == mouse_moved_handler_) 433 if (target == mouse_moved_handler_)
452 return; 434 return;
453 435
454 // Send an exited event. 436 // Send an exited event.
455 if (mouse_moved_handler_ && mouse_moved_handler_->delegate()) { 437 if (mouse_moved_handler_ && mouse_moved_handler_->delegate()) {
456 MouseEvent translated_event(event, this, mouse_moved_handler_, 438 MouseEvent translated_event(event, this, mouse_moved_handler_,
457 ui::ET_MOUSE_EXITED, event.flags()); 439 ui::ET_MOUSE_EXITED, event.flags());
458 ProcessMouseEvent(mouse_moved_handler_, &translated_event); 440 ProcessMouseEvent(mouse_moved_handler_, &translated_event);
459 } 441 }
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 base::StringToInt(parts[1], &parsed_height) && parsed_height > 0) { 588 base::StringToInt(parts[1], &parsed_height) && parsed_height > 0) {
607 bounds.set_size(gfx::Size(parsed_width, parsed_height)); 589 bounds.set_size(gfx::Size(parsed_width, parsed_height));
608 } else if (use_fullscreen_host_window_) { 590 } else if (use_fullscreen_host_window_) {
609 bounds = gfx::Rect(DesktopHost::GetNativeDisplaySize()); 591 bounds = gfx::Rect(DesktopHost::GetNativeDisplaySize());
610 } 592 }
611 593
612 return bounds; 594 return bounds;
613 } 595 }
614 596
615 } // namespace aura 597 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/desktop.h ('k') | ui/aura_shell/aura_shell.gyp » ('j') | ui/aura_shell/shell.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698