Skip to content

Commit 319654a

Browse files
AlanGriffithsSaviq
authored andcommitted
Expose the cursor's renerable via Cursor::renderable and access it in the compositor itself instead of the scene (#3980)
- Exposed `Cursor::renderable()` that will return the renderable associated with the cursor, if there is any - No longer adding the `Cursor::renderable()` to the `Scene`. Instead, adding directly in the compositor - Updated the associated `SoftwareCursor` implementation and tests for this new interface - Existing hardware implementations return `nullptr` for now (but I will address this in later work, as I state below!) The `Cursor` is not logically a part of the `Scene` as it is not a surface or anything. Hence, it is up to the compositor to decide whether or not it will display it. This work isn't done, but this is the minimal reviewable chunk that I want to get in before tackling the rest of it. Coming next: 1. Add `Cursor::needs_compositing` so that the compositor can rely on that boolean flag to decide whether or not to add that `Cursor`'s renderable 2. Implement `Cursor::renderable()` for each hardware cursor 3. Render the cursor in the `BasicScreenShooter` based off whether or not an `include_cursor` flag is set
1 parent 7d8b3f6 commit 319654a

22 files changed

Lines changed: 170 additions & 181 deletions

include/platform/mir/graphics/cursor.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include "mir/geometry/size.h"
2222
#include "mir/geometry/point.h"
23+
#include "mir/graphics/renderable.h"
2324

2425
#include <memory>
2526

@@ -28,6 +29,7 @@ namespace mir
2829
namespace graphics
2930
{
3031
class CursorImage;
32+
class Renderable;
3133
class Cursor
3234
{
3335
public:
@@ -37,6 +39,8 @@ class Cursor
3739
virtual void move_to(geometry::Point position) = 0;
3840

3941
virtual void scale(float new_scale) = 0;
42+
43+
virtual auto renderable() -> std::shared_ptr<Renderable> = 0;
4044
protected:
4145
Cursor() = default;
4246
virtual ~Cursor() = default;

include/test/mir/test/doubles/stub_cursor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ struct StubCursor : public graphics::Cursor
3333
void hide() override {}
3434
void move_to(geometry::Point) override {}
3535
void scale(float) override {}
36+
auto renderable() -> std::shared_ptr<graphics::Renderable> override { return nullptr; }
3637
};
3738

3839
}

src/miroil/mir_server_hooks.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ struct HiddenCursorWrapper : mg::Cursor
7878

7979
void scale(float new_scale) override { wrapped->scale(new_scale); }
8080

81+
auto renderable() -> std::shared_ptr<mir::graphics::Renderable> override { return wrapped->renderable(); }
82+
8183
private:
8284
std::shared_ptr<mg::Cursor> const wrapped;
8385
};

src/platforms/atomic-kms/server/kms/cursor.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,3 +452,8 @@ void mir::graphics::atomic::Cursor::scale(float new_scale)
452452

453453
show(current_cursor_image);
454454
}
455+
456+
auto mir::graphics::atomic::Cursor::renderable() -> std::shared_ptr<Renderable>
457+
{
458+
return nullptr;
459+
}

src/platforms/atomic-kms/server/kms/cursor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ class Cursor : public graphics::Cursor
7878

7979
void scale(float) override;
8080

81+
auto renderable() -> std::shared_ptr<Renderable> override;
82+
8183
private:
8284
enum ForceCursorState { UpdateState, ForceState };
8385
struct GBMBOWrapper;

src/platforms/gbm-kms/server/kms/cursor.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,3 +452,9 @@ void mir::graphics::gbm::Cursor::scale(float new_scale)
452452

453453
show(current_cursor_image);
454454
}
455+
456+
auto mir::graphics::gbm::Cursor::renderable() -> std::shared_ptr<Renderable>
457+
{
458+
return nullptr;
459+
}
460+

src/platforms/gbm-kms/server/kms/cursor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ class Cursor : public graphics::Cursor
7979

8080
void scale(float) override;
8181

82+
auto renderable() -> std::shared_ptr<Renderable> override;
83+
8284
private:
8385
enum ForceCursorState { UpdateState, ForceState };
8486
struct GBMBOWrapper;

src/platforms/wayland/cursor.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,9 @@ void mir::platform::wayland::Cursor::scale(float new_scale)
138138

139139
show(current_cursor_image);
140140
}
141+
142+
auto mir::platform::wayland::Cursor::renderable() -> std::shared_ptr<graphics::Renderable>
143+
{
144+
return nullptr;
145+
}
146+

src/platforms/wayland/cursor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ class Cursor : public graphics::Cursor
5050

5151
void scale(float) override;
5252

53+
auto renderable() -> std::shared_ptr<graphics::Renderable> override;
54+
5355
private:
5456
wl_shm* const shm;
5557
std::function<void()> const flush_wl;

src/server/compositor/default_configuration.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ mir::DefaultServerConfiguration::the_compositor()
8282
the_scene(),
8383
the_shell(),
8484
the_compositor_report(),
85+
the_cursor(),
8586
composite_delay,
8687
true);
8788
});

0 commit comments

Comments
 (0)