Skip to content

Commit

Permalink
Remove DecorationManagerBuilder, use DecorationManagerAdapter in
Browse files Browse the repository at this point in the history
`DecorationBasicManager` instead.
  • Loading branch information
tarek-y-ismail committed Nov 21, 2024
1 parent d5ae982 commit 6d461ef
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 157 deletions.
1 change: 0 additions & 1 deletion examples/miral-shell/decoration/decoration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include "miral/decoration.h"
#include "miral/decoration_window_state.h"
#include "miral/decoration_basic_manager.h"
#include "miral/decoration_manager_builder.h"

#include <memory>

Expand Down
3 changes: 2 additions & 1 deletion include/miral/miral/custom_decorations.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
#ifndef MIRAL_CUSTOM_DECORATIONS_H
#define MIRAL_CUSTOM_DECORATIONS_H

#include "miral/decoration_manager_builder.h"
#include <functional>
#include <memory>

namespace mir { class Server; }

namespace miral
{
class DecorationManagerAdapter;
class CustomDecorations
{
public:
Expand Down
57 changes: 0 additions & 57 deletions include/miral/miral/decoration_manager_builder.h

This file was deleted.

3 changes: 2 additions & 1 deletion src/include/server/mir/shell/decoration/basic_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ class BasicManager :

protected:
DecorationBuilder const decoration_builder;
std::weak_ptr<shell::Shell> shell;

private:
std::shared_ptr<DisplayConfigurationListener> const display_config_monitor;
std::weak_ptr<shell::Shell> shell;

std::mutex mutex;
std::unordered_map<scene::Surface*, std::unique_ptr<Decoration>> decorations;
Expand Down
2 changes: 1 addition & 1 deletion src/miral/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ add_library(miral-internal STATIC
window_info_defaults.h
window_specification_internal.cpp window_specification_internal.h
decoration_window_state.cpp
decoration_manager_adapter.cpp
)

# Already implied by the linker's symbol version script, but can avoid accidents
Expand Down Expand Up @@ -90,7 +91,6 @@ add_library(miral-external OBJECT
zone.cpp ${miral_include}/miral/zone.h
decorations.cpp ${miral_include}/miral/decorations.h
custom_decorations.cpp ${miral_include}/miral/custom_decorations.h
decoration_manager_builder.cpp ${miral_include}/miral/decoration_manager_builder.h
decoration_basic_manager.cpp ${miral_include}/miral/decoration_basic_manager.h
decoration_adapter.cpp ${miral_include}/miral/decoration_adapter.h
decoration.cpp
Expand Down
1 change: 0 additions & 1 deletion src/miral/custom_decorations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "decoration_manager_adapter.h"

#include "mir/shell/decoration/manager.h"
#include "miral/decoration_manager_builder.h"

#include "mir/options/option.h"
#include "mir/log.h"
Expand Down
2 changes: 0 additions & 2 deletions src/miral/decoration_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "mir/geometry/forward.h"
#include "miral/decoration_window_state.h"
#include "miral/decoration.h"
#include "miral/decoration_manager_builder.h"

#include "mir/compositor/buffer_stream.h"
#include "mir/geometry/displacement.h"
Expand All @@ -35,7 +34,6 @@
#include "mir/shell/surface_specification.h"
#include "mir/log.h"

#include <iterator>
#include <memory>

namespace msh = mir::shell;
Expand Down
38 changes: 28 additions & 10 deletions src/miral/decoration_basic_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,20 @@
*/

#include "miral/decoration_basic_manager.h"
#include "mir/compositor/buffer_stream.h"
#include "mir/optional_value.h"
#include "mir/scene/session.h"
#include "mir/scene/surface.h"
#include "mir/server.h"
#include "mir/shell/decoration.h"
#include "mir/shell/decoration/basic_manager.h"
#include "mir/shell/shell.h"
#include "mir/shell/surface_specification.h"
#include "mir/optional_value.h"
#include "mir/wayland/weak.h"
#include "mir/compositor/buffer_stream.h"

#include "miral/decoration_adapter.h"
#include "miral/decoration_manager_builder.h"
#include "decoration_manager_adapter.h"

#include <boost/multi_index/detail/ord_index_node.hpp>
#include <memory>
#include <utility>

Expand Down Expand Up @@ -84,6 +83,11 @@ struct miral::DecorationBasicManager::Self : public mir::shell::decoration::Basi
})
{
}

void init(std::weak_ptr<mir::shell::Shell> const& shell)
{
this->shell = shell;
}
};

miral::DecorationBasicManager::DecorationBasicManager(
Expand All @@ -94,10 +98,24 @@ miral::DecorationBasicManager::DecorationBasicManager(

auto miral::DecorationBasicManager::to_adapter() -> std::shared_ptr<DecorationManagerAdapter>
{
return DecorationManagerBuilder::build(
[self=this->self](auto... args) { self->init(args...); },
[self=this->self](auto... args) { self->decorate(args...); },
[self=this->self](auto... args) { self->undecorate(args...); },
[self=this->self]() { self->undecorate_all(); }
).done();
auto adapter = std::shared_ptr<DecorationManagerAdapter>(new DecorationManagerAdapter());

adapter->on_init = [self = this->self](auto shell)
{
self->init(shell);
};
adapter->on_decorate = [self = this->self](auto... args)
{
self->decorate(args...);
};
adapter->on_undecorate = [self = this->self](auto... args)
{
self->undecorate(args...);
};
adapter->on_undecorate_all = [self = this->self]()
{
self->undecorate_all();
};

return adapter;
}
5 changes: 3 additions & 2 deletions src/miral/decoration_manager_adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Surface;

namespace miral
{
class DecorationManagerBuilder;
class DecorationBasicManager;
class DecorationManagerAdapter : public mir::shell::decoration::Manager
{
public:
Expand All @@ -41,8 +41,9 @@ class DecorationManagerAdapter : public mir::shell::decoration::Manager
void undecorate(std::shared_ptr<mir::scene::Surface> const& surface) override;
void undecorate_all() override;

virtual ~DecorationManagerAdapter();
private:
friend DecorationManagerBuilder;
friend miral::DecorationBasicManager;
DecorationManagerAdapter();

std::function<void(std::weak_ptr<mir::shell::Shell> const& shell)> on_init;
Expand Down
81 changes: 0 additions & 81 deletions src/miral/decoration_manager_builder.cpp

This file was deleted.

0 comments on commit 6d461ef

Please sign in to comment.