summaryrefslogtreecommitdiffstats
path: root/ui/platform_window/x11/x11_cursor_ozone.h
blob: 8a83080e7462cffc0ed7a2ccc8a3ec9f53e6f606 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_PLATFORM_WINDOW_X11_X11_CURSOR_OZONE_H_
#define UI_PLATFORM_WINDOW_X11_X11_CURSOR_OZONE_H_

#include <X11/X.h>

#include <vector>

#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "ui/base/cursor/cursor.h"
#include "ui/platform_window/x11/x11_window_export.h"

class SkBitmap;

namespace ui {

// Ref counted class to hold an X11 cursor resource. Handles creating X11 cursor
// resources from SkBitmap/hotspot and clears the X11 resources on destruction.
class X11_WINDOW_EXPORT X11CursorOzone
    : public base::RefCounted<X11CursorOzone> {
 public:
  X11CursorOzone(const SkBitmap& bitmap, const gfx::Point& hotspot);
  X11CursorOzone(const std::vector<SkBitmap>& bitmaps,
                 const gfx::Point& hotspot,
                 int frame_delay_ms);

  // Creates a new cursor that is invisible.
  static scoped_refptr<X11CursorOzone> CreateInvisible();

  ::Cursor xcursor() const { return xcursor_; }

 private:
  friend class base::RefCounted<X11CursorOzone>;

  X11CursorOzone();
  ~X11CursorOzone();

  ::Cursor xcursor_ = None;

  DISALLOW_COPY_AND_ASSIGN(X11CursorOzone);
};

}  // namespace ui
#endif  // UI_PLATFORM_WINDOW_X11_X11_CURSOR_OZONE_H_