workspace taskbars: Fix windows not showing
Windows were not being shown or updated unless the window-rewrite config were present.
This commit is contained in:
@ -33,7 +33,7 @@ struct WindowRepr {
|
||||
std::string repr_rewrite;
|
||||
|
||||
public:
|
||||
bool empty() const { return repr_rewrite.empty(); }
|
||||
bool empty() const { return address.empty(); }
|
||||
};
|
||||
|
||||
class WindowCreationPayload {
|
||||
|
@ -39,7 +39,7 @@ class Workspaces : public AModule, public EventHandler {
|
||||
auto activeOnly() const -> bool { return m_activeOnly; }
|
||||
auto specialVisibleOnly() const -> bool { return m_specialVisibleOnly; }
|
||||
auto moveToMonitor() const -> bool { return m_moveToMonitor; }
|
||||
auto enableWorkspaceTaskbar() const -> bool { return m_enableWorkspaceTaskbar; }
|
||||
auto enableTaskbar() const -> bool { return m_enableTaskbar; }
|
||||
auto taskbarWithIcon() const -> bool { return m_taskbarWithIcon; }
|
||||
|
||||
auto getBarOutput() const -> std::string { return m_bar.output->name; }
|
||||
@ -159,8 +159,9 @@ class Workspaces : public AModule, public EventHandler {
|
||||
std::vector<WindowCreationPayload> m_windowsToCreate;
|
||||
|
||||
IconLoader m_iconLoader;
|
||||
bool m_enableWorkspaceTaskbar = false;
|
||||
bool m_enableTaskbar = false;
|
||||
bool m_taskbarWithIcon = false;
|
||||
bool m_taskbarWithTitle = false;
|
||||
std::string m_taskbarFormatBefore;
|
||||
std::string m_taskbarFormatAfter;
|
||||
int m_taskbarIconSize = 16;
|
||||
|
@ -32,7 +32,7 @@ Workspace::Workspace(const Json::Value &workspace_data, Workspaces &workspace_ma
|
||||
false);
|
||||
|
||||
m_button.set_relief(Gtk::RELIEF_NONE);
|
||||
if (m_workspaceManager.enableWorkspaceTaskbar()) {
|
||||
if (m_workspaceManager.enableTaskbar()) {
|
||||
m_content.set_orientation(m_workspaceManager.taskbarOrientation());
|
||||
m_content.pack_start(m_labelBefore, false, false);
|
||||
} else {
|
||||
@ -105,7 +105,7 @@ void Workspace::insertWindow(WindowCreationPayload create_window_paylod) {
|
||||
if (!create_window_paylod.isEmpty(m_workspaceManager)) {
|
||||
auto repr = create_window_paylod.repr(m_workspaceManager);
|
||||
|
||||
if (!repr.empty()) {
|
||||
if (!repr.empty() || m_workspaceManager.enableTaskbar()) {
|
||||
auto addr = create_window_paylod.getAddress();
|
||||
auto it = std::ranges::find_if(
|
||||
m_windowMap, [&addr](const auto &window) { return window.address == addr; });
|
||||
@ -213,8 +213,8 @@ void Workspace::update(const std::string &workspace_icon) {
|
||||
|
||||
std::string windows;
|
||||
// Optimization: The {windows} substitution string is only possible if the taskbar is disabled, no
|
||||
// need to compute this if enableWorkspaceTaskbar() is true
|
||||
if (!m_workspaceManager.enableWorkspaceTaskbar()) {
|
||||
// need to compute this if enableTaskbar() is true
|
||||
if (!m_workspaceManager.enableTaskbar()) {
|
||||
auto windowSeparator = m_workspaceManager.getWindowSeparator();
|
||||
|
||||
bool isNotFirst = false;
|
||||
@ -233,7 +233,7 @@ void Workspace::update(const std::string &workspace_icon) {
|
||||
fmt::arg("name", name()), fmt::arg("icon", workspace_icon),
|
||||
fmt::arg("windows", windows)));
|
||||
|
||||
if (m_workspaceManager.enableWorkspaceTaskbar()) {
|
||||
if (m_workspaceManager.enableTaskbar()) {
|
||||
updateTaskbar(workspace_icon);
|
||||
}
|
||||
}
|
||||
|
@ -589,7 +589,7 @@ auto Workspaces::parseConfig(const Json::Value &config) -> void {
|
||||
if (withWindows) {
|
||||
populateWorkspaceTaskbarConfig(config);
|
||||
}
|
||||
if (m_enableWorkspaceTaskbar) {
|
||||
if (m_enableTaskbar) {
|
||||
auto parts = split(m_formatBefore, "{windows}", 1);
|
||||
m_formatBefore = parts[0];
|
||||
m_formatAfter = parts.size() > 1 ? parts[1] : "";
|
||||
@ -673,11 +673,13 @@ auto Workspaces::populateWorkspaceTaskbarConfig(const Json::Value &config) -> vo
|
||||
return;
|
||||
}
|
||||
|
||||
populateBoolConfig(workspaceTaskbar, "enable", m_enableWorkspaceTaskbar);
|
||||
populateBoolConfig(workspaceTaskbar, "enable", m_enableTaskbar);
|
||||
|
||||
if (workspaceTaskbar["format"].isString()) {
|
||||
/* The user defined a format string, use it */
|
||||
auto parts = split(workspaceTaskbar["format"].asString(), "{icon}", 1);
|
||||
std::string format = workspaceTaskbar["format"].asString();
|
||||
m_taskbarWithTitle = format.find("{title") != std::string::npos; /* {title} or {title.length} */
|
||||
auto parts = split(format, "{icon}", 1);
|
||||
m_taskbarFormatBefore = parts[0];
|
||||
if (parts.size() > 1) {
|
||||
m_taskbarWithIcon = true;
|
||||
@ -726,7 +728,7 @@ auto Workspaces::registerIpc() -> void {
|
||||
gIPC->registerForIPC("urgent", this);
|
||||
gIPC->registerForIPC("configreloaded", this);
|
||||
|
||||
if (windowRewriteConfigUsesTitle()) {
|
||||
if (windowRewriteConfigUsesTitle() || m_taskbarWithTitle) {
|
||||
spdlog::info(
|
||||
"Registering for Hyprland's 'windowtitle' events because a user-defined window "
|
||||
"rewrite rule uses the 'title' field.");
|
||||
|
Reference in New Issue
Block a user