Store reload flag in controller
This commit is contained in:
parent
ce63305c1d
commit
2c7af2a60c
2 changed files with 22 additions and 12 deletions
|
@ -63,10 +63,13 @@ class controller : public signal_receiver<SIGN_PRIORITY_CONTROLLER, signals::eve
|
||||||
void screenshot_handler();
|
void screenshot_handler();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void trigger_notification();
|
||||||
void read_events(bool confwatch);
|
void read_events(bool confwatch);
|
||||||
void process_inputdata(string&& cmd);
|
void process_inputdata(string&& cmd);
|
||||||
bool process_update(bool force);
|
bool process_update(bool force);
|
||||||
|
|
||||||
|
void update_reload(bool reload);
|
||||||
|
|
||||||
bool on(const signals::eventqueue::notify_change& evt) override;
|
bool on(const signals::eventqueue::notify_change& evt) override;
|
||||||
bool on(const signals::eventqueue::notify_forcechange& evt) override;
|
bool on(const signals::eventqueue::notify_forcechange& evt) override;
|
||||||
bool on(const signals::eventqueue::exit_reload& evt) override;
|
bool on(const signals::eventqueue::exit_reload& evt) override;
|
||||||
|
@ -143,6 +146,11 @@ class controller : public signal_receiver<SIGN_PRIORITY_CONTROLLER, signals::eve
|
||||||
* \brief Loaded modules grouped by block
|
* \brief Loaded modules grouped by block
|
||||||
*/
|
*/
|
||||||
modulemap_t m_blocks;
|
modulemap_t m_blocks;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Flag to trigger reload after shutdown
|
||||||
|
*/
|
||||||
|
bool m_reload{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
POLYBAR_NS_END
|
POLYBAR_NS_END
|
||||||
|
|
|
@ -28,8 +28,6 @@
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
sig_atomic_t g_reload{0};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build controller instance
|
* Build controller instance
|
||||||
*/
|
*/
|
||||||
|
@ -126,7 +124,7 @@ bool controller::run(bool writeback, string snapshot_dst, bool confwatch) {
|
||||||
|
|
||||||
m_log.notice("Termination signal received, shutting down...");
|
m_log.notice("Termination signal received, shutting down...");
|
||||||
|
|
||||||
return !g_reload;
|
return !m_reload;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -137,8 +135,7 @@ void controller::trigger_action(string&& input_data) {
|
||||||
|
|
||||||
if (m_notifications.inputdata.empty()) {
|
if (m_notifications.inputdata.empty()) {
|
||||||
m_notifications.inputdata = std::forward<string>(input_data);
|
m_notifications.inputdata = std::forward<string>(input_data);
|
||||||
// TODO create function for this
|
trigger_notification();
|
||||||
UV(uv_async_send, m_notifier.get());
|
|
||||||
} else {
|
} else {
|
||||||
m_log.trace("controller: Swallowing input event (pending data)");
|
m_log.trace("controller: Swallowing input event (pending data)");
|
||||||
}
|
}
|
||||||
|
@ -148,8 +145,7 @@ void controller::trigger_quit(bool reload) {
|
||||||
std::unique_lock<std::mutex> guard(m_notification_mutex);
|
std::unique_lock<std::mutex> guard(m_notification_mutex);
|
||||||
m_notifications.quit = true;
|
m_notifications.quit = true;
|
||||||
m_notifications.reload = m_notifications.reload || reload;
|
m_notifications.reload = m_notifications.reload || reload;
|
||||||
// TODO create function for this
|
trigger_notification();
|
||||||
UV(uv_async_send, m_notifier.get());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void controller::trigger_update(bool force) {
|
void controller::trigger_update(bool force) {
|
||||||
|
@ -159,13 +155,16 @@ void controller::trigger_update(bool force) {
|
||||||
|
|
||||||
// TODO this isn't really safe
|
// TODO this isn't really safe
|
||||||
if (m_notifier) {
|
if (m_notifier) {
|
||||||
// TODO create function for this
|
trigger_notification();
|
||||||
UV(uv_async_send, m_notifier.get());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void controller::trigger_notification() {
|
||||||
|
UV(uv_async_send, m_notifier.get());
|
||||||
|
}
|
||||||
|
|
||||||
void controller::stop(bool reload) {
|
void controller::stop(bool reload) {
|
||||||
g_reload = reload;
|
update_reload(reload);
|
||||||
eloop->stop();
|
eloop->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,8 +224,7 @@ void controller::notifier_handler() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.quit) {
|
if (data.quit) {
|
||||||
// TODO store this in the instance
|
update_reload(data.reload);
|
||||||
g_reload = data.reload;
|
|
||||||
eloop->stop();
|
eloop->stop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -607,6 +605,10 @@ bool controller::process_update(bool force) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void controller::update_reload(bool reload) {
|
||||||
|
m_reload = m_reload || reload;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates module instances for all the modules in the given alignment block
|
* Creates module instances for all the modules in the given alignment block
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue