Mir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cursor.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2013 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser 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 Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Alan Griffiths <alan@octopull.co.uk>
17  */
18 
19 
20 #ifndef MIR_GRAPHICS_MESA_CURSOR_H_
21 #define MIR_GRAPHICS_MESA_CURSOR_H_
22 
23 #include "mir/graphics/cursor.h"
24 #include "mir_toolkit/common.h"
25 
26 #include <gbm.h>
27 #include <memory>
28 
29 namespace mir
30 {
31 namespace geometry
32 {
33 struct Rectangle;
34 }
35 namespace graphics
36 {
37 namespace mesa
38 {
39 class KMSOutputContainer;
40 class KMSOutput;
41 class KMSDisplayConfiguration;
42 class GBMPlatform;
43 
45 {
46 public:
47  virtual ~CurrentConfiguration() = default;
48 
49  virtual void with_current_configuration_do(
50  std::function<void(KMSDisplayConfiguration const&)> const& exec) = 0;
51 
52 protected:
53  CurrentConfiguration() = default;
56 };
57 
58 class Cursor : public graphics::Cursor
59 {
60 public:
61  Cursor(
62  gbm_device* device,
63  KMSOutputContainer& output_container,
64  std::shared_ptr<CurrentConfiguration> const& current_configuration);
65 
66  ~Cursor() noexcept;
67 
68  void set_image(const void* raw_argb, geometry::Size size);
69 
70  void move_to(geometry::Point position);
71 
73  void hide();
74 
75 private:
76  enum ForceCursorState { UpdateState, ForceState };
77  void for_each_used_output(std::function<void(KMSOutput&, geometry::Rectangle const&, MirOrientation orientation)> const& f);
78  void place_cursor_at(geometry::Point position, ForceCursorState force_state);
79 
80  KMSOutputContainer& output_container;
81  geometry::Point current_position;
82 
83  struct GBMBOWrapper
84  {
85  GBMBOWrapper(gbm_device* gbm);
86  operator gbm_bo*();
87  ~GBMBOWrapper();
88  private:
89  gbm_bo* buffer;
90  GBMBOWrapper(GBMBOWrapper const&) = delete;
91  GBMBOWrapper& operator=(GBMBOWrapper const&) = delete;
92  } buffer;
93 
94  std::shared_ptr<CurrentConfiguration> const current_configuration;
95 };
96 }
97 }
98 }
99 
100 
101 #endif /* MIR_GRAPHICS_MESA_CURSOR_H_ */
Definition: size.h:30
void hide()
Definition: cursor.cpp:116
Definition: kms_output_container.h:34
void move_to(geometry::Point position)
Definition: cursor.cpp:106
Definition: point.h:30
void show_at_last_known_position()
Definition: cursor.cpp:111
void set_image(const void *raw_argb, geometry::Size size)
Definition: cursor.cpp:91
Definition: kms_output.h:37
MirOrientation
Definition: common.h:113
CurrentConfiguration & operator=(CurrentConfiguration const &)=delete
Definition: cursor.h:30
virtual void with_current_configuration_do(std::function< void(KMSDisplayConfiguration const &)> const &exec)=0
Cursor & operator=(Cursor const &)=delete
Definition: cursor.h:58
Definition: kms_display_configuration.h:33
Definition: rectangle.h:33
~Cursor() noexcept
Definition: cursor.cpp:86
int const size
Definition: make_socket_rpc_channel.cpp:50

Copyright © 2012,2013 Canonical Ltd.
Generated on Fri Apr 11 21:14:53 UTC 2014