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

Unified Diff: ash/accelerators/accelerator_commands.cc

Issue 2162193003: Separates out accelerators using non-common types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@accelerators
Patch Set: sim=20 Created 4 years, 5 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/accelerators/accelerator_commands.h ('k') | ash/accelerators/accelerator_commands_aura.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/accelerators/accelerator_commands.cc
diff --git a/ash/accelerators/accelerator_commands.cc b/ash/accelerators/accelerator_commands.cc
index b804d9150aaae5ab68b889a8193b9e7007ca8686..e7100b594eb3bb98e24be0251dee2406044186dd 100644
--- a/ash/accelerators/accelerator_commands.cc
+++ b/ash/accelerators/accelerator_commands.cc
@@ -9,19 +9,13 @@
#include "ash/common/wm/wm_event.h"
#include "ash/common/wm_shell.h"
#include "ash/common/wm_window.h"
-#include "ash/display/display_manager.h"
-#include "ash/display/display_util.h"
-#include "ash/shell.h"
-#include "ash/wm/screen_pinning_controller.h"
-#include "ash/wm/window_state_aura.h"
-#include "ash/wm/window_util.h"
#include "base/metrics/user_metrics.h"
namespace ash {
namespace accelerators {
bool ToggleMinimized() {
- aura::Window* window = wm::GetActiveWindow();
+ WmWindow* window = WmShell::Get()->GetActiveWindow();
// Attempt to restore the window that would be cycled through next from
// the launcher when there is no active window.
if (!window) {
@@ -31,7 +25,7 @@ bool ToggleMinimized() {
mru_windows.front()->GetWindowState()->Activate();
return true;
}
- wm::WindowState* window_state = wm::GetWindowState(window);
+ wm::WindowState* window_state = window->GetWindowState();
if (!window_state->CanMinimize())
return false;
window_state->Minimize();
@@ -39,80 +33,20 @@ bool ToggleMinimized() {
}
void ToggleMaximized() {
- wm::WindowState* window_state = wm::GetActiveWindowState();
- if (!window_state)
+ WmWindow* active_window = WmShell::Get()->GetActiveWindow();
+ if (!active_window)
return;
base::RecordAction(base::UserMetricsAction("Accel_Toggle_Maximized"));
wm::WMEvent event(wm::WM_EVENT_TOGGLE_MAXIMIZE);
- window_state->OnWMEvent(&event);
+ active_window->GetWindowState()->OnWMEvent(&event);
}
void ToggleFullscreen() {
- wm::WindowState* window_state = wm::GetActiveWindowState();
- if (window_state) {
- const wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN);
- window_state->OnWMEvent(&event);
- }
-}
-
-void ToggleTouchHudProjection() {
- base::RecordAction(base::UserMetricsAction("Accel_Touch_Hud_Clear"));
- bool enabled = Shell::GetInstance()->is_touch_hud_projection_enabled();
- Shell::GetInstance()->SetTouchHudProjectionEnabled(!enabled);
-}
-
-bool IsInternalDisplayZoomEnabled() {
- DisplayManager* display_manager = Shell::GetInstance()->display_manager();
- return display_manager->IsDisplayUIScalingEnabled() ||
- display_manager->IsInUnifiedMode();
-}
-
-bool ZoomInternalDisplay(bool up) {
- if (up)
- base::RecordAction(base::UserMetricsAction("Accel_Scale_Ui_Up"));
- else
- base::RecordAction(base::UserMetricsAction("Accel_Scale_Ui_Down"));
-
- DisplayManager* display_manager = Shell::GetInstance()->display_manager();
-
- int64_t display_id = display_manager->IsInUnifiedMode()
- ? DisplayManager::kUnifiedDisplayId
- : display_manager->GetDisplayIdForUIScaling();
- const DisplayInfo& display_info = display_manager->GetDisplayInfo(display_id);
- DisplayMode mode;
-
- if (display_manager->IsInUnifiedMode()) {
- if (!GetDisplayModeForNextResolution(display_info, up, &mode))
- return false;
- } else {
- if (!GetDisplayModeForNextUIScale(display_info, up, &mode))
- return false;
- }
- return display_manager->SetDisplayMode(display_id, mode);
-}
-
-void ResetInternalDisplayZoom() {
- base::RecordAction(base::UserMetricsAction("Accel_Scale_Ui_Reset"));
- DisplayManager* display_manager = Shell::GetInstance()->display_manager();
-
- if (display_manager->IsInUnifiedMode()) {
- const DisplayInfo& display_info =
- display_manager->GetDisplayInfo(DisplayManager::kUnifiedDisplayId);
- const std::vector<DisplayMode>& modes = display_info.display_modes();
- auto iter =
- std::find_if(modes.begin(), modes.end(),
- [](const DisplayMode& mode) { return mode.native; });
- display_manager->SetDisplayMode(DisplayManager::kUnifiedDisplayId, *iter);
- } else {
- SetDisplayUIScale(display_manager->GetDisplayIdForUIScaling(), 1.0f);
- }
-}
-
-void Unpin() {
- WmWindow* pinned_window =
- Shell::GetInstance()->screen_pinning_controller()->pinned_window();
- if (pinned_window)
- pinned_window->GetWindowState()->Restore();
+ WmWindow* active_window = WmShell::Get()->GetActiveWindow();
+ if (!active_window)
+ return;
+ const wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN);
+ active_window->GetWindowState()->OnWMEvent(&event);
}
} // namespace accelerators
« no previous file with comments | « ash/accelerators/accelerator_commands.h ('k') | ash/accelerators/accelerator_commands_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698