This source file includes following definitions.
- immersive_controller_
- OnPostWindowStateTypeChange
- OnWindowDestroying
- FindTargetForLocatedEvent
- SubtreeShouldBeExploredForEvent
#include "ash/wm/resize_handle_window_targeter.h"
#include "ash/ash_constants.h"
#include "ash/wm/immersive_fullscreen_controller.h"
#include "ash/wm/window_state.h"
#include "ui/aura/window.h"
namespace ash {
ResizeHandleWindowTargeter::ResizeHandleWindowTargeter(
aura::Window* window,
ImmersiveFullscreenController* controller)
: window_(window),
immersive_controller_(controller) {
wm::WindowState* window_state = wm::GetWindowState(window_);
OnPostWindowStateTypeChange(window_state, wm::WINDOW_STATE_TYPE_DEFAULT);
window_state->AddObserver(this);
window_->AddObserver(this);
}
ResizeHandleWindowTargeter::~ResizeHandleWindowTargeter() {
if (window_) {
window_->RemoveObserver(this);
wm::GetWindowState(window_)->RemoveObserver(this);
}
}
void ResizeHandleWindowTargeter::OnPostWindowStateTypeChange(
wm::WindowState* window_state,
wm::WindowStateType old_type) {
if (window_state->IsMaximizedOrFullscreen()) {
frame_border_inset_ = gfx::Insets();
} else {
frame_border_inset_ = gfx::Insets(kResizeInsideBoundsSize,
kResizeInsideBoundsSize,
kResizeInsideBoundsSize,
kResizeInsideBoundsSize);
}
}
void ResizeHandleWindowTargeter::OnWindowDestroying(aura::Window* window) {
CHECK_EQ(window_, window);
wm::GetWindowState(window_)->RemoveObserver(this);
window_ = NULL;
}
ui::EventTarget* ResizeHandleWindowTargeter::FindTargetForLocatedEvent(
ui::EventTarget* root,
ui::LocatedEvent* event) {
aura::Window* window = static_cast<aura::Window*>(root);
if (window == window_) {
gfx::Insets insets;
if (immersive_controller_ && immersive_controller_->IsEnabled() &&
!immersive_controller_->IsRevealed() &&
event->IsTouchEvent()) {
insets = gfx::Insets(kImmersiveFullscreenTopEdgeInset, 0, 0, 0);
} else {
insets = frame_border_inset_;
}
if (!insets.empty()) {
gfx::Rect bounds = gfx::Rect(window_->bounds().size());
bounds.Inset(insets);
if (!bounds.Contains(event->location()))
return window_;
}
}
return aura::WindowTargeter::FindTargetForLocatedEvent(root, event);
}
bool ResizeHandleWindowTargeter::SubtreeShouldBeExploredForEvent(
ui::EventTarget* target,
const ui::LocatedEvent& event) {
if (target == window_) {
ui::EventTarget* parent = target->GetParentTarget();
if (parent) {
ui::EventTargeter* targeter = parent->GetEventTargeter();
if (targeter)
return targeter->SubtreeShouldBeExploredForEvent(target, event);
}
}
return aura::WindowTargeter::SubtreeShouldBeExploredForEvent(target, event);
}
}