Gtk4: Migration dwl/tags
Signed-off-by: Viktar Lukashonak <myxabeer@gmail.com>pull/2956/head
parent
b4a28042d8
commit
7e61e5f5d5
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace waybar::modules {
|
||||
|
||||
class Bluetooth : public ALabel {
|
||||
class Bluetooth final : public ALabel {
|
||||
struct ControllerInfo {
|
||||
std::string path;
|
||||
std::string address;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
namespace waybar::modules {
|
||||
|
||||
class Cpu : public ALabel {
|
||||
class Cpu final : public ALabel {
|
||||
public:
|
||||
Cpu(const std::string&, const Json::Value&);
|
||||
virtual ~Cpu() = default;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace waybar::modules {
|
||||
|
||||
class Custom : public ALabel {
|
||||
class Custom final : public ALabel {
|
||||
public:
|
||||
Custom(const std::string&, const std::string&, const Json::Value&, const std::string&);
|
||||
virtual ~Custom();
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
namespace waybar::modules {
|
||||
|
||||
class Disk : public ALabel {
|
||||
class Disk final : public ALabel {
|
||||
public:
|
||||
Disk(const std::string&, const Json::Value&);
|
||||
virtual ~Disk() = default;
|
||||
|
|
|
@ -1,34 +1,32 @@
|
|||
#pragma once
|
||||
|
||||
#include <gtkmm/button.h>
|
||||
#include <wayland-client.h>
|
||||
|
||||
#include "AModule.hpp"
|
||||
#include "bar.hpp"
|
||||
#include "dwl-ipc-unstable-v2-client-protocol.h"
|
||||
#include "xdg-output-unstable-v1-client-protocol.h"
|
||||
|
||||
namespace waybar::modules::dwl {
|
||||
|
||||
class Tags : public waybar::AModule {
|
||||
class Tags final : public waybar::AModule {
|
||||
public:
|
||||
Tags(const std::string &, const waybar::Bar &, const Json::Value &);
|
||||
virtual ~Tags();
|
||||
|
||||
// Handlers for wayland events
|
||||
void handle_view_tags(uint32_t tag, uint32_t state, uint32_t clients, uint32_t focused);
|
||||
|
||||
void handle_primary_clicked(uint32_t tag);
|
||||
bool handle_button_press(GdkEventButton *event_button, uint32_t tag);
|
||||
|
||||
struct zdwl_ipc_manager_v2 *status_manager_;
|
||||
struct wl_seat *seat_;
|
||||
|
||||
private:
|
||||
const waybar::Bar &bar_;
|
||||
Gtk::Box box_;
|
||||
std::vector<Gtk::Button> buttons_;
|
||||
std::vector<Glib::RefPtr<Gtk::GestureClick>> clickControls_;
|
||||
struct zdwl_ipc_output_v2 *output_status_;
|
||||
|
||||
void handle_primary_clicked(int n_press, double dx, double dy, uint32_t tag);
|
||||
void handle_button_press(int n_press, double dx, double dy, uint32_t tag,
|
||||
Glib::RefPtr<Gtk::GestureClick> controlClick);
|
||||
};
|
||||
|
||||
} /* namespace waybar::modules::dwl */
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace waybar::modules {
|
||||
|
||||
class Memory : public ALabel {
|
||||
class Memory final : public ALabel {
|
||||
public:
|
||||
Memory(const std::string&, const Json::Value&);
|
||||
virtual ~Memory() = default;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
namespace waybar::modules {
|
||||
|
||||
class Temperature : public ALabel {
|
||||
class Temperature final : public ALabel {
|
||||
public:
|
||||
Temperature(const std::string&, const Json::Value&);
|
||||
virtual ~Temperature() = default;
|
||||
|
|
|
@ -229,6 +229,10 @@ elif is_dragonfly or is_freebsd or is_netbsd or is_openbsd
|
|||
endif
|
||||
endif
|
||||
|
||||
add_project_arguments('-DHAVE_DWL', language: 'cpp')
|
||||
src_files += files('src/modules/dwl/tags.cpp')
|
||||
man_files += files('man/waybar-dwl-tags.5.scd')
|
||||
|
||||
subdir('protocol')
|
||||
|
||||
executable(
|
||||
|
|
|
@ -182,12 +182,12 @@ waybar::AModule* waybar::Factory::makeModule(const std::string& name,
|
|||
if (ref == "river/layout") {
|
||||
return new waybar::modules::river::Layout(id, bar_, config_[name]);
|
||||
}
|
||||
#endif
|
||||
#endif*/
|
||||
#ifdef HAVE_DWL
|
||||
if (ref == "dwl/tags") {
|
||||
return new waybar::modules::dwl::Tags(id, bar_, config_[name]);
|
||||
}
|
||||
#endif
|
||||
#endif/*
|
||||
#ifdef HAVE_HYPRLAND
|
||||
if (ref == "hyprland/window") {
|
||||
return new waybar::modules::hyprland::Window(id, bar_, config_[name]);
|
||||
|
|
|
@ -1,14 +1,7 @@
|
|||
#include "modules/dwl/tags.hpp"
|
||||
|
||||
#include <gtkmm/button.h>
|
||||
#include <gtkmm/label.h>
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <wayland-client.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "client.hpp"
|
||||
#include "dwl-ipc-unstable-v2-client-protocol.h"
|
||||
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
#define TAG_INACTIVE 0
|
||||
#define TAG_ACTIVE 1
|
||||
|
@ -114,7 +107,6 @@ Tags::Tags(const std::string &id, const waybar::Bar &bar, const Json::Value &con
|
|||
box_.get_style_context()->add_class(id);
|
||||
}
|
||||
box_.get_style_context()->add_class(MODULE_CLASS);
|
||||
event_box_.add(box_);
|
||||
|
||||
// Default to 9 tags, cap at 32
|
||||
const uint32_t num_tags =
|
||||
|
@ -133,14 +125,18 @@ Tags::Tags(const std::string &id, const waybar::Bar &bar, const Json::Value &con
|
|||
|
||||
uint32_t i = 1;
|
||||
for (const auto &tag_label : tag_labels) {
|
||||
Gtk::Button &button = buttons_.emplace_back(tag_label);
|
||||
button.set_relief(Gtk::RELIEF_NONE);
|
||||
box_.pack_start(button, false, false, 0);
|
||||
Gtk::Button &button{buttons_.emplace_back(tag_label)};
|
||||
auto controlClick{clickControls_.emplace_back(Gtk::GestureClick::create())};
|
||||
controlClick->set_propagation_phase(Gtk::PropagationPhase::TARGET);
|
||||
controlClick->set_button(0);
|
||||
button.add_controller(controlClick);
|
||||
button.set_has_frame(false);
|
||||
box_.prepend(button);
|
||||
if (!config_["disable-click"].asBool()) {
|
||||
button.signal_clicked().connect(
|
||||
sigc::bind(sigc::mem_fun(*this, &Tags::handle_primary_clicked), i));
|
||||
button.signal_button_press_event().connect(
|
||||
sigc::bind(sigc::mem_fun(*this, &Tags::handle_button_press), i));
|
||||
controlClick->signal_pressed().connect(sigc::bind(sigc::mem_fun(*this,
|
||||
&Tags::handle_button_press), i, controlClick));
|
||||
controlClick->signal_released().connect(sigc::bind(sigc::mem_fun(*this,
|
||||
&Tags::handle_primary_clicked), i));
|
||||
}
|
||||
button.show();
|
||||
i <<= 1;
|
||||
|
@ -160,18 +156,17 @@ Tags::~Tags() {
|
|||
}
|
||||
}
|
||||
|
||||
void Tags::handle_primary_clicked(uint32_t tag) {
|
||||
void Tags::handle_primary_clicked(int n_press, double dx, double dy, uint32_t tag) {
|
||||
if (!output_status_) return;
|
||||
|
||||
zdwl_ipc_output_v2_set_tags(output_status_, tag, 1);
|
||||
}
|
||||
|
||||
bool Tags::handle_button_press(GdkEventButton *event_button, uint32_t tag) {
|
||||
if (event_button->type == GDK_BUTTON_PRESS && event_button->button == 3) {
|
||||
if (!output_status_) return true;
|
||||
void Tags::handle_button_press(int n_press, double dx, double dy, uint32_t tag,
|
||||
Glib::RefPtr<Gtk::GestureClick> controlClick) {
|
||||
if (controlClick->get_current_button() == 3) {
|
||||
if (!output_status_) return;
|
||||
zdwl_ipc_output_v2_set_tags(output_status_, num_tags ^ tag, 0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void Tags::handle_view_tags(uint32_t tag, uint32_t state, uint32_t clients, uint32_t focused) {
|
||||
|
|
Loading…
Reference in New Issue