Commit 2c27a755 authored by Antonio Gomes's avatar Antonio Gomes Committed by Commit Bot

Factor InteriorResizeHandleTargeter out into chromeos/ui/frame

This is a preparation step to share BrowserNonClientFrameViewAsh
with lacros/chrome.

BUG=1113900
R=jamescook@chromium.org

Change-Id: I60ded69e234b17d4012d35843f5ac646c1c80f57
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2545231
Commit-Queue: Antonio Gomes <tonikitoo@igalia.com>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828438}
parent 083f1c17
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "ash/wm/window_state.h" #include "ash/wm/window_state.h"
#include "ash/wm/wm_event.h" #include "ash/wm/wm_event.h"
#include "chromeos/ui/base/chromeos_ui_constants.h" #include "chromeos/ui/base/chromeos_ui_constants.h"
#include "chromeos/ui/frame/interior_resize_handler_targeter.h"
#include "ui/aura/client/aura_constants.h" #include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/capture_client.h" #include "ui/aura/client/capture_client.h"
#include "ui/aura/client/focus_client.h" #include "ui/aura/client/focus_client.h"
...@@ -54,42 +55,25 @@ namespace { ...@@ -54,42 +55,25 @@ namespace {
// This window targeter reserves space for the portion of the resize handles // This window targeter reserves space for the portion of the resize handles
// that extend within a top level window. // that extend within a top level window.
class InteriorResizeHandleTargeter : public aura::WindowTargeter { class InteriorResizeHandleTargeterAsh
: public chromeos::InteriorResizeHandleTargeter {
public: public:
InteriorResizeHandleTargeter() { InteriorResizeHandleTargeterAsh() = default;
SetInsets(gfx::Insets(chromeos::kResizeInsideBoundsSize)); InteriorResizeHandleTargeterAsh(const InteriorResizeHandleTargeterAsh&) =
} delete;
InteriorResizeHandleTargeterAsh& operator=(
~InteriorResizeHandleTargeter() override = default; const InteriorResizeHandleTargeterAsh&) = delete;
~InteriorResizeHandleTargeterAsh() override = default;
bool GetHitTestRects(aura::Window* target,
gfx::Rect* hit_test_rect_mouse,
gfx::Rect* hit_test_rect_touch) const override {
if (target == window() && window()->parent() &&
window()->parent()->targeter()) {
// Defer to the parent's targeter on whether |window_| should be able to
// receive the event. This should be EasyResizeWindowTargeter, which is
// installed on the container window, and is necessary for
// kResizeOutsideBoundsSize to work.
return window()->parent()->targeter()->GetHitTestRects(
target, hit_test_rect_mouse, hit_test_rect_touch);
}
return WindowTargeter::GetHitTestRects(target, hit_test_rect_mouse,
hit_test_rect_touch);
}
bool ShouldUseExtendedBounds(const aura::Window* target) const override { bool ShouldUseExtendedBounds(const aura::Window* target) const override {
// Fullscreen/maximized windows can't be drag-resized. // Fullscreen/maximized windows can't be drag-resized.
const WindowState* window_state = WindowState::Get(window()); const WindowState* window_state = WindowState::Get(window());
if (window_state && window_state->IsMaximizedOrFullscreenOrPinned()) if (window_state && window_state->IsMaximizedOrFullscreenOrPinned())
return false; return false;
// The shrunken hit region only applies to children of |window()|. // The shrunken hit region only applies to children of |window()|.
return target->parent() == window(); return InteriorResizeHandleTargeter::ShouldUseExtendedBounds(target);
} }
private:
DISALLOW_COPY_AND_ASSIGN(InteriorResizeHandleTargeter);
}; };
} // namespace } // namespace
...@@ -203,7 +187,7 @@ void CloseWidgetForWindow(aura::Window* window) { ...@@ -203,7 +187,7 @@ void CloseWidgetForWindow(aura::Window* window) {
} }
void InstallResizeHandleWindowTargeterForWindow(aura::Window* window) { void InstallResizeHandleWindowTargeterForWindow(aura::Window* window) {
window->SetEventTargeter(std::make_unique<InteriorResizeHandleTargeter>()); window->SetEventTargeter(std::make_unique<InteriorResizeHandleTargeterAsh>());
} }
bool IsDraggingTabs(const aura::Window* window) { bool IsDraggingTabs(const aura::Window* window) {
......
...@@ -37,6 +37,8 @@ source_set("frame") { ...@@ -37,6 +37,8 @@ source_set("frame") {
"immersive/immersive_fullscreen_controller_delegate.h", "immersive/immersive_fullscreen_controller_delegate.h",
"immersive/immersive_revealed_lock.cc", "immersive/immersive_revealed_lock.cc",
"immersive/immersive_revealed_lock.h", "immersive/immersive_revealed_lock.h",
"interior_resize_handler_targeter.cc",
"interior_resize_handler_targeter.h",
] ]
deps = [ deps = [
......
// Copyright 2020 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 "chromeos/ui/frame/interior_resize_handler_targeter.h"
#include "chromeos/ui/base/chromeos_ui_constants.h"
#include "ui/aura/window.h"
namespace chromeos {
InteriorResizeHandleTargeter::InteriorResizeHandleTargeter() {
SetInsets(gfx::Insets(chromeos::kResizeInsideBoundsSize));
}
InteriorResizeHandleTargeter::~InteriorResizeHandleTargeter() = default;
bool InteriorResizeHandleTargeter::GetHitTestRects(
aura::Window* target,
gfx::Rect* hit_test_rect_mouse,
gfx::Rect* hit_test_rect_touch) const {
if (target == window() && window()->parent() &&
window()->parent()->targeter()) {
// Defer to the parent's targeter on whether |window_| should be able to
// receive the event. This should be EasyResizeWindowTargeter, which is
// installed on the container window, and is necessary for
// kResizeOutsideBoundsSize to work.
return window()->parent()->targeter()->GetHitTestRects(
target, hit_test_rect_mouse, hit_test_rect_touch);
}
return WindowTargeter::GetHitTestRects(target, hit_test_rect_mouse,
hit_test_rect_touch);
}
bool InteriorResizeHandleTargeter::ShouldUseExtendedBounds(
const aura::Window* target) const {
// Fullscreen/maximized/pinned windows can't be drag-resized.
// TODO(https://crbug.com/1113900): Incorporate the check in
// InteriorResizeHandleTargeterAsh::ShouldUseExtendedBounds() override here.
//
// The shrunken hit region only applies to children of |window()|.
return target->parent() == window();
}
} // namespace chromeos
// Copyright 2020 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 CHROMEOS_UI_FRAME_INTERIOR_RESIZE_HANDLER_TARGETER_H_
#define CHROMEOS_UI_FRAME_INTERIOR_RESIZE_HANDLER_TARGETER_H_
#include "ui/aura/window_targeter.h"
namespace chromeos {
// This window targeter reserves space for the portion of the resize handles
// that extend within a top level window.
class InteriorResizeHandleTargeter : public aura::WindowTargeter {
public:
InteriorResizeHandleTargeter();
InteriorResizeHandleTargeter(const InteriorResizeHandleTargeter&) = delete;
InteriorResizeHandleTargeter& operator=(const InteriorResizeHandleTargeter&) =
delete;
~InteriorResizeHandleTargeter() override;
// aura::WindowTargeter
bool GetHitTestRects(aura::Window* target,
gfx::Rect* hit_test_rect_mouse,
gfx::Rect* hit_test_rect_touch) const override;
bool ShouldUseExtendedBounds(const aura::Window* target) const override;
};
} // namespace chromeos
#endif // CHROMEOS_UI_BASE_WINDOW_PROPERTIES_H_
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