mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
Merge branch 'master' into master
This commit is contained in:
commit
9b9daaee6f
@ -51,6 +51,7 @@ class Client {
|
|||||||
static void handleOutputDescription(void *, struct zxdg_output_v1 *, const char *);
|
static void handleOutputDescription(void *, struct zxdg_output_v1 *, const char *);
|
||||||
void handleMonitorAdded(Glib::RefPtr<Gdk::Monitor> monitor);
|
void handleMonitorAdded(Glib::RefPtr<Gdk::Monitor> monitor);
|
||||||
void handleMonitorRemoved(Glib::RefPtr<Gdk::Monitor> monitor);
|
void handleMonitorRemoved(Glib::RefPtr<Gdk::Monitor> monitor);
|
||||||
|
void handleDeferredMonitorRemoval(Glib::RefPtr<Gdk::Monitor> monitor);
|
||||||
|
|
||||||
Json::Value config_;
|
Json::Value config_;
|
||||||
Glib::RefPtr<Gtk::StyleContext> style_context_;
|
Glib::RefPtr<Gtk::StyleContext> style_context_;
|
||||||
|
@ -5,6 +5,13 @@
|
|||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
#include <sys/prctl.h>
|
||||||
|
#endif
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
#include <sys/procctl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
extern std::mutex reap_mtx;
|
extern std::mutex reap_mtx;
|
||||||
@ -77,6 +84,18 @@ inline FILE* open(const std::string& cmd, int& pid) {
|
|||||||
// Reset sigmask
|
// Reset sigmask
|
||||||
err = pthread_sigmask(SIG_UNBLOCK, &mask, nullptr);
|
err = pthread_sigmask(SIG_UNBLOCK, &mask, nullptr);
|
||||||
if (err != 0) spdlog::error("pthread_sigmask in open failed: {}", strerror(err));
|
if (err != 0) spdlog::error("pthread_sigmask in open failed: {}", strerror(err));
|
||||||
|
// Kill child if Waybar exits
|
||||||
|
int deathsig = SIGTERM;
|
||||||
|
#ifdef __linux__
|
||||||
|
if (prctl(PR_SET_PDEATHSIG, deathsig) != 0) {
|
||||||
|
spdlog::error("prctl(PR_SET_PDEATHSIG) in open failed: {}", strerror(errno));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
if (procctl(P_PID, 0, PROC_PDEATHSIG_CTL, reinterpret_cast<void*>(&deathsig)) == -1) {
|
||||||
|
spdlog::error("procctl(PROC_PDEATHSIG_CTL) in open failed: {}", strerror(errno));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
::close(fd[0]);
|
::close(fd[0]);
|
||||||
dup2(fd[1], 1);
|
dup2(fd[1], 1);
|
||||||
setpgid(child_pid, child_pid);
|
setpgid(child_pid, child_pid);
|
||||||
|
@ -179,6 +179,16 @@ void waybar::Client::handleMonitorAdded(Glib::RefPtr<Gdk::Monitor> monitor) {
|
|||||||
|
|
||||||
void waybar::Client::handleMonitorRemoved(Glib::RefPtr<Gdk::Monitor> monitor) {
|
void waybar::Client::handleMonitorRemoved(Glib::RefPtr<Gdk::Monitor> monitor) {
|
||||||
spdlog::debug("Output removed: {} {}", monitor->get_manufacturer(), monitor->get_model());
|
spdlog::debug("Output removed: {} {}", monitor->get_manufacturer(), monitor->get_model());
|
||||||
|
/* This event can be triggered from wl_display_roundtrip called by GTK or our code.
|
||||||
|
* Defer destruction of bars for the output to the next iteration of the event loop to avoid
|
||||||
|
* deleting objects referenced by currently executed code.
|
||||||
|
*/
|
||||||
|
Glib::signal_idle().connect_once(
|
||||||
|
sigc::bind(sigc::mem_fun(*this, &Client::handleDeferredMonitorRemoval), monitor),
|
||||||
|
Glib::PRIORITY_HIGH_IDLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void waybar::Client::handleDeferredMonitorRemoval(Glib::RefPtr<Gdk::Monitor> monitor) {
|
||||||
for (auto it = bars.begin(); it != bars.end();) {
|
for (auto it = bars.begin(); it != bars.end();) {
|
||||||
if ((*it)->output->monitor == monitor) {
|
if ((*it)->output->monitor == monitor) {
|
||||||
auto output_name = (*it)->output->name;
|
auto output_name = (*it)->output->name;
|
||||||
|
Loading…
Reference in New Issue
Block a user