fix: cancel thread and fix window close

This commit is contained in:
Alex
2020-05-27 09:10:38 +02:00
parent 3b16946c25
commit 6e7f22ac3a
11 changed files with 47 additions and 94 deletions

View File

@ -4,14 +4,15 @@
#include <glibmm/markup.h>
#include <gtkmm/eventbox.h>
#include <json/json.h>
#include "IModule.hpp"
namespace waybar {
class AModule : public IModule {
public:
AModule(const Json::Value &, const std::string &, const std::string &,
bool enable_click = false, bool enable_scroll = false);
AModule(const Json::Value &, const std::string &, const std::string &, bool enable_click = false,
bool enable_scroll = false);
virtual ~AModule();
virtual auto update() -> void;
virtual operator Gtk::Widget &();
@ -24,6 +25,7 @@ class AModule : public IModule {
SCROLL_DIR getScrollDir(GdkEventScroll *e);
bool tooltipEnabled();
const std::string name_;
const Json::Value &config_;
Gtk::EventBox event_box_;

View File

@ -34,10 +34,10 @@ class Bar {
struct waybar_output *output;
Json::Value config;
Gtk::Window window;
struct wl_surface * surface;
bool visible = true;
bool vertical = false;
Gtk::Window window;
private:
static constexpr const char *MIN_HEIGHT_MSG =

View File

@ -52,8 +52,6 @@ class Network : public ALabel {
struct sockaddr_nl nladdr_ = {0};
struct nl_sock* sock_ = nullptr;
struct nl_sock* ev_sock_ = nullptr;
int efd_;
int ev_fd_;
int nl80211_id_;
std::mutex mutex_;

View File

@ -5,7 +5,7 @@
namespace waybar::util {
class Rfkill {
public:;
public:
Rfkill(enum rfkill_type rfkill_type);
~Rfkill() = default;
void waitForEvent();
@ -13,7 +13,7 @@ class Rfkill {
private:
enum rfkill_type rfkill_type_;
int state_ = 0;
int state_ = 0;
};
} // namespace waybar::util

View File

@ -59,6 +59,11 @@ class SleeperThread {
do_run_ = false;
}
condvar_.notify_all();
auto handle = thread_.native_handle();
if (handle != 0) {
// TODO: find a proper way to terminate thread...
pthread_cancel(handle);
}
}
~SleeperThread() {