workspace_event_handler.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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_WM_WORKSPACE_WORKSPACE_EVENT_HANDLER_H_
  5. #define ASH_WM_WORKSPACE_WORKSPACE_EVENT_HANDLER_H_
  6. #include "ash/ash_export.h"
  7. #include "ash/wm/workspace/multi_window_resize_controller.h"
  8. #include "ui/events/event_handler.h"
  9. namespace aura {
  10. class Window;
  11. }
  12. namespace ui {
  13. class GestureEvent;
  14. class MouseEvent;
  15. }
  16. namespace ash {
  17. class WindowState;
  18. class WorkspaceEventHandlerTestHelper;
  19. // Handles events on workspace windows, such as double-click on the resize edge
  20. // to maximize in one dimension.
  21. class ASH_EXPORT WorkspaceEventHandler : public ui::EventHandler {
  22. public:
  23. explicit WorkspaceEventHandler(aura::Window* workspace_window);
  24. WorkspaceEventHandler(const WorkspaceEventHandler&) = delete;
  25. WorkspaceEventHandler& operator=(const WorkspaceEventHandler&) = delete;
  26. ~WorkspaceEventHandler() override;
  27. // ui::EventHandler:
  28. void OnMouseEvent(ui::MouseEvent* event) override;
  29. void OnGestureEvent(ui::GestureEvent* event) override;
  30. private:
  31. friend class WorkspaceEventHandlerTestHelper;
  32. // Determines if |event| corresponds to a double click on a resize edge, and
  33. // if so toggles the width/height of the window (width when the left or right
  34. // edge is double clicked, height when the top or bottom edge is double
  35. // clicked) between its restored state and the full available width/height of
  36. // the workspace.
  37. void HandleResizeDoubleClick(WindowState* window_state,
  38. ui::MouseEvent* event);
  39. aura::Window* workspace_window_;
  40. MultiWindowResizeController multi_window_resize_controller_;
  41. // The non-client component for the target of a MouseEvent or GestureEvent.
  42. // Events can be destructive to the window tree, which can cause the
  43. // component of a ui::EF_IS_DOUBLE_CLICK event to no longer be the same as
  44. // that of the initial click. Acting on a double click should only occur for
  45. // matching components. This will be set for left clicks, and tap events.
  46. int click_component_;
  47. };
  48. } // namespace ash
  49. #endif // ASH_WM_WORKSPACE_WORKSPACE_EVENT_HANDLER_H_