Commit dc645d50 authored by sadrul@chromium.org's avatar sadrul@chromium.org

aura: Remove WindowTreeHost::QueryMouseLocation().

The primary use-case for QueryMouseLocation() is for X11 interactive
tests. The only other use was in WindowEventDispatcher, but that code
is no longer necessary.

BUG=none
R=sky@chromium.org

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@266565 0039d316-1c4b-4281-b951-d872f2087c98
parent 3ecf6982
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "ui/aura/client/aura_constants.h" #include "ui/aura/client/aura_constants.h"
#include "ui/aura/env.h" #include "ui/aura/env.h"
#include "ui/aura/test/aura_test_utils.h"
#include "ui/aura/test/event_generator.h" #include "ui/aura/test/event_generator.h"
#include "ui/aura/window_tree_host.h" #include "ui/aura/window_tree_host.h"
#include "ui/gfx/rect_conversions.h" #include "ui/gfx/rect_conversions.h"
...@@ -53,9 +54,10 @@ class MagnificationControllerTest: public test::AshTestBase { ...@@ -53,9 +54,10 @@ class MagnificationControllerTest: public test::AshTestBase {
} }
std::string GetHostMouseLocation() { std::string GetHostMouseLocation() {
gfx::Point point; const gfx::Point& location =
GetRootWindow()->GetHost()->QueryMouseLocation(&point); aura::test::QueryLatestMousePositionRequestInHost(
return point.ToString(); GetRootWindow()->GetHost());
return location.ToString();
} }
ash::MagnificationController* GetMagnificationController() const { ash::MagnificationController* GetMagnificationController() const {
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "ash/test/ash_test_base.h" #include "ash/test/ash_test_base.h"
#include "ash/test/cursor_manager_test_api.h" #include "ash/test/cursor_manager_test_api.h"
#include "ash/wm/image_cursors.h" #include "ash/wm/image_cursors.h"
#include "ui/aura/test/aura_test_utils.h"
#include "ui/aura/test/test_window_delegate.h" #include "ui/aura/test/test_window_delegate.h"
#include "ui/aura/test/test_windows.h" #include "ui/aura/test/test_windows.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
...@@ -174,35 +175,5 @@ TEST_F(AshNativeCursorManagerTest, UIScaleShouldNotChangeCursor) { ...@@ -174,35 +175,5 @@ TEST_F(AshNativeCursorManagerTest, UIScaleShouldNotChangeCursor) {
EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor()); EXPECT_EQ(2.0f, test_api.GetCurrentCursor().device_scale_factor());
} }
TEST_F(AshNativeCursorManagerTest, DisabledQueryMouseLocation) {
aura::Window* root_window = Shell::GetInstance()->GetPrimaryRootWindow();
#if defined(OS_WIN)
if (base::win::GetVersion() < base::win::VERSION_WIN8)
return;
// On Windows 8 the ASH environment has two processes, the viewer process
// which runs in Windows 8 mode and the browser process. The initialization
// happens when the viewer process connects to the browser channel and sends
// the initial IPC message.
RunAllPendingInMessageLoop();
#endif
root_window->MoveCursorTo(gfx::Point(10, 10));
#if defined(OS_WIN)
// The MoveCursor operation on Windows 8 is implemented in the viewer process
// which is notified by an IPC message to perform the MoveCursor operation.
// We need to ensure that the IPC is delivered to the viewer process and it
// the ACK is sent back from the viewer indicating that the operation
// completed.
Sleep(100);
RunAllPendingInMessageLoop();
#endif
aura::WindowTreeHost* host = root_window->GetHost();
gfx::Point mouse_location;
EXPECT_TRUE(host->QueryMouseLocation(&mouse_location));
EXPECT_EQ("10,10", mouse_location.ToString());
Shell::GetInstance()->cursor_manager()->DisableMouseEvents();
EXPECT_FALSE(host->QueryMouseLocation(&mouse_location));
EXPECT_EQ("0,0", mouse_location.ToString());
}
} // namespace test } // namespace test
} // namespace ash } // namespace ash
...@@ -96,11 +96,6 @@ void WindowTreeHostMojo::ReleaseCapture() { ...@@ -96,11 +96,6 @@ void WindowTreeHostMojo::ReleaseCapture() {
NOTIMPLEMENTED(); NOTIMPLEMENTED();
} }
bool WindowTreeHostMojo::QueryMouseLocation(gfx::Point* location_return) {
NOTIMPLEMENTED() << "QueryMouseLocation";
return false;
}
void WindowTreeHostMojo::PostNativeEvent( void WindowTreeHostMojo::PostNativeEvent(
const base::NativeEvent& native_event) { const base::NativeEvent& native_event) {
NOTIMPLEMENTED(); NOTIMPLEMENTED();
......
...@@ -42,7 +42,6 @@ class WindowTreeHostMojo : public aura::WindowTreeHost, ...@@ -42,7 +42,6 @@ class WindowTreeHostMojo : public aura::WindowTreeHost,
virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE; virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE;
virtual void SetCapture() OVERRIDE; virtual void SetCapture() OVERRIDE;
virtual void ReleaseCapture() OVERRIDE; virtual void ReleaseCapture() OVERRIDE;
virtual bool QueryMouseLocation(gfx::Point* location_return) OVERRIDE;
virtual void PostNativeEvent(const base::NativeEvent& native_event) OVERRIDE; virtual void PostNativeEvent(const base::NativeEvent& native_event) OVERRIDE;
virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE; virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
virtual void SetCursorNative(gfx::NativeCursor cursor) OVERRIDE; virtual void SetCursorNative(gfx::NativeCursor cursor) OVERRIDE;
......
...@@ -160,6 +160,8 @@ ...@@ -160,6 +160,8 @@
'test/aura_test_base.h', 'test/aura_test_base.h',
'test/aura_test_helper.cc', 'test/aura_test_helper.cc',
'test/aura_test_helper.h', 'test/aura_test_helper.h',
'test/aura_test_utils.cc',
'test/aura_test_utils.h',
'test/env_test_helper.h', 'test/env_test_helper.h',
'test/event_generator.cc', 'test/event_generator.cc',
'test/event_generator.h', 'test/event_generator.h',
......
...@@ -414,20 +414,6 @@ void RemoteWindowTreeHostWin::SetCapture() { ...@@ -414,20 +414,6 @@ void RemoteWindowTreeHostWin::SetCapture() {
void RemoteWindowTreeHostWin::ReleaseCapture() { void RemoteWindowTreeHostWin::ReleaseCapture() {
} }
bool RemoteWindowTreeHostWin::QueryMouseLocation(gfx::Point* location_return) {
aura::client::CursorClient* cursor_client =
aura::client::GetCursorClient(window());
if (cursor_client && !cursor_client->IsMouseEventsEnabled()) {
*location_return = gfx::Point(0, 0);
return false;
}
POINT pt;
GetCursorPos(&pt);
*location_return =
gfx::Point(static_cast<int>(pt.x), static_cast<int>(pt.y));
return true;
}
void RemoteWindowTreeHostWin::SetCursorNative(gfx::NativeCursor native_cursor) { void RemoteWindowTreeHostWin::SetCursorNative(gfx::NativeCursor native_cursor) {
if (!host_) if (!host_)
return; return;
......
...@@ -231,7 +231,6 @@ class AURA_EXPORT RemoteWindowTreeHostWin ...@@ -231,7 +231,6 @@ class AURA_EXPORT RemoteWindowTreeHostWin
virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE; virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE;
virtual void SetCapture() OVERRIDE; virtual void SetCapture() OVERRIDE;
virtual void ReleaseCapture() OVERRIDE; virtual void ReleaseCapture() OVERRIDE;
virtual bool QueryMouseLocation(gfx::Point* location_return) OVERRIDE;
virtual void PostNativeEvent(const base::NativeEvent& native_event) OVERRIDE; virtual void PostNativeEvent(const base::NativeEvent& native_event) OVERRIDE;
virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE; virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
virtual void SetCursorNative(gfx::NativeCursor cursor) OVERRIDE; virtual void SetCursorNative(gfx::NativeCursor cursor) OVERRIDE;
......
// 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.
#include "ui/aura/test/aura_test_utils.h"
#include "ui/aura/window_tree_host.h"
namespace aura {
namespace test {
class WindowTreeHostTestApi {
public:
explicit WindowTreeHostTestApi(WindowTreeHost* host) : host_(host) {}
const gfx::Point& last_cursor_request_position_in_host() {
return host_->last_cursor_request_position_in_host_;
}
private:
WindowTreeHost* host_;
DISALLOW_COPY_AND_ASSIGN(WindowTreeHostTestApi);
};
const gfx::Point& QueryLatestMousePositionRequestInHost(WindowTreeHost* host) {
WindowTreeHostTestApi host_test_api(host);
return host_test_api.last_cursor_request_position_in_host();
}
} // namespace test
} // namespace aura
// 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_AURA_TEST_AURA_TEST_UTILS_H_
#define UI_AURA_TEST_AURA_TEST_UTILS_H_
#include "base/macros.h"
namespace gfx {
class Point;
}
namespace aura {
class WindowTreeHost;
namespace test {
const gfx::Point& QueryLatestMousePositionRequestInHost(WindowTreeHost* host);
} // namespace test
} // namespace aura
#endif // UI_AURA_TEST_AURA_TEST_UTILS_H_
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/logging.h" #include "base/logging.h"
#include "ui/aura/client/screen_position_client.h" #include "ui/aura/client/screen_position_client.h"
#include "ui/aura/env.h" #include "ui/aura/env.h"
#include "ui/aura/test/aura_test_utils.h"
#include "ui/aura/test/ui_controls_factory_aura.h" #include "ui/aura/test/ui_controls_factory_aura.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"
...@@ -109,8 +110,8 @@ class UIControlsX11 : public UIControlsAura { ...@@ -109,8 +110,8 @@ class UIControlsX11 : public UIControlsAura {
screen_position_client->ConvertPointFromScreen(host_->window(), screen_position_client->ConvertPointFromScreen(host_->window(),
&root_location); &root_location);
} }
gfx::Point root_current_location; gfx::Point root_current_location =
host_->QueryMouseLocation(&root_current_location); QueryLatestMousePositionRequestInHost(host_);
host_->ConvertPointFromHost(&root_current_location); host_->ConvertPointFromHost(&root_current_location);
if (root_location != root_current_location && button_down_mask == 0) { if (root_location != root_current_location && button_down_mask == 0) {
......
...@@ -584,13 +584,6 @@ void WindowEventDispatcher::OnWindowBoundsChanged(Window* window, ...@@ -584,13 +584,6 @@ void WindowEventDispatcher::OnWindowBoundsChanged(Window* window,
if (details.dispatcher_destroyed) if (details.dispatcher_destroyed)
return; return;
// Constrain the mouse position within the new root Window size.
gfx::Point point;
if (host_->QueryMouseLocation(&point)) {
SetLastMouseLocation(
host_->window(),
ui::ConvertPointToDIP(host_->window()->layer(), point));
}
synthesize_mouse_move_ = false; synthesize_mouse_move_ = false;
} }
......
...@@ -257,6 +257,7 @@ void WindowTreeHost::OnHostLostWindowCapture() { ...@@ -257,6 +257,7 @@ void WindowTreeHost::OnHostLostWindowCapture() {
void WindowTreeHost::MoveCursorToInternal(const gfx::Point& root_location, void WindowTreeHost::MoveCursorToInternal(const gfx::Point& root_location,
const gfx::Point& host_location) { const gfx::Point& host_location) {
last_cursor_request_position_in_host_ = host_location;
MoveCursorToNative(host_location); MoveCursorToNative(host_location);
client::CursorClient* cursor_client = client::GetCursorClient(window()); client::CursorClient* cursor_client = client::GetCursorClient(window());
if (cursor_client) { if (cursor_client) {
......
...@@ -29,6 +29,10 @@ class ViewProp; ...@@ -29,6 +29,10 @@ class ViewProp;
} }
namespace aura { namespace aura {
namespace test {
class WindowTreeHostTestApi;
}
class WindowEventDispatcher; class WindowEventDispatcher;
class WindowTreeHostObserver; class WindowTreeHostObserver;
...@@ -135,14 +139,6 @@ class AURA_EXPORT WindowTreeHost { ...@@ -135,14 +139,6 @@ class AURA_EXPORT WindowTreeHost {
// Releases OS capture of the root window. // Releases OS capture of the root window.
virtual void ReleaseCapture() = 0; virtual void ReleaseCapture() = 0;
// Queries the mouse's current position relative to the host window and sets
// it in |location_return|. Returns true if the cursor is within the host
// window. The position set to |location_return| is constrained within the
// host window. If the cursor is disabled, returns false and (0, 0) is set to
// |location_return|.
// This method is expensive, instead use gfx::Screen::GetCursorScreenPoint().
virtual bool QueryMouseLocation(gfx::Point* location_return) = 0;
// Posts |native_event| to the platform's event queue. // Posts |native_event| to the platform's event queue.
virtual void PostNativeEvent(const base::NativeEvent& native_event) = 0; virtual void PostNativeEvent(const base::NativeEvent& native_event) = 0;
...@@ -177,6 +173,8 @@ class AURA_EXPORT WindowTreeHost { ...@@ -177,6 +173,8 @@ class AURA_EXPORT WindowTreeHost {
virtual void OnCursorVisibilityChangedNative(bool show) = 0; virtual void OnCursorVisibilityChangedNative(bool show) = 0;
private: private:
friend class test::WindowTreeHostTestApi;
// Moves the cursor to the specified location. This method is internally used // Moves the cursor to the specified location. This method is internally used
// by MoveCursorTo() and MoveCursorToHostLocation(). // by MoveCursorTo() and MoveCursorToHostLocation().
void MoveCursorToInternal(const gfx::Point& root_location, void MoveCursorToInternal(const gfx::Point& root_location,
...@@ -196,6 +194,7 @@ class AURA_EXPORT WindowTreeHost { ...@@ -196,6 +194,7 @@ class AURA_EXPORT WindowTreeHost {
// Last cursor set. Used for testing. // Last cursor set. Used for testing.
gfx::NativeCursor last_cursor_; gfx::NativeCursor last_cursor_;
gfx::Point last_cursor_request_position_in_host_;
scoped_ptr<ui::ViewProp> prop_; scoped_ptr<ui::ViewProp> prop_;
......
...@@ -42,7 +42,6 @@ class AURA_EXPORT WindowTreeHostMac : public WindowTreeHost { ...@@ -42,7 +42,6 @@ class AURA_EXPORT WindowTreeHostMac : public WindowTreeHost {
virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE; virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE;
virtual void SetCapture() OVERRIDE; virtual void SetCapture() OVERRIDE;
virtual void ReleaseCapture() OVERRIDE; virtual void ReleaseCapture() OVERRIDE;
virtual bool QueryMouseLocation(gfx::Point* location_return) OVERRIDE;
virtual bool ConfineCursorToRootWindow() OVERRIDE; virtual bool ConfineCursorToRootWindow() OVERRIDE;
virtual void UnConfineCursor() OVERRIDE; virtual void UnConfineCursor() OVERRIDE;
virtual void SetCursorNative(gfx::NativeCursor cursor_type) OVERRIDE; virtual void SetCursorNative(gfx::NativeCursor cursor_type) OVERRIDE;
......
...@@ -72,11 +72,6 @@ void WindowTreeHostMac::ReleaseCapture() { ...@@ -72,11 +72,6 @@ void WindowTreeHostMac::ReleaseCapture() {
NOTIMPLEMENTED(); NOTIMPLEMENTED();
} }
bool WindowTreeHostMac::QueryMouseLocation(gfx::Point* location_return) {
NOTIMPLEMENTED();
return false;
}
bool WindowTreeHostMac::ConfineCursorToRootWindow() { bool WindowTreeHostMac::ConfineCursorToRootWindow() {
return false; return false;
} }
......
...@@ -83,11 +83,6 @@ void WindowTreeHostOzone::SetCapture() { NOTIMPLEMENTED(); } ...@@ -83,11 +83,6 @@ void WindowTreeHostOzone::SetCapture() { NOTIMPLEMENTED(); }
void WindowTreeHostOzone::ReleaseCapture() { NOTIMPLEMENTED(); } void WindowTreeHostOzone::ReleaseCapture() { NOTIMPLEMENTED(); }
bool WindowTreeHostOzone::QueryMouseLocation(gfx::Point* location_return) {
NOTIMPLEMENTED();
return false;
}
void WindowTreeHostOzone::PostNativeEvent( void WindowTreeHostOzone::PostNativeEvent(
const base::NativeEvent& native_event) { const base::NativeEvent& native_event) {
NOTIMPLEMENTED(); NOTIMPLEMENTED();
......
...@@ -38,7 +38,6 @@ class AURA_EXPORT WindowTreeHostOzone : public WindowTreeHost, ...@@ -38,7 +38,6 @@ class AURA_EXPORT WindowTreeHostOzone : public WindowTreeHost,
virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE; virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE;
virtual void SetCapture() OVERRIDE; virtual void SetCapture() OVERRIDE;
virtual void ReleaseCapture() OVERRIDE; virtual void ReleaseCapture() OVERRIDE;
virtual bool QueryMouseLocation(gfx::Point* location_return) OVERRIDE;
virtual void PostNativeEvent(const base::NativeEvent& event) OVERRIDE; virtual void PostNativeEvent(const base::NativeEvent& event) OVERRIDE;
virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE; virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
virtual void SetCursorNative(gfx::NativeCursor cursor_type) OVERRIDE; virtual void SetCursorNative(gfx::NativeCursor cursor_type) OVERRIDE;
......
...@@ -126,24 +126,6 @@ void WindowTreeHostWin::ReleaseCapture() { ...@@ -126,24 +126,6 @@ void WindowTreeHostWin::ReleaseCapture() {
} }
} }
bool WindowTreeHostWin::QueryMouseLocation(gfx::Point* location_return) {
client::CursorClient* cursor_client = client::GetCursorClient(window());
if (cursor_client && !cursor_client->IsMouseEventsEnabled()) {
*location_return = gfx::Point(0, 0);
return false;
}
POINT pt;
GetCursorPos(&pt);
ScreenToClient(hwnd(), &pt);
const gfx::Size size = GetBounds().size();
*location_return =
gfx::Point(max(0, min(size.width(), static_cast<int>(pt.x))),
max(0, min(size.height(), static_cast<int>(pt.y))));
return (pt.x >= 0 && static_cast<int>(pt.x) < size.width() &&
pt.y >= 0 && static_cast<int>(pt.y) < size.height());
}
void WindowTreeHostWin::SetCursorNative(gfx::NativeCursor native_cursor) { void WindowTreeHostWin::SetCursorNative(gfx::NativeCursor native_cursor) {
// Custom web cursors are handled directly. // Custom web cursors are handled directly.
if (native_cursor == ui::kCursorCustom) if (native_cursor == ui::kCursorCustom)
......
...@@ -29,7 +29,6 @@ class AURA_EXPORT WindowTreeHostWin : public WindowTreeHost, ...@@ -29,7 +29,6 @@ class AURA_EXPORT WindowTreeHostWin : public WindowTreeHost,
virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE; virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE;
virtual void SetCapture() OVERRIDE; virtual void SetCapture() OVERRIDE;
virtual void ReleaseCapture() OVERRIDE; virtual void ReleaseCapture() OVERRIDE;
virtual bool QueryMouseLocation(gfx::Point* location_return) OVERRIDE;
virtual void SetCursorNative(gfx::NativeCursor cursor) OVERRIDE; virtual void SetCursorNative(gfx::NativeCursor cursor) OVERRIDE;
virtual void MoveCursorToNative(const gfx::Point& location) OVERRIDE; virtual void MoveCursorToNative(const gfx::Point& location) OVERRIDE;
virtual void OnCursorVisibilityChangedNative(bool show) OVERRIDE; virtual void OnCursorVisibilityChangedNative(bool show) OVERRIDE;
......
...@@ -438,30 +438,6 @@ void WindowTreeHostX11::ReleaseCapture() { ...@@ -438,30 +438,6 @@ void WindowTreeHostX11::ReleaseCapture() {
// TODO(oshima): Release x input. // TODO(oshima): Release x input.
} }
bool WindowTreeHostX11::QueryMouseLocation(gfx::Point* location_return) {
client::CursorClient* cursor_client =
client::GetCursorClient(window());
if (cursor_client && !cursor_client->IsMouseEventsEnabled()) {
*location_return = gfx::Point(0, 0);
return false;
}
::Window root_return, child_return;
int root_x_return, root_y_return, win_x_return, win_y_return;
unsigned int mask_return;
XQueryPointer(xdisplay_,
xwindow_,
&root_return,
&child_return,
&root_x_return, &root_y_return,
&win_x_return, &win_y_return,
&mask_return);
*location_return = gfx::Point(max(0, min(bounds_.width(), win_x_return)),
max(0, min(bounds_.height(), win_y_return)));
return (win_x_return >= 0 && win_x_return < bounds_.width() &&
win_y_return >= 0 && win_y_return < bounds_.height());
}
void WindowTreeHostX11::PostNativeEvent( void WindowTreeHostX11::PostNativeEvent(
const base::NativeEvent& native_event) { const base::NativeEvent& native_event) {
DCHECK(xwindow_); DCHECK(xwindow_);
......
...@@ -51,7 +51,6 @@ class AURA_EXPORT WindowTreeHostX11 : public WindowTreeHost, ...@@ -51,7 +51,6 @@ class AURA_EXPORT WindowTreeHostX11 : public WindowTreeHost,
virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE; virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE;
virtual void SetCapture() OVERRIDE; virtual void SetCapture() OVERRIDE;
virtual void ReleaseCapture() OVERRIDE; virtual void ReleaseCapture() OVERRIDE;
virtual bool QueryMouseLocation(gfx::Point* location_return) OVERRIDE;
virtual void PostNativeEvent(const base::NativeEvent& event) OVERRIDE; virtual void PostNativeEvent(const base::NativeEvent& event) OVERRIDE;
virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE; virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
virtual void SetCursorNative(gfx::NativeCursor cursor_type) OVERRIDE; virtual void SetCursorNative(gfx::NativeCursor cursor_type) OVERRIDE;
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "ui/aura/client/visibility_client.h" #include "ui/aura/client/visibility_client.h"
#include "ui/aura/client/window_tree_client.h" #include "ui/aura/client/window_tree_client.h"
#include "ui/aura/test/aura_test_base.h" #include "ui/aura/test/aura_test_base.h"
#include "ui/aura/test/aura_test_utils.h"
#include "ui/aura/test/event_generator.h" #include "ui/aura/test/event_generator.h"
#include "ui/aura/test/test_window_delegate.h" #include "ui/aura/test/test_window_delegate.h"
#include "ui/aura/test/test_windows.h" #include "ui/aura/test/test_windows.h"
...@@ -373,10 +374,8 @@ TEST_F(WindowTest, MoveCursorToWithTransformRootWindow) { ...@@ -373,10 +374,8 @@ TEST_F(WindowTest, MoveCursorToWithTransformRootWindow) {
host()->SetRootTransform(transform); host()->SetRootTransform(transform);
host()->MoveCursorTo(gfx::Point(10, 10)); host()->MoveCursorTo(gfx::Point(10, 10));
#if !defined(OS_WIN) #if !defined(OS_WIN)
gfx::Point mouse_location;
EXPECT_TRUE(host()->QueryMouseLocation(&mouse_location));
// TODO(yoshiki): fix this to build on Windows. See crbug.com/133413.OD // TODO(yoshiki): fix this to build on Windows. See crbug.com/133413.OD
EXPECT_EQ("50,120", mouse_location.ToString()); EXPECT_EQ("50,120", QueryLatestMousePositionRequestInHost(host()).ToString());
#endif #endif
EXPECT_EQ("10,10", gfx::Screen::GetScreenFor( EXPECT_EQ("10,10", gfx::Screen::GetScreenFor(
root_window())->GetCursorScreenPoint().ToString()); root_window())->GetCursorScreenPoint().ToString());
...@@ -461,9 +460,7 @@ TEST_F(WindowTest, MoveCursorToWithComplexTransform) { ...@@ -461,9 +460,7 @@ TEST_F(WindowTest, MoveCursorToWithComplexTransform) {
#if !defined(OS_WIN) #if !defined(OS_WIN)
// TODO(yoshiki): fix this to build on Windows. See crbug.com/133413. // TODO(yoshiki): fix this to build on Windows. See crbug.com/133413.
gfx::Point mouse_location; EXPECT_EQ("169,80", QueryLatestMousePositionRequestInHost(host()).ToString());
EXPECT_TRUE(host()->QueryMouseLocation(&mouse_location));
EXPECT_EQ("169,80", mouse_location.ToString());
#endif #endif
EXPECT_EQ("20,53", EXPECT_EQ("20,53",
gfx::Screen::GetScreenFor(root)->GetCursorScreenPoint().ToString()); gfx::Screen::GetScreenFor(root)->GetCursorScreenPoint().ToString());
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "base/logging.h" #include "base/logging.h"
#include "ui/aura/client/screen_position_client.h" #include "ui/aura/client/screen_position_client.h"
#include "ui/aura/env.h" #include "ui/aura/env.h"
#include "ui/aura/test/aura_test_utils.h"
#include "ui/aura/test/ui_controls_factory_aura.h" #include "ui/aura/test/ui_controls_factory_aura.h"
#include "ui/aura/window_event_dispatcher.h" #include "ui/aura/window_event_dispatcher.h"
#include "ui/base/test/ui_controls_aura.h" #include "ui/base/test/ui_controls_aura.h"
...@@ -142,8 +143,8 @@ class UIControlsDesktopX11 : public UIControlsAura { ...@@ -142,8 +143,8 @@ class UIControlsDesktopX11 : public UIControlsAura {
} }
aura::WindowTreeHost* host = root_window->GetHost(); aura::WindowTreeHost* host = root_window->GetHost();
gfx::Point root_current_location; gfx::Point root_current_location =
host->QueryMouseLocation(&root_current_location); aura::test::QueryLatestMousePositionRequestInHost(host);
host->ConvertPointFromHost(&root_current_location); host->ConvertPointFromHost(&root_current_location);
if (root_location != root_current_location && button_down_mask == 0) { if (root_location != root_current_location && button_down_mask == 0) {
......
...@@ -512,20 +512,6 @@ void DesktopWindowTreeHostWin::ReleaseCapture() { ...@@ -512,20 +512,6 @@ void DesktopWindowTreeHostWin::ReleaseCapture() {
message_handler_->ReleaseCapture(); message_handler_->ReleaseCapture();
} }
bool DesktopWindowTreeHostWin::QueryMouseLocation(gfx::Point* location_return) {
aura::client::CursorClient* cursor_client =
aura::client::GetCursorClient(window());
if (cursor_client && !cursor_client->IsMouseEventsEnabled()) {
*location_return = gfx::Point(0, 0);
return false;
}
POINT pt = {0};
::GetCursorPos(&pt);
*location_return =
gfx::Point(static_cast<int>(pt.x), static_cast<int>(pt.y));
return true;
}
void DesktopWindowTreeHostWin::PostNativeEvent( void DesktopWindowTreeHostWin::PostNativeEvent(
const base::NativeEvent& native_event) { const base::NativeEvent& native_event) {
} }
......
...@@ -115,7 +115,6 @@ class VIEWS_EXPORT DesktopWindowTreeHostWin ...@@ -115,7 +115,6 @@ class VIEWS_EXPORT DesktopWindowTreeHostWin
virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE; virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE;
virtual void SetCapture() OVERRIDE; virtual void SetCapture() OVERRIDE;
virtual void ReleaseCapture() OVERRIDE; virtual void ReleaseCapture() OVERRIDE;
virtual bool QueryMouseLocation(gfx::Point* location_return) OVERRIDE;
virtual void PostNativeEvent(const base::NativeEvent& native_event) OVERRIDE; virtual void PostNativeEvent(const base::NativeEvent& native_event) OVERRIDE;
virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE; virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
virtual void SetCursorNative(gfx::NativeCursor cursor) OVERRIDE; virtual void SetCursorNative(gfx::NativeCursor cursor) OVERRIDE;
......
...@@ -856,32 +856,6 @@ void DesktopWindowTreeHostX11::ReleaseCapture() { ...@@ -856,32 +856,6 @@ void DesktopWindowTreeHostX11::ReleaseCapture() {
g_current_capture->OnCaptureReleased(); g_current_capture->OnCaptureReleased();
} }
bool DesktopWindowTreeHostX11::QueryMouseLocation(
gfx::Point* location_return) {
aura::client::CursorClient* cursor_client =
aura::client::GetCursorClient(window());
if (cursor_client && !cursor_client->IsMouseEventsEnabled()) {
*location_return = gfx::Point(0, 0);
return false;
}
::Window root_return, child_return;
int root_x_return, root_y_return, win_x_return, win_y_return;
unsigned int mask_return;
XQueryPointer(xdisplay_,
xwindow_,
&root_return,
&child_return,
&root_x_return, &root_y_return,
&win_x_return, &win_y_return,
&mask_return);
*location_return = gfx::Point(
std::max(0, std::min(bounds_.width(), win_x_return)),
std::max(0, std::min(bounds_.height(), win_y_return)));
return (win_x_return >= 0 && win_x_return < bounds_.width() &&
win_y_return >= 0 && win_y_return < bounds_.height());
}
void DesktopWindowTreeHostX11::SetCursorNative(gfx::NativeCursor cursor) { void DesktopWindowTreeHostX11::SetCursorNative(gfx::NativeCursor cursor) {
XDefineCursor(xdisplay_, xwindow_, cursor.platform()); XDefineCursor(xdisplay_, xwindow_, cursor.platform());
} }
......
...@@ -140,7 +140,6 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 ...@@ -140,7 +140,6 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11
virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE; virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE;
virtual void SetCapture() OVERRIDE; virtual void SetCapture() OVERRIDE;
virtual void ReleaseCapture() OVERRIDE; virtual void ReleaseCapture() OVERRIDE;
virtual bool QueryMouseLocation(gfx::Point* location_return) OVERRIDE;
virtual void PostNativeEvent(const base::NativeEvent& native_event) OVERRIDE; virtual void PostNativeEvent(const base::NativeEvent& native_event) OVERRIDE;
virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE; virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
virtual void SetCursorNative(gfx::NativeCursor cursor) OVERRIDE; virtual void SetCursorNative(gfx::NativeCursor cursor) OVERRIDE;
......
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