Commit f8e6aad2 authored by oshima@chromium.org's avatar oshima@chromium.org

Introduce RootWindowProperty for RootWindow's properties

BUG=272460

Review URL: https://chromiumcodereview.appspot.com/23496024

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@220667 0039d316-1c4b-4281-b951-d872f2087c98
parent c70e539e
......@@ -169,6 +169,8 @@
'popup_message.h',
'root_window_controller.cc',
'root_window_controller.h',
'root_window_settings.cc',
'root_window_settings.h',
'rotator/screen_rotation.cc',
'rotator/screen_rotation.h',
'scoped_target_root_window.cc',
......
......@@ -15,12 +15,11 @@
#include "ash/display/root_window_transformers.h"
#include "ash/host/root_window_host_factory.h"
#include "ash/root_window_controller.h"
#include "ash/root_window_settings.h"
#include "ash/screen_ash.h"
#include "ash/shell.h"
#include "ash/wm/coordinate_conversion.h"
#include "ash/wm/property_util.h"
#include "ash/wm/window_properties.h"
#include "ash/wm/window_util.h"
#include "base/command_line.h"
#include "base/strings/stringprintf.h"
#include "third_party/skia/include/utils/SkMatrix44.h"
......@@ -54,8 +53,6 @@
#endif // defined(USE_X11)
#endif // defined(OS_CHROMEOS)
DECLARE_WINDOW_PROPERTY_TYPE(int64);
namespace ash {
namespace {
......@@ -133,9 +130,6 @@ void SetDisplayPropertiesOnHostWindow(aura::RootWindow* root,
namespace internal {
DEFINE_WINDOW_PROPERTY_KEY(int64, kDisplayIdKey,
gfx::Display::kInvalidDisplayID);
// A utility class to store/restore focused/active window
// when the display configuration has changed.
class FocusActivationStore {
......@@ -492,11 +486,12 @@ void DisplayController::SetPrimaryDisplay(
DCHECK_NE(primary_root, non_primary_root);
root_windows_[new_primary_display.id()] = primary_root;
primary_root->SetProperty(internal::kDisplayIdKey, new_primary_display.id());
internal::GetRootWindowSettings(primary_root)->display_id =
new_primary_display.id();
root_windows_[old_primary_display.id()] = non_primary_root;
non_primary_root->SetProperty(internal::kDisplayIdKey,
old_primary_display.id());
internal::GetRootWindowSettings(non_primary_root)->display_id =
old_primary_display.id();
primary_display_id = new_primary_display.id();
GetDisplayManager()->layout_store()->UpdatePrimaryDisplayId(
......@@ -568,7 +563,7 @@ bool DisplayController::UpdateWorkAreaOfDisplayNearestWindow(
const aura::Window* window,
const gfx::Insets& insets) {
const aura::RootWindow* root_window = window->GetRootWindow();
int64 id = root_window->GetProperty(internal::kDisplayIdKey);
int64 id = internal::GetRootWindowSettings(root_window)->display_id;
// if id is |kInvaildDisplayID|, it's being deleted.
DCHECK(id != gfx::Display::kInvalidDisplayID);
return GetDisplayManager()->UpdateWorkAreaOfDisplay(id, insets);
......@@ -581,7 +576,7 @@ const gfx::Display& DisplayController::GetDisplayNearestWindow(
const aura::RootWindow* root_window = window->GetRootWindow();
if (!root_window)
return GetPrimaryDisplay();
int64 id = root_window->GetProperty(internal::kDisplayIdKey);
int64 id = internal::GetRootWindowSettings(root_window)->display_id;
// if id is |kInvaildDisplayID|, it's being deleted.
DCHECK(id != gfx::Display::kInvalidDisplayID);
......@@ -638,8 +633,8 @@ void DisplayController::OnDisplayAdded(const gfx::Display& display) {
DCHECK(root_windows_.empty());
primary_display_id = display.id();
root_windows_[display.id()] = primary_root_window_for_replace_;
primary_root_window_for_replace_->SetProperty(
internal::kDisplayIdKey, display.id());
internal::GetRootWindowSettings(primary_root_window_for_replace_)->
display_id = display.id();
primary_root_window_for_replace_ = NULL;
const internal::DisplayInfo& display_info =
GetDisplayManager()->GetDisplayInfo(display.id());
......@@ -678,11 +673,12 @@ void DisplayController::OnDisplayRemoved(const gfx::Display& display) {
// Delete the other root instead.
root_to_delete = root_windows_[primary_display_id];
root_to_delete->SetProperty(internal::kDisplayIdKey, display.id());
internal::GetRootWindowSettings(root_to_delete)->display_id = display.id();
// Setup primary root.
root_windows_[primary_display_id] = primary_root;
primary_root->SetProperty(internal::kDisplayIdKey, primary_display_id);
internal::GetRootWindowSettings(primary_root)->display_id =
primary_display_id;
OnDisplayBoundsChanged(
GetDisplayManager()->GetDisplayForId(primary_display_id));
......@@ -778,7 +774,7 @@ aura::RootWindow* DisplayController::AddRootWindowForDisplay(
// No need to remove RootWindowObserver because
// the DisplayController object outlives RootWindow objects.
root_window->AddRootWindowObserver(this);
root_window->SetProperty(internal::kDisplayIdKey, display.id());
internal::InitRootWindowSettings(root_window)->display_id = display.id();
root_window->Init();
root_windows_[display.id()] = root_window;
......
......@@ -16,8 +16,8 @@
#include "ash/display/display_manager.h"
#include "ash/display/root_window_transformers.h"
#include "ash/host/root_window_host_factory.h"
#include "ash/root_window_settings.h"
#include "ash/shell.h"
#include "ash/wm/window_properties.h"
#include "base/strings/stringprintf.h"
#include "ui/aura/client/capture_client.h"
#include "ui/aura/env.h"
......@@ -174,7 +174,7 @@ void MirrorWindowController::UpdateWindow(const DisplayInfo& display_info) {
Shell::GetInstance()->display_controller());
root_window_->AddRootWindowObserver(this);
// TODO(oshima): TouchHUD is using idkey.
root_window_->SetProperty(internal::kDisplayIdKey, display_info.id());
InitRootWindowSettings(root_window_.get())->display_id = display_info.id();
root_window_->Init();
#if defined(USE_X11)
DisableInput(root_window_->GetAcceleratedWidget());
......@@ -199,7 +199,7 @@ void MirrorWindowController::UpdateWindow(const DisplayInfo& display_info) {
root_window_->AddChild(cursor_window_);
cursor_window_->Show();
} else {
root_window_->SetProperty(internal::kDisplayIdKey, display_info.id());
GetRootWindowSettings(root_window_.get())->display_id = display_info.id();
root_window_->SetHostBounds(display_info.bounds_in_pixel());
}
......
......@@ -13,6 +13,7 @@
#include "ash/desktop_background/user_wallpaper_delegate.h"
#include "ash/display/display_manager.h"
#include "ash/focus_cycler.h"
#include "ash/root_window_settings.h"
#include "ash/session_state_delegate.h"
#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shelf/shelf_types.h"
......@@ -54,6 +55,7 @@
#include "ui/aura/window_tracker.h"
#include "ui/base/hit_test.h"
#include "ui/base/models/menu_model.h"
#include "ui/gfx/display.h"
#include "ui/gfx/screen.h"
#include "ui/keyboard/keyboard_controller.h"
#include "ui/keyboard/keyboard_util.h"
......@@ -280,7 +282,8 @@ void RootWindowController::Shutdown() {
workspace_controller_.reset();
// Forget with the display ID so that display lookup
// ends up with invalid display.
root_window_->ClearProperty(kDisplayIdKey);
internal::GetRootWindowSettings(root_window_.get())->display_id =
gfx::Display::kInvalidDisplayID;
// And this root window should no longer process events.
root_window_->PrepareForShutdown();
......
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/root_window_settings.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window_property.h"
#include "ui/gfx/display.h"
DECLARE_WINDOW_PROPERTY_TYPE(ash::internal::RootWindowSettings*);
namespace ash {
namespace internal {
DEFINE_OWNED_WINDOW_PROPERTY_KEY(RootWindowSettings,
kRootWindowSettingsKey, NULL);
RootWindowSettings::RootWindowSettings()
: solo_window_header(false),
display_id(gfx::Display::kInvalidDisplayID),
controller(NULL) {
}
RootWindowSettings* InitRootWindowSettings(aura::RootWindow* root) {
RootWindowSettings* property = new RootWindowSettings();
root->SetProperty(kRootWindowSettingsKey, property);
return property;
}
RootWindowSettings* GetRootWindowSettings(aura::RootWindow* root) {
return root->GetProperty(kRootWindowSettingsKey);
}
const RootWindowSettings* GetRootWindowSettings(const aura::RootWindow* root) {
return root->GetProperty(kRootWindowSettingsKey);
}
} // namespace internal
} // namespace ash
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_WM_ROOT_WINDOW_SETTINGS_H_
#define ASH_WM_ROOT_WINDOW_SETTINGS_H_
#include "ash/ash_export.h"
#include "base/basictypes.h"
namespace aura {
class RootWindow;
}
namespace ash {
namespace internal {
class RootWindowController;
// Per root window information should be stored here
// instead of using plain aura root window property because
// it can prevent mis-using on non root window.
struct RootWindowSettings {
RootWindowSettings();
// Indicate if the window in the active workspace should
// use the transparent "solo-window" header style.
bool solo_window_header;
// ID of the display associated with the root window.
int64 display_id;
// RootWindowController for the root window. This may be NULL
// for the root window used for mirroring.
RootWindowController* controller;
};
// Initializes and creates RootWindowSettings for |root|, and returns
// the property.
RootWindowSettings* InitRootWindowSettings(aura::RootWindow* root);
// Returns the RootWindowSettings for |root|.
ASH_EXPORT RootWindowSettings* GetRootWindowSettings(aura::RootWindow* root);
// const version of GetRootWindowSettings.
ASH_EXPORT const RootWindowSettings*
GetRootWindowSettings(const aura::RootWindow* root);
} // namespace internal
} // namespace ash
#endif // ASH_WM_ROOT_WINDOW_SETTINGS_H_
......@@ -5,10 +5,10 @@
#include "ash/touch/touch_observer_hud.h"
#include "ash/root_window_controller.h"
#include "ash/root_window_settings.h"
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
#include "ash/wm/property_util.h"
#include "ash/wm/window_properties.h"
#include "ui/aura/root_window.h"
#include "ui/gfx/display.h"
#include "ui/gfx/rect.h"
......@@ -20,7 +20,7 @@ namespace ash {
namespace internal {
TouchObserverHUD::TouchObserverHUD(aura::RootWindow* initial_root)
: display_id_(initial_root->GetProperty(kDisplayIdKey)),
: display_id_(GetRootWindowSettings(initial_root)->display_id),
root_window_(initial_root),
widget_(NULL) {
const gfx::Display& display =
......
......@@ -8,6 +8,7 @@
#include "ash/ash_constants.h"
#include "ash/root_window_controller.h"
#include "ash/root_window_settings.h"
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
#include "ash/wm/property_util.h"
......@@ -755,7 +756,7 @@ bool FramePainter::UseSoloWindowHeader() const {
return false;
// Don't recompute every time, as it would require many window property
// lookups.
return root->GetProperty(internal::kSoloWindowHeaderKey);
return internal::GetRootWindowSettings(root)->solo_window_header;
}
// static
......@@ -794,11 +795,14 @@ void FramePainter::UpdateSoloWindowInRoot(RootWindow* root,
#endif
if (!root)
return;
bool old_solo_header = root->GetProperty(internal::kSoloWindowHeaderKey);
internal::RootWindowSettings* root_window_settings =
internal::GetRootWindowSettings(root);
bool old_solo_header = root_window_settings->solo_window_header;
bool new_solo_header = UseSoloWindowHeaderInRoot(root, ignore_window);
if (old_solo_header == new_solo_header)
return;
root->SetProperty(internal::kSoloWindowHeaderKey, new_solo_header);
root_window_settings->solo_window_header = new_solo_header;
// Invalidate all the window frames in the desktop. There should only be
// a few.
std::vector<Window*> windows = GetWindowsForSoloHeaderUpdate(root);
......
......@@ -5,11 +5,11 @@
#include "ash/wm/frame_painter.h"
#include "ash/ash_constants.h"
#include "ash/root_window_settings.h"
#include "ash/shell.h"
#include "ash/shell_window_ids.h"
#include "ash/test/ash_test_base.h"
#include "ash/wm/property_util.h"
#include "ash/wm/window_properties.h"
#include "ash/wm/window_util.h"
#include "ash/wm/workspace/frame_caption_button_container_view.h"
#include "base/memory/scoped_ptr.h"
......@@ -216,18 +216,18 @@ TEST_F(FramePainterTest, CreateAndDeleteSingleWindow) {
// We only have one window, so it should use a solo header.
EXPECT_TRUE(painter->UseSoloWindowHeader());
EXPECT_TRUE(root->GetProperty(internal::kSoloWindowHeaderKey));
EXPECT_TRUE(internal::GetRootWindowSettings(root)->solo_window_header);
// Close the window.
widget.reset();
EXPECT_FALSE(root->GetProperty(internal::kSoloWindowHeaderKey));
EXPECT_FALSE(internal::GetRootWindowSettings(root)->solo_window_header);
// Recreate another window again.
widget.reset(CreateTestWidget());
painter.reset(CreateTestPainter(widget.get()));
widget->Show();
EXPECT_TRUE(painter->UseSoloWindowHeader());
EXPECT_TRUE(root->GetProperty(internal::kSoloWindowHeaderKey));
EXPECT_TRUE(internal::GetRootWindowSettings(root)->solo_window_header);
}
TEST_F(FramePainterTest, UseSoloWindowHeader) {
......
......@@ -5,6 +5,7 @@
#include "ash/wm/property_util.h"
#include "ash/ash_export.h"
#include "ash/root_window_settings.h"
#include "ash/screen_ash.h"
#include "ash/wm/window_properties.h"
#include "ash/wm/window_util.h"
......@@ -67,12 +68,12 @@ bool GetWindowAlwaysRestoresToRestoreBounds(const aura::Window* window) {
internal::RootWindowController* GetRootWindowController(
const aura::RootWindow* root_window) {
return root_window ?
root_window->GetProperty(internal::kRootWindowControllerKey) : NULL;
internal::GetRootWindowSettings(root_window)->controller : NULL;
}
void SetRootWindowController(aura::RootWindow* root_window,
internal::RootWindowController* controller) {
root_window->SetProperty(internal::kRootWindowControllerKey, controller);
internal::GetRootWindowSettings(root_window)->controller = controller;
}
} // namespace ash
......@@ -9,9 +9,6 @@
#include "ui/aura/window_property.h"
#include "ui/gfx/rect.h"
DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(ASH_EXPORT, ash::FramePainter*);
DECLARE_WINDOW_PROPERTY_TYPE(ash::internal::RootWindowController*);
namespace ash {
namespace internal {
DEFINE_WINDOW_PROPERTY_KEY(bool, kAnimateToFullscreenKey, true);
......@@ -20,9 +17,6 @@ DEFINE_WINDOW_PROPERTY_KEY(bool, kFullscreenUsesMinimalChromeKey, false);
DEFINE_WINDOW_PROPERTY_KEY(bool, kIgnoreSoloWindowFramePainterPolicy, false);
DEFINE_WINDOW_PROPERTY_KEY(bool, kIgnoredByShelfKey, false);
DEFINE_WINDOW_PROPERTY_KEY(bool, kPanelAttachedKey, true);
DEFINE_WINDOW_PROPERTY_KEY(RootWindowController*,
kRootWindowControllerKey, NULL);
DEFINE_WINDOW_PROPERTY_KEY(bool, kSoloWindowHeaderKey, false);
DEFINE_WINDOW_PROPERTY_KEY(bool, kStayInSameRootWindowKey, false);
DEFINE_WINDOW_PROPERTY_KEY(bool, kUsesScreenCoordinatesKey, false);
DEFINE_WINDOW_PROPERTY_KEY(bool, kUserChangedWindowPositionOrSizeKey, false);
......
......@@ -15,9 +15,7 @@ class Rect;
}
namespace ash {
class FramePainter;
namespace internal {
class RootWindowController;
// Shell-specific window property keys.
......@@ -31,9 +29,6 @@ extern const aura::WindowProperty<bool>* const kAnimateToFullscreenKey;
// after the window is reparented to another container.
extern const aura::WindowProperty<bool>* const kContinueDragAfterReparent;
// A property key to store display_id an aura::RootWindow is mapped to.
extern const aura::WindowProperty<int64>* const kDisplayIdKey;
// A property key to indicate whether there is any chrome at all that cannot be
// hidden when the window is fullscreen. This is unrelated to whether the full
// chrome can be revealed by hovering the mouse at the top of the screen.
......@@ -53,14 +48,6 @@ extern const aura::WindowProperty<bool>* const
// True if this window is an attached panel.
ASH_EXPORT extern const aura::WindowProperty<bool>* const kPanelAttachedKey;
extern const aura::WindowProperty<RootWindowController*>* const
kRootWindowControllerKey;
// RootWindow property to indicate if the window in the active workspace should
// use the transparent "solo-window" header style.
ASH_EXPORT extern const aura::WindowProperty<bool>* const
kSoloWindowHeaderKey;
// If this is set to true, the window stays in the same root window
// even if the bounds outside of its root window is set.
// This is exported as it's used in the tests.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment