mouse_cursor_event_filter.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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.
  4. #ifndef ASH_DISPLAY_MOUSE_CURSOR_EVENT_FILTER_H_
  5. #define ASH_DISPLAY_MOUSE_CURSOR_EVENT_FILTER_H_
  6. #include <memory>
  7. #include "ash/ash_export.h"
  8. #include "ash/display/window_tree_host_manager.h"
  9. #include "base/compiler_specific.h"
  10. #include "base/gtest_prod_util.h"
  11. #include "ui/events/event_handler.h"
  12. #include "ui/gfx/geometry/rect.h"
  13. namespace aura {
  14. class Window;
  15. }
  16. namespace ash {
  17. class MouseWarpController;
  18. // An event filter that controls mouse location in extended desktop
  19. // environment.
  20. class ASH_EXPORT MouseCursorEventFilter
  21. : public ui::EventHandler,
  22. public WindowTreeHostManager::Observer {
  23. public:
  24. MouseCursorEventFilter();
  25. MouseCursorEventFilter(const MouseCursorEventFilter&) = delete;
  26. MouseCursorEventFilter& operator=(const MouseCursorEventFilter&) = delete;
  27. ~MouseCursorEventFilter() override;
  28. bool mouse_warp_enabled() const { return mouse_warp_enabled_; }
  29. void set_mouse_warp_enabled(bool enabled) { mouse_warp_enabled_ = enabled; }
  30. // Shows/Hide the indicator for window dragging. The |from|
  31. // is the window where the dragging started.
  32. void ShowSharedEdgeIndicator(aura::Window* from);
  33. void HideSharedEdgeIndicator();
  34. // WindowTreeHostManager::Observer:
  35. void OnDisplaysInitialized() override;
  36. void OnDisplayConfigurationChanged() override;
  37. // ui::EventHandler:
  38. void OnMouseEvent(ui::MouseEvent* event) override;
  39. private:
  40. friend class AshTestBase;
  41. friend class ExtendedMouseWarpControllerTest;
  42. friend class MouseCursorEventFilterTest;
  43. friend class UnifiedMouseWarpControllerTest;
  44. FRIEND_TEST_ALL_PREFIXES(MouseCursorEventFilterTest, DoNotWarpTwice);
  45. FRIEND_TEST_ALL_PREFIXES(MouseCursorEventFilterTest, SetMouseWarpModeFlag);
  46. FRIEND_TEST_ALL_PREFIXES(MouseCursorEventFilterTest,
  47. WarpMouseDifferentScaleDisplaysInNative);
  48. FRIEND_TEST_ALL_PREFIXES(DragWindowResizerTest, WarpMousePointer);
  49. MouseWarpController* mouse_warp_controller_for_test() {
  50. return mouse_warp_controller_.get();
  51. }
  52. bool mouse_warp_enabled_;
  53. std::unique_ptr<MouseWarpController> mouse_warp_controller_;
  54. };
  55. } // namespace ash
  56. #endif // ASH_DISPLAY_MOUSE_CURSOR_EVENT_FILTER_H_