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

Unified Diff: components/exo/wm_helper_mus.cc

Issue 2264503003: exo: WMHelperMus: Hook up event handlers for mus+ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove changes in pointer.cc Created 4 years, 4 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 | « components/exo/wm_helper_mus.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/exo/wm_helper_mus.cc
diff --git a/components/exo/wm_helper_mus.cc b/components/exo/wm_helper_mus.cc
index 46400317b5ee934f4ded13a4e589dcac927debbd..068baf569c4c8b1dd42ec7f96687bc041b0d9b51 100644
--- a/components/exo/wm_helper_mus.cc
+++ b/components/exo/wm_helper_mus.cc
@@ -7,6 +7,8 @@
#include "ash/common/display/display_info.h"
#include "services/ui/public/cpp/window_tree_client.h"
#include "ui/aura/client/focus_client.h"
+#include "ui/aura/env.h"
+#include "ui/aura/window.h"
#include "ui/views/mus/native_widget_mus.h"
#include "ui/views/mus/window_manager_connection.h"
#include "ui/views/widget/widget.h"
@@ -27,24 +29,53 @@ aura::Window* GetToplevelAuraWindow(ui::Window* window) {
} // namespace
////////////////////////////////////////////////////////////////////////////////
+// WMHelperMus::EventForwarder:
+
+class WMHelperMus::EventForwarder : public ui::EventHandler {
+ public:
+ explicit EventForwarder(ui::EventHandlerList* event_handlers)
+ : event_handlers_(event_handlers) {}
+ ~EventForwarder() override {}
+
+ // Overriden from ui::EventHandler:
+ void OnEvent(ui::Event* event) override;
+
+ private:
+ const ui::EventHandlerList* event_handlers_;
+
+ DISALLOW_COPY_AND_ASSIGN(EventForwarder);
+};
+
+void WMHelperMus::EventForwarder::OnEvent(ui::Event* event) {
+ for (ui::EventHandler* handler : *event_handlers_) {
+ if (event->stopped_propagation())
+ break;
+ handler->OnEvent(event);
+ }
+}
+////////////////////////////////////////////////////////////////////////////////
// WMHelperMus, public:
WMHelperMus::WMHelperMus()
- : active_window_(WMHelperMus::GetActiveWindow()),
+ : pre_target_event_forwarder_(new EventForwarder(&pre_target_list_)),
+ post_target_event_forwarder_(new EventForwarder(&post_target_list_)),
+ active_window_(WMHelperMus::GetActiveWindow()),
focused_window_(WMHelperMus::GetFocusedWindow()) {
views::WindowManagerConnection::Get()->client()->AddObserver(this);
+ aura::Env::GetInstance()->AddObserver(this);
}
WMHelperMus::~WMHelperMus() {
views::WindowManagerConnection::Get()->client()->RemoveObserver(this);
+ aura::Env::GetInstance()->RemoveObserver(this);
}
////////////////////////////////////////////////////////////////////////////////
// WMHelperMus, private:
const ash::DisplayInfo WMHelperMus::GetDisplayInfo(int64_t display_id) const {
- NOTIMPLEMENTED();
- return ash::DisplayInfo();
+ // TODO(penghuang): Return real display info when it is supported in mus.
+ return ash::DisplayInfo(display_id, "", false);
}
aura::Window* WMHelperMus::GetContainer(int container_id) {
@@ -73,23 +104,29 @@ ui::CursorSetType WMHelperMus::GetCursorSet() const {
}
void WMHelperMus::AddPreTargetHandler(ui::EventHandler* handler) {
- NOTIMPLEMENTED();
+ pre_target_list_.push_back(handler);
}
void WMHelperMus::PrependPreTargetHandler(ui::EventHandler* handler) {
- NOTIMPLEMENTED();
+ pre_target_list_.insert(pre_target_list_.begin(), handler);
}
void WMHelperMus::RemovePreTargetHandler(ui::EventHandler* handler) {
- NOTIMPLEMENTED();
+ auto it =
+ std::find(pre_target_list_.begin(), pre_target_list_.end(), handler);
+ if (it != pre_target_list_.end())
+ pre_target_list_.erase(it);
}
void WMHelperMus::AddPostTargetHandler(ui::EventHandler* handler) {
- NOTIMPLEMENTED();
+ post_target_list_.push_back(handler);
}
void WMHelperMus::RemovePostTargetHandler(ui::EventHandler* handler) {
- NOTIMPLEMENTED();
+ auto it =
+ std::find(post_target_list_.begin(), post_target_list_.end(), handler);
+ if (it != post_target_list_.end())
+ post_target_list_.erase(it);
}
bool WMHelperMus::IsMaximizeModeWindowManagerEnabled() const {
@@ -97,6 +134,12 @@ bool WMHelperMus::IsMaximizeModeWindowManagerEnabled() const {
return false;
}
+void WMHelperMus::OnHostInitialized(aura::WindowTreeHost* host) {
+ aura::Window* root_window = host->window();
+ root_window->AddPreTargetHandler(pre_target_event_forwarder_.get());
+ root_window->AddPostTargetHandler(post_target_event_forwarder_.get());
+}
+
void WMHelperMus::OnWindowTreeFocusChanged(ui::Window* gained_focus,
ui::Window* lost_focus) {
aura::Window* gained_active =
« no previous file with comments | « components/exo/wm_helper_mus.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698