1 // Copyright 2016 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_X11_X11_CURSOR_FACTORY_OZONE_H_ 6 #define UI_OZONE_PLATFORM_X11_X11_CURSOR_FACTORY_OZONE_H_ 7 8 #include <map> 9 #include <memory> 10 #include <vector> 11 12 #include "base/macros.h" 13 #include "ui/base/cursor/cursor.h" 14 #include "ui/base/mojom/cursor_type.mojom-forward.h" 15 #include "ui/gfx/x/x11.h" 16 #include "ui/ozone/platform/x11/x11_cursor_ozone.h" 17 #include "ui/ozone/public/cursor_factory_ozone.h" 18 19 namespace ui { 20 21 // CursorFactoryOzone implementation for X11 cursors. 22 class X11CursorFactoryOzone : public CursorFactoryOzone { 23 public: 24 X11CursorFactoryOzone(); 25 ~X11CursorFactoryOzone() override; 26 27 // CursorFactoryOzone: 28 PlatformCursor GetDefaultCursor(mojom::CursorType type) override; 29 PlatformCursor CreateImageCursor(const SkBitmap& bitmap, 30 const gfx::Point& hotspot, 31 float bitmap_dpi) override; 32 PlatformCursor CreateAnimatedCursor(const std::vector<SkBitmap>& bitmaps, 33 const gfx::Point& hotspot, 34 int frame_delay_ms, 35 float bitmap_dpi) override; 36 void RefImageCursor(PlatformCursor cursor) override; 37 void UnrefImageCursor(PlatformCursor cursor) override; 38 39 private: 40 // Loads/caches default cursor or returns cached version. 41 scoped_refptr<X11CursorOzone> GetDefaultCursorInternal( 42 mojom::CursorType type); 43 44 // Holds a single instance of the invisible cursor. X11 has no way to hide 45 // the cursor so an invisible cursor mimics that. 46 scoped_refptr<X11CursorOzone> invisible_cursor_; 47 48 std::map<mojom::CursorType, scoped_refptr<X11CursorOzone>> default_cursors_; 49 50 DISALLOW_COPY_AND_ASSIGN(X11CursorFactoryOzone); 51 }; 52 53 } // namespace ui 54 55 #endif // UI_OZONE_PLATFORM_X11_X11_CURSOR_FACTORY_OZONE_H_ 56