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

Side by Side Diff: ui/aura_shell/toplevel_layout_manager.cc

Issue 9035001: Move some more WM functionality down into ash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 12 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/aura_shell/toplevel_layout_manager.h"
6
7 #include "ui/aura/client/aura_constants.h"
8 #include "ui/aura/window.h"
9 #include "ui/aura_shell/shelf_layout_manager.h"
10 #include "ui/aura_shell/window_util.h"
11 #include "ui/base/ui_base_types.h"
12 #include "ui/gfx/screen.h"
13
14 namespace aura_shell {
15 namespace internal {
16
17 ToplevelLayoutManager::ToplevelLayoutManager() : shelf_(NULL) {
18 }
19
20 ToplevelLayoutManager::~ToplevelLayoutManager() {
21 for (Windows::const_iterator i = windows_.begin(); i != windows_.end(); ++i)
22 (*i)->RemoveObserver(this);
23 }
24
25 void ToplevelLayoutManager::OnWindowResized() {
26 }
27
28 void ToplevelLayoutManager::OnWindowAddedToLayout(aura::Window* child) {
29 windows_.insert(child);
30 child->AddObserver(this);
31 if (child->GetProperty(aura::client::kShowStateKey)) {
32 UpdateBoundsFromShowState(child);
33 UpdateShelfVisibility();
34 }
35 }
36
37 void ToplevelLayoutManager::OnWillRemoveWindowFromLayout(
38 aura::Window* child) {
39 windows_.erase(child);
40 child->RemoveObserver(this);
41 UpdateShelfVisibility();
42 }
43
44 void ToplevelLayoutManager::OnChildWindowVisibilityChanged(aura::Window* child,
45 bool visibile) {
46 UpdateShelfVisibility();
47 }
48
49 void ToplevelLayoutManager::SetChildBounds(aura::Window* child,
50 const gfx::Rect& requested_bounds) {
51 const static int kTitleHeight = 12;
52 gfx::Rect child_bounds(requested_bounds);
53 gfx::Rect work_area = gfx::Screen::GetMonitorWorkAreaNearestWindow(child);
54 if (child_bounds.y() < 0)
55 child_bounds.set_y(0);
56 else if (child_bounds.y() + kTitleHeight > work_area.bottom())
57 child_bounds.set_y(work_area.bottom() - kTitleHeight);
58 SetChildBoundsDirect(child, child_bounds);
59 }
60
61 void ToplevelLayoutManager::OnWindowPropertyChanged(aura::Window* window,
62 const char* name,
63 void* old) {
64 if (name == aura::client::kShowStateKey) {
65 UpdateBoundsFromShowState(window);
66 UpdateShelfVisibility();
67 }
68 }
69
70 void ToplevelLayoutManager::UpdateShelfVisibility() {
71 if (!shelf_)
72 return;
73
74 bool has_fullscreen_window = false;
75 for (Windows::const_iterator i = windows_.begin(); i != windows_.end(); ++i) {
76 if ((*i)->GetIntProperty(aura::client::kShowStateKey) ==
77 ui::SHOW_STATE_FULLSCREEN) {
78 has_fullscreen_window = true;
79 break;
80 }
81 }
82 shelf_->SetVisible(!has_fullscreen_window);
83 }
84
85 } // namespace internal
86 } // namespace aura_shell
OLDNEW
« no previous file with comments | « ui/aura_shell/toplevel_layout_manager.h ('k') | ui/aura_shell/toplevel_layout_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698