Merge branch 'Alexays:master' into master
This commit is contained in:
commit
bf36f2abed
|
@ -24,6 +24,10 @@
|
||||||
|
|
||||||
namespace waybar::modules::wlr {
|
namespace waybar::modules::wlr {
|
||||||
|
|
||||||
|
struct widget_geometry {
|
||||||
|
int x, y, w, h;
|
||||||
|
};
|
||||||
|
|
||||||
class Taskbar;
|
class Taskbar;
|
||||||
|
|
||||||
class Task {
|
class Task {
|
||||||
|
@ -42,6 +46,7 @@ class Task {
|
||||||
};
|
};
|
||||||
// made public so TaskBar can reorder based on configuration.
|
// made public so TaskBar can reorder based on configuration.
|
||||||
Gtk::Button button;
|
Gtk::Button button;
|
||||||
|
struct widget_geometry minimize_hint;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static uint32_t global_id;
|
static uint32_t global_id;
|
||||||
|
@ -82,6 +87,8 @@ class Task {
|
||||||
private:
|
private:
|
||||||
std::string repr() const;
|
std::string repr() const;
|
||||||
std::string state_string(bool = false) const;
|
std::string state_string(bool = false) const;
|
||||||
|
void set_minimize_hint();
|
||||||
|
void on_button_size_allocated(Gtk::Allocation &alloc);
|
||||||
void set_app_info_from_app_id_list(const std::string &app_id_list);
|
void set_app_info_from_app_id_list(const std::string &app_id_list);
|
||||||
bool image_load_icon(Gtk::Image &image, const Glib::RefPtr<Gtk::IconTheme> &icon_theme,
|
bool image_load_icon(Gtk::Image &image, const Glib::RefPtr<Gtk::IconTheme> &icon_theme,
|
||||||
Glib::RefPtr<Gio::DesktopAppInfo> app_info, int size);
|
Glib::RefPtr<Gio::DesktopAppInfo> app_info, int size);
|
||||||
|
|
|
@ -148,22 +148,12 @@ void IPC::unregisterForIPC(EventHandler* ev_handler) {
|
||||||
std::string IPC::getSocket1Reply(const std::string& rq) {
|
std::string IPC::getSocket1Reply(const std::string& rq) {
|
||||||
// basically hyprctl
|
// basically hyprctl
|
||||||
|
|
||||||
struct addrinfo aiHints;
|
|
||||||
struct addrinfo* aiRes = nullptr;
|
|
||||||
const auto serverSocket = socket(AF_UNIX, SOCK_STREAM, 0);
|
const auto serverSocket = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||||
|
|
||||||
if (serverSocket < 0) {
|
if (serverSocket < 0) {
|
||||||
throw std::runtime_error("Hyprland IPC: Couldn't open a socket (1)");
|
throw std::runtime_error("Hyprland IPC: Couldn't open a socket (1)");
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&aiHints, 0, sizeof(struct addrinfo));
|
|
||||||
aiHints.ai_family = AF_UNSPEC;
|
|
||||||
aiHints.ai_socktype = SOCK_STREAM;
|
|
||||||
|
|
||||||
if (getaddrinfo("localhost", nullptr, &aiHints, &aiRes) != 0) {
|
|
||||||
throw std::runtime_error("Hyprland IPC: Couldn't get host (2)");
|
|
||||||
}
|
|
||||||
|
|
||||||
// get the instance signature
|
// get the instance signature
|
||||||
auto* instanceSig = getenv("HYPRLAND_INSTANCE_SIGNATURE");
|
auto* instanceSig = getenv("HYPRLAND_INSTANCE_SIGNATURE");
|
||||||
|
|
||||||
|
|
|
@ -387,6 +387,11 @@ void Task::handle_title(const char *title) {
|
||||||
hide_if_ignored();
|
hide_if_ignored();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Task::set_minimize_hint() {
|
||||||
|
zwlr_foreign_toplevel_handle_v1_set_rectangle(handle_, bar_.surface, minimize_hint.x,
|
||||||
|
minimize_hint.y, minimize_hint.w, minimize_hint.h);
|
||||||
|
}
|
||||||
|
|
||||||
void Task::hide_if_ignored() {
|
void Task::hide_if_ignored() {
|
||||||
if (tbar_->ignore_list().count(app_id_) || tbar_->ignore_list().count(title_)) {
|
if (tbar_->ignore_list().count(app_id_) || tbar_->ignore_list().count(title_)) {
|
||||||
ignored_ = true;
|
ignored_ = true;
|
||||||
|
@ -447,6 +452,13 @@ void Task::handle_app_id(const char *app_id) {
|
||||||
spdlog::debug("Couldn't find icon for {}", app_id_);
|
spdlog::debug("Couldn't find icon for {}", app_id_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Task::on_button_size_allocated(Gtk::Allocation &alloc) {
|
||||||
|
gtk_widget_translate_coordinates(GTK_WIDGET(button.gobj()), GTK_WIDGET(bar_.window.gobj()), 0, 0,
|
||||||
|
&minimize_hint.x, &minimize_hint.y);
|
||||||
|
minimize_hint.w = button.get_width();
|
||||||
|
minimize_hint.h = button.get_height();
|
||||||
|
}
|
||||||
|
|
||||||
void Task::handle_output_enter(struct wl_output *output) {
|
void Task::handle_output_enter(struct wl_output *output) {
|
||||||
if (ignored_) {
|
if (ignored_) {
|
||||||
spdlog::debug("{} is ignored", repr());
|
spdlog::debug("{} is ignored", repr());
|
||||||
|
@ -457,6 +469,8 @@ void Task::handle_output_enter(struct wl_output *output) {
|
||||||
|
|
||||||
if (!button_visible_ && (tbar_->all_outputs() || tbar_->show_output(output))) {
|
if (!button_visible_ && (tbar_->all_outputs() || tbar_->show_output(output))) {
|
||||||
/* The task entered the output of the current bar make the button visible */
|
/* The task entered the output of the current bar make the button visible */
|
||||||
|
button.signal_size_allocate().connect_notify(
|
||||||
|
sigc::mem_fun(this, &Task::on_button_size_allocated));
|
||||||
tbar_->add_button(button);
|
tbar_->add_button(button);
|
||||||
button.show();
|
button.show();
|
||||||
button_visible_ = true;
|
button_visible_ = true;
|
||||||
|
@ -553,9 +567,11 @@ bool Task::handle_clicked(GdkEventButton *bt) {
|
||||||
return true;
|
return true;
|
||||||
else if (action == "activate")
|
else if (action == "activate")
|
||||||
activate();
|
activate();
|
||||||
else if (action == "minimize")
|
else if (action == "minimize") {
|
||||||
|
set_minimize_hint();
|
||||||
minimize(!minimized());
|
minimize(!minimized());
|
||||||
else if (action == "minimize-raise") {
|
} else if (action == "minimize-raise") {
|
||||||
|
set_minimize_hint();
|
||||||
if (minimized())
|
if (minimized())
|
||||||
minimize(false);
|
minimize(false);
|
||||||
else if (active())
|
else if (active())
|
||||||
|
|
Loading…
Reference in New Issue