1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "athena/screen/screen_accelerator_handler.h"
7 #include "athena/input/public/accelerator_manager.h"
8 #include "athena/screen/public/screen_manager.h"
9 #include "ui/events/event_constants.h"
10 #include "ui/gfx/display.h"
11 #include "ui/gfx/screen.h"
20 const AcceleratorData accelerator_data
[] = {
21 {TRIGGER_ON_PRESS
, ui::VKEY_F3
,
22 ui::EF_CONTROL_DOWN
| ui::EF_SHIFT_DOWN
,
23 CMD_ROTATE_SCREEN
, AF_NONE
},
26 void HandleRotateScreen() {
27 ScreenManager
* screen_manager
= ScreenManager::Get();
28 gfx::Display::Rotation current_rotation
=
29 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().rotation();
30 if (current_rotation
== gfx::Display::ROTATE_0
)
31 screen_manager
->SetRotation(gfx::Display::ROTATE_90
);
32 else if (current_rotation
== gfx::Display::ROTATE_90
)
33 screen_manager
->SetRotation(gfx::Display::ROTATE_180
);
34 else if (current_rotation
== gfx::Display::ROTATE_180
)
35 screen_manager
->SetRotation(gfx::Display::ROTATE_270
);
36 else if (current_rotation
== gfx::Display::ROTATE_270
)
37 screen_manager
->SetRotation(gfx::Display::ROTATE_0
);
42 ScreenAcceleratorHandler::ScreenAcceleratorHandler() {
43 AcceleratorManager::Get()->RegisterAccelerators(
44 accelerator_data
, arraysize(accelerator_data
), this);
47 ScreenAcceleratorHandler::~ScreenAcceleratorHandler() {
50 bool ScreenAcceleratorHandler::IsCommandEnabled(int command_id
) const {
54 bool ScreenAcceleratorHandler::OnAcceleratorFired(
56 const ui::Accelerator
& accelerator
) {
58 case CMD_ROTATE_SCREEN
: