Add monitor isolation

This commit is contained in:
Charles Gagnon
2018-10-03 21:49:11 -04:00
parent 73893b5d42
commit a927344517
4 changed files with 39 additions and 22 deletions

View File

@@ -96,11 +96,11 @@ var taskbarAppIcon = new Lang.Class({
Name: 'DashToPanel.TaskbarAppIcon',
Extends: AppDisplay.AppIcon,
_init: function(settings, appInfo, panel, iconParams, onActivateOverride) {
_init: function(settings, appInfo, panelWrapper, iconParams, onActivateOverride) {
// a prefix is required to avoid conflicting with the parent class variable
this._dtpSettings = settings;
this.panel = panel;
this.panelWrapper = panelWrapper;
this._nWindows = 0;
this.window = appInfo.window;
this.isLauncher = appInfo.isLauncher;
@@ -313,7 +313,7 @@ var taskbarAppIcon = new Lang.Class({
shouldShowTooltip: function() {
if (!this.isLauncher && this._dtpSettings.get_boolean("show-window-previews") &&
getInterestingWindows(this.app, this._dtpSettings).length > 0) {
this.getAppIconInterestingWindows().length > 0) {
return false;
} else {
return this.actor.hover && !this.window &&
@@ -367,7 +367,7 @@ var taskbarAppIcon = new Lang.Class({
[rect.x, rect.y] = this.actor.get_transformed_position();
[rect.width, rect.height] = this.actor.get_transformed_size();
let windows = this.window ? [this.window] : this.app.get_windows();
let windows = this.window ? [this.window] : this.getAppIconInterestingWindows();
windows.forEach(function(w) {
w.set_icon_geometry(rect);
});
@@ -515,7 +515,7 @@ var taskbarAppIcon = new Lang.Class({
_setAppIconPadding: function() {
let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor;
let availSize = this.panel.actor.get_height() - this._dtpSettings.get_int('dot-size') * scaleFactor * 2;
let availSize = this.panelWrapper.panel.actor.get_height() - this._dtpSettings.get_int('dot-size') * scaleFactor * 2;
let padding = this._dtpSettings.get_int('appicon-padding');
let margin = this._dtpSettings.get_int('appicon-margin');
@@ -743,7 +743,7 @@ var taskbarAppIcon = new Lang.Class({
// We check if the app is running, and that the # of windows is > 0 in
// case we use workspace isolation,
let appIsRunning = this.app.state == Shell.AppState.RUNNING
&& getInterestingWindows(this.app, this._dtpSettings).length > 0
&& this.getAppIconInterestingWindows().length > 0
// We customize the action only when the application is already running
if (appIsRunning && !this.isLauncher) {
@@ -866,7 +866,7 @@ var taskbarAppIcon = new Lang.Class({
_updateCounterClass: function() {
let maxN = 4;
this._nWindows = Math.min(getInterestingWindows(this.app, this._dtpSettings).length, maxN);
this._nWindows = Math.min(this.getAppIconInterestingWindows().length, maxN);
for (let i = 1; i <= maxN; i++){
let className = 'running'+i;
@@ -1065,6 +1065,10 @@ var taskbarAppIcon = new Lang.Class({
}
return DND.DragMotionResult.CONTINUE;
},
getAppIconInterestingWindows: function() {
return getInterestingWindows(this.app, this._dtpSettings, this.panelWrapper.monitor);
}
});
@@ -1101,12 +1105,9 @@ function activateAllWindows(app, settings){
if (windows.length <= 0)
return;
let activatedWindows = 0;
for (let i = windows.length - 1; i >= 0; i--){
if (windows[i].get_workspace().index() == activeWorkspace){
Main.activateWindow(windows[i]);
activatedWindows++;
}
}
}
@@ -1174,18 +1175,24 @@ function closeAllWindows(app, settings) {
// Filter out unnecessary windows, for instance
// nautilus desktop window.
function getInterestingWindows(app, settings) {
function getInterestingWindows(app, settings, monitor) {
let windows = app.get_windows().filter(function(w) {
return !w.skip_taskbar;
});
// When using workspace isolation, we filter out windows
// that are not in the current workspace
// When using workspace or monitor isolation, we filter out windows
// that are not in the current workspace or on the same monitor as the appicon
if (settings.get_boolean('isolate-workspaces'))
windows = windows.filter(function(w) {
return w.get_workspace().index() == Utils.DisplayWrapper.getWorkspaceManager().get_active_workspace_index();
});
if (monitor && settings.get_boolean('multi-monitors') && settings.get_boolean('isolate-monitors')) {
windows = windows.filter(function(w) {
return w.get_monitor() == monitor.index;
});
}
return windows;
}

View File

@@ -334,6 +334,16 @@
<summary>Use favorite icons as application launchers</summary>
<description>When the applications are ungrouped, this defines if running applications stay separate from the favorite icons.</description>
</key>
<key type="b" name="multi-monitors">
<default>false</default>
<summary>Display panels on all monitors</summary>
<description>Specifies if a panel is shown on every monitors</description>
</key>
<key type="b" name="isolate-monitors">
<default>false</default>
<summary>Provide monitor isolation</summary>
<description>Dash shows only windows from the current monitor</description>
</key>
<key type="b" name="customize-click">
<default>true</default>
<summary>Customize click behaviour</summary>

View File

@@ -498,7 +498,7 @@ var taskbar = new Lang.Class({
window: window,
isLauncher: isLauncher
},
this.panelWrapper.panel,
this.panelWrapper,
{
setSizeManually: true,
showLabel: false
@@ -859,7 +859,7 @@ var taskbar = new Lang.Class({
return apps.map(app => ({
app: app,
isLauncher: defaultIsLauncher || false,
windows: defaultWindows || AppIcons.getInterestingWindows(app, this._dtpSettings)
windows: defaultWindows || AppIcons.getInterestingWindows(app, this._dtpSettings, this.panelWrapper.monitor)
.sort(this.sortWindowsCompareFunction)
}));
},

View File

@@ -85,7 +85,7 @@ var thumbnailPreviewMenu = new Lang.Class({
this._boxPointer._arrowSide = side;
this._boxPointer._userArrowSide = side;
this._previewBox = new thumbnailPreviewList(this._app, source.window, this._dtpSettings);
this._previewBox = new thumbnailPreviewList(this._app, source, this._dtpSettings);
this.addMenuItem(this._previewBox);
this._peekMode = false;
@@ -141,7 +141,7 @@ var thumbnailPreviewMenu = new Lang.Class({
},
popup: function() {
let windows = AppIcons.getInterestingWindows(this._app, this._dtpSettings);
let windows = AppIcons.getInterestingWindows(this._app, this._dtpSettings, this._source.panelWrapper.monitor);
if (windows.length > 0) {
this._redisplay();
this.open();
@@ -873,7 +873,7 @@ var thumbnailPreviewList = new Lang.Class({
Name: 'DashToPanel.ThumbnailPreviewList',
Extends: PopupMenu.PopupMenuSection,
_init: function(app, window, settings) {
_init: function(app, source, settings) {
this._dtpSettings = settings;
this.parent();
@@ -895,7 +895,7 @@ var thumbnailPreviewList = new Lang.Class({
this._shownInitially = false;
this.app = app;
this.window = window;
this._source = source;
this._redisplayId = Main.initializeDeferredWork(this.actor, Lang.bind(this, this._redisplay));
this._scrollbarId = Main.initializeDeferredWork(this.actor, Lang.bind(this, this._showHideScrollbar));
@@ -907,7 +907,7 @@ var thumbnailPreviewList = new Lang.Class({
this._dtpSettings.connect('changed::window-preview-show-title', () => this._resetPreviews());
this._dtpSettings.connect('changed::window-preview-padding', () => this._resetPreviews());
this._stateChangedId = this.window ? 0 :
this._stateChangedId = this._source.window ? 0 :
this.app.connect('windows-changed', Lang.bind(this, this._queueRedisplay));
},
@@ -1051,8 +1051,8 @@ var thumbnailPreviewList = new Lang.Class({
},
_redisplay: function () {
let windows = this.window ? [this.window] :
AppIcons.getInterestingWindows(this.app, this._dtpSettings).sort(this.sortWindowsCompareFunction);
let windows = this._source.window ? [this._source.window] :
AppIcons.getInterestingWindows(this.app, this._dtpSettings, this._source.panelWrapper.monitor).sort(this.sortWindowsCompareFunction);
let children = this._getPreviews();
// Apps currently in the taskbar
let oldWin = children.map(function(actor) {