1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ui/views/widget/desktop_aura/x11_desktop_window_move_client.h"
9 #include "base/debug/stack_trace.h"
10 #include "base/message_loop/message_loop.h"
11 #include "base/run_loop.h"
12 #include "ui/aura/env.h"
13 #include "ui/aura/window.h"
14 #include "ui/aura/window_tree_host.h"
15 #include "ui/base/x/x11_util.h"
16 #include "ui/events/event.h"
17 #include "ui/gfx/screen.h"
21 X11DesktopWindowMoveClient::X11DesktopWindowMoveClient()
26 X11DesktopWindowMoveClient::~X11DesktopWindowMoveClient() {}
28 void X11DesktopWindowMoveClient::OnMouseMovement(
29 const gfx::Point
& screen_point
,
31 base::TimeDelta event_time
) {
32 gfx::Point system_loc
= screen_point
- window_offset_
;
33 host_
->SetBounds(gfx::Rect(system_loc
, host_
->GetBounds().size()));
36 void X11DesktopWindowMoveClient::OnMouseReleased() {
40 void X11DesktopWindowMoveClient::OnMoveLoopEnded() {
44 ////////////////////////////////////////////////////////////////////////////////
45 // DesktopWindowTreeHostLinux, aura::client::WindowMoveClient implementation:
47 aura::client::WindowMoveResult
X11DesktopWindowMoveClient::RunMoveLoop(
49 const gfx::Vector2d
& drag_offset
,
50 aura::client::WindowMoveSource move_source
) {
51 window_offset_
= drag_offset
;
52 host_
= source
->GetHost();
55 bool success
= move_loop_
.RunMoveLoop(source
, host_
->last_cursor());
56 return success
? aura::client::MOVE_SUCCESSFUL
: aura::client::MOVE_CANCELED
;
59 void X11DesktopWindowMoveClient::EndMoveLoop() {
60 move_loop_
.EndMoveLoop();