Commit 0021ce28 authored by James Cook's avatar James Cook Committed by Commit Bot

Collapse ash::WindowCycleEventFilter with WindowCycleEventFilterClassic

There's no separate "classic" mode in ash anymore. Collapse the
superclass with its only subclass.

Just cleanup, no functional changes.

Bug: 873266
Test: ash_unittests
Change-Id: I70cdf56a8cb534cc5f5f1385ef5d702d3694b5a5
Reviewed-on: https://chromium-review.googlesource.com/1171821Reviewed-by: default avatarJun Mukai <mukai@chromium.org>
Commit-Queue: James Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#582499}
parent 17e044d3
......@@ -663,7 +663,6 @@ component("ash") {
"wm/window_animations.h",
"wm/window_cycle_controller.h",
"wm/window_cycle_event_filter.h",
"wm/window_cycle_event_filter_classic.h",
"wm/window_cycle_list.h",
"wm/window_dimmer.h",
"wm/window_finder.h",
......@@ -1264,7 +1263,7 @@ component("ash") {
"wm/widget_finder.cc",
"wm/window_animations.cc",
"wm/window_cycle_controller.cc",
"wm/window_cycle_event_filter_classic.cc",
"wm/window_cycle_event_filter.cc",
"wm/window_cycle_list.cc",
"wm/window_dimmer.cc",
"wm/window_finder.cc",
......
......@@ -12,7 +12,7 @@
#include "ash/shell.h"
#include "ash/wm/mru_window_tracker.h"
#include "ash/wm/screen_pinning_controller.h"
#include "ash/wm/window_cycle_event_filter_classic.h"
#include "ash/wm/window_cycle_event_filter.h"
#include "ash/wm/window_cycle_list.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics.h"
......@@ -61,7 +61,7 @@ void WindowCycleController::StartCycling() {
active_window_before_window_cycle_ = GetActiveWindow(window_list);
window_cycle_list_.reset(new WindowCycleList(window_list));
event_filter_ = std::make_unique<WindowCycleEventFilterClassic>();
event_filter_ = std::make_unique<WindowCycleEventFilter>();
cycle_start_time_ = base::Time::Now();
base::RecordAction(base::UserMetricsAction("WindowCycleController_Cycle"));
UMA_HISTOGRAM_COUNTS_100("Ash.WindowCycleController.Items",
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/wm/window_cycle_event_filter_classic.h"
#include "ash/wm/window_cycle_event_filter.h"
#include "ash/accelerators/debug_commands.h"
#include "ash/shell.h"
......@@ -12,7 +12,7 @@
namespace ash {
WindowCycleEventFilterClassic::WindowCycleEventFilterClassic() {
WindowCycleEventFilter::WindowCycleEventFilter() {
Shell::Get()->AddPreTargetHandler(this);
// Handling release of "Alt" must come before other pretarget handlers
// (specifically, the partial screenshot handler). See crbug.com/651939
......@@ -22,12 +22,12 @@ WindowCycleEventFilterClassic::WindowCycleEventFilterClassic() {
ui::EventTarget::Priority::kSystem);
}
WindowCycleEventFilterClassic::~WindowCycleEventFilterClassic() {
WindowCycleEventFilter::~WindowCycleEventFilter() {
Shell::Get()->RemovePreTargetHandler(this);
Shell::Get()->RemovePreTargetHandler(&alt_release_handler_);
}
void WindowCycleEventFilterClassic::OnKeyEvent(ui::KeyEvent* event) {
void WindowCycleEventFilter::OnKeyEvent(ui::KeyEvent* event) {
// Until the alt key is released, all key events except the trigger key press
// (which is handled by the accelerator controller to call Step) are handled
// by this window cycle controller: https://crbug.com/340339.
......@@ -53,7 +53,7 @@ void WindowCycleEventFilterClassic::OnKeyEvent(ui::KeyEvent* event) {
}
}
void WindowCycleEventFilterClassic::OnMouseEvent(ui::MouseEvent* event) {
void WindowCycleEventFilter::OnMouseEvent(ui::MouseEvent* event) {
// Prevent mouse clicks from doing anything while the Alt+Tab UI is active
// <crbug.com/641171> but don't interfere with drag and drop operations
// <crbug.com/660945>.
......@@ -63,12 +63,11 @@ void WindowCycleEventFilterClassic::OnMouseEvent(ui::MouseEvent* event) {
}
}
WindowCycleEventFilterClassic::AltReleaseHandler::AltReleaseHandler() = default;
WindowCycleEventFilter::AltReleaseHandler::AltReleaseHandler() = default;
WindowCycleEventFilterClassic::AltReleaseHandler::~AltReleaseHandler() =
default;
WindowCycleEventFilter::AltReleaseHandler::~AltReleaseHandler() = default;
void WindowCycleEventFilterClassic::AltReleaseHandler::OnKeyEvent(
void WindowCycleEventFilter::AltReleaseHandler::OnKeyEvent(
ui::KeyEvent* event) {
// Views uses VKEY_MENU for both left and right Alt keys.
if (event->key_code() == ui::VKEY_MENU &&
......
......@@ -6,16 +6,46 @@
#define ASH_WM_WINDOW_CYCLE_EVENT_FILTER_H_
#include "ash/ash_export.h"
#include "base/macros.h"
#include "base/timer/timer.h"
#include "ui/events/event_handler.h"
namespace ash {
// Created by WindowCycleController when cycling through windows. Eats all key
// events and stops cycling when the necessary key sequence is encountered.
class ASH_EXPORT WindowCycleEventFilter {
class ASH_EXPORT WindowCycleEventFilter : public ui::EventHandler {
public:
virtual ~WindowCycleEventFilter() {}
WindowCycleEventFilter();
~WindowCycleEventFilter() override;
// Overridden from ui::EventHandler:
void OnKeyEvent(ui::KeyEvent* event) override;
void OnMouseEvent(ui::MouseEvent* event) override;
private:
class AltReleaseHandler : public ui::EventHandler {
public:
AltReleaseHandler();
~AltReleaseHandler() override;
void OnKeyEvent(ui::KeyEvent* event) override;
private:
DISALLOW_COPY_AND_ASSIGN(AltReleaseHandler);
};
// When the user holds Alt+Tab, this timer is used to send repeated
// cycle commands to WindowCycleController. Note this is not accomplished
// by marking the Alt+Tab accelerator as "repeatable" in the accelerator
// table because we wish to control the repeat interval.
base::RepeatingTimer repeat_timer_;
AltReleaseHandler alt_release_handler_;
DISALLOW_COPY_AND_ASSIGN(WindowCycleEventFilter);
};
} // namepsace ash
} // namespace ash
#endif // ASH_WM_WINDOW_CYCLE_EVENT_FILTER_H_
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_WM_WINDOW_CYCLE_EVENT_FILTER_CLASSIC_H_
#define ASH_WM_WINDOW_CYCLE_EVENT_FILTER_CLASSIC_H_
#include "ash/ash_export.h"
#include "ash/wm/window_cycle_event_filter.h"
#include "base/macros.h"
#include "base/timer/timer.h"
#include "ui/events/event_handler.h"
namespace ash {
// TODO(jamescook): Collapse with WindowCycleEventFilter.
// https://crbug.com/866523
class ASH_EXPORT WindowCycleEventFilterClassic : public ui::EventHandler,
public WindowCycleEventFilter {
public:
WindowCycleEventFilterClassic();
~WindowCycleEventFilterClassic() override;
// Overridden from ui::EventHandler:
void OnKeyEvent(ui::KeyEvent* event) override;
void OnMouseEvent(ui::MouseEvent* event) override;
private:
class AltReleaseHandler : public ui::EventHandler {
public:
AltReleaseHandler();
~AltReleaseHandler() override;
void OnKeyEvent(ui::KeyEvent* event) override;
private:
DISALLOW_COPY_AND_ASSIGN(AltReleaseHandler);
};
// When the user holds Alt+Tab, this timer is used to send repeated
// cycle commands to WindowCycleController. Note this is not accomplished
// by marking the Alt+Tab accelerator as "repeatable" in the accelerator
// table because we wish to control the repeat interval.
base::RepeatingTimer repeat_timer_;
AltReleaseHandler alt_release_handler_;
DISALLOW_COPY_AND_ASSIGN(WindowCycleEventFilterClassic);
};
} // namespace ash
#endif // ASH_WM_WINDOW_CYCLE_EVENT_FILTER_CLASSIC_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment