Skip to content

Commit d02b408

Browse files
authored
Merge pull request #27 from ebeem/switcher_caching
Implement complete switcher caching
2 parents b4fa09f + 1bd3631 commit d02b408

File tree

6 files changed

+95
-4
lines changed

6 files changed

+95
-4
lines changed

wsmatrix@martin.zurowietz.de/ThumbnailWsmatrixPopup.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,9 @@ class ThumbnailWsmatrixPopupList extends WorkspaceSwitcherPopupList {
105105

106106
var ThumbnailWsmatrixPopup = GObject.registerClass(
107107
class ThumbnailWsmatrixPopup extends BaseWorkspaceSwitcherPopup {
108-
_init(rows, columns, scale, popupTimeout) {
108+
_init(rows, columns, scale, popupTimeout, hideOnly) {
109109
super._init(popupTimeout);
110+
this._hideOnly = hideOnly;
110111
this._workspaceManager = DisplayWrapper.getWorkspaceManager();
111112
let oldList = this._list;
112113
this._list = new ThumbnailWsmatrixPopupList(rows, columns, scale);
@@ -161,4 +162,12 @@ class ThumbnailWsmatrixPopup extends BaseWorkspaceSwitcherPopup {
161162
actor.set_scale(hScale, vScale);
162163
}
163164
}
165+
166+
destroy(force = false) {
167+
if (this._hideOnly && !force) {
168+
this.hide();
169+
} else {
170+
super.destroy();
171+
}
172+
}
164173
});

wsmatrix@martin.zurowietz.de/WmOverride.js

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@ var WmOverride = class {
3030
this._handleScaleChanged();
3131
this._handleShowThumbnailsChanged();
3232
this._handleShowWorkspaceNamesChanged();
33+
this._handleCachePopupChanged();
3334
this._handleWraparoundModeChanged();
3435
this._connectSettings();
3536
this._notify();
3637
}
3738

3839
destroy() {
40+
this._destroyWorkspaceSwitcherPopup();
3941
this._disconnectSettings();
4042
this._restoreKeybindingHandlers();
4143
this._restoreLayout();
@@ -79,6 +81,11 @@ var WmOverride = class {
7981
'changed::show-workspace-names',
8082
this._handleShowWorkspaceNamesChanged.bind(this)
8183
);
84+
85+
this.settingsHandlerCachePopup = this.settings.connect(
86+
'changed::cache-popup',
87+
this._handleCachePopupChanged.bind(this)
88+
);
8289
}
8390

8491
_disconnectSettings() {
@@ -89,25 +96,30 @@ var WmOverride = class {
8996
this.settings.disconnect(this.settingsHandlerShowThumbnails);
9097
this.settings.disconnect(this.settingsHandlerWraparoundMode);
9198
this.settings.disconnect(this.settingsHandlerShowWorkspaceNames);
99+
this.settings.disconnect(this.settingsHandlerCachePopup);
92100
}
93101

94102
_handleNumberOfWorkspacesChanged() {
95103
this.rows = this.settings.get_int('num-rows');
96104
this.columns = this.settings.get_int('num-columns');
97105
this._overrideNumberOfWorkspaces();
98106
this._overrideLayout();
107+
this._destroyWorkspaceSwitcherPopup();
99108
}
100109

101110
_handlePopupTimeoutChanged() {
102111
this.popupTimeout = this.settings.get_int('popup-timeout');
112+
this._destroyWorkspaceSwitcherPopup();
103113
}
104114

105115
_handleScaleChanged() {
106116
this.scale = this.settings.get_double('scale');
117+
this._destroyWorkspaceSwitcherPopup();
107118
}
108119

109120
_handleShowThumbnailsChanged() {
110121
this.showThumbnails = this.settings.get_boolean('show-thumbnails');
122+
this._destroyWorkspaceSwitcherPopup();
111123
}
112124

113125
_handleWraparoundModeChanged() {
@@ -116,6 +128,12 @@ var WmOverride = class {
116128

117129
_handleShowWorkspaceNamesChanged() {
118130
this.showWorkspaceNames = this.settings.get_boolean('show-workspace-names');
131+
this._destroyWorkspaceSwitcherPopup();
132+
}
133+
134+
_handleCachePopupChanged() {
135+
this.cachePopup = this.settings.get_boolean('cache-popup');
136+
this._destroyWorkspaceSwitcherPopup();
119137
}
120138

121139
_overrideLayout() {
@@ -294,7 +312,8 @@ var WmOverride = class {
294312
this.rows,
295313
this.columns,
296314
this.scale,
297-
this.popupTimeout
315+
this.popupTimeout,
316+
this.cachePopup
298317
);
299318
} else {
300319
this.wm._workspaceSwitcherPopup = new IndicatorWsmatrixPopup(
@@ -313,4 +332,14 @@ var WmOverride = class {
313332
this.wm._workspaceSwitcherPopup.display(direction, newWs.index());
314333
}
315334
}
335+
336+
_destroyWorkspaceSwitcherPopup() {
337+
if (this.wm._workspaceSwitcherPopup) {
338+
if (this.wm._workspaceSwitcherPopup instanceof ThumbnailWsmatrixPopup) {
339+
this.wm._workspaceSwitcherPopup.destroy(true);
340+
} else {
341+
this.wm._workspaceSwitcherPopup.destroy();
342+
}
343+
}
344+
}
316345
}

wsmatrix@martin.zurowietz.de/prefs.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ var PrefsWidget = new GObject.Class({
3030
);
3131
this._setScaleSensitive();
3232

33+
this._settings.connect(
34+
'changed::show-thumbnails',
35+
this._setSetCachePopupSensitive.bind(this)
36+
);
37+
this._setSetCachePopupSensitive();
38+
3339
this._settings.connect(
3440
'changed::show-thumbnails',
3541
this._setSetShowWorkspaceNamesSensitive.bind(this)
@@ -46,6 +52,7 @@ var PrefsWidget = new GObject.Class({
4652
return [
4753
'show-thumbnails',
4854
'show-workspace-names',
55+
'cache-popup',
4956
];
5057
},
5158

@@ -118,6 +125,10 @@ var PrefsWidget = new GObject.Class({
118125
this._getWidget('scale').set_sensitive(this._settings.get_boolean('show-thumbnails'));
119126
},
120127

128+
_setSetCachePopupSensitive: function () {
129+
this._getWidget('cache-popup').set_sensitive(this._settings.get_boolean('show-thumbnails'));
130+
},
131+
121132
_setSetShowWorkspaceNamesSensitive: function () {
122133
this._getWidget('show-workspace-names').set_sensitive(!this._settings.get_boolean('show-thumbnails'));
123134
},
60 Bytes
Binary file not shown.

wsmatrix@martin.zurowietz.de/schemas/org.gnome.shell.extensions.wsmatrix.gschema.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
<default>true</default>
3030
<summary>Whether to show workspace thumbnails or not</summary>
3131
</key>
32+
<key type="b" name="cache-popup">
33+
<default>false</default>
34+
<summary>Cache popup (faster, consumes more memory)</summary>
35+
</key>
3236
<key type="b" name="show-workspace-names">
3337
<default>false</default>
3438
<summary>Whether to show workspace names or not</summary>

wsmatrix@martin.zurowietz.de/settings.ui

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,44 @@
232232
<property name="position">4</property>
233233
</packing>
234234
</child>
235+
<child>
236+
<object class="GtkBox">
237+
<property name="visible">True</property>
238+
<property name="can_focus">False</property>
239+
<property name="spacing">50</property>
240+
<child>
241+
<object class="GtkLabel">
242+
<property name="visible">True</property>
243+
<property name="can_focus">False</property>
244+
<property name="valign">center</property>
245+
<property name="label" translatable="yes">Cache popup (faster, consumes more memory)</property>
246+
</object>
247+
<packing>
248+
<property name="expand">False</property>
249+
<property name="fill">True</property>
250+
<property name="position">0</property>
251+
</packing>
252+
</child>
253+
<child>
254+
<object class="GtkSwitch" id="cache_popup">
255+
<property name="visible">True</property>
256+
<property name="can_focus">True</property>
257+
<property name="valign">center</property>
258+
</object>
259+
<packing>
260+
<property name="expand">False</property>
261+
<property name="fill">True</property>
262+
<property name="pack_type">end</property>
263+
<property name="position">1</property>
264+
</packing>
265+
</child>
266+
</object>
267+
<packing>
268+
<property name="expand">False</property>
269+
<property name="fill">True</property>
270+
<property name="position">5</property>
271+
</packing>
272+
</child>
235273
<child>
236274
<object class="GtkBox">
237275
<property name="visible">True</property>
@@ -267,7 +305,7 @@
267305
<packing>
268306
<property name="expand">False</property>
269307
<property name="fill">True</property>
270-
<property name="position">5</property>
308+
<property name="position">6</property>
271309
</packing>
272310
</child>
273311
<child>
@@ -310,7 +348,7 @@
310348
<packing>
311349
<property name="expand">False</property>
312350
<property name="fill">True</property>
313-
<property name="position">6</property>
351+
<property name="position">7</property>
314352
</packing>
315353
</child>
316354
</object>

0 commit comments

Comments
 (0)