diff options
| author | Joel Klinghed <the_jk@opera.com> | 2020-07-17 12:10:54 +0200 |
|---|---|---|
| committer | Joel Klinghed <the_jk@opera.com> | 2020-07-17 12:10:54 +0200 |
| commit | 2df36164c6dfaa4c1dfbd7bb652ff9837c8d912c (patch) | |
| tree | c5dbbf55619c2dc0dee01672d21cafbf6340369a /src | |
| parent | c8fd8d3c3f12e6895246c5a0566a9f595ce5db20 (diff) | |
Move IceccMonMon::connect to MonMon
All implementations are going to need a "connect" method
Diffstat (limited to 'src')
| -rw-r--r-- | src/icecc.cc | 19 | ||||
| -rw-r--r-- | src/icecc.hh | 15 | ||||
| -rw-r--r-- | src/main.cc | 5 | ||||
| -rw-r--r-- | src/monmon.hh | 4 |
4 files changed, 19 insertions, 24 deletions
diff --git a/src/icecc.cc b/src/icecc.cc index 5e99981..7982f7c 100644 --- a/src/icecc.cc +++ b/src/icecc.cc @@ -10,18 +10,19 @@ #include "fake_monitor.hh" #include "icecc.hh" #include "monitor.hh" +#include "monmon.hh" #include "pango.hh" namespace { -class IceccMonMonImpl : public IceccMonMon, virtual Monitor::Observer { +class IceccMonMon : public MonMon, virtual Monitor::Observer { public: - IceccMonMonImpl(std::shared_ptr<PollLooper> const& looper, unsigned columns) - : IceccMonMon(looper), connected_(false), max_jobs_(0), jobs_(0), - requests_(0), force_columns_(columns) { + IceccMonMon(std::shared_ptr<PollLooper> const& looper, unsigned columns) + : MonMon(looper), connected_(false), max_jobs_(0), jobs_(0), requests_(0), + force_columns_(columns) { } - void connect(Args const* args) override { + bool connect(Args const* args) override { std::unique_ptr<Monitor> monitor; #if FAKE_MONITOR monitor = FakeMonitor::create(looper_); @@ -32,6 +33,7 @@ public: monitor_->add_observer(this); monitor_->connect(args->arg("network", ""), args->arg("scheduler", "")); + return true; } protected: @@ -348,10 +350,7 @@ private: } // namespace -IceccMonMon::IceccMonMon(std::shared_ptr<PollLooper> const& looper) - : MonMon(looper) {} - -std::unique_ptr<IceccMonMon> create_icecc_monmon( +std::unique_ptr<MonMon> create_icecc_monmon( std::shared_ptr<PollLooper> const& looper, unsigned columns) { - return std::make_unique<IceccMonMonImpl>(looper, columns); + return std::make_unique<IceccMonMon>(looper, columns); } diff --git a/src/icecc.hh b/src/icecc.hh index 2b3cdf0..f061de6 100644 --- a/src/icecc.hh +++ b/src/icecc.hh @@ -3,19 +3,10 @@ #include <memory> -#include "monmon.hh" +class MonMon; +class PollLooper; -class Args; - -class IceccMonMon : public MonMon { -public: - virtual void connect(Args const* args) = 0; - -protected: - IceccMonMon(std::shared_ptr<PollLooper> const& looper); -}; - -std::unique_ptr<IceccMonMon> create_icecc_monmon( +std::unique_ptr<MonMon> create_icecc_monmon( std::shared_ptr<PollLooper> const& looper, unsigned columns); #endif // ICECC_HH diff --git a/src/main.cc b/src/main.cc index 53e9a7f..4bcbdd3 100644 --- a/src/main.cc +++ b/src/main.cc @@ -200,10 +200,11 @@ int main(int argc, char** argv) { atoms->preload("__MONMON_QUIT"); MonMon::preload(atoms.get()); std::shared_ptr<x::Ewmh> ewmh(x::Ewmh::create(conn, screen_index)); - std::shared_ptr<IceccMonMon> monmon(create_icecc_monmon(looper, columns)); + std::shared_ptr<MonMon> monmon(create_icecc_monmon(looper, columns)); monmon->init(conn, screen, format, atoms, ewmh, 400, 400, args->is_set("titlebar"), args->is_set("black")); - monmon->connect(args.get()); + if (!monmon->connect(args.get())) + return EXIT_FAILURE; std::thread xcb_thread(xcb_event_loop, conn, atoms, monmon); conn.reset(); looper->run(); diff --git a/src/monmon.hh b/src/monmon.hh index e41be5b..05d58a5 100644 --- a/src/monmon.hh +++ b/src/monmon.hh @@ -11,10 +11,14 @@ #include "poll_looper.hh" #include "x.hh" +class Args; + class MonMon : protected virtual Animator::Observer { public: virtual ~MonMon(); + virtual bool connect(Args const* args) = 0; + void init(x::shared_connection const& conn, xcb_screen_t const* screen, x::Format format, std::shared_ptr<x::Atoms> const& atoms, std::shared_ptr<x::Ewmh> const& ewmh, |
