Merge pull request #2628 from andresilva/fix-hyprland-workspaces-init

hyprland/workspaces: fix crash on monitor off/on
This commit is contained in:
Alexis Rouillard 2023-11-01 23:12:32 +01:00 committed by GitHub
commit 121dcc645f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 7 deletions

View File

@ -38,6 +38,7 @@ Workspaces::Workspaces(const std::string &id, const Bar &bar, const Json::Value
: AModule(config, "workspaces", id, false, false), : AModule(config, "workspaces", id, false, false),
bar_(bar), bar_(bar),
box_(bar.vertical ? Gtk::ORIENTATION_VERTICAL : Gtk::ORIENTATION_HORIZONTAL, 0) { box_(bar.vertical ? Gtk::ORIENTATION_VERTICAL : Gtk::ORIENTATION_HORIZONTAL, 0) {
modulesReady = true;
parse_config(config); parse_config(config);
box_.set_name("workspaces"); box_.set_name("workspaces");
@ -46,9 +47,12 @@ Workspaces::Workspaces(const std::string &id, const Bar &bar, const Json::Value
} }
event_box_.add(box_); event_box_.add(box_);
register_ipc(); if (!gIPC.get()) {
gIPC = std::make_unique<IPC>();
}
init(); init();
register_ipc();
} }
auto Workspaces::parse_config(const Json::Value &config) -> void { auto Workspaces::parse_config(const Json::Value &config) -> void {
@ -127,12 +131,6 @@ auto Workspaces::parse_config(const Json::Value &config) -> void {
} }
auto Workspaces::register_ipc() -> void { auto Workspaces::register_ipc() -> void {
modulesReady = true;
if (!gIPC) {
gIPC = std::make_unique<IPC>();
}
gIPC->registerForIPC("workspace", this); gIPC->registerForIPC("workspace", this);
gIPC->registerForIPC("createworkspace", this); gIPC->registerForIPC("createworkspace", this);
gIPC->registerForIPC("destroyworkspace", this); gIPC->registerForIPC("destroyworkspace", this);