OLD | NEW |
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 "mash/wm/frame/non_client_frame_view_mash.h" | 5 #include "mash/wm/frame/non_client_frame_view_mash.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <memory> | 8 #include <memory> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "components/mus/public/cpp/window.h" | 12 #include "components/mus/public/cpp/window.h" |
13 #include "components/mus/public/cpp/window_tree_connection.h" | 13 #include "components/mus/public/cpp/window_tree_client.h" |
14 #include "grit/mash_wm_resources.h" | 14 #include "grit/mash_wm_resources.h" |
15 #include "mash/wm/frame/caption_buttons/frame_caption_button_container_view.h" | 15 #include "mash/wm/frame/caption_buttons/frame_caption_button_container_view.h" |
16 #include "mash/wm/frame/default_header_painter.h" | 16 #include "mash/wm/frame/default_header_painter.h" |
17 #include "mash/wm/frame/frame_border_hit_test_controller.h" | 17 #include "mash/wm/frame/frame_border_hit_test_controller.h" |
18 #include "mash/wm/frame/header_painter.h" | 18 #include "mash/wm/frame/header_painter.h" |
19 #include "ui/base/resource/resource_bundle.h" | 19 #include "ui/base/resource/resource_bundle.h" |
20 #include "ui/compositor/paint_recorder.h" | 20 #include "ui/compositor/paint_recorder.h" |
21 #include "ui/events/mojo/input_events_type_converters.h" | 21 #include "ui/events/mojo/input_events_type_converters.h" |
22 #include "ui/gfx/canvas.h" | 22 #include "ui/gfx/canvas.h" |
23 #include "ui/gfx/geometry/rect.h" | 23 #include "ui/gfx/geometry/rect.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 } | 125 } |
126 | 126 |
127 /////////////////////////////////////////////////////////////////////////////// | 127 /////////////////////////////////////////////////////////////////////////////// |
128 // NonClientFrameViewMash::HeaderView, views::View overrides: | 128 // NonClientFrameViewMash::HeaderView, views::View overrides: |
129 | 129 |
130 void NonClientFrameViewMash::HeaderView::Layout() { | 130 void NonClientFrameViewMash::HeaderView::Layout() { |
131 header_painter_->LayoutHeader(); | 131 header_painter_->LayoutHeader(); |
132 } | 132 } |
133 | 133 |
134 void NonClientFrameViewMash::HeaderView::OnPaint(gfx::Canvas* canvas) { | 134 void NonClientFrameViewMash::HeaderView::OnPaint(gfx::Canvas* canvas) { |
135 const mus::Window* focused_window = window_->connection()->GetFocusedWindow(); | 135 const mus::Window* focused_window = |
| 136 window_->window_tree()->GetFocusedWindow(); |
136 const bool paint_as_active = | 137 const bool paint_as_active = |
137 focused_window && window_->Contains(focused_window); | 138 focused_window && window_->Contains(focused_window); |
138 caption_button_container_->SetPaintAsActive(paint_as_active); | 139 caption_button_container_->SetPaintAsActive(paint_as_active); |
139 | 140 |
140 HeaderPainter::Mode header_mode = paint_as_active | 141 HeaderPainter::Mode header_mode = paint_as_active |
141 ? HeaderPainter::MODE_ACTIVE | 142 ? HeaderPainter::MODE_ACTIVE |
142 : HeaderPainter::MODE_INACTIVE; | 143 : HeaderPainter::MODE_INACTIVE; |
143 header_painter_->PaintHeader(canvas, header_mode); | 144 header_painter_->PaintHeader(canvas, header_mode); |
144 } | 145 } |
145 | 146 |
(...skipping 16 matching lines...) Expand all Loading... |
162 | 163 |
163 NonClientFrameViewMash::NonClientFrameViewMash(views::Widget* frame, | 164 NonClientFrameViewMash::NonClientFrameViewMash(views::Widget* frame, |
164 mus::Window* window) | 165 mus::Window* window) |
165 : frame_(frame), | 166 : frame_(frame), |
166 window_(window), | 167 window_(window), |
167 header_view_(new HeaderView(frame, window)) { | 168 header_view_(new HeaderView(frame, window)) { |
168 // |header_view_| is set as the non client view's overlay view so that it can | 169 // |header_view_| is set as the non client view's overlay view so that it can |
169 // overlay the web contents in immersive fullscreen. | 170 // overlay the web contents in immersive fullscreen. |
170 AddChildView(header_view_); | 171 AddChildView(header_view_); |
171 window_->AddObserver(this); | 172 window_->AddObserver(this); |
172 window_->connection()->AddObserver(this); | 173 window_->window_tree()->AddObserver(this); |
173 } | 174 } |
174 | 175 |
175 NonClientFrameViewMash::~NonClientFrameViewMash() { | 176 NonClientFrameViewMash::~NonClientFrameViewMash() { |
176 RemoveObservers(); | 177 RemoveObservers(); |
177 } | 178 } |
178 | 179 |
179 // static | 180 // static |
180 gfx::Insets NonClientFrameViewMash::GetPreferredClientAreaInsets() { | 181 gfx::Insets NonClientFrameViewMash::GetPreferredClientAreaInsets() { |
181 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 182 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
182 const int header_height = | 183 const int header_height = |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 | 347 |
347 int NonClientFrameViewMash::NonClientTopBorderHeight() const { | 348 int NonClientFrameViewMash::NonClientTopBorderHeight() const { |
348 return header_view_->GetPreferredHeight(); | 349 return header_view_->GetPreferredHeight(); |
349 } | 350 } |
350 | 351 |
351 void NonClientFrameViewMash::RemoveObservers() { | 352 void NonClientFrameViewMash::RemoveObservers() { |
352 if (!window_) | 353 if (!window_) |
353 return; | 354 return; |
354 | 355 |
355 window_->RemoveObserver(this); | 356 window_->RemoveObserver(this); |
356 window_->connection()->RemoveObserver(this); | 357 window_->window_tree()->RemoveObserver(this); |
357 window_ = nullptr; | 358 window_ = nullptr; |
358 } | 359 } |
359 | 360 |
360 void NonClientFrameViewMash::OnWindowTreeFocusChanged(mus::Window* gained_focus, | 361 void NonClientFrameViewMash::OnWindowTreeFocusChanged(mus::Window* gained_focus, |
361 mus::Window* lost_focus) { | 362 mus::Window* lost_focus) { |
362 const bool had_focus = lost_focus && window_->Contains(lost_focus); | 363 const bool had_focus = lost_focus && window_->Contains(lost_focus); |
363 const bool has_focus = gained_focus && window_->Contains(gained_focus); | 364 const bool has_focus = gained_focus && window_->Contains(gained_focus); |
364 if (had_focus != has_focus) | 365 if (had_focus != has_focus) |
365 SchedulePaint(); | 366 SchedulePaint(); |
366 } | 367 } |
367 | 368 |
368 } // namespace wm | 369 } // namespace wm |
369 } // namespace mash | 370 } // namespace mash |
OLD | NEW |