Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/window/proxywindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,10 @@ void ProxyWindowBase::onSceneGraphError(

void ProxyWindowBase::onVisibleChanged() {
if (this->mVisible && !this->window->isVisible()) {
this->mVisible = false;
if (!this->deleteOnInvisible()) {
this->mVisible = false;
}

this->setVisibleDirect(false);
emit this->closed();
}
Expand Down Expand Up @@ -403,6 +406,10 @@ void ProxyWindowBase::setScreen(QuickshellScreenInfo* screen) {
if (oldScreen != qscreen) {
if (this->window == nullptr) {
emit this->screenChanged();

if (qscreen != nullptr && this->mVisible && this->reloadComplete) {
this->setVisibleDirect(true);
}
} else if (qscreen) {
auto reshow = this->isVisibleDirect();
if (reshow) this->setVisibleDirect(false);
Expand Down
4 changes: 2 additions & 2 deletions src/x11/i3/ipc/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void I3IpcController::handleGetWorkspacesEvent(I3IpcEvent* event) {
}

if (!this->bFocusedWorkspace && object.value("focused").value<bool>()) {
this->bFocusedMonitor = workspace->bindableMonitor().value();
this->setFocusedMonitor(workspace->bindableMonitor().value());
}

names.push_back(name);
Expand Down Expand Up @@ -277,7 +277,7 @@ void I3IpcController::handleWorkspaceEvent(I3IpcEvent* event) {
if (newWorkspace->bindableMonitor().value()) {
auto* monitor = newWorkspace->bindableMonitor().value();
monitor->setFocusedWorkspace(newWorkspace);
this->bFocusedMonitor = monitor;
this->setFocusedMonitor(monitor);
}
} else if (change == "empty") {
auto name = event->mData["current"]["name"].toString();
Expand Down
27 changes: 24 additions & 3 deletions src/x11/i3/ipc/monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ void I3Monitor::updateFromObject(const QVariantMap& obj) {
|| activeWorkspaceName != this->bActiveWorkspace->bindableName().value())
{
if (activeWorkspaceName.isEmpty()) {
this->bActiveWorkspace = nullptr;
this->setFocusedWorkspace(nullptr);
} else {
this->bActiveWorkspace = this->ipc->findWorkspaceByName(activeWorkspaceName);
this->setFocusedWorkspace(this->ipc->findWorkspaceByName(activeWorkspaceName));
}
};

Expand All @@ -55,6 +55,27 @@ void I3Monitor::updateFromObject(const QVariantMap& obj) {

void I3Monitor::updateInitial(const QString& name) { this->bName = name; }

void I3Monitor::setFocusedWorkspace(I3Workspace* workspace) { this->bActiveWorkspace = workspace; };
void I3Monitor::setFocusedWorkspace(I3Workspace* workspace) {
auto* oldWorkspace = this->bActiveWorkspace.value();

if (oldWorkspace == workspace) return;

if (oldWorkspace != nullptr) {
QObject::disconnect(oldWorkspace, nullptr, this, nullptr);
}

if (workspace != nullptr) {
QObject::connect(
workspace,
&QObject::destroyed,
this,
&I3Monitor::onActiveWorkspaceDestroyed
);
}

this->bActiveWorkspace = workspace;
}

void I3Monitor::onActiveWorkspaceDestroyed() { this->bActiveWorkspace = nullptr; }

} // namespace qs::i3::ipc
2 changes: 2 additions & 0 deletions src/x11/i3/ipc/monitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ class I3Monitor: public QObject {
private:
I3IpcController* ipc;

void onActiveWorkspaceDestroyed();

QVariantMap mLastIpcObject;

// clang-format off
Expand Down
22 changes: 20 additions & 2 deletions src/x11/i3/ipc/workspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,33 @@ void I3Workspace::updateFromObject(const QVariantMap& obj) {

if (!this->bMonitor || monitorName != this->bMonitor->bindableName().value()) {
if (monitorName.isEmpty()) {
this->bMonitor = nullptr;
this->setMonitor(nullptr);
} else {
this->bMonitor = this->ipc->findMonitorByName(monitorName, true);
this->setMonitor(this->ipc->findMonitorByName(monitorName, true));
}
}

Qt::endPropertyUpdateGroup();
}

void I3Workspace::setMonitor(I3Monitor* monitor) {
auto* oldMonitor = this->bMonitor.value();

if (oldMonitor == monitor) return;

if (oldMonitor != nullptr) {
QObject::disconnect(oldMonitor, nullptr, this, nullptr);
}

if (monitor != nullptr) {
QObject::connect(monitor, &QObject::destroyed, this, &I3Workspace::onMonitorDestroyed);
}

this->bMonitor = monitor;
}

void I3Workspace::onMonitorDestroyed() { this->bMonitor = nullptr; }

void I3Workspace::activate() {
this->ipc->dispatch(QString("workspace number %1").arg(this->bNumber.value()));
}
Expand Down
3 changes: 3 additions & 0 deletions src/x11/i3/ipc/workspace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ class I3Workspace: public QObject {
private:
I3IpcController* ipc;

void setMonitor(I3Monitor* monitor);
void onMonitorDestroyed();

QVariantMap mLastIpcObject;

// clang-format off
Expand Down
Loading