forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimmersive_gesture_handler_aura.cc
43 lines (34 loc) · 1.44 KB
/
immersive_gesture_handler_aura.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright 2016 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/wm/immersive_gesture_handler_aura.h"
#include "ash/public/cpp/immersive/immersive_fullscreen_controller.h"
#include "ash/shell.h"
#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/window.h"
#include "ui/events/event.h"
namespace ash {
namespace {
// Returns the location of |event| in screen coordinates.
gfx::Point GetEventLocationInScreen(const ui::LocatedEvent& event) {
gfx::Point location_in_screen = event.location();
aura::Window* target = static_cast<aura::Window*>(event.target());
aura::client::ScreenPositionClient* screen_position_client =
aura::client::GetScreenPositionClient(target->GetRootWindow());
screen_position_client->ConvertPointToScreen(target, &location_in_screen);
return location_in_screen;
}
} // namespace
ImmersiveGestureHandlerAura::ImmersiveGestureHandlerAura(
ImmersiveFullscreenController* controller)
: immersive_fullscreen_controller_(controller) {
Shell::Get()->AddPreTargetHandler(this);
}
ImmersiveGestureHandlerAura::~ImmersiveGestureHandlerAura() {
Shell::Get()->RemovePreTargetHandler(this);
}
void ImmersiveGestureHandlerAura::OnGestureEvent(ui::GestureEvent* event) {
immersive_fullscreen_controller_->OnGestureEvent(
event, GetEventLocationInScreen(*event));
}
} // namespace ash