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

Unified Diff: ash/common/shelf/wm_shelf.cc

Issue 2626483002: Removes WmShelfAura and WmShelfMus (Closed)
Patch Set: merge Created 3 years, 11 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/common/shelf/wm_shelf.h ('k') | ash/mus/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/shelf/wm_shelf.cc
diff --git a/ash/common/shelf/wm_shelf.cc b/ash/common/shelf/wm_shelf.cc
index a86a9915a3f02315610627c1a69a46971b185e69..191d11e734d953b7d578ddf2fe5d911590fa0ace 100644
--- a/ash/common/shelf/wm_shelf.cc
+++ b/ash/common/shelf/wm_shelf.cc
@@ -4,6 +4,7 @@
#include "ash/common/shelf/wm_shelf.h"
+#include "ash/aura/wm_window_aura.h"
#include "ash/common/shelf/shelf_controller.h"
#include "ash/common/shelf/shelf_delegate.h"
#include "ash/common/shelf/shelf_item_delegate.h"
@@ -18,11 +19,50 @@
#include "ash/common/wm_shell.h"
#include "ash/common/wm_window.h"
#include "ash/public/cpp/shell_window_ids.h"
+#include "ash/shelf/shelf_bezel_event_handler.h"
+#include "ash/shell.h"
#include "base/logging.h"
+#include "base/memory/ptr_util.h"
+#include "ui/aura/env.h"
#include "ui/gfx/geometry/rect.h"
namespace ash {
+// WmShelf::AutoHideEventHandler -----------------------------------------------
+
+// Forwards mouse and gesture events to ShelfLayoutManager for auto-hide.
+// TODO(mash): Add similar event handling support for mash.
+class WmShelf::AutoHideEventHandler : public ui::EventHandler {
+ public:
+ explicit AutoHideEventHandler(ShelfLayoutManager* shelf_layout_manager)
+ : shelf_layout_manager_(shelf_layout_manager) {
+ Shell::GetInstance()->AddPreTargetHandler(this);
+ }
+ ~AutoHideEventHandler() override {
+ Shell::GetInstance()->RemovePreTargetHandler(this);
+ }
+
+ // Overridden from ui::EventHandler:
+ void OnMouseEvent(ui::MouseEvent* event) override {
+ shelf_layout_manager_->UpdateAutoHideForMouseEvent(
+ event, WmWindowAura::Get(static_cast<aura::Window*>(event->target())));
+ }
+ void OnGestureEvent(ui::GestureEvent* event) override {
+ shelf_layout_manager_->UpdateAutoHideForGestureEvent(
+ event, WmWindowAura::Get(static_cast<aura::Window*>(event->target())));
+ }
+
+ private:
+ ShelfLayoutManager* shelf_layout_manager_;
+ DISALLOW_COPY_AND_ASSIGN(AutoHideEventHandler);
+};
+
+// WmShelf ---------------------------------------------------------------------
+
+WmShelf::WmShelf() : time_last_auto_hide_change_(base::TimeTicks::Now()) {}
+
+WmShelf::~WmShelf() {}
+
// static
WmShelf* WmShelf::ForWindow(WmWindow* window) {
return window->GetRootWindowController()->GetShelf();
@@ -72,6 +112,11 @@ void WmShelf::CreateShelfWidget(WmWindow* root) {
WmWindow* status_container =
root->GetChildByShellWindowId(kShellWindowId_StatusContainer);
shelf_widget_->CreateStatusAreaWidget(status_container);
+
+ // TODO: ShelfBezelEventHandler needs to work with mus too.
+ // http://crbug.com/636647
+ if (aura::Env::GetInstance()->mode() == aura::Env::Mode::LOCAL)
+ bezel_event_handler_ = base::MakeUnique<ShelfBezelEventHandler>(this);
}
void WmShelf::ShutdownShelfWidget() {
@@ -309,11 +354,16 @@ ShelfView* WmShelf::GetShelfViewForTesting() {
return shelf_view_;
}
-WmShelf::WmShelf() : time_last_auto_hide_change_(base::TimeTicks::Now()) {}
+void WmShelf::WillDeleteShelfLayoutManager() {
+ if (aura::Env::GetInstance()->mode() == aura::Env::Mode::MUS) {
+ // TODO(sky): this should be removed once Shell is used everywhere.
+ ShutdownShelfWidget();
+ }
-WmShelf::~WmShelf() {}
+ // Clear event handlers that might forward events to the destroyed instance.
+ auto_hide_event_handler_.reset();
+ bezel_event_handler_.reset();
-void WmShelf::WillDeleteShelfLayoutManager() {
DCHECK(shelf_layout_manager_);
shelf_layout_manager_->RemoveObserver(this);
shelf_layout_manager_ = nullptr;
@@ -322,6 +372,13 @@ void WmShelf::WillDeleteShelfLayoutManager() {
void WmShelf::WillChangeVisibilityState(ShelfVisibilityState new_state) {
for (auto& observer : observers_)
observer.WillChangeVisibilityState(new_state);
+ if (new_state != SHELF_AUTO_HIDE) {
+ auto_hide_event_handler_.reset();
+ } else if (!auto_hide_event_handler_ &&
+ aura::Env::GetInstance()->mode() == aura::Env::Mode::LOCAL) {
+ auto_hide_event_handler_ =
+ base::MakeUnique<AutoHideEventHandler>(shelf_layout_manager());
+ }
}
void WmShelf::OnAutoHideStateChanged(ShelfAutoHideState new_state) {
« no previous file with comments | « ash/common/shelf/wm_shelf.h ('k') | ash/mus/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698