Skip to content

Commit

Permalink
Dont expose DecorationStrategy in miral::Decorations's interface.
Browse files Browse the repository at this point in the history
Also, changed `DecorationStrategy::Self` to inherit from
`DecorationStrategy` and cleaned up the code a bit.
  • Loading branch information
tarek-y-ismail committed Jul 3, 2024
1 parent b79e5c3 commit a1555bc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 49 deletions.
36 changes: 0 additions & 36 deletions include/core/mir/decoration_strategy.h

This file was deleted.

6 changes: 2 additions & 4 deletions include/miral/miral/decorations.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@
#define MIRAL_DECORATIONS_H


#include "mir/decoration_strategy.h"

#include <memory>

namespace mir { class Server; }
namespace mir { class Server; class DecorationStrategy; }

namespace miral
{
Expand Down Expand Up @@ -52,7 +50,7 @@ class Decorations
private:
struct Self;

Decorations(std::shared_ptr<mir::DecorationStrategy> strategy);
Decorations(std::shared_ptr<Self> strategy);

std::shared_ptr<Self> self;
};
Expand Down
19 changes: 10 additions & 9 deletions src/miral/decorations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,33 @@
#include "miral/decorations.h"

#include <memory>

#include <mir/default_server_configuration.h>
#include <mir/server.h>
#include <mir/decoration_strategy.h>


struct miral::Decorations::Self
struct miral::Decorations::Self : mir::DecorationStrategy
{
std::shared_ptr<mir::DecorationStrategy> strategy;
};

void miral::Decorations::operator()(mir::Server& server) const
{
server.add_pre_init_callback(
[this, &server]()
{
server.set_the_decoration_strategy(self->strategy);
server.set_the_decoration_strategy(self);
});
}

miral::Decorations::Decorations(std::shared_ptr<mir::DecorationStrategy> strategy) :
self{std::make_shared<Self>(std::move(strategy))}
miral::Decorations::Decorations(std::shared_ptr<Self> strategy) :
self{std::move(strategy)}
{
}

auto miral::Decorations::always_ssd() -> Decorations
{
struct AlwaysServerSide : public mir::DecorationStrategy
struct AlwaysServerSide : Self
{
DecorationsType default_style() const override { return DecorationsType::ssd; }
DecorationsType request_style(DecorationsType) const override { return DecorationsType::ssd; }
Expand All @@ -53,7 +54,7 @@ auto miral::Decorations::always_ssd() -> Decorations

auto miral::Decorations::always_csd() -> Decorations
{
struct AlwaysClientSide : public mir::DecorationStrategy
struct AlwaysClientSide : Self
{
DecorationsType default_style() const override { return DecorationsType::csd; }
DecorationsType request_style(DecorationsType) const override { return DecorationsType::csd; }
Expand All @@ -64,7 +65,7 @@ auto miral::Decorations::always_csd() -> Decorations

auto miral::Decorations::prefer_ssd() -> Decorations
{
struct PreferServerSide : public mir::DecorationStrategy
struct PreferServerSide : Self
{
DecorationsType default_style() const override { return DecorationsType::ssd; }
DecorationsType request_style(DecorationsType type) const override { return type; }
Expand All @@ -75,7 +76,7 @@ auto miral::Decorations::prefer_ssd() -> Decorations

auto miral::Decorations::prefer_csd() -> Decorations
{
struct PreferClientSide : public mir::DecorationStrategy
struct PreferClientSide : Self
{
DecorationsType default_style() const override { return DecorationsType::csd; }
DecorationsType request_style(DecorationsType type) const override { return type; }
Expand Down

0 comments on commit a1555bc

Please sign in to comment.