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

Unified Diff: mojo/examples/wm_flow/wm/frame_controller.cc

Issue 599213002: First cut at supporting activation in the window manager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: / Created 6 years, 3 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 | « mojo/examples/wm_flow/wm/frame_controller.h ('k') | mojo/examples/wm_flow/wm/wm.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/examples/wm_flow/wm/frame_controller.cc
diff --git a/mojo/examples/wm_flow/wm/frame_controller.cc b/mojo/examples/wm_flow/wm/frame_controller.cc
index 381dc0243e64295997115986c7ca65d6295d075f..f8d8b495a6cc78d31f7fa807b9a3039175bf00d9 100644
--- a/mojo/examples/wm_flow/wm/frame_controller.cc
+++ b/mojo/examples/wm_flow/wm/frame_controller.cc
@@ -6,11 +6,13 @@
#include "base/strings/utf_string_conversions.h"
#include "mojo/services/public/cpp/view_manager/view.h"
+#include "mojo/services/window_manager/window_manager_app.h"
#include "mojo/views/native_widget_view_manager.h"
#include "ui/views/background.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/layout/layout_manager.h"
#include "ui/views/widget/widget.h"
+#include "ui/wm/public/activation_client.h"
class FrameController::LayoutManager : public views::LayoutManager,
public views::ButtonListener {
@@ -69,22 +71,49 @@ class FrameController::LayoutManager : public views::LayoutManager,
DISALLOW_COPY_AND_ASSIGN(LayoutManager);
};
+class FrameController::FrameEventHandler : public ui::EventHandler {
+ public:
+ explicit FrameEventHandler(FrameController* frame_controller)
+ : frame_controller_(frame_controller) {}
+ virtual ~FrameEventHandler() {}
+
+ private:
+
+ // Overriden from ui::EventHandler:
+ virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE {
+ if (event->type() == ui::ET_MOUSE_PRESSED)
+ frame_controller_->ActivateWindow();
+ }
+
+ FrameController* frame_controller_;
+
+ DISALLOW_COPY_AND_ASSIGN(FrameEventHandler);
+};
+
////////////////////////////////////////////////////////////////////////////////
// FrameController, public:
-FrameController::FrameController(mojo::View* view, mojo::View** app_view)
+FrameController::FrameController(
+ mojo::View* view,
+ mojo::View** app_view,
+ aura::client::ActivationClient* activation_client,
+ mojo::WindowManagerApp* window_manager_app)
: view_(view),
app_view_(mojo::View::Create(view->view_manager())),
frame_view_(new views::View),
frame_view_layout_manager_(new LayoutManager(this)),
widget_(new views::Widget),
- maximized_(false) {
+ maximized_(false),
+ activation_client_(activation_client),
+ window_manager_app_(window_manager_app) {
view_->AddChild(app_view_);
view_->AddObserver(this);
*app_view = app_view_;
frame_view_->set_background(
views::Background::CreateSolidBackground(SK_ColorBLUE));
frame_view_->SetLayoutManager(frame_view_layout_manager_);
+ frame_event_handler_.reset(new FrameEventHandler(this));
+ frame_view_->AddPreTargetHandler(frame_event_handler_.get());
views::Widget::InitParams params(
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
params.native_widget = new mojo::NativeWidgetViewManager(widget_, view_);
@@ -111,6 +140,11 @@ void FrameController::ToggleMaximize() {
view_->SetBounds(restored_bounds_);
}
+void FrameController::ActivateWindow() {
+ aura::Window* window = window_manager_app_->GetWindowForViewId(view_->id());
+ activation_client_->ActivateWindow(window);
+}
+
////////////////////////////////////////////////////////////////////////////////
// FrameController, mojo::ViewObserver implementation:
« no previous file with comments | « mojo/examples/wm_flow/wm/frame_controller.h ('k') | mojo/examples/wm_flow/wm/wm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698