Mir
xcursor_loader.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2014 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Robert Carr <robert.carr@canonical.com>
17  */
18 
19 
20 #ifndef MIR_INPUT_XCURSOR_CURSOR_LOADER_H_
21 #define MIR_INPUT_XCURSOR_CURSOR_LOADER_H_
22 
24 
25 #include <memory>
26 #include <string>
27 #include <map>
28 #include <mutex>
29 #include <functional>
30 
31 // Unfortunately this library does not compile as C++ so we can not namespace it.
32 extern "C"
33 {
34 struct _XcursorImages;
35 }
36 
37 namespace mir
38 {
39 namespace graphics
40 {
41 class CursorImage;
42 }
43 
44 namespace examples
45 {
47 {
48 public:
49  XCursorLoader();
50 
51  explicit XCursorLoader(std::string const& theme);
52 
53  virtual ~XCursorLoader() = default;
54 
55  std::shared_ptr<graphics::CursorImage> image(std::string const& cursor_name,
56  geometry::Size const& size);
57 
58 protected:
59  XCursorLoader(XCursorLoader const&) = delete;
60  XCursorLoader& operator=(XCursorLoader const&) = delete;
61 
62 private:
63  std::mutex guard;
64 
65  std::map<std::string, std::shared_ptr<graphics::CursorImage>> loaded_images;
66 
67  void load_cursor_theme(std::string const& theme_name);
68  void load_appropriately_sized_image(_XcursorImages *images);
69 };
70 }
71 }
72 
73 
74 #endif /* MIR_INPUT_XCURSOR_CURSOR_LOADER_H_ */
Definition: size.h:30
Definition: as_render_target.h:27
Definition: cursor_images.h:40
Definition: xcursor.h:49
Definition: xcursor_loader.h:46

Copyright © 2012-2016 Canonical Ltd.
Generated on Sat Dec 3 12:48:59 UTC 2016