1 // Copyright 2020 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 
5 #ifndef UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_ZCR_CURSOR_SHAPES_H_
6 #define UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_ZCR_CURSOR_SHAPES_H_
7 
8 #include "base/optional.h"
9 #include "ui/base/cursor/mojom/cursor_type.mojom-forward.h"
10 #include "ui/ozone/platform/wayland/common/wayland_object.h"
11 
12 namespace ui {
13 
14 class WaylandConnection;
15 
16 // Wraps the zcr_cursor_shapes interface for Wayland (exo) server-side cursor
17 // support. Exists to support Lacros, which uses server-side cursors for
18 // consistency with ARC++ and for accessibility support.
19 class WaylandZcrCursorShapes {
20  public:
21   WaylandZcrCursorShapes(zcr_cursor_shapes_v1* zcr_cursor_shapes,
22                          WaylandConnection* connection);
23   WaylandZcrCursorShapes(const WaylandZcrCursorShapes&) = delete;
24   WaylandZcrCursorShapes& operator=(const WaylandZcrCursorShapes&) = delete;
25   virtual ~WaylandZcrCursorShapes();
26 
27   // Returns the cursor shape value for a cursor |type|, or nullopt if the
28   // type isn't supported by the cursor API.
29   static base::Optional<int32_t> ShapeFromType(mojom::CursorType type);
30 
31   // Calls zcr_cursor_shapes_v1_set_cursor_shape(). See interface description
32   // for values for |shape|. Virtual for testing.
33   virtual void SetCursorShape(int32_t shape);
34 
35  private:
36   wl::Object<zcr_cursor_shapes_v1> zcr_cursor_shapes_v1_;
37   WaylandConnection* const connection_;
38 };
39 
40 }  // namespace ui
41 
42 #endif  // UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_ZCR_CURSOR_SHAPES_H_
43