Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3549)

Unified Diff: ash/display/mouse_cursor_event_filter.h

Issue 270863005: Use native coordinates to warp the cursor to another display. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/display/display_controller.cc ('k') | ash/display/mouse_cursor_event_filter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/display/mouse_cursor_event_filter.h
diff --git a/ash/display/mouse_cursor_event_filter.h b/ash/display/mouse_cursor_event_filter.h
index e7201ed9c32c25a34e7ce25aa308e681cb7dcc0b..3c5304f3475e0668604d699d4145e9745f58b0ef 100644
--- a/ash/display/mouse_cursor_event_filter.h
+++ b/ash/display/mouse_cursor_event_filter.h
@@ -6,6 +6,7 @@
#define ASH_DISPLAY_MOUSE_CURSOR_EVENT_FILTER_H
#include "ash/ash_export.h"
+#include "ash/display/display_controller.h"
#include "base/compiler_specific.h"
#include "base/gtest_prod_util.h"
#include "base/memory/scoped_ptr.h"
@@ -18,13 +19,15 @@ class Window;
}
namespace ash {
-class DisplayController;
class SharedDisplayEdgeIndicator;
// An event filter that controls mouse location in extended desktop
// environment.
-class ASH_EXPORT MouseCursorEventFilter : public ui::EventHandler {
+class ASH_EXPORT MouseCursorEventFilter : public ui::EventHandler,
+ public DisplayController::Observer {
public:
+ static bool IsMouseWarpInNativeCoordsEnabled();
+
enum MouseWarpMode {
WARP_ALWAYS, // Always warp the mouse when possible.
WARP_DRAG, // Used when dragging a window. Top and bottom
@@ -42,10 +45,14 @@ class ASH_EXPORT MouseCursorEventFilter : public ui::EventHandler {
// Shows/Hide the indicator for window dragging. The |from|
// is the window where the dragging started.
- void ShowSharedEdgeIndicator(const aura::Window* from);
+ void ShowSharedEdgeIndicator(aura::Window* from);
void HideSharedEdgeIndicator();
- // Overridden from ui::EventHandler:
+ // DisplayController::Observer:
+ virtual void OnDisplaysInitialized() OVERRIDE;
+ virtual void OnDisplayConfigurationChanged() OVERRIDE;
+
+ // ui::EventHandler:
virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE;
private:
@@ -59,20 +66,39 @@ class ASH_EXPORT MouseCursorEventFilter : public ui::EventHandler {
IndicatorBoundsTestOnLeft);
FRIEND_TEST_ALL_PREFIXES(MouseCursorEventFilterTest,
IndicatorBoundsTestOnTopBottom);
- FRIEND_TEST_ALL_PREFIXES(DragWindowResizerTest, WarpMousePointer);
+ FRIEND_TEST_ALL_PREFIXES(MouseCursorEventFilterTest,
+ WarpMouseDifferentScaleDisplaysInNative);
- void reset_was_mouse_warped_for_test() { was_mouse_warped_ = false; }
+ FRIEND_TEST_ALL_PREFIXES(DragWindowResizerTest, WarpMousePointer);
// Warps the mouse cursor to an alternate root window when the
- // |point_in_screen|, which is the location of the mouse cursor,
- // hits or exceeds the edge of the |target_root| and the mouse cursor
- // is considered to be in an alternate display. Returns true if
- // the cursor was moved.
- bool WarpMouseCursorIfNecessary(aura::Window* target_root,
- const gfx::Point& point_in_screen);
+ // mouse location in |event|, hits the edge of the event target's root and
+ // the mouse cursor is considered to be in an alternate display.
+ // Returns true if/ the cursor was moved.
+ bool WarpMouseCursorIfNecessary(ui::MouseEvent* event);
+
+ bool WarpMouseCursorInNativeCoords(const gfx::Point& point_in_native,
+ const gfx::Point& point_in_screen);
+ bool WarpMouseCursorInScreenCoords(aura::Window* target_root,
+ const gfx::Point& point_in_screen);
+
+ // Update the edge/indicator bounds based on the current
+ // display configuration.
+ void UpdateHorizontalEdgeBounds();
+ void UpdateVerticalEdgeBounds();
+
+ // Returns the source and destination window. When the
+ // mouse_warp_mode_ is WARP_DRAG, src_window is the root window
+ // where the drag starts. When the mouse_warp_mode_ is WARP_ALWAYS,
+ // the src_window is always the primary root window, because there
+ // is no difference between moving src to dst and moving dst to src.
+ void GetSrcAndDstRootWindows(aura::Window** src_window,
+ aura::Window** dst_window);
+
+ void reset_was_mouse_warped_for_test() { was_mouse_warped_ = false; }
- void UpdateHorizontalIndicatorWindowBounds();
- void UpdateVerticalIndicatorWindowBounds();
+ bool WarpMouseCursorIfNecessaryForTest(aura::Window* target_root,
+ const gfx::Point& point_in_screen);
MouseWarpMode mouse_warp_mode_;
@@ -85,8 +111,11 @@ class ASH_EXPORT MouseCursorEventFilter : public ui::EventHandler {
gfx::Rect src_indicator_bounds_;
gfx::Rect dst_indicator_bounds_;
+ gfx::Rect src_edge_bounds_in_native_;
+ gfx::Rect dst_edge_bounds_in_native_;
+
// The root window in which the dragging started.
- const aura::Window* drag_source_root_;
+ aura::Window* drag_source_root_;
float scale_when_drag_started_;
« no previous file with comments | « ash/display/display_controller.cc ('k') | ash/display/mouse_cursor_event_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698