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

Side by Side Diff: ash/mus/non_client_frame_controller.cc

Issue 2042903002: Support app window draggable areas in mash. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup. Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/mus/non_client_frame_controller.h" 5 #include "ash/mus/non_client_frame_controller.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "ash/mus/bridge/wm_window_mus.h" 13 #include "ash/mus/bridge/wm_window_mus.h"
14 #include "ash/mus/frame/frame_border_hit_test_controller.h" 14 #include "ash/mus/frame/frame_border_hit_test_controller.h"
15 #include "ash/mus/frame/move_event_handler.h" 15 #include "ash/mus/frame/move_event_handler.h"
16 #include "ash/mus/frame/non_client_frame_view_mash.h" 16 #include "ash/mus/frame/non_client_frame_view_mash.h"
17 #include "ash/mus/property_util.h" 17 #include "ash/mus/property_util.h"
18 #include "ash/mus/shadow.h" 18 #include "ash/mus/shadow.h"
19 #include "base/macros.h" 19 #include "base/macros.h"
20 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
21 #include "components/mus/public/cpp/property_type_converters.h" 21 #include "components/mus/public/cpp/property_type_converters.h"
22 #include "components/mus/public/cpp/window.h" 22 #include "components/mus/public/cpp/window.h"
23 #include "components/mus/public/cpp/window_manager_delegate.h" 23 #include "components/mus/public/cpp/window_manager_delegate.h"
24 #include "components/mus/public/cpp/window_property.h" 24 #include "components/mus/public/cpp/window_property.h"
25 #include "components/mus/public/interfaces/window_manager.mojom.h" 25 #include "components/mus/public/interfaces/window_manager.mojom.h"
26 #include "components/mus/public/interfaces/window_tree_host.mojom.h" 26 #include "components/mus/public/interfaces/window_tree_host.mojom.h"
27 #include "ui/aura/layout_manager.h" 27 #include "ui/aura/layout_manager.h"
28 #include "ui/aura/window.h" 28 #include "ui/aura/window.h"
29 #include "ui/aura/window_tree_host.h" 29 #include "ui/aura/window_tree_host.h"
30 #include "ui/base/hit_test.h"
30 #include "ui/compositor/layer.h" 31 #include "ui/compositor/layer.h"
31 #include "ui/gfx/geometry/vector2d.h" 32 #include "ui/gfx/geometry/vector2d.h"
32 #include "ui/views/mus/native_widget_mus.h" 33 #include "ui/views/mus/native_widget_mus.h"
33 #include "ui/views/widget/widget.h" 34 #include "ui/views/widget/widget.h"
34 35
35 namespace ash { 36 namespace ash {
36 namespace mus { 37 namespace mus {
37 namespace { 38 namespace {
38 39
39 // LayoutManager associated with the window created by WindowTreeHost. Resizes 40 // LayoutManager associated with the window created by WindowTreeHost. Resizes
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 const gfx::Rect& requested_bounds) override { 78 const gfx::Rect& requested_bounds) override {
78 SetChildBoundsDirect(child, requested_bounds); 79 SetChildBoundsDirect(child, requested_bounds);
79 } 80 }
80 81
81 aura::Window* window_; 82 aura::Window* window_;
82 Shadow* shadow_; 83 Shadow* shadow_;
83 84
84 DISALLOW_COPY_AND_ASSIGN(ContentWindowLayoutManager); 85 DISALLOW_COPY_AND_ASSIGN(ContentWindowLayoutManager);
85 }; 86 };
86 87
88 // This class supports draggable regions for windows with non-standard frames.
James Cook 2016/06/14 23:44:56 Nice class comment. optional: Maybe cite an examp
msw 2016/06/15 17:06:40 Done.
89 // It uses empty insets, doesn't paint anything, and hit tests return HTCAPTION.
90 class StubNonClientFrameView : public views::NonClientFrameView {
James Cook 2016/06/14 23:44:56 optional: I wish there was a better name for this.
msw 2016/06/15 17:06:40 Went with EmptyDraggableNonClientFrameView, but I'
James Cook 2016/06/15 23:21:13 SGTM
91 public:
92 StubNonClientFrameView() {}
93 ~StubNonClientFrameView() override {}
94
95 // views::NonClientFrameView:
96 gfx::Rect GetBoundsForClientView() const override { return bounds(); }
97 gfx::Rect GetWindowBoundsForClientBounds(
98 const gfx::Rect& client_bounds) const override {
99 return bounds();
100 }
101 int NonClientHitTest(const gfx::Point& point) override { return HTCAPTION; }
102 void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask) override {}
103 void ResetWindowControls() override {}
104 void UpdateWindowIcon() override {}
105 void UpdateWindowTitle() override {}
106 void SizeConstraintsChanged() override {}
107
108 private:
109 DISALLOW_COPY_AND_ASSIGN(StubNonClientFrameView);
110 };
111
87 class WmNativeWidgetMus : public views::NativeWidgetMus { 112 class WmNativeWidgetMus : public views::NativeWidgetMus {
88 public: 113 public:
89 WmNativeWidgetMus(views::internal::NativeWidgetDelegate* delegate, 114 WmNativeWidgetMus(views::internal::NativeWidgetDelegate* delegate,
90 shell::Connector* connector, 115 shell::Connector* connector,
91 ::mus::Window* window, 116 ::mus::Window* window,
92 ::mus::WindowManagerClient* window_manager_client) 117 ::mus::WindowManagerClient* window_manager_client)
93 : NativeWidgetMus(delegate, 118 : NativeWidgetMus(delegate,
94 connector, 119 connector,
95 window, 120 window,
96 ::mus::mojom::SurfaceType::UNDERLAY), 121 ::mus::mojom::SurfaceType::UNDERLAY),
97 window_manager_client_(window_manager_client) {} 122 window_manager_client_(window_manager_client) {}
98 ~WmNativeWidgetMus() override {} 123 ~WmNativeWidgetMus() override {}
99 124
100 // NativeWidgetMus: 125 // NativeWidgetMus:
101 views::NonClientFrameView* CreateNonClientFrameView() override { 126 views::NonClientFrameView* CreateNonClientFrameView() override {
102 views::Widget* widget =
103 static_cast<views::internal::NativeWidgetPrivate*>(this)->GetWidget();
104 NonClientFrameViewMash* frame_view =
105 new NonClientFrameViewMash(widget, window());
106 move_event_handler_.reset(new MoveEventHandler( 127 move_event_handler_.reset(new MoveEventHandler(
107 window(), window_manager_client_, GetNativeView())); 128 window(), window_manager_client_, GetNativeView()));
108 return frame_view; 129 if (ShouldRemoveStandardFrame(window()))
130 return new StubNonClientFrameView();
131 return new NonClientFrameViewMash(GetWidget(), window());
109 } 132 }
110 void InitNativeWidget(const views::Widget::InitParams& params) override { 133 void InitNativeWidget(const views::Widget::InitParams& params) override {
111 views::NativeWidgetMus::InitNativeWidget(params); 134 views::NativeWidgetMus::InitNativeWidget(params);
112 aura::WindowTreeHost* window_tree_host = GetNativeView()->GetHost(); 135 aura::WindowTreeHost* window_tree_host = GetNativeView()->GetHost();
113 // TODO(sky): shadow should be determined by window type and shadow type. 136 // TODO(sky): shadow should be determined by window type and shadow type.
114 shadow_.reset(new Shadow); 137 shadow_.reset(new Shadow);
115 shadow_->Init(Shadow::STYLE_INACTIVE); 138 shadow_->Init(Shadow::STYLE_INACTIVE);
116 shadow_->Install(window()); 139 shadow_->Install(window());
117 ContentWindowLayoutManager* layout_manager = new ContentWindowLayoutManager( 140 ContentWindowLayoutManager* layout_manager = new ContentWindowLayoutManager(
118 window_tree_host->window(), shadow_.get()); 141 window_tree_host->window(), shadow_.get());
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 } 329 }
307 } 330 }
308 331
309 void NonClientFrameController::OnWindowDestroyed(::mus::Window* window) { 332 void NonClientFrameController::OnWindowDestroyed(::mus::Window* window) {
310 window_->RemoveObserver(this); 333 window_->RemoveObserver(this);
311 window_ = nullptr; 334 window_ = nullptr;
312 } 335 }
313 336
314 } // namespace mus 337 } // namespace mus
315 } // namespace ash 338 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/mus/property_util.h » ('j') | chrome/browser/ui/views/apps/chrome_native_app_window_views_aura_ash.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698