Commit ebb8e653 authored by sky's avatar sky Committed by Commit bot

Removes/promotes functions from WmWindowMus to WmWindowAura

The remaining functions are rather specific to aura-mus, will tackle
them next.

BUG=671246
TEST=none
R=jamescook@chromium.org

Review-Url: https://codereview.chromium.org/2613863005
Cr-Commit-Position: refs/heads/master@{#441815}
parent 262009cc
......@@ -348,8 +348,14 @@ int WmWindowAura::GetIntProperty(WmWindowProperty key) {
if (key == WmWindowProperty::SHELF_ID)
return window_->GetProperty(kShelfIDKey);
if (key == WmWindowProperty::SHELF_ITEM_TYPE)
return window_->GetProperty(kShelfItemTypeKey);
if (key == WmWindowProperty::SHELF_ITEM_TYPE) {
if (aura::Env::GetInstance()->mode() == aura::Env::Mode::LOCAL ||
window_->GetProperty(kShelfItemTypeKey) != TYPE_UNDEFINED) {
return window_->GetProperty(kShelfItemTypeKey);
}
// Mash provides a default shelf item type for non-ignored windows.
return GetWindowState()->ignored_by_shelf() ? TYPE_UNDEFINED : TYPE_APP;
}
if (key == WmWindowProperty::TOP_VIEW_INSET)
return window_->GetProperty(aura::client::kTopViewInset);
......@@ -660,6 +666,8 @@ bool WmWindowAura::CanResize() const {
}
bool WmWindowAura::CanActivate() const {
// TODO(sky): for aura-mus need to key off CanFocus() as well, which is not
// currently mirrored to ash.
return ::wm::CanActivateWindow(window_);
}
......@@ -680,6 +688,12 @@ void WmWindowAura::StackChildBelow(WmWindow* child, WmWindow* target) {
}
void WmWindowAura::SetPinned(bool trusted) {
if (aura::Env::GetInstance()->mode() == aura::Env::Mode::MUS) {
// TODO: fix, see http://crbug.com/622486. With aura-mus pinning may just
// work.
NOTIMPLEMENTED();
return;
}
wm::PinWindow(window_, trusted);
}
......@@ -759,6 +773,10 @@ WmWindow* WmWindowAura::GetChildByShellWindowId(int id) {
}
void WmWindowAura::ShowResizeShadow(int component) {
if (aura::Env::GetInstance()->mode() == aura::Env::Mode::MUS) {
// TODO: http://crbug.com/640773.
return;
}
ResizeShadowController* resize_shadow_controller =
Shell::GetInstance()->resize_shadow_controller();
if (resize_shadow_controller)
......@@ -766,6 +784,10 @@ void WmWindowAura::ShowResizeShadow(int component) {
}
void WmWindowAura::HideResizeShadow() {
if (aura::Env::GetInstance()->mode() == aura::Env::Mode::MUS) {
// TODO: http://crbug.com/640773.
return;
}
ResizeShadowController* resize_shadow_controller =
Shell::GetInstance()->resize_shadow_controller();
if (resize_shadow_controller)
......@@ -774,6 +796,12 @@ void WmWindowAura::HideResizeShadow() {
void WmWindowAura::InstallResizeHandleWindowTargeter(
ImmersiveFullscreenController* immersive_fullscreen_controller) {
if (aura::Env::GetInstance()->mode() == aura::Env::Mode::MUS) {
// TODO(sky): I believe once ImmersiveFullscreenController is ported this
// won't be necessary in mash, but I need to verify that:
// http://crbug.com/548435.
return;
}
window_->SetEventTargeter(base::MakeUnique<ResizeHandleWindowTargeter>(
window_, immersive_fullscreen_controller));
}
......
......@@ -74,52 +74,6 @@ WmShell* WmWindowMus::GetShell() const {
return WmShellMus::Get();
}
int WmWindowMus::GetIntProperty(WmWindowProperty key) {
if (key == WmWindowProperty::SHELF_ITEM_TYPE) {
if (aura_window()->GetProperty(kShelfItemTypeKey) != TYPE_UNDEFINED)
return aura_window()->GetProperty(kShelfItemTypeKey);
// Mash provides a default shelf item type for non-ignored windows.
return GetWindowState()->ignored_by_shelf() ? TYPE_UNDEFINED : TYPE_APP;
}
return WmWindowAura::GetIntProperty(key);
}
// TODO(sky): investigate if needed.
bool WmWindowMus::MoveToEventRoot(const ui::Event& event) {
views::View* target = static_cast<views::View*>(event.target());
if (!target)
return false;
WmWindow* target_root =
WmLookup::Get()->GetWindowForWidget(target->GetWidget())->GetRootWindow();
if (!target_root || target_root == GetRootWindow())
return false;
WmWindow* window_container =
target_root->GetChildByShellWindowId(GetParent()->GetShellWindowId());
window_container->AddChild(this);
return true;
}
// TODO(sky): investigate if needed.
void WmWindowMus::SetBoundsInScreen(const gfx::Rect& bounds_in_screen,
const display::Display& dst_display) {
DCHECK(GetParent()); // Aura code assumed a parent, so this does too.
if (static_cast<const WmWindowMus*>(GetParent())
->child_bounds_in_screen_behavior_ ==
BoundsInScreenBehavior::USE_LOCAL_COORDINATES) {
SetBounds(bounds_in_screen);
return;
}
wm::SetBoundsInScreen(this, bounds_in_screen, dst_display);
}
// TODO(sky): remove this override.
void WmWindowMus::SetPinned(bool trusted) {
// http://crbug.com/622486.
NOTIMPLEMENTED();
}
void WmWindowMus::CloseWidget() {
views::Widget* widget = views::Widget::GetWidgetForNativeView(aura_window());
DCHECK(widget);
......@@ -133,39 +87,6 @@ void WmWindowMus::CloseWidget() {
}
}
// TODO(sky): investigate if needed.
bool WmWindowMus::CanActivate() const {
// TODO(sky): this isn't quite right. Should key off CanFocus(), which is not
// replicated.
// TODO(sky): fix const cast (most likely remove this override entirely).
return WmWindowAura::CanActivate() &&
views::Widget::GetWidgetForNativeView(
const_cast<aura::Window*>(aura_window())) != nullptr;
}
void WmWindowMus::ShowResizeShadow(int component) {
// TODO: http://crbug.com/640773.
NOTIMPLEMENTED();
}
void WmWindowMus::HideResizeShadow() {
// TODO: http://crbug.com/640773.
NOTIMPLEMENTED();
}
void WmWindowMus::InstallResizeHandleWindowTargeter(
ImmersiveFullscreenController* immersive_fullscreen_controller) {
// TODO(sky): I believe once ImmersiveFullscreenController is ported this
// won't be necessary in mash, but I need to verify that:
// http://crbug.com/548435.
}
// TODO: nuke this once SetBoundsInScreen() is updated.
void WmWindowMus::SetBoundsInScreenBehaviorForChildren(
WmWindow::BoundsInScreenBehavior behavior) {
child_bounds_in_screen_behavior_ = behavior;
}
void WmWindowMus::AddLimitedPreTargetHandler(ui::EventHandler* handler) {
DCHECK(WmShellMus::Get()->window_tree_client()->WasCreatedByThisClient(
aura::WindowMus::Get(aura_window())));
......
......@@ -62,25 +62,10 @@ class WmWindowMus : public WmWindowAura {
// WmWindow:
WmRootWindowController* GetRootWindowController() override;
WmShell* GetShell() const override;
int GetIntProperty(WmWindowProperty key) override;
bool MoveToEventRoot(const ui::Event& event) override;
void SetBoundsInScreen(const gfx::Rect& bounds_in_screen,
const display::Display& dst_display) override;
void SetPinned(bool trusted) override;
void CloseWidget() override;
bool CanActivate() const override;
void ShowResizeShadow(int component) override;
void HideResizeShadow() override;
void InstallResizeHandleWindowTargeter(
ImmersiveFullscreenController* immersive_fullscreen_controller) override;
void SetBoundsInScreenBehaviorForChildren(
BoundsInScreenBehavior behavior) override;
void AddLimitedPreTargetHandler(ui::EventHandler* handler) override;
private:
BoundsInScreenBehavior child_bounds_in_screen_behavior_ =
BoundsInScreenBehavior::USE_LOCAL_COORDINATES;
DISALLOW_COPY_AND_ASSIGN(WmWindowMus);
};
......
......@@ -11,6 +11,7 @@
#include "ash/common/wm/window_state.h"
#include "ash/common/wm/wm_event.h"
#include "ash/common/wm/wm_screen_util.h"
#include "ash/common/wm_root_window_controller.h"
#include "ash/common/wm_window.h"
#include "ash/shell.h"
#include "ash/wm/window_properties.h"
......@@ -73,10 +74,11 @@ bool MoveWindowToEventRoot(aura::Window* window, const ui::Event& event) {
target->GetWidget()->GetNativeView()->GetRootWindow();
if (!target_root || target_root == window->GetRootWindow())
return false;
aura::Window* window_container =
ash::Shell::GetContainer(target_root, window->parent()->id());
WmWindow* window_container = WmWindowAura::Get(target_root)
->GetRootWindowController()
->GetContainer(window->parent()->id());
// Move the window to the target launcher.
window_container->AddChild(window);
window_container->AddChild(WmWindowAura::Get(window));
return true;
}
......
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