Commit 04b3f54b authored by Maksim Sisov's avatar Maksim Sisov Committed by Commit Bot

X11: Move X11 move loop source to ui/base/x from ui/views

This Cl doesn't bring any functional changes, but just moves
the X11 code down to ui/base/x.

Bug: 1069469
Change-Id: Idaddec11dfbe88226a190d2ba4b5050ad38eed6e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2144056
Commit-Queue: Maksim Sisov <msisov@igalia.com>
Reviewed-by: default avatarThomas Anderson <thomasanderson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758493}
parent 78d9e009
......@@ -44,12 +44,18 @@ jumbo_component("x") {
sources += [
"selection_owner.cc",
"selection_owner.h",
"x11_desktop_window_move_client.cc",
"x11_desktop_window_move_client.h",
"x11_drag_context.cc",
"x11_drag_context.h",
"x11_drag_drop_client.cc",
"x11_drag_drop_client.h",
"x11_move_loop.h",
"x11_move_loop_delegate.h",
"x11_os_exchange_data_provider.cc",
"x11_os_exchange_data_provider.h",
"x11_whole_screen_move_loop.cc",
"x11_whole_screen_move_loop.h",
]
}
......
......@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/views/widget/desktop_aura/x11_desktop_window_move_client.h"
#include "ui/base/x/x11_desktop_window_move_client.h"
#include "ui/base/x/x11_util.h"
#include "ui/base/x/x11_window.h"
#include "ui/events/event.h"
#include "ui/gfx/x/x11.h"
namespace views {
namespace ui {
X11DesktopWindowMoveClient::X11DesktopWindowMoveClient(ui::XWindow* window)
: window_(window) {}
......@@ -40,4 +40,4 @@ void X11DesktopWindowMoveClient::EndMoveLoop() {
move_loop_.EndMoveLoop();
}
} // namespace views
} // namespace ui
......@@ -2,26 +2,24 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_WINDOW_MOVE_CLIENT_H_
#define UI_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_WINDOW_MOVE_CLIENT_H_
#ifndef UI_BASE_X_X11_DESKTOP_WINDOW_MOVE_CLIENT_H_
#define UI_BASE_X_X11_DESKTOP_WINDOW_MOVE_CLIENT_H_
#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/component_export.h"
#include "ui/base/x/x11_move_loop_delegate.h"
#include "ui/base/x/x11_whole_screen_move_loop.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/x/x11.h"
#include "ui/views/views_export.h"
#include "ui/views/widget/desktop_aura/x11_move_loop_delegate.h"
#include "ui/views/widget/desktop_aura/x11_whole_screen_move_loop.h"
namespace ui {
class XWindow;
}
namespace views {
class XWindow;
// When we're dragging tabs, we need to manually position our window.
class VIEWS_EXPORT X11DesktopWindowMoveClient
: public views::X11MoveLoopDelegate {
class COMPONENT_EXPORT(UI_BASE_X) X11DesktopWindowMoveClient
: public X11MoveLoopDelegate {
public:
explicit X11DesktopWindowMoveClient(ui::XWindow* window);
~X11DesktopWindowMoveClient() override;
......@@ -49,6 +47,6 @@ class VIEWS_EXPORT X11DesktopWindowMoveClient
gfx::Vector2d window_offset_;
};
} // namespace views
} // namespace ui
#endif // UI_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_WINDOW_MOVE_CLIENT_H_
#endif // UI_BASE_X_X11_DESKTOP_WINDOW_MOVE_CLIENT_H_
......@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_VIEWS_WIDGET_DESKTOP_AURA_X11_MOVE_LOOP_H_
#define UI_VIEWS_WIDGET_DESKTOP_AURA_X11_MOVE_LOOP_H_
#ifndef UI_BASE_X_X11_MOVE_LOOP_H_
#define UI_BASE_X_X11_MOVE_LOOP_H_
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/x/x11.h"
#include "ui/gfx/x/x11_types.h"
namespace views {
namespace ui {
// Runs a nested run loop and grabs the mouse. This is used to implement
// dragging.
......@@ -32,6 +32,6 @@ class X11MoveLoop {
virtual void EndMoveLoop() = 0;
};
} // namespace views
} // namespace ui
#endif // UI_VIEWS_WIDGET_DESKTOP_AURA_X11_MOVE_LOOP_H_
#endif // UI_BASE_X_X11_MOVE_LOOP_H_
......@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_VIEWS_WIDGET_DESKTOP_AURA_X11_MOVE_LOOP_DELEGATE_H_
#define UI_VIEWS_WIDGET_DESKTOP_AURA_X11_MOVE_LOOP_DELEGATE_H_
#ifndef UI_BASE_X_X11_MOVE_LOOP_DELEGATE_H_
#define UI_BASE_X_X11_MOVE_LOOP_DELEGATE_H_
namespace gfx {
class Point;
}
namespace views {
namespace ui {
// Receives mouse events while the X11MoveLoop is tracking a drag.
class X11MoveLoopDelegate {
......@@ -29,6 +29,6 @@ class X11MoveLoopDelegate {
virtual void OnMoveLoopEnded() = 0;
};
} // namespace views
} // namespace ui
#endif // UI_VIEWS_WIDGET_DESKTOP_AURA_X11_MOVE_LOOP_DELEGATE_H_
#endif // UI_BASE_X_X11_MOVE_LOOP_DELEGATE_H_
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/views/widget/desktop_aura/x11_whole_screen_move_loop.h"
#include "ui/base/x/x11_whole_screen_move_loop.h"
#include <stddef.h>
......@@ -27,9 +27,8 @@
#include "ui/events/x/events_x_utils.h"
#include "ui/events/x/x11_window_event_manager.h"
#include "ui/gfx/x/x11.h"
#include "ui/platform_window/x11/x11_window.h"
namespace views {
namespace ui {
// XGrabKey requires the modifier mask to explicitly be specified.
const unsigned int kModifiersMasks[] = {0, // No additional modifier.
......@@ -250,4 +249,4 @@ void X11WholeScreenMoveLoop::CreateDragInputWindow(XDisplay* display) {
XMapRaised(display, grab_input_window_);
}
} // namespace views
} // namespace ui
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_VIEWS_WIDGET_DESKTOP_AURA_X11_WHOLE_SCREEN_MOVE_LOOP_H_
#define UI_VIEWS_WIDGET_DESKTOP_AURA_X11_WHOLE_SCREEN_MOVE_LOOP_H_
#ifndef UI_BASE_X_X11_WHOLE_SCREEN_MOVE_LOOP_H_
#define UI_BASE_X_X11_WHOLE_SCREEN_MOVE_LOOP_H_
#include <stdint.h>
......@@ -11,29 +11,27 @@
#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/component_export.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "ui/base/cursor/cursor.h"
#include "ui/base/x/x11_move_loop.h"
#include "ui/base/x/x11_move_loop_delegate.h"
#include "ui/events/platform/platform_event_dispatcher.h"
#include "ui/gfx/geometry/vector2d_f.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/views/widget/desktop_aura/x11_move_loop.h"
#include "ui/views/widget/desktop_aura/x11_move_loop_delegate.h"
namespace ui {
class MouseEvent;
class ScopedEventDispatcher;
class XScopedEventSelector;
} // namespace ui
namespace views {
// Runs a nested run loop and grabs the mouse. This is used to implement
// dragging.
class X11WholeScreenMoveLoop : public X11MoveLoop,
public ui::PlatformEventDispatcher {
class COMPONENT_EXPORT(UI_BASE_X) X11WholeScreenMoveLoop
: public X11MoveLoop,
public ui::PlatformEventDispatcher {
public:
explicit X11WholeScreenMoveLoop(X11MoveLoopDelegate* delegate);
~X11WholeScreenMoveLoop() override;
......@@ -96,6 +94,6 @@ class X11WholeScreenMoveLoop : public X11MoveLoop,
DISALLOW_COPY_AND_ASSIGN(X11WholeScreenMoveLoop);
};
} // namespace views
} // namespace ui
#endif // UI_VIEWS_WIDGET_DESKTOP_AURA_X11_WHOLE_SCREEN_MOVE_LOOP_H_
#endif // UI_BASE_X_X11_WHOLE_SCREEN_MOVE_LOOP_H_
......@@ -757,24 +757,21 @@ jumbo_component("views") {
]
public_deps += [ "//ui/base/mojom:cursor_type" ]
if (use_x11) {
deps += [ "//ui/platform_window/x11" ]
deps += [
"//ui/base/x",
"//ui/platform_window/x11",
]
public += [
"widget/desktop_aura/desktop_drag_drop_client_aurax11.h",
"widget/desktop_aura/desktop_screen_x11.h",
"widget/desktop_aura/desktop_window_tree_host_x11.h",
"widget/desktop_aura/x11_desktop_window_move_client.h",
"widget/desktop_aura/x11_move_loop.h",
"widget/desktop_aura/x11_move_loop_delegate.h",
"widget/desktop_aura/x11_topmost_window_finder.h",
"widget/desktop_aura/x11_whole_screen_move_loop.h",
]
sources += [
"widget/desktop_aura/desktop_drag_drop_client_aurax11.cc",
"widget/desktop_aura/desktop_screen_x11.cc",
"widget/desktop_aura/desktop_window_tree_host_x11.cc",
"widget/desktop_aura/x11_desktop_window_move_client.cc",
"widget/desktop_aura/x11_topmost_window_finder.cc",
"widget/desktop_aura/x11_whole_screen_move_loop.cc",
]
} else if (is_win) {
public += [ "widget/desktop_aura/desktop_window_tree_host_win.h" ]
......
......@@ -26,6 +26,7 @@
#include "ui/base/x/selection_utils.h"
#include "ui/base/x/x11_drag_context.h"
#include "ui/base/x/x11_util.h"
#include "ui/base/x/x11_whole_screen_move_loop.h"
#include "ui/display/screen.h"
#include "ui/events/event.h"
#include "ui/events/event_utils.h"
......@@ -34,7 +35,6 @@
#include "ui/views/controls/image_view.h"
#include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h"
#include "ui/views/widget/desktop_aura/x11_topmost_window_finder.h"
#include "ui/views/widget/desktop_aura/x11_whole_screen_move_loop.h"
#include "ui/views/widget/widget.h"
using aura::client::DragDropDelegate;
......@@ -251,9 +251,9 @@ void DesktopDragDropClientAuraX11::OnMoveLoopEnded() {
XDragDropClient::HandleMoveLoopEnded();
}
std::unique_ptr<X11MoveLoop> DesktopDragDropClientAuraX11::CreateMoveLoop(
std::unique_ptr<ui::X11MoveLoop> DesktopDragDropClientAuraX11::CreateMoveLoop(
X11MoveLoopDelegate* delegate) {
return base::WrapUnique(new X11WholeScreenMoveLoop(this));
return base::WrapUnique(new ui::X11WholeScreenMoveLoop(this));
}
void DesktopDragDropClientAuraX11::DragTranslate(
......
......@@ -16,6 +16,7 @@
#include "ui/base/cursor/cursor.h"
#include "ui/base/dragdrop/drag_drop_types.h"
#include "ui/base/x/x11_drag_drop_client.h"
#include "ui/base/x/x11_move_loop_delegate.h"
#include "ui/events/event_constants.h"
#include "ui/events/platform/x11/x11_event_source.h"
#include "ui/events/x/x11_window_event_manager.h"
......@@ -23,7 +24,6 @@
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/x/x11.h"
#include "ui/views/views_export.h"
#include "ui/views/widget/desktop_aura/x11_move_loop_delegate.h"
namespace aura {
namespace client {
......@@ -40,12 +40,12 @@ namespace ui {
class DropTargetEvent;
class OSExchangeData;
class XTopmostWindowFinder;
class X11MoveLoop;
} // namespace ui
namespace views {
class DesktopNativeCursorManager;
class Widget;
class X11MoveLoop;
// Implements drag and drop on X11 for aura. On one side, this class takes raw
// X11 events forwarded from DesktopWindowTreeHostLinux, while on the other, it
......@@ -56,7 +56,7 @@ class VIEWS_EXPORT DesktopDragDropClientAuraX11
public aura::client::DragDropClient,
public ui::XEventDispatcher,
public aura::WindowObserver,
public X11MoveLoopDelegate {
public ui::X11MoveLoopDelegate {
public:
DesktopDragDropClientAuraX11(
aura::Window* root_window,
......@@ -85,7 +85,7 @@ class VIEWS_EXPORT DesktopDragDropClientAuraX11
// aura::WindowObserver:
void OnWindowDestroyed(aura::Window* window) override;
// X11MoveLoopDelegate:
// ui::X11MoveLoopDelegate:
void OnMouseMovement(const gfx::Point& screen_point,
int flags,
base::TimeTicks event_time) override;
......@@ -97,7 +97,7 @@ class VIEWS_EXPORT DesktopDragDropClientAuraX11
Widget* drag_widget() { return drag_widget_.get(); }
// Creates a move loop. Virtual for testing.
virtual std::unique_ptr<X11MoveLoop> CreateMoveLoop(
virtual std::unique_ptr<ui::X11MoveLoop> CreateMoveLoop(
X11MoveLoopDelegate* delegate);
private:
......@@ -125,8 +125,8 @@ class VIEWS_EXPORT DesktopDragDropClientAuraX11
void EndMoveLoop() override;
// A nested run loop that notifies this object of events through the
// X11MoveLoopDelegate interface.
std::unique_ptr<X11MoveLoop> move_loop_;
// ui::X11MoveLoopDelegate interface.
std::unique_ptr<ui::X11MoveLoop> move_loop_;
aura::Window* root_window_;
......
......@@ -20,6 +20,7 @@
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
#include "ui/base/dragdrop/os_exchange_data.h"
#include "ui/base/x/x11_move_loop.h"
#include "ui/base/x/x11_util.h"
#include "ui/events/event_utils.h"
#include "ui/gfx/x/x11.h"
......@@ -29,7 +30,6 @@
#include "ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.h"
#include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h"
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
#include "ui/views/widget/desktop_aura/x11_move_loop.h"
#include "ui/views/widget/widget.h"
namespace views {
......@@ -66,17 +66,17 @@ class ClientMessageEventCollector {
DISALLOW_COPY_AND_ASSIGN(ClientMessageEventCollector);
};
// An implementation of X11MoveLoop where RunMoveLoop() always starts the move
// loop.
class TestMoveLoop : public X11MoveLoop {
// An implementation of ui::X11MoveLoop where RunMoveLoop() always starts the
// move loop.
class TestMoveLoop : public ui::X11MoveLoop {
public:
explicit TestMoveLoop(X11MoveLoopDelegate* delegate);
explicit TestMoveLoop(ui::X11MoveLoopDelegate* delegate);
~TestMoveLoop() override;
// Returns true if the move loop is running.
bool IsRunning() const;
// X11MoveLoop:
// ui::X11MoveLoop:
bool RunMoveLoop(bool can_grab_pointer,
::Cursor old_cursor,
::Cursor new_cursor) override;
......@@ -85,7 +85,7 @@ class TestMoveLoop : public X11MoveLoop {
private:
// Not owned.
X11MoveLoopDelegate* delegate_;
ui::X11MoveLoopDelegate* delegate_;
// Ends the move loop.
base::OnceClosure quit_closure_;
......@@ -111,8 +111,8 @@ class SimpleTestDragDropClient : public DesktopDragDropClientAuraX11 {
private:
// DesktopDragDropClientAuraX11:
std::unique_ptr<X11MoveLoop> CreateMoveLoop(
X11MoveLoopDelegate* delegate) override;
std::unique_ptr<ui::X11MoveLoop> CreateMoveLoop(
ui::X11MoveLoopDelegate* delegate) override;
XID FindWindowFor(const gfx::Point& screen_point) override;
// The XID of the window which is simulated to be the topmost window.
......@@ -209,7 +209,7 @@ void ClientMessageEventCollector::RecordEvent(
///////////////////////////////////////////////////////////////////////////////
// TestMoveLoop
TestMoveLoop::TestMoveLoop(X11MoveLoopDelegate* delegate)
TestMoveLoop::TestMoveLoop(ui::X11MoveLoopDelegate* delegate)
: delegate_(delegate) {}
TestMoveLoop::~TestMoveLoop() = default;
......@@ -259,8 +259,8 @@ bool SimpleTestDragDropClient::IsMoveLoopRunning() {
return loop_->IsRunning();
}
std::unique_ptr<X11MoveLoop> SimpleTestDragDropClient::CreateMoveLoop(
X11MoveLoopDelegate* delegate) {
std::unique_ptr<ui::X11MoveLoop> SimpleTestDragDropClient::CreateMoveLoop(
ui::X11MoveLoopDelegate* delegate) {
loop_ = new TestMoveLoop(delegate);
return base::WrapUnique(loop_);
}
......
......@@ -35,6 +35,7 @@
#include "ui/base/hit_test.h"
#include "ui/base/ime/input_method.h"
#include "ui/base/layout.h"
#include "ui/base/x/x11_desktop_window_move_client.h"
#include "ui/base/x/x11_pointer_grab.h"
#include "ui/base/x/x11_util.h"
#include "ui/base/x/x11_util_internal.h"
......@@ -57,7 +58,6 @@
#include "ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.h"
#include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h"
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
#include "ui/views/widget/desktop_aura/x11_desktop_window_move_client.h"
#include "ui/views/window/native_frame_view.h"
#include "ui/wm/core/compound_event_filter.h"
#include "ui/wm/core/window_util.h"
......@@ -91,7 +91,7 @@ void DesktopWindowTreeHostX11::Init(const Widget::InitParams& params) {
void DesktopWindowTreeHostX11::OnNativeWidgetCreated(
const Widget::InitParams& params) {
x11_window_move_client_ = std::make_unique<X11DesktopWindowMoveClient>(
x11_window_move_client_ = std::make_unique<ui::X11DesktopWindowMoveClient>(
static_cast<ui::X11Window*>(platform_window()));
DesktopWindowTreeHostLinux::OnNativeWidgetCreated(params);
}
......
......@@ -17,11 +17,11 @@
namespace ui {
enum class DomCode;
class X11Window;
class X11DesktopWindowMoveClient;
} // namespace ui
namespace views {
class DesktopDragDropClientAuraX11;
class X11DesktopWindowMoveClient;
class VIEWS_EXPORT DesktopWindowTreeHostX11 : public DesktopWindowTreeHostLinux,
public ui::XEventDelegate {
......@@ -58,7 +58,7 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 : public DesktopWindowTreeHostLinux,
DesktopDragDropClientAuraX11* drag_drop_client_ = nullptr;
std::unique_ptr<X11DesktopWindowMoveClient> x11_window_move_client_;
std::unique_ptr<ui::X11DesktopWindowMoveClient> x11_window_move_client_;
DISALLOW_COPY_AND_ASSIGN(DesktopWindowTreeHostX11);
};
......
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