Skip to content

Commit 5a7a13c

Browse files
committed
fix restore on geometry change not working
1 parent 1386123 commit 5a7a13c

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

contents/code/main.js

+19-13
Original file line numberDiff line numberDiff line change
@@ -103,18 +103,20 @@ workspace.clientActivated.connect(onActivated);
103103
function onActivated(client) {
104104
if (client == null || client == undefined) return;
105105
if (undoAutoReactivate(client)) return;
106-
debug("\nactivated", client.caption);
106+
debug("activated", client.caption);
107107
addActive(client);
108108
removeMinimized(client);
109-
onRegeometrized(client);
109+
minimizeOverlapping(client);
110+
debug("");
110111
}
111112

112113
// add to watchlist on added and trigger minimize and restore when client is moved or resized or screen geometry changes
113114
workspace.clientList().forEach(client => onAdded(client));
114115
workspace.clientAdded.connect(onAdded);
115116
function onAdded(client) {
116-
debug("\nadded", client.caption);
117+
debug("added", client.caption);
117118
added = [client];
119+
debug("");
118120
client.geometryChanged.connect(onRegeometrized);
119121
client.clientGeometryChanged.connect(onRegeometrized);
120122
client.frameGeometryChanged.connect(onRegeometrized);
@@ -133,32 +135,35 @@ function onAdded(client) {
133135
}
134136
function onRegeometrized(client) {
135137
// don't act on windows that are still undergoing geometry change
136-
if (client == null || client == undefined || client.caption == undefined || client.caption == "Plasma" || client.move || client.resize) return;
137-
debug("\nregeometrized", client.caption);
138+
if (client == null || client == undefined || client.caption == "Plasma" || client.move || client.resize) return;
139+
debug("regeometrized", client.caption);
138140
removeMinimized(client);
139-
onRegeometrized(client);
140-
restoreMinimized();
141+
minimizeOverlapping(client);
142+
restoreMinimized(client);
143+
debug("");
141144
}
142145

143146
// trigger minimize, restore and reactivate when client minimized
144147
workspace.clientMinimized.connect(onMinimized);
145148
function onMinimized(client) {
146-
debug("\nminimized", client && client.caption ? client.caption : client);
149+
debug("minimized", client && client.caption ? client.caption : client);
147150
resetMinimized(client);
148151
if (!minimized.includes(client)) { // manually minimized
149152
removeActive(client);
150153
}
151-
restoreMinimized();
154+
restoreMinimized(client);
155+
debug("");
152156
}
153157

154158
// trigger minimize, restore and reactivate when client is closed
155159
workspace.clientRemoved.connect(onRemoved);
156160
function onRemoved(client) {
157-
debug("\nclosed", client && client.caption ? client.caption : client);
161+
debug("closed", client && client.caption ? client.caption : client);
158162
removeActive(client);
159163
removeMinimized(client);
160-
restoreMinimized();
164+
restoreMinimized(client);
161165
removed = true;
166+
debug("");
162167
}
163168

164169

@@ -167,7 +172,7 @@ function onRemoved(client) {
167172
///////////////////////
168173

169174
// minimize all windows overlapped by active window
170-
function onRegeometrized(active) {
175+
function minimizeOverlapping(active) {
171176
// if no window is provided, try the active window, if that fails too abort
172177
if (active == null || active == undefined) active = workspace.activeClient;
173178
if (active == undefined || active == null) return;
@@ -187,9 +192,10 @@ function onRegeometrized(active) {
187192
}
188193

189194
// restore all previously minimized windows that are now no longer overlapping
190-
function restoreMinimized() {
195+
function restoreMinimized(trigger) {
191196
// don't restore if auto-restore is disabled
192197
if (!config.autoRestore) return;
198+
debug("try restore for", trigger.caption);
193199

194200
// iterate minimized windows
195201
minimized = minimized.filter(client => client != null && client != undefined

0 commit comments

Comments
 (0)