wm_move_resize_handler.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Copyright 2018 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 UI_PLATFORM_WINDOW_WM_WM_MOVE_RESIZE_HANDLER_H_
  5. #define UI_PLATFORM_WINDOW_WM_WM_MOVE_RESIZE_HANDLER_H_
  6. #include "base/component_export.h"
  7. namespace gfx {
  8. class Point;
  9. } // namespace gfx
  10. namespace ui {
  11. class PlatformWindow;
  12. class COMPONENT_EXPORT(WM) WmMoveResizeHandler {
  13. public:
  14. // A system window manager starts interactive drag or resize of a window based
  15. // on the |hittest| value. The |hittest| value identifies in which direction
  16. // the window should be resized or whether it should be moved. See
  17. // ui/base/hit_test.h for a concrete example with chromium symbolic names
  18. // defined. The |pointer_location_in_px| indicates the position of the button
  19. // press with respect to the platform window in screen pixel coordinates,
  20. // which is needed when sending a move/resize request in such backends as X11.
  21. // See _NET_WM_MOVERESIZE section in
  22. // https://specifications.freedesktop.org/wm-spec/1.4/ar01s04.html.
  23. //
  24. // There is no need to implement this by all the platforms except Ozone/X11
  25. // and Ozone/Wayland, compositors of which support interactive move/resize.
  26. //
  27. // This API must be used on mouse or touch events, which are targeted for
  28. // non-client components (check ui/base/hit_test.h again) except the ones
  29. // targeted for components like HTMAXBUTTON. In that case, the mouse events
  30. // are used to identify clicks on maximize/minimize/restore buttons located in
  31. // the top non-client area of the chromium window. See
  32. // WindowEventFilter::OnMouseEvent for a concrete example of how mouse events
  33. // are identified as client or non-client.
  34. //
  35. // When the API is called, there is no way to know that the call was
  36. // successful or not. The browser continues performing as usual except that a
  37. // system compositor does not send any mouse/keyboard/etc events until user
  38. // releases a mouse button. Instead, the compositor sends new bounds, which a
  39. // client uses to recreate gpu buffers and redraw visual represantation of the
  40. // browser.
  41. virtual void DispatchHostWindowDragMovement(
  42. int hittest,
  43. const gfx::Point& pointer_location_in_px) = 0;
  44. protected:
  45. virtual ~WmMoveResizeHandler() {}
  46. };
  47. COMPONENT_EXPORT(WM)
  48. void SetWmMoveResizeHandler(PlatformWindow* platform_window,
  49. WmMoveResizeHandler* move_resize_handler);
  50. COMPONENT_EXPORT(WM)
  51. WmMoveResizeHandler* GetWmMoveResizeHandler(
  52. const PlatformWindow& platform_window);
  53. } // namespace ui
  54. #endif // UI_PLATFORM_WINDOW_WM_WM_MOVE_RESIZE_HANDLER_H_