Commit 35f5421c authored by rch@chromium.org's avatar rch@chromium.org

Revert of Fix flakiness of DesktopDragDropClientAuraX11Tests...

Revert of Fix flakiness of DesktopDragDropClientAuraX11Tests (https://codereview.chromium.org/431973006/)

Reason for revert:
http://build.chromium.org/p/chromium.memory/builders/Linux%20ASan%20LSan%20Builder/builds/11578/steps/compile/logs/stdio#error1

FAILED: /b/build/goma/gomacc ../../third_party/llvm-build/Release+Asserts/bin/clang++ -MMD -MF obj/ui/views/widget/desktop_aura/views.desktop_drag_drop_client_aurax11.o.d -DV8_DEPRECATION_WARNINGS -DBLINK_SCALE_FILTERS_AT_RECORD_TIME -D_FILE_OFFSET_BITS=64 -DNO_TCMALLOC -DCHROMIUM_BUILD -DCR_CLANG_REVISION=214024 -DTOOLKIT_VIEWS=1 -DUI_COMPOSITOR_IMAGE_TRANSPORT -DUSE_AURA=1 -DUSE_ASH=1 -DUSE_PANGO=1 -DUSE_CAIRO=1 -DUSE_GLIB=1 -DUSE_DEFAULT_RENDER_THEME=1 -DUSE_LIBJPEG_TURBO=1 -DUSE_X11=1 -DUSE_CLIPBOARD_AURAX11=1 -DENABLE_ONE_CLICK_SIGNIN -DENABLE_PRE_SYNC_BACKUP -DUSE_XI2_MT=2 -DENABLE_REMOTING=1 -DENABLE_WEBRTC=1 -DENABLE_PEPPER_CDMS -DENABLE_CONFIGURATION_POLICY -DENABLE_NOTIFICATIONS -DUSE_UDEV -DENABLE_EGLIMAGE=1 -DADDRESS_SANITIZER -DMEMORY_TOOL_REPLACES_ALLOCATOR -DMEMORY_SANITIZER_INITIAL_SIZE -DENABLE_TASK_MANAGER=1 -DENABLE_EXTENSIONS=1 -DENABLE_PLUGINS=1 -DENABLE_SESSION_SERVICE=1 -DENABLE_THEMES=1 -DENABLE_AUTOFILL_DIALOG=1 -DENABLE_BACKGROUND=1 -DENABLE_GOOGLE_NOW=1 -DCLD_VERSION=2 -DCLD2_DATA_SOURCE=static -DENABLE_FULL_PRINTING=1 -DENABLE_PRINTING=1 -DENABLE_SPELLCHECK=1 -DENABLE_CAPTIVE_PORTAL_DETECTION=1 -DENABLE_APP_LIST=1 -DENABLE_SETTINGS_APP=1 -DENABLE_MANAGED_USERS=1 -DENABLE_MDNS=1 -DENABLE_SERVICE_DISCOVERY=1 -DVIEWS_IMPLEMENTATION -DGL_GLEXT_PROTOTYPES -DSK_ENABLE_INST_COUNT=0 -DSK_SUPPORT_GPU=1 '-DGR_GL_CUSTOM_SETUP_HEADER="GrGLConfig_chrome.h"' -DSK_ENABLE_LEGACY_API_ALIASING=1 -DSK_ATTR_DEPRECATED=SK_NOTHING_ARG1 -DGR_GL_IGNORE_ES3_MSAA=0 -DSK_WILL_NEVER_DRAW_PERSPECTIVE_TEXT -DSK_SUPPORT_LEGACY_PICTURE_CLONE -DSK_SUPPORT_LEGACY_GETDEVICE -DSK_IGNORE_ETC1_SUPPORT -DSK_IGNORE_GPU_DITHER -DSK_USE_POSIX_THREADS -DSK_DEFERRED_CANVAS_USES_FACTORIES=1 -DU_USING_ICU_NAMESPACE=0 -DU_ENABLE_DYLOAD=0 -DU_STATIC_IMPLEMENTATION -DUSE_NSS=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -DLEAK_SANITIZER -DWTF_USE_LEAK_SANITIZER=1 -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -Igen -I../../third_party/wtl/include -I../.. -I../../skia/config -I../../third_party/khronos -I../../gpu -I../../third_party/skia/src/core -I../../third_party/skia/include/core -I../../third_party/skia/include/effects -I../../third_party/skia/include/pdf -I../../third_party/skia/include/gpu -I../../third_party/skia/include/lazy -I../../third_party/skia/include/pathops -I../../third_party/skia/include/pipe -I../../third_party/skia/include/ports -I../../third_party/skia/include/utils -I../../skia/ext -I../../third_party/icu/source/i18n -I../../third_party/icu/source/common -Igen/ui/resources -Igen/ui/strings '-I../../third_party/libc++/trunk/include' '-I../../third_party/libc++abi/trunk/include' -fstack-protector --param=ssp-buffer-size=4 -Werror -pthread -fno-exceptions -fno-strict-aliasing -Wall -Wno-unused-parameter -Wno-missing-field-initializers -fvisibility=hidden -pipe -fPIC -Wno-reserved-user-defined-literal -Xclang -load -Xclang /b/build/slave/Linux_ASan_LSan_Builder/build/src/tools/clang/scripts/../../../third_party/llvm-build/Release+Asserts/lib/libFindBadConstructs.so -Xclang -add-plugin -Xclang find-bad-constructs -fcolor-diagnostics -B/b/build/slave/Linux_ASan_LSan_Builder/build/src/third_party/binutils/Linux_x64/Release/bin -Wheader-hygiene -Wno-char-subscripts -Wno-unneeded-internal-declaration -Wno-covered-switch-default -Wstring-conversion -Wno-c++11-narrowing -Wno-deprecated-register -pthread -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -m64 -march=x86-64 -fno-omit-frame-pointer -gline-tables-only -fsanitize=address -fsanitize=leak -O2 -fdata-sections -ffunction-sections -fno-slp-vectorize -funwind-tables -fno-rtti -fno-threadsafe-statics -fvisibility-inlines-hidden -Wsign-compare -std=gnu++11 -nostdinc++  -c ../../ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.cc -o obj/ui/views/widget/desktop_aura/views.desktop_drag_drop_client_aurax11.o
In file included from ../../ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.cc:5:
../../ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.h:166:8:error: no type named 'vector' in namespace 'std'
  std::vector< ::Atom> GetOfferedDragOperations();
  ~~~~~^
../../ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.h:166:14:error: expected member name or ';' after declaration specifiers
  std::vector< ::Atom> GetOfferedDragOperations();
  ~~~~~~~~~~~^
../../ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.cc:316:32:error: no member named 'GetOfferedDragOperations' in 'views::DesktopDragDropClientAuraX11'
    actions_ = source_client_->GetOfferedDragOperations();
               ~~~~~~~~~~~~~~  ^
../../ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.cc:614:34:error: use of undeclared identifier 'GetOfferedDragOperations'
  std::vector< ::Atom> actions = GetOfferedDragOperations();
                                 ^
../../ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.cc:924:52:error: out-of-line definition of 'GetOfferedDragOperations' does not match any declaration in 'views::DesktopDragDropClientAuraX11'
std::vector< ::Atom> DesktopDragDropClientAuraX11::GetOfferedDragOperations() {
                                                   ^~~~~~~~~~~~~~~~~~~~~~~~


Original issue's description:
> Fix flakiness of DesktopDragDropClientAuraX11Tests
> 
> I suspect that the flakiness was caused by X11WholeScreenMoveLoop::RunMoveLoop()
> sometimes failing. This CL fixes this potential source of flakiness by using
> a stub move loop in tests.
> 
> BUG=396468
> TEST=None
> TBR=erg
> 
> Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=287622

TBR=erg@chromium.org,pkotwicz@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=396468

Review URL: https://codereview.chromium.org/443773003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287627 0039d316-1c4b-4281-b951-d872f2087c98
parent 7804332e
...@@ -417,12 +417,11 @@ ...@@ -417,12 +417,11 @@
'widget/desktop_aura/x11_desktop_handler.h', 'widget/desktop_aura/x11_desktop_handler.h',
'widget/desktop_aura/x11_desktop_window_move_client.cc', 'widget/desktop_aura/x11_desktop_window_move_client.cc',
'widget/desktop_aura/x11_desktop_window_move_client.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.cc', 'widget/desktop_aura/x11_topmost_window_finder.cc',
'widget/desktop_aura/x11_topmost_window_finder.h', 'widget/desktop_aura/x11_topmost_window_finder.h',
'widget/desktop_aura/x11_whole_screen_move_loop.cc', 'widget/desktop_aura/x11_whole_screen_move_loop.cc',
'widget/desktop_aura/x11_whole_screen_move_loop.h', 'widget/desktop_aura/x11_whole_screen_move_loop.h',
'widget/desktop_aura/x11_whole_screen_move_loop_delegate.h',
'widget/desktop_aura/x11_window_event_filter.cc', 'widget/desktop_aura/x11_window_event_filter.cc',
'widget/desktop_aura/x11_window_event_filter.h', 'widget/desktop_aura/x11_window_event_filter.h',
], ],
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include "ui/events/platform/platform_event_source.h" #include "ui/events/platform/platform_event_source.h"
#include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.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_topmost_window_finder.h"
#include "ui/views/widget/desktop_aura/x11_whole_screen_move_loop.h"
#include "ui/wm/public/drag_drop_client.h" #include "ui/wm/public/drag_drop_client.h"
#include "ui/wm/public/drag_drop_delegate.h" #include "ui/wm/public/drag_drop_delegate.h"
...@@ -362,7 +361,8 @@ DesktopDragDropClientAuraX11::DesktopDragDropClientAuraX11( ...@@ -362,7 +361,8 @@ DesktopDragDropClientAuraX11::DesktopDragDropClientAuraX11(
views::DesktopNativeCursorManager* cursor_manager, views::DesktopNativeCursorManager* cursor_manager,
Display* xdisplay, Display* xdisplay,
::Window xwindow) ::Window xwindow)
: root_window_(root_window), : move_loop_(this),
root_window_(root_window),
xdisplay_(xdisplay), xdisplay_(xdisplay),
xwindow_(xwindow), xwindow_(xwindow),
atom_cache_(xdisplay_, kAtomsToCache), atom_cache_(xdisplay_, kAtomsToCache),
...@@ -407,10 +407,6 @@ DesktopDragDropClientAuraX11* DesktopDragDropClientAuraX11::GetForWindow( ...@@ -407,10 +407,6 @@ DesktopDragDropClientAuraX11* DesktopDragDropClientAuraX11::GetForWindow(
return it->second; return it->second;
} }
void DesktopDragDropClientAuraX11::Init() {
move_loop_ = CreateMoveLoop(this);
}
void DesktopDragDropClientAuraX11::OnXdndEnter( void DesktopDragDropClientAuraX11::OnXdndEnter(
const XClientMessageEvent& event) { const XClientMessageEvent& event) {
DVLOG(1) << "XdndEnter"; DVLOG(1) << "XdndEnter";
...@@ -487,7 +483,7 @@ void DesktopDragDropClientAuraX11::OnXdndStatus( ...@@ -487,7 +483,7 @@ void DesktopDragDropClientAuraX11::OnXdndStatus(
if (source_state_ == SOURCE_STATE_PENDING_DROP) { if (source_state_ == SOURCE_STATE_PENDING_DROP) {
// We were waiting on the status message so we could send the XdndDrop. // We were waiting on the status message so we could send the XdndDrop.
if (negotiated_operation_ == ui::DragDropTypes::DRAG_NONE) { if (negotiated_operation_ == ui::DragDropTypes::DRAG_NONE) {
move_loop_->EndMoveLoop(); move_loop_.EndMoveLoop();
return; return;
} }
source_state_ = SOURCE_STATE_DROPPED; source_state_ = SOURCE_STATE_DROPPED;
...@@ -497,13 +493,13 @@ void DesktopDragDropClientAuraX11::OnXdndStatus( ...@@ -497,13 +493,13 @@ void DesktopDragDropClientAuraX11::OnXdndStatus(
switch (negotiated_operation_) { switch (negotiated_operation_) {
case ui::DragDropTypes::DRAG_COPY: case ui::DragDropTypes::DRAG_COPY:
move_loop_->UpdateCursor(copy_grab_cursor_); move_loop_.UpdateCursor(copy_grab_cursor_);
break; break;
case ui::DragDropTypes::DRAG_MOVE: case ui::DragDropTypes::DRAG_MOVE:
move_loop_->UpdateCursor(move_grab_cursor_); move_loop_.UpdateCursor(move_grab_cursor_);
break; break;
default: default:
move_loop_->UpdateCursor(grab_cursor_); move_loop_.UpdateCursor(grab_cursor_);
break; break;
} }
...@@ -538,7 +534,7 @@ void DesktopDragDropClientAuraX11::OnXdndFinished( ...@@ -538,7 +534,7 @@ void DesktopDragDropClientAuraX11::OnXdndFinished(
// Clear |source_current_window_| to avoid sending XdndLeave upon ending the // Clear |source_current_window_| to avoid sending XdndLeave upon ending the
// move loop. // move loop.
source_current_window_ = None; source_current_window_ = None;
move_loop_->EndMoveLoop(); move_loop_.EndMoveLoop();
} }
void DesktopDragDropClientAuraX11::OnXdndDrop( void DesktopDragDropClientAuraX11::OnXdndDrop(
...@@ -631,12 +627,12 @@ int DesktopDragDropClientAuraX11::StartDragAndDrop( ...@@ -631,12 +627,12 @@ int DesktopDragDropClientAuraX11::StartDragAndDrop(
// Windows has a specific method, DoDragDrop(), which performs the entire // Windows has a specific method, DoDragDrop(), which performs the entire
// drag. We have to emulate this, so we spin off a nested runloop which will // drag. We have to emulate this, so we spin off a nested runloop which will
// track all cursor movement and reroute events to a specific handler. // track all cursor movement and reroute events to a specific handler.
move_loop_->SetDragImage(source_provider_->GetDragImage(), move_loop_.SetDragImage(source_provider_->GetDragImage(),
source_provider_->GetDragImageOffset()); source_provider_->GetDragImageOffset());
move_loop_->RunMoveLoop(source_window, grab_cursor_); move_loop_.RunMoveLoop(source_window, grab_cursor_);
if (alive) { if (alive) {
move_loop_->SetDragImage(gfx::ImageSkia(), gfx::Vector2dF()); move_loop_.SetDragImage(gfx::ImageSkia(), gfx::Vector2dF());
source_provider_ = NULL; source_provider_ = NULL;
g_current_drag_drop_client = NULL; g_current_drag_drop_client = NULL;
...@@ -660,7 +656,7 @@ void DesktopDragDropClientAuraX11::Drop(aura::Window* target, ...@@ -660,7 +656,7 @@ void DesktopDragDropClientAuraX11::Drop(aura::Window* target,
} }
void DesktopDragDropClientAuraX11::DragCancel() { void DesktopDragDropClientAuraX11::DragCancel() {
move_loop_->EndMoveLoop(); move_loop_.EndMoveLoop();
} }
bool DesktopDragDropClientAuraX11::IsDragDropInProgress() { bool DesktopDragDropClientAuraX11::IsDragDropInProgress() {
...@@ -683,7 +679,7 @@ void DesktopDragDropClientAuraX11::OnMouseReleased() { ...@@ -683,7 +679,7 @@ void DesktopDragDropClientAuraX11::OnMouseReleased() {
if (source_state_ != SOURCE_STATE_OTHER) { if (source_state_ != SOURCE_STATE_OTHER) {
// The user has previously released the mouse and is clicking in // The user has previously released the mouse and is clicking in
// frustration. // frustration.
move_loop_->EndMoveLoop(); move_loop_.EndMoveLoop();
return; return;
} }
...@@ -700,7 +696,7 @@ void DesktopDragDropClientAuraX11::OnMouseReleased() { ...@@ -700,7 +696,7 @@ void DesktopDragDropClientAuraX11::OnMouseReleased() {
return; return;
} }
move_loop_->EndMoveLoop(); move_loop_.EndMoveLoop();
return; return;
} }
...@@ -719,7 +715,7 @@ void DesktopDragDropClientAuraX11::OnMouseReleased() { ...@@ -719,7 +715,7 @@ void DesktopDragDropClientAuraX11::OnMouseReleased() {
} }
} }
move_loop_->EndMoveLoop(); move_loop_.EndMoveLoop();
} }
void DesktopDragDropClientAuraX11::OnMoveLoopEnded() { void DesktopDragDropClientAuraX11::OnMoveLoopEnded() {
...@@ -732,11 +728,6 @@ void DesktopDragDropClientAuraX11::OnMoveLoopEnded() { ...@@ -732,11 +728,6 @@ void DesktopDragDropClientAuraX11::OnMoveLoopEnded() {
end_move_loop_timer_.Stop(); end_move_loop_timer_.Stop();
} }
scoped_ptr<X11MoveLoop> DesktopDragDropClientAuraX11::CreateMoveLoop(
X11MoveLoopDelegate* delegate) {
return scoped_ptr<X11MoveLoop>(new X11WholeScreenMoveLoop(this));
}
XID DesktopDragDropClientAuraX11::FindWindowFor( XID DesktopDragDropClientAuraX11::FindWindowFor(
const gfx::Point& screen_point) { const gfx::Point& screen_point) {
views::X11TopmostWindowFinder finder; views::X11TopmostWindowFinder finder;
...@@ -841,7 +832,7 @@ void DesktopDragDropClientAuraX11::StartEndMoveLoopTimer() { ...@@ -841,7 +832,7 @@ void DesktopDragDropClientAuraX11::StartEndMoveLoopTimer() {
} }
void DesktopDragDropClientAuraX11::EndMoveLoop() { void DesktopDragDropClientAuraX11::EndMoveLoop() {
move_loop_->EndMoveLoop(); move_loop_.EndMoveLoop();
} }
void DesktopDragDropClientAuraX11::DragTranslate( void DesktopDragDropClientAuraX11::DragTranslate(
......
...@@ -18,7 +18,8 @@ ...@@ -18,7 +18,8 @@
#include "ui/gfx/point.h" #include "ui/gfx/point.h"
#include "ui/gfx/x/x11_atom_cache.h" #include "ui/gfx/x/x11_atom_cache.h"
#include "ui/views/views_export.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"
#include "ui/views/widget/desktop_aura/x11_whole_screen_move_loop_delegate.h"
#include "ui/wm/public/drag_drop_client.h" #include "ui/wm/public/drag_drop_client.h"
namespace aura { namespace aura {
...@@ -41,7 +42,6 @@ class SelectionFormatMap; ...@@ -41,7 +42,6 @@ class SelectionFormatMap;
namespace views { namespace views {
class DesktopNativeCursorManager; class DesktopNativeCursorManager;
class X11MoveLoop;
// Implements drag and drop on X11 for aura. On one side, this class takes raw // 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 // X11 events forwarded from DesktopWindowTreeHostLinux, while on the other, it
...@@ -49,7 +49,7 @@ class X11MoveLoop; ...@@ -49,7 +49,7 @@ class X11MoveLoop;
class VIEWS_EXPORT DesktopDragDropClientAuraX11 class VIEWS_EXPORT DesktopDragDropClientAuraX11
: public aura::client::DragDropClient, : public aura::client::DragDropClient,
public aura::WindowObserver, public aura::WindowObserver,
public X11MoveLoopDelegate { public X11WholeScreenMoveLoopDelegate {
public: public:
DesktopDragDropClientAuraX11( DesktopDragDropClientAuraX11(
aura::Window* root_window, aura::Window* root_window,
...@@ -63,8 +63,6 @@ class VIEWS_EXPORT DesktopDragDropClientAuraX11 ...@@ -63,8 +63,6 @@ class VIEWS_EXPORT DesktopDragDropClientAuraX11
// X11 messages to windows in our process. // X11 messages to windows in our process.
static DesktopDragDropClientAuraX11* GetForWindow(::Window window); static DesktopDragDropClientAuraX11* GetForWindow(::Window window);
void Init();
// These methods handle the various X11 client messages from the platform. // These methods handle the various X11 client messages from the platform.
void OnXdndEnter(const XClientMessageEvent& event); void OnXdndEnter(const XClientMessageEvent& event);
void OnXdndLeave(const XClientMessageEvent& event); void OnXdndLeave(const XClientMessageEvent& event);
...@@ -102,10 +100,6 @@ class VIEWS_EXPORT DesktopDragDropClientAuraX11 ...@@ -102,10 +100,6 @@ class VIEWS_EXPORT DesktopDragDropClientAuraX11
protected: protected:
// The following methods are virtual for the sake of testing. // The following methods are virtual for the sake of testing.
// Creates a move loop.
virtual scoped_ptr<X11MoveLoop> CreateMoveLoop(
X11MoveLoopDelegate* delegate);
// Finds the topmost X11 window at |screen_point| and returns it if it is // Finds the topmost X11 window at |screen_point| and returns it if it is
// Xdnd aware. Returns NULL otherwise. // Xdnd aware. Returns NULL otherwise.
virtual ::Window FindWindowFor(const gfx::Point& screen_point); virtual ::Window FindWindowFor(const gfx::Point& screen_point);
...@@ -184,8 +178,8 @@ class VIEWS_EXPORT DesktopDragDropClientAuraX11 ...@@ -184,8 +178,8 @@ class VIEWS_EXPORT DesktopDragDropClientAuraX11
void SendXdndDrop(::Window dest_window); void SendXdndDrop(::Window dest_window);
// A nested message loop that notifies this object of events through the // A nested message loop that notifies this object of events through the
// X11MoveLoopDelegate interface. // X11WholeScreenMoveLoopDelegate interface.
scoped_ptr<X11MoveLoop> move_loop_; X11WholeScreenMoveLoop move_loop_;
aura::Window* root_window_; aura::Window* root_window_;
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "ui/views/test/views_test_base.h" #include "ui/views/test/views_test_base.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h" #include "ui/aura/window_tree_host.h"
...@@ -22,7 +21,6 @@ ...@@ -22,7 +21,6 @@
#include "ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.h" #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_cursor_manager.h"
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.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" #include "ui/views/widget/widget.h"
#include <X11/Xlib.h> #include <X11/Xlib.h>
...@@ -75,34 +73,6 @@ class ClientMessageEventCollector { ...@@ -75,34 +73,6 @@ class ClientMessageEventCollector {
DISALLOW_COPY_AND_ASSIGN(ClientMessageEventCollector); DISALLOW_COPY_AND_ASSIGN(ClientMessageEventCollector);
}; };
// An implementation of X11MoveLoop where RunMoveLoop() always starts the move
// loop.
class TestMoveLoop : public X11MoveLoop {
public:
explicit TestMoveLoop(X11MoveLoopDelegate* delegate);
virtual ~TestMoveLoop();
// Returns true if the move loop is running.
bool IsRunning() const;
// X11MoveLoop:
virtual bool RunMoveLoop(aura::Window* window,
gfx::NativeCursor cursor) OVERRIDE;
virtual void UpdateCursor(gfx::NativeCursor cursor) OVERRIDE;
virtual void EndMoveLoop() OVERRIDE;
virtual void SetDragImage(const gfx::ImageSkia& image,
const gfx::Vector2dF& offset) OVERRIDE;
private:
// Not owned.
X11MoveLoopDelegate* delegate_;
// Ends the move loop.
base::Closure quit_closure_;
bool is_running_;
};
// Implementation of DesktopDragDropClientAuraX11 which works with a fake // Implementation of DesktopDragDropClientAuraX11 which works with a fake
// |DesktopDragDropClientAuraX11::source_current_window_|. // |DesktopDragDropClientAuraX11::source_current_window_|.
class TestDragDropClient : public DesktopDragDropClientAuraX11 { class TestDragDropClient : public DesktopDragDropClientAuraX11 {
...@@ -152,10 +122,18 @@ class TestDragDropClient : public DesktopDragDropClientAuraX11 { ...@@ -152,10 +122,18 @@ class TestDragDropClient : public DesktopDragDropClientAuraX11 {
// Returns true if the move loop is running. // Returns true if the move loop is running.
bool IsMoveLoopRunning(); bool IsMoveLoopRunning();
// DesktopDragDropClientAuraX11:
virtual int StartDragAndDrop(
const ui::OSExchangeData& data,
aura::Window* root_window,
aura::Window* source_window,
const gfx::Point& root_location,
int operation,
ui::DragDropTypes::DragEventSource source) OVERRIDE;
virtual void OnMoveLoopEnded() OVERRIDE;
private: private:
// DesktopDragDropClientAuraX11: // DesktopDragDropClientAuraX11:
virtual scoped_ptr<X11MoveLoop> CreateMoveLoop(
X11MoveLoopDelegate* delegate) OVERRIDE;
virtual ::Window FindWindowFor(const gfx::Point& screen_point) OVERRIDE; virtual ::Window FindWindowFor(const gfx::Point& screen_point) OVERRIDE;
virtual void SendXClientEvent(::Window xid, XEvent* event) OVERRIDE; virtual void SendXClientEvent(::Window xid, XEvent* event) OVERRIDE;
...@@ -166,8 +144,8 @@ class TestDragDropClient : public DesktopDragDropClientAuraX11 { ...@@ -166,8 +144,8 @@ class TestDragDropClient : public DesktopDragDropClientAuraX11 {
// current mouse position. // current mouse position.
::Window target_xid_; ::Window target_xid_;
// The move loop. Not owned. // Whether the move loop is running.
TestMoveLoop* loop_; bool move_loop_running_;
// Map of ::Windows to the collector which intercepts XClientMessageEvents // Map of ::Windows to the collector which intercepts XClientMessageEvents
// for that window. // for that window.
...@@ -204,46 +182,6 @@ void ClientMessageEventCollector::RecordEvent( ...@@ -204,46 +182,6 @@ void ClientMessageEventCollector::RecordEvent(
events_.push_back(event); events_.push_back(event);
} }
///////////////////////////////////////////////////////////////////////////////
// TestMoveLoop
TestMoveLoop::TestMoveLoop(X11MoveLoopDelegate* delegate)
: delegate_(delegate),
is_running_(false) {
}
TestMoveLoop::~TestMoveLoop() {
}
bool TestMoveLoop::IsRunning() const {
return is_running_;
}
bool TestMoveLoop::RunMoveLoop(
aura::Window* window,
gfx::NativeCursor cursor) {
is_running_ = true;
base::RunLoop run_loop;
quit_closure_ = run_loop.QuitClosure();
run_loop.Run();
return true;
}
void TestMoveLoop::UpdateCursor(gfx::NativeCursor cursor) {
}
void TestMoveLoop::EndMoveLoop() {
if (is_running_) {
delegate_->OnMoveLoopEnded();
is_running_ = false;
quit_closure_.Run();
}
}
void TestMoveLoop::SetDragImage(const gfx::ImageSkia& image,
const gfx::Vector2dF& offset) {
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// TestDragDropClient // TestDragDropClient
...@@ -262,7 +200,7 @@ TestDragDropClient::TestDragDropClient( ...@@ -262,7 +200,7 @@ TestDragDropClient::TestDragDropClient(
window->GetHost()->GetAcceleratedWidget()), window->GetHost()->GetAcceleratedWidget()),
source_xid_(window->GetHost()->GetAcceleratedWidget()), source_xid_(window->GetHost()->GetAcceleratedWidget()),
target_xid_(None), target_xid_(None),
loop_(NULL), move_loop_running_(false),
atom_cache_(gfx::GetXDisplay(), kAtomsToCache) { atom_cache_(gfx::GetXDisplay(), kAtomsToCache) {
} }
...@@ -328,13 +266,24 @@ void TestDragDropClient::SetTopmostXWindowAndMoveMouse(::Window xid) { ...@@ -328,13 +266,24 @@ void TestDragDropClient::SetTopmostXWindowAndMoveMouse(::Window xid) {
} }
bool TestDragDropClient::IsMoveLoopRunning() { bool TestDragDropClient::IsMoveLoopRunning() {
return loop_->IsRunning(); return move_loop_running_;
}
int TestDragDropClient::StartDragAndDrop(
const ui::OSExchangeData& data,
aura::Window* root_window,
aura::Window* source_window,
const gfx::Point& root_location,
int operation,
ui::DragDropTypes::DragEventSource source) {
move_loop_running_ = true;
return DesktopDragDropClientAuraX11::StartDragAndDrop(data, root_window,
source_window, root_location, operation, source);
} }
scoped_ptr<X11MoveLoop> TestDragDropClient::CreateMoveLoop( void TestDragDropClient::OnMoveLoopEnded() {
X11MoveLoopDelegate* delegate) { DesktopDragDropClientAuraX11::OnMoveLoopEnded();
loop_ = new TestMoveLoop(delegate); move_loop_running_ = false;
return scoped_ptr<X11MoveLoop>(loop_);
} }
::Window TestDragDropClient::FindWindowFor(const gfx::Point& screen_point) { ::Window TestDragDropClient::FindWindowFor(const gfx::Point& screen_point) {
...@@ -389,7 +338,6 @@ class DesktopDragDropClientAuraX11Test : public ViewsTestBase { ...@@ -389,7 +338,6 @@ class DesktopDragDropClientAuraX11Test : public ViewsTestBase {
client_.reset(new TestDragDropClient(widget_->GetNativeWindow(), client_.reset(new TestDragDropClient(widget_->GetNativeWindow(),
cursor_manager_.get())); cursor_manager_.get()));
client_->Init();
} }
virtual void TearDown() OVERRIDE { virtual void TearDown() OVERRIDE {
......
...@@ -291,7 +291,6 @@ DesktopWindowTreeHostX11::CreateDragDropClient( ...@@ -291,7 +291,6 @@ DesktopWindowTreeHostX11::CreateDragDropClient(
DesktopNativeCursorManager* cursor_manager) { DesktopNativeCursorManager* cursor_manager) {
drag_drop_client_ = new DesktopDragDropClientAuraX11( drag_drop_client_ = new DesktopDragDropClientAuraX11(
window(), cursor_manager, xdisplay_, xwindow_); window(), cursor_manager, xdisplay_, xwindow_);
drag_drop_client_->Init();
return scoped_ptr<aura::client::DragDropClient>(drag_drop_client_).Pass(); return scoped_ptr<aura::client::DragDropClient>(drag_drop_client_).Pass();
} }
......
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "ui/gfx/point.h" #include "ui/gfx/point.h"
#include "ui/views/views_export.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" #include "ui/views/widget/desktop_aura/x11_whole_screen_move_loop.h"
#include "ui/views/widget/desktop_aura/x11_whole_screen_move_loop_delegate.h"
#include "ui/wm/public/window_move_client.h" #include "ui/wm/public/window_move_client.h"
namespace aura { namespace aura {
...@@ -24,7 +24,7 @@ namespace views { ...@@ -24,7 +24,7 @@ namespace views {
// When we're dragging tabs, we need to manually position our window. // When we're dragging tabs, we need to manually position our window.
class VIEWS_EXPORT X11DesktopWindowMoveClient : class VIEWS_EXPORT X11DesktopWindowMoveClient :
public views::X11MoveLoopDelegate, public views::X11WholeScreenMoveLoopDelegate,
public aura::client::WindowMoveClient { public aura::client::WindowMoveClient {
public: public:
X11DesktopWindowMoveClient(); X11DesktopWindowMoveClient();
......
// Copyright 2014 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.
#ifndef UI_VIEWS_WIDGET_DESKTOP_AURA_X11_MOVE_LOOP_H_
#define UI_VIEWS_WIDGET_DESKTOP_AURA_X11_MOVE_LOOP_H_
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/x/x11_types.h"
namespace views {
// Runs a nested message loop and grabs the mouse. This is used to implement
// dragging.
class X11MoveLoop {
public:
virtual ~X11MoveLoop() {}
// Runs the nested message loop. While the mouse is grabbed, use |cursor| as
// the mouse cursor. Returns true if the move-loop is completed successfully.
// If the pointer-grab fails, or the move-loop is canceled by the user (e.g.
// by pressing escape), then returns false.
virtual bool RunMoveLoop(aura::Window* window, gfx::NativeCursor cursor) = 0;
// Updates the cursor while the move loop is running.
virtual void UpdateCursor(gfx::NativeCursor cursor) = 0;
// Ends the RunMoveLoop() that's currently in progress.
virtual void EndMoveLoop() = 0;
// Sets an image to be used during the drag.
virtual void SetDragImage(const gfx::ImageSkia& image,
const gfx::Vector2dF& offset) = 0;
};
} // namespace views
#endif // UI_VIEWS_WIDGET_DESKTOP_AURA_X11_MOVE_LOOP_H_
...@@ -55,7 +55,8 @@ class ScopedCapturer { ...@@ -55,7 +55,8 @@ class ScopedCapturer {
} // namespace } // namespace
X11WholeScreenMoveLoop::X11WholeScreenMoveLoop(X11MoveLoopDelegate* delegate) X11WholeScreenMoveLoop::X11WholeScreenMoveLoop(
X11WholeScreenMoveLoopDelegate* delegate)
: delegate_(delegate), : delegate_(delegate),
in_move_loop_(false), in_move_loop_(false),
should_reset_mouse_flags_(false), should_reset_mouse_flags_(false),
...@@ -276,7 +277,7 @@ void X11WholeScreenMoveLoop::EndMoveLoop() { ...@@ -276,7 +277,7 @@ void X11WholeScreenMoveLoop::EndMoveLoop() {
} }
void X11WholeScreenMoveLoop::SetDragImage(const gfx::ImageSkia& image, void X11WholeScreenMoveLoop::SetDragImage(const gfx::ImageSkia& image,
const gfx::Vector2dF& offset) { gfx::Vector2dF offset) {
drag_image_ = image; drag_image_ = image;
drag_offset_ = offset; drag_offset_ = offset;
} }
......
...@@ -12,8 +12,7 @@ ...@@ -12,8 +12,7 @@
#include "ui/gfx/image/image_skia.h" #include "ui/gfx/image/image_skia.h"
#include "ui/gfx/native_widget_types.h" #include "ui/gfx/native_widget_types.h"
#include "ui/gfx/vector2d_f.h" #include "ui/gfx/vector2d_f.h"
#include "ui/views/widget/desktop_aura/x11_move_loop.h" #include "ui/views/widget/desktop_aura/x11_whole_screen_move_loop_delegate.h"
#include "ui/views/widget/desktop_aura/x11_move_loop_delegate.h"
typedef struct _XDisplay XDisplay; typedef struct _XDisplay XDisplay;
...@@ -31,23 +30,29 @@ class Widget; ...@@ -31,23 +30,29 @@ class Widget;
// Runs a nested message loop and grabs the mouse. This is used to implement // Runs a nested message loop and grabs the mouse. This is used to implement
// dragging. // dragging.
class X11WholeScreenMoveLoop : public X11MoveLoop, class X11WholeScreenMoveLoop : public ui::PlatformEventDispatcher {
public ui::PlatformEventDispatcher {
public: public:
explicit X11WholeScreenMoveLoop(X11MoveLoopDelegate* delegate); explicit X11WholeScreenMoveLoop(X11WholeScreenMoveLoopDelegate* delegate);
virtual ~X11WholeScreenMoveLoop(); virtual ~X11WholeScreenMoveLoop();
// ui:::PlatformEventDispatcher: // ui:::PlatformEventDispatcher:
virtual bool CanDispatchEvent(const ui::PlatformEvent& event) OVERRIDE; virtual bool CanDispatchEvent(const ui::PlatformEvent& event) OVERRIDE;
virtual uint32_t DispatchEvent(const ui::PlatformEvent& event) OVERRIDE; virtual uint32_t DispatchEvent(const ui::PlatformEvent& event) OVERRIDE;
// X11MoveLoop: // Runs the nested message loop. While the mouse is grabbed, use |cursor| as
virtual bool RunMoveLoop(aura::Window* window, // the mouse cursor. Returns true if the move-loop is completed successfully.
gfx::NativeCursor cursor) OVERRIDE; // If the pointer-grab fails, or the move-loop is canceled by the user (e.g.
virtual void UpdateCursor(gfx::NativeCursor cursor) OVERRIDE; // by pressing escape), then returns false.
virtual void EndMoveLoop() OVERRIDE; bool RunMoveLoop(aura::Window* window, gfx::NativeCursor cursor);
virtual void SetDragImage(const gfx::ImageSkia& image,
const gfx::Vector2dF& offset) OVERRIDE; // Updates the cursor while the move loop is running.
void UpdateCursor(gfx::NativeCursor cursor);
// Ends the RunMoveLoop() that's currently in progress.
void EndMoveLoop();
// Sets an image to be used during the drag.
void SetDragImage(const gfx::ImageSkia& image, gfx::Vector2dF offset);
private: private:
// Grabs the pointer and keyboard, setting the mouse cursor to |cursor|. // Grabs the pointer and keyboard, setting the mouse cursor to |cursor|.
...@@ -67,7 +72,7 @@ class X11WholeScreenMoveLoop : public X11MoveLoop, ...@@ -67,7 +72,7 @@ class X11WholeScreenMoveLoop : public X11MoveLoop,
// Dispatch mouse movement event to |delegate_| in a posted task. // Dispatch mouse movement event to |delegate_| in a posted task.
void DispatchMouseMovement(); void DispatchMouseMovement();
X11MoveLoopDelegate* delegate_; X11WholeScreenMoveLoopDelegate* delegate_;
// Are we running a nested message loop from RunMoveLoop()? // Are we running a nested message loop from RunMoveLoop()?
bool in_move_loop_; bool in_move_loop_;
......
...@@ -2,15 +2,18 @@ ...@@ -2,15 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef UI_VIEWS_WIDGET_DESKTOP_AURA_X11_MOVE_LOOP_DELEGATE_H_ #ifndef UI_VIEWS_WIDGET_DESKTOP_AURA_X11_WHOLE_SCREEN_MOVE_LOOP_DELEGATE_H_
#define UI_VIEWS_WIDGET_DESKTOP_AURA_X11_MOVE_LOOP_DELEGATE_H_ #define UI_VIEWS_WIDGET_DESKTOP_AURA_X11_WHOLE_SCREEN_MOVE_LOOP_DELEGATE_H_
#include <X11/Xlib.h> #include <X11/Xlib.h>
// Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class.
#undef RootWindow
namespace views { namespace views {
// Receives mouse events while the X11MoveLoop is tracking a drag. // Receives mouse events while the X11WholeScreenMoveLoop is tracking a drag on
class X11MoveLoopDelegate { // the screen.
class X11WholeScreenMoveLoopDelegate {
public: public:
// Called when we receive a motion event. // Called when we receive a motion event.
virtual void OnMouseMovement(XMotionEvent* event) = 0; virtual void OnMouseMovement(XMotionEvent* event) = 0;
...@@ -25,4 +28,4 @@ class X11MoveLoopDelegate { ...@@ -25,4 +28,4 @@ class X11MoveLoopDelegate {
} // namespace views } // namespace views
#endif // UI_VIEWS_WIDGET_DESKTOP_AURA_X11_MOVE_LOOP_DELEGATE_H_ #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_X11_WHOLE_SCREEN_MOVE_LOOP_DELEGATE_H_
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