This source file includes following definitions.
- touch_extend_
- EventLocationInsideBounds
- ShouldUseExtendedBounds
#include "ui/wm/core/easy_resize_window_targeter.h"
#include "ui/aura/window.h"
#include "ui/gfx/geometry/insets_f.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/wm/public/transient_window_client.h"
namespace wm {
EasyResizeWindowTargeter::EasyResizeWindowTargeter(
aura::Window* container,
const gfx::Insets& mouse_extend,
const gfx::Insets& touch_extend)
: container_(container),
mouse_extend_(mouse_extend),
touch_extend_(touch_extend) {
}
EasyResizeWindowTargeter::~EasyResizeWindowTargeter() {
}
bool EasyResizeWindowTargeter::EventLocationInsideBounds(
aura::Window* window,
const ui::LocatedEvent& event) const {
if (ShouldUseExtendedBounds(window)) {
gfx::Point point = event.location();
if (window->parent())
aura::Window::ConvertPointToTarget(window->parent(), window, &point);
gfx::Rect bounds(window->bounds().size());
if (event.IsTouchEvent() || event.IsGestureEvent())
bounds.Inset(touch_extend_);
else
bounds.Inset(mouse_extend_);
return bounds.Contains(point);
}
return WindowTargeter::EventLocationInsideBounds(window, event);
}
bool EasyResizeWindowTargeter::ShouldUseExtendedBounds(
const aura::Window* window) const {
if (window->parent() != container_)
return false;
aura::client::TransientWindowClient* transient_window_client =
aura::client::GetTransientWindowClient();
return !transient_window_client ||
!transient_window_client->GetTransientParent(window) ||
transient_window_client->GetTransientParent(window) == container_;
}
}