Merge pull request #4911 from khaneliman/gtkmenu
fix(menu): keep popup menus alive after builder teardown
This commit is contained in:
@@ -13,8 +13,8 @@
|
|||||||
|
|
||||||
#include "ipc.hpp"
|
#include "ipc.hpp"
|
||||||
#include "util/SafeSignal.hpp"
|
#include "util/SafeSignal.hpp"
|
||||||
#include "util/sleeper_thread.hpp"
|
|
||||||
#include "util/scoped_fd.hpp"
|
#include "util/scoped_fd.hpp"
|
||||||
|
#include "util/sleeper_thread.hpp"
|
||||||
|
|
||||||
namespace waybar::modules::sway {
|
namespace waybar::modules::sway {
|
||||||
|
|
||||||
|
|||||||
@@ -100,6 +100,8 @@ ALabel::ALabel(const Json::Value& config, const std::string& name, const std::st
|
|||||||
g_object_unref(builder);
|
g_object_unref(builder);
|
||||||
throw std::runtime_error("Failed to get 'menu' object from GtkBuilder");
|
throw std::runtime_error("Failed to get 'menu' object from GtkBuilder");
|
||||||
}
|
}
|
||||||
|
// Keep the menu alive after dropping the transient GtkBuilder.
|
||||||
|
g_object_ref(menu_);
|
||||||
submenus_ = std::map<std::string, GtkMenuItem*>();
|
submenus_ = std::map<std::string, GtkMenuItem*>();
|
||||||
menuActionsMap_ = std::map<std::string, std::string>();
|
menuActionsMap_ = std::map<std::string, std::string>();
|
||||||
|
|
||||||
|
|||||||
@@ -88,6 +88,10 @@ AModule::~AModule() {
|
|||||||
killpg(pid, SIGTERM);
|
killpg(pid, SIGTERM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (menu_ != nullptr) {
|
||||||
|
g_object_unref(menu_);
|
||||||
|
menu_ = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto AModule::update() -> void {
|
auto AModule::update() -> void {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "modules/custom.hpp"
|
#include "modules/custom.hpp"
|
||||||
|
|
||||||
#include <spdlog/spdlog.h>
|
#include <spdlog/spdlog.h>
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "util/scope_guard.hpp"
|
#include "util/scope_guard.hpp"
|
||||||
|
|||||||
@@ -189,8 +189,9 @@ void Window::queryActiveWorkspace() {
|
|||||||
if (workspace_.windows > 0) {
|
if (workspace_.windows > 0) {
|
||||||
const auto clients = m_ipc.getSocket1JsonReply("clients");
|
const auto clients = m_ipc.getSocket1JsonReply("clients");
|
||||||
if (clients.isArray()) {
|
if (clients.isArray()) {
|
||||||
auto activeWindow = std::ranges::find_if(
|
auto activeWindow = std::ranges::find_if(clients, [&](const Json::Value& window) {
|
||||||
clients, [&](const Json::Value& window) { return window["address"] == workspace_.last_window; });
|
return window["address"] == workspace_.last_window;
|
||||||
|
});
|
||||||
|
|
||||||
if (activeWindow == std::end(clients)) {
|
if (activeWindow == std::end(clients)) {
|
||||||
focused_ = false;
|
focused_ = false;
|
||||||
@@ -200,17 +201,19 @@ void Window::queryActiveWorkspace() {
|
|||||||
windowData_ = WindowData::parse(*activeWindow);
|
windowData_ = WindowData::parse(*activeWindow);
|
||||||
updateAppIconName(windowData_.class_name, windowData_.initial_class_name);
|
updateAppIconName(windowData_.class_name, windowData_.initial_class_name);
|
||||||
std::vector<Json::Value> workspaceWindows;
|
std::vector<Json::Value> workspaceWindows;
|
||||||
std::ranges::copy_if(clients, std::back_inserter(workspaceWindows), [&](const Json::Value& window) {
|
std::ranges::copy_if(
|
||||||
return window["workspace"]["id"] == workspace_.id && window["mapped"].asBool();
|
clients, std::back_inserter(workspaceWindows), [&](const Json::Value& window) {
|
||||||
});
|
return window["workspace"]["id"] == workspace_.id && window["mapped"].asBool();
|
||||||
|
});
|
||||||
swallowing_ = std::ranges::any_of(workspaceWindows, [&](const Json::Value& window) {
|
swallowing_ = std::ranges::any_of(workspaceWindows, [&](const Json::Value& window) {
|
||||||
return !window["swallowing"].isNull() && window["swallowing"].asString() != "0x0";
|
return !window["swallowing"].isNull() && window["swallowing"].asString() != "0x0";
|
||||||
});
|
});
|
||||||
std::vector<Json::Value> visibleWindows;
|
std::vector<Json::Value> visibleWindows;
|
||||||
std::ranges::copy_if(workspaceWindows, std::back_inserter(visibleWindows),
|
std::ranges::copy_if(workspaceWindows, std::back_inserter(visibleWindows),
|
||||||
[&](const Json::Value& window) { return !window["hidden"].asBool(); });
|
[&](const Json::Value& window) { return !window["hidden"].asBool(); });
|
||||||
solo_ = 1 == std::count_if(visibleWindows.begin(), visibleWindows.end(),
|
solo_ = 1 == std::count_if(
|
||||||
[&](const Json::Value& window) { return !window["floating"].asBool(); });
|
visibleWindows.begin(), visibleWindows.end(),
|
||||||
|
[&](const Json::Value& window) { return !window["floating"].asBool(); });
|
||||||
allFloating_ = std::ranges::all_of(
|
allFloating_ = std::ranges::all_of(
|
||||||
visibleWindows, [&](const Json::Value& window) { return window["floating"].asBool(); });
|
visibleWindows, [&](const Json::Value& window) { return window["floating"].asBool(); });
|
||||||
fullscreen_ = windowData_.fullscreen;
|
fullscreen_ = windowData_.fullscreen;
|
||||||
|
|||||||
@@ -13,11 +13,11 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
#include "util/scoped_fd.hpp"
|
|
||||||
#include "giomm/datainputstream.h"
|
#include "giomm/datainputstream.h"
|
||||||
#include "giomm/dataoutputstream.h"
|
#include "giomm/dataoutputstream.h"
|
||||||
#include "giomm/unixinputstream.h"
|
#include "giomm/unixinputstream.h"
|
||||||
#include "giomm/unixoutputstream.h"
|
#include "giomm/unixoutputstream.h"
|
||||||
|
#include "util/scoped_fd.hpp"
|
||||||
|
|
||||||
namespace waybar::modules::niri {
|
namespace waybar::modules::niri {
|
||||||
|
|
||||||
|
|||||||
@@ -4,11 +4,12 @@
|
|||||||
#include <catch2/catch.hpp>
|
#include <catch2/catch.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
std::mutex reap_mtx;
|
std::mutex reap_mtx;
|
||||||
std::list<pid_t> reap;
|
std::list<pid_t> reap;
|
||||||
|
|||||||
Reference in New Issue
Block a user