Mir
cursor_controller.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 #ifndef MIR_INPUT_CURSOR_CONTROLLER_H_
20 #define MIR_INPUT_CURSOR_CONTROLLER_H_
21 
23 #include "mir/geometry/point.h"
24 
25 #include <memory>
26 #include <mutex>
27 
28 namespace mir
29 {
30 namespace graphics
31 {
32 class Cursor;
33 class CursorImage;
34 }
35 namespace scene
36 {
37 class Observer;
38 }
39 
40 namespace input
41 {
42 class Scene;
43 
45 {
46 public:
47  CursorController(std::shared_ptr<Scene> const& input_targets,
48  std::shared_ptr<graphics::Cursor> const& cursor,
49  std::shared_ptr<graphics::CursorImage> const& default_cursor_image);
50  virtual ~CursorController();
51 
52  void cursor_moved_to(float abs_x, float abs_y);
53 
54  // Trigger an update of the cursor image without cursor motion, e.g.
55  // in response to scene changes.
56  void update_cursor_image();
57 
58 private:
59  std::shared_ptr<Scene> const input_targets;
60  std::shared_ptr<graphics::Cursor> const cursor;
61  std::shared_ptr<graphics::CursorImage> const default_cursor_image;
62 
63  std::mutex cursor_state_guard;
64  geometry::Point cursor_location;
65  std::shared_ptr<graphics::CursorImage> current_cursor;
66 
67  std::weak_ptr<scene::Observer> observer;
68 
69 
70  void update_cursor_image_locked(std::unique_lock<std::mutex>&);
71  void set_cursor_image_locked(std::unique_lock<std::mutex>&, std::shared_ptr<graphics::CursorImage> const& image);
72 };
73 
74 }
75 }
76 
77 #endif // MIR_INPUT_CURSOR_CONTROLLER_H_
All things Mir.
Definition: atomic_callback.h:25
Definition: point.h:30
Definition: cursor_controller.h:44
An interface for listening to absolute cursor events (without context): For example to update the pos...
Definition: cursor_listener.h:29

Copyright © 2012-2015 Canonical Ltd.
Generated on Wed Mar 30 00:29:56 UTC 2016