Skip to content

Commit

Permalink
Merge pull request #27 from ebeem/switcher_caching
Browse files Browse the repository at this point in the history
Implement complete switcher caching
  • Loading branch information
mzur authored May 13, 2019
2 parents b4fa09f + 1bd3631 commit d02b408
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 4 deletions.
11 changes: 10 additions & 1 deletion [email protected]/ThumbnailWsmatrixPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ class ThumbnailWsmatrixPopupList extends WorkspaceSwitcherPopupList {

var ThumbnailWsmatrixPopup = GObject.registerClass(
class ThumbnailWsmatrixPopup extends BaseWorkspaceSwitcherPopup {
_init(rows, columns, scale, popupTimeout) {
_init(rows, columns, scale, popupTimeout, hideOnly) {
super._init(popupTimeout);
this._hideOnly = hideOnly;
this._workspaceManager = DisplayWrapper.getWorkspaceManager();
let oldList = this._list;
this._list = new ThumbnailWsmatrixPopupList(rows, columns, scale);
Expand Down Expand Up @@ -161,4 +162,12 @@ class ThumbnailWsmatrixPopup extends BaseWorkspaceSwitcherPopup {
actor.set_scale(hScale, vScale);
}
}

destroy(force = false) {
if (this._hideOnly && !force) {
this.hide();
} else {
super.destroy();
}
}
});
31 changes: 30 additions & 1 deletion [email protected]/WmOverride.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ var WmOverride = class {
this._handleScaleChanged();
this._handleShowThumbnailsChanged();
this._handleShowWorkspaceNamesChanged();
this._handleCachePopupChanged();
this._handleWraparoundModeChanged();
this._connectSettings();
this._notify();
}

destroy() {
this._destroyWorkspaceSwitcherPopup();
this._disconnectSettings();
this._restoreKeybindingHandlers();
this._restoreLayout();
Expand Down Expand Up @@ -79,6 +81,11 @@ var WmOverride = class {
'changed::show-workspace-names',
this._handleShowWorkspaceNamesChanged.bind(this)
);

this.settingsHandlerCachePopup = this.settings.connect(
'changed::cache-popup',
this._handleCachePopupChanged.bind(this)
);
}

_disconnectSettings() {
Expand All @@ -89,25 +96,30 @@ var WmOverride = class {
this.settings.disconnect(this.settingsHandlerShowThumbnails);
this.settings.disconnect(this.settingsHandlerWraparoundMode);
this.settings.disconnect(this.settingsHandlerShowWorkspaceNames);
this.settings.disconnect(this.settingsHandlerCachePopup);
}

_handleNumberOfWorkspacesChanged() {
this.rows = this.settings.get_int('num-rows');
this.columns = this.settings.get_int('num-columns');
this._overrideNumberOfWorkspaces();
this._overrideLayout();
this._destroyWorkspaceSwitcherPopup();
}

_handlePopupTimeoutChanged() {
this.popupTimeout = this.settings.get_int('popup-timeout');
this._destroyWorkspaceSwitcherPopup();
}

_handleScaleChanged() {
this.scale = this.settings.get_double('scale');
this._destroyWorkspaceSwitcherPopup();
}

_handleShowThumbnailsChanged() {
this.showThumbnails = this.settings.get_boolean('show-thumbnails');
this._destroyWorkspaceSwitcherPopup();
}

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

_handleShowWorkspaceNamesChanged() {
this.showWorkspaceNames = this.settings.get_boolean('show-workspace-names');
this._destroyWorkspaceSwitcherPopup();
}

_handleCachePopupChanged() {
this.cachePopup = this.settings.get_boolean('cache-popup');
this._destroyWorkspaceSwitcherPopup();
}

_overrideLayout() {
Expand Down Expand Up @@ -294,7 +312,8 @@ var WmOverride = class {
this.rows,
this.columns,
this.scale,
this.popupTimeout
this.popupTimeout,
this.cachePopup
);
} else {
this.wm._workspaceSwitcherPopup = new IndicatorWsmatrixPopup(
Expand All @@ -313,4 +332,14 @@ var WmOverride = class {
this.wm._workspaceSwitcherPopup.display(direction, newWs.index());
}
}

_destroyWorkspaceSwitcherPopup() {
if (this.wm._workspaceSwitcherPopup) {
if (this.wm._workspaceSwitcherPopup instanceof ThumbnailWsmatrixPopup) {
this.wm._workspaceSwitcherPopup.destroy(true);
} else {
this.wm._workspaceSwitcherPopup.destroy();
}
}
}
}
11 changes: 11 additions & 0 deletions [email protected]/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ var PrefsWidget = new GObject.Class({
);
this._setScaleSensitive();

this._settings.connect(
'changed::show-thumbnails',
this._setSetCachePopupSensitive.bind(this)
);
this._setSetCachePopupSensitive();

this._settings.connect(
'changed::show-thumbnails',
this._setSetShowWorkspaceNamesSensitive.bind(this)
Expand All @@ -46,6 +52,7 @@ var PrefsWidget = new GObject.Class({
return [
'show-thumbnails',
'show-workspace-names',
'cache-popup',
];
},

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

_setSetCachePopupSensitive: function () {
this._getWidget('cache-popup').set_sensitive(this._settings.get_boolean('show-thumbnails'));
},

_setSetShowWorkspaceNamesSensitive: function () {
this._getWidget('show-workspace-names').set_sensitive(!this._settings.get_boolean('show-thumbnails'));
},
Expand Down
Binary file modified [email protected]/schemas/gschemas.compiled
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
<default>true</default>
<summary>Whether to show workspace thumbnails or not</summary>
</key>
<key type="b" name="cache-popup">
<default>false</default>
<summary>Cache popup (faster, consumes more memory)</summary>
</key>
<key type="b" name="show-workspace-names">
<default>false</default>
<summary>Whether to show workspace names or not</summary>
Expand Down
42 changes: 40 additions & 2 deletions [email protected]/settings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,44 @@
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">50</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<property name="label" translatable="yes">Cache popup (faster, consumes more memory)</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="cache_popup">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="valign">center</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">5</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
Expand Down Expand Up @@ -267,7 +305,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">5</property>
<property name="position">6</property>
</packing>
</child>
<child>
Expand Down Expand Up @@ -310,7 +348,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">6</property>
<property name="position">7</property>
</packing>
</child>
</object>
Expand Down

0 comments on commit d02b408

Please sign in to comment.