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 input
45 {
47 {
48 public:
49  XCursorLoader();
50  virtual ~XCursorLoader() = default;
51 
52  std::shared_ptr<graphics::CursorImage> image(std::string const& cursor_name,
53  geometry::Size const& size);
54 
55 protected:
56  XCursorLoader(XCursorLoader const&) = delete;
57  XCursorLoader& operator=(XCursorLoader const&) = delete;
58 
59 private:
60  std::mutex guard;
61 
62  std::map<std::string, std::shared_ptr<graphics::CursorImage>> loaded_images;
63 
64  void load_cursor_theme(std::string const& theme_name);
65  void load_appropriately_sized_image(_XcursorImages *images);
66 };
67 }
68 }
69 
70 
71 #endif /* MIR_INPUT_XCURSOR_CURSOR_LOADER_H_ */
Definition: size.h:30
virtual ~XCursorLoader()=default
All things Mir.
Definition: atomic_callback.h:25
Definition: cursor_images.h:40
XCursorLoader()
Definition: xcursor_loader.cpp:151
std::shared_ptr< graphics::CursorImage > image(std::string const &cursor_name, geometry::Size const &size)
Looks up the image for a named cursor. Cursor names follow the XCursor naming conventions.
Definition: xcursor_loader.cpp:200
XCursorLoader & operator=(XCursorLoader const &)=delete
Definition: xcursor_loader.h:46
int const size
Definition: make_socket_rpc_channel.cpp:51

Copyright © 2012-2015 Canonical Ltd.
Generated on Thu Oct 8 16:20:16 UTC 2015