Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Partial Support for Gnome 41 #163

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ in dynamic fashion, no restart needed.
Versions
========

* Branch [master](https://github.com/spin83/multi-monitors-add-on/tree/master) contains extension for GNOME 3.38
* Branch [master](https://github.com/realh/multi-monitors-add-on/tree/master) contains extension for GNOME 40
* Branch [gnome-3-32_3-36](https://github.com/spin83/multi-monitors-add-on/tree/gnome-3-32_3-36) contains extension for GNOME 3.32, 3.34 and 3.36
* Branch [gnome-3-24_3-30](https://github.com/spin83/multi-monitors-add-on/tree/gnome-3-24_3-30) contains extension for GNOME 3.24, 3.26, 3.28 and 3.30
* Branch [gnome-3-20_3-22](https://github.com/spin83/multi-monitors-add-on/tree/gnome-3-20_3-22) contains extension for GNOME 3.20 and 3.22
Expand Down
7 changes: 4 additions & 3 deletions multi-monitors-add-on@spin83/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const THUMBNAILS_SLIDER_POSITION_ID = 'thumbnails-slider-position';

function copyClass (s, d) {
// global.log(s.name +" > "+ d.name);
if (!s) throw Error(`copyClass s undefined for d ${d.name}`)
let propertyNames = Reflect.ownKeys(s.prototype);
for (let pName of propertyNames.values()) {

Expand Down Expand Up @@ -114,8 +115,8 @@ class MultiMonitorsAddOn {
}
}

this.syncWorkspacesActualGeometry = Main.overview.viewSelector._workspacesDisplay._syncWorkspacesActualGeometry;
Main.overview.viewSelector._workspacesDisplay._syncWorkspacesActualGeometry = function() {
this.syncWorkspacesActualGeometry = Main.overview.searchController._workspacesDisplay._syncWorkspacesActualGeometry;
Main.overview.searchController._workspacesDisplay._syncWorkspacesActualGeometry = function() {
if (this._inWindowFade)
return;

Expand Down Expand Up @@ -156,7 +157,7 @@ class MultiMonitorsAddOn {
Main.mmOverview[idx].destroy();
}
Main.mmOverview = null;
Main.overview.viewSelector._workspacesDisplay._syncWorkspacesActualGeometry = this.syncWorkspacesActualGeometry;
Main.overview.searchController._workspacesDisplay._syncWorkspacesActualGeometry = this.syncWorkspacesActualGeometry;
}

_relayout() {
Expand Down
4 changes: 2 additions & 2 deletions multi-monitors-add-on@spin83/metadata.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"shell-version": ["3.38"],
"shell-version": ["40", "41", "42"],
"uuid": "multi-monitors-add-on@spin83",
"name": "Multi Monitors Add-On",
"settings-schema": "org.gnome.shell.extensions.multi-monitors-add-on",
"gettext-domain": "multi-monitors-add-on",
"description": "Add multiple monitors overview and panel for gnome-shell.",
"url": "https://github.com/spin83/multi-monitors-add-on.git",
"version": 23
"version": 24
}
57 changes: 33 additions & 24 deletions multi-monitors-add-on@spin83/mmoverview.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const Params = imports.misc.params;
const WorkspaceThumbnail = imports.ui.workspaceThumbnail;
const OverviewControls = imports.ui.overviewControls;
const Overview = imports.ui.overview;
const ViewSelector = imports.ui.viewSelector;
const SearchController = imports.ui.searchController;
const LayoutManager = imports.ui.layout;
const Background = imports.ui.background;
const WorkspacesView = imports.ui.workspacesView;
Expand Down Expand Up @@ -278,6 +278,7 @@ const MultiMonitorsThumbnailsBox = (() => {
}, MultiMonitorsThumbnailsBox);
})();

/* This isn't compatible with GNOME 40 and i don't know how to fix it -- TH
var MultiMonitorsSlidingControl = (() => {
let MultiMonitorsSlidingControl = class MultiMonitorsSlidingControl extends St.Widget {
_init(params) {
Expand Down Expand Up @@ -353,6 +354,7 @@ var MultiMonitorsThumbnailsSlider = (() => {
MultiMonitors.copyClass(OverviewControls.ThumbnailsSlider, MultiMonitorsThumbnailsSlider);
return GObject.registerClass(MultiMonitorsThumbnailsSlider);
})();
*/

var MultiMonitorsControlsManager = GObject.registerClass(
class MultiMonitorsControlsManager extends St.Widget {
Expand All @@ -363,7 +365,12 @@ class MultiMonitorsControlsManager extends St.Widget {
this._fixGeometry = 0;
this._visible = false;

let layout = new OverviewControls.ControlsLayout();
let layout
if (OverviewControls.ControlsManagerLayout) {
layout = new OverviewControls.ControlsManagerLayout();
} else {
layout = new OverviewControls.ControlsLayout();
}
super._init({
layout_manager: layout,
x_expand: true,
Expand All @@ -375,35 +382,35 @@ class MultiMonitorsControlsManager extends St.Widget {

this._thumbnailsBox =
new MultiMonitorsThumbnailsBox(this._workspaceAdjustment, this._monitorIndex);
this._thumbnailsSlider = new MultiMonitorsThumbnailsSlider(this._thumbnailsBox);
//this._thumbnailsSlider = new MultiMonitorsThumbnailsSlider(this._thumbnailsBox);

this._viewSelector = new St.Widget({ visible: false, x_expand: true, y_expand: true, clip_to_allocation: true });
this._pageChangedId = Main.overview.viewSelector.connect('page-changed', this._setVisibility.bind(this));
this._pageEmptyId = Main.overview.viewSelector.connect('page-empty', this._onPageEmpty.bind(this));
this._searchController = new St.Widget({ visible: false, x_expand: true, y_expand: true, clip_to_allocation: true });
this._pageChangedId = Main.overview.searchController.connect('page-changed', this._setVisibility.bind(this));
this._pageEmptyId = Main.overview.searchController.connect('page-empty', this._onPageEmpty.bind(this));

this._group = new St.BoxLayout({ name: 'mm-overview-group-'+index,
x_expand: true, y_expand: true });
this.add_actor(this._group);

this._group.add_child(this._viewSelector);
this._group.add_actor(this._thumbnailsSlider);
this._group.add_child(this._searchController);
//this._group.add_actor(this._thumbnailsSlider);

this._settings = Convenience.getSettings();

this._monitorsChanged();
this._thumbnailsSlider.slideOut();
//this._thumbnailsSlider.slideOut();
this._thumbnailsBox._updatePorthole();

this.connect('notify::allocation', this._updateSpacerVisibility.bind(this));
this.connect('destroy', this._onDestroy.bind(this));
this._thumbnailsSelectSideId = this._settings.connect('changed::'+THUMBNAILS_SLIDER_POSITION_ID,
this._thumbnailsSelectSide.bind(this));
//this._thumbnailsSelectSideId = this._settings.connect('changed::'+THUMBNAILS_SLIDER_POSITION_ID,
// this._thumbnailsSelectSide.bind(this));
this._monitorsChangedId = Main.layoutManager.connect('monitors-changed', this._monitorsChanged.bind(this));
}

_onDestroy() {
Main.overview.viewSelector.disconnect(this._pageChangedId);
Main.overview.viewSelector.disconnect(this._pageEmptyId);
Main.overview.searchController.disconnect(this._pageChangedId);
Main.overview.searchController.disconnect(this._pageEmptyId);
this._settings.disconnect(this._thumbnailsSelectSideId);
Main.layoutManager.disconnect(this._monitorsChangedId);
}
Expand All @@ -413,6 +420,7 @@ class MultiMonitorsControlsManager extends St.Widget {
this._thumbnailsSelectSide();
}

/*
_thumbnailsSelectSide() {
let thumbnailsSlider;
thumbnailsSlider = this._thumbnailsSlider;
Expand Down Expand Up @@ -440,6 +448,7 @@ class MultiMonitorsControlsManager extends St.Widget {
}
this._fixGeometry = 3;
}
*/

_updateSpacerVisibility() {
if (Main.layoutManager.monitors.length<this._monitorIndex)
Expand Down Expand Up @@ -468,9 +477,9 @@ class MultiMonitorsControlsManager extends St.Widget {
getWorkspacesActualGeometry() {
let geometry;
if (this._visible) {
const [x, y] = this._viewSelector.get_transformed_position();
const width = this._viewSelector.allocation.get_width();
const height = this._viewSelector.allocation.get_height();
const [x, y] = this._searchController.get_transformed_position();
const width = this._searchController.allocation.get_width();
const height = this._searchController.allocation.get_height();
geometry = { x, y, width, height };
}
else {
Expand All @@ -496,20 +505,18 @@ class MultiMonitorsControlsManager extends St.Widget {
(Main.overview.animationInProgress && !Main.overview.visibleTarget))
return;

let activePage = Main.overview.viewSelector.getActivePage();
let thumbnailsVisible = activePage == ViewSelector.ViewPage.WINDOWS;
let activePage = Main.overview.searchController.getActivePage();
let thumbnailsVisible = activePage == SearchController.ViewPage.WINDOWS;

let opacity = null;
if (thumbnailsVisible) {
opacity = 255;
if (this._fixGeometry===1)
this._fixGeometry = 0;
this._thumbnailsSlider.slideIn();
}
else {
opacity = 0;
this._fixGeometry = 1;
this._thumbnailsSlider.slideOut();
}

if (!this._workspacesViews)
Expand All @@ -523,12 +530,12 @@ class MultiMonitorsControlsManager extends St.Widget {
}

_onPageEmpty() {
this._thumbnailsSlider.pageEmpty();
//this._thumbnailsSlider.pageEmpty();
}

show() {
this._viewSelector.visible = true;
this._workspacesViews = Main.overview.viewSelector._workspacesDisplay._workspacesViews[this._monitorIndex];
this._searchController.visible = true;
this._workspacesViews = Main.overview.searchController._workspacesDisplay._workspacesViews[this._monitorIndex];
this._visible = true;
const geometry = this.getWorkspacesActualGeometry();

Expand All @@ -537,6 +544,7 @@ class MultiMonitorsControlsManager extends St.Widget {
return;
}

/*
if (this._fixGeometry) {
const width = this._thumbnailsSlider.get_width();
if (this._fixGeometry===2) {
Expand All @@ -552,6 +560,7 @@ class MultiMonitorsControlsManager extends St.Widget {
}
this._fixGeometry = 0;
}
*/

this._workspacesViews.ease({
...geometry,
Expand All @@ -571,7 +580,7 @@ class MultiMonitorsControlsManager extends St.Widget {
duration: Main.overview.animationInProgress ? Overview.ANIMATION_TIME : 0,
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
onComplete: () => {
this._viewSelector.visible = false;
this._searchController.visible = false;
},
});
this._workspacesViews = null;
Expand Down
66 changes: 38 additions & 28 deletions multi-monitors-add-on@spin83/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,18 @@ var MultiMonitorsPrefsWidget = GObject.registerClass(
class MultiMonitorsPrefsWidget extends Gtk.Grid {
_init() {
super._init({
margin: 6,
margin_top: 6, margin_end: 6, margin_bottom: 6, margin_start: 6
});

this._numRows = 0;

this.set_orientation(Gtk.Orientation.VERTICAL);

this._settings = Convenience.getSettings();
this._desktopSettings = Convenience.getSettings("org.gnome.desktop.interface");

this._screen = Gdk.Screen.get_default();
this._display = Gdk.Display.get_default();
this._monitors = this._display.get_monitors()

this._addBooleanSwitch(_('Show Multi Monitors indicator on Top Panel.'), SHOW_INDICATOR_ID);
this._addBooleanSwitch(_('Show Panel on additional monitors.'), SHOW_PANEL_ID);
Expand Down Expand Up @@ -93,23 +96,27 @@ class MultiMonitorsPrefsWidget extends Gtk.Grid {
this._treeView.append_column(appColumn);
this.add(this._treeView);

let toolbar = new Gtk.Toolbar();
toolbar.get_style_context().add_class(Gtk.STYLE_CLASS_INLINE_TOOLBAR);
let toolbar = new Gtk.Box({orientation: Gtk.Orientation.HORIZONTAL});
toolbar.get_style_context().add_class("inline-toolbar");

this._settings.connect('changed::'+TRANSFER_INDICATORS_ID, Lang.bind(this, this._updateIndicators));
this._updateIndicators();

let addTButton = new Gtk.ToolButton({ stock_id: Gtk.STOCK_ADD });
let addTButton = new Gtk.Button({ icon_name: "list-add" });
addTButton.connect('clicked', Lang.bind(this, this._addIndicator));
toolbar.add(addTButton);
toolbar.append(addTButton);

let removeTButton = new Gtk.ToolButton({ stock_id: Gtk.STOCK_REMOVE });
let removeTButton = new Gtk.Button({ icon_name: "list-remove" });
removeTButton.connect('clicked', Lang.bind(this, this._removeIndicator));
toolbar.add(removeTButton);
toolbar.append(removeTButton);

this.add(toolbar);
}

add(child) {
this.attach(child, 0, this._numRows++, 1, 1);
}

_updateIndicators() {
this._store.clear();

Expand All @@ -132,7 +139,8 @@ class MultiMonitorsPrefsWidget extends Gtk.Grid {
dialog.add_button(_("Add"), Gtk.ResponseType.OK);
dialog.set_default_response(Gtk.ResponseType.OK);

let grid = new Gtk.Grid({ column_spacing: 10, row_spacing: 15, margin: 10 });
let grid = new Gtk.Grid({ column_spacing: 10, row_spacing: 15,
margin_top: 10, margin_end: 10, margin_bottom: 10, margin_start: 10 });

grid.set_orientation(Gtk.Orientation.VERTICAL);

Expand Down Expand Up @@ -168,31 +176,32 @@ class MultiMonitorsPrefsWidget extends Gtk.Grid {
availableIndicators);

availableIndicators.apply(this);
// grid.attach(dialog._treeView, 0, 0, 2, 1);
grid.add(dialog._treeView);
grid.attach(dialog._treeView, 0, 0, 2, 1);

let gHBox = new Gtk.HBox({margin: 10, spacing: 20, hexpand: true});
let gHBox = new Gtk.Box({orientation: Gtk.Orientation.HORIZONTAL,
margin_top: 10, margin_end: 10, margin_bottom: 10, margin_start: 10,
spacing: 20, hexpand: true});
let gLabel = new Gtk.Label({label: _('Monitor index:'), halign: Gtk.Align.START});
gHBox.add(gLabel);
gHBox.append(gLabel);
dialog._adjustment = new Gtk.Adjustment({lower: 0.0, upper: 0.0, step_increment:1.0});
let spinButton = new Gtk.SpinButton({halign: Gtk.Align.END, adjustment: dialog._adjustment, numeric: 1});
gHBox.add(spinButton);
gHBox.append(spinButton);

let monitorsChanged = () => {
let n_monitors = this._screen.get_n_monitors() -1;
let n_monitors = this._monitors.get_n_items() -1;
dialog._adjustment.set_upper(n_monitors)
dialog._adjustment.set_value(n_monitors);
};

let monitorsChangedId = this._screen.connect('monitors-changed', monitorsChanged);
let monitorsChangedId = this._monitors.connect('items-changed', monitorsChanged);

monitorsChanged.apply(this);
grid.add(gHBox);
grid.append(gHBox);

dialog.get_content_area().add(grid);
dialog.get_content_area().append(grid);

dialog.connect('response', (dialog, id) => {
this._screen.disconnect(monitorsChangedId);
this._monitors.disconnect(monitorsChangedId);
this._settings.disconnect(availableIndicatorsId);
this._settings.disconnect(transferIndicatorsId);
if (id != Gtk.ResponseType.OK) {
Expand All @@ -213,8 +222,6 @@ class MultiMonitorsPrefsWidget extends Gtk.Grid {

dialog.destroy();
});

dialog.show_all();
}

_removeIndicator() {
Expand All @@ -235,16 +242,18 @@ class MultiMonitorsPrefsWidget extends Gtk.Grid {
}

_addSettingsComboBoxSwitch(label, settings, schema_id, options) {
let gHBox = new Gtk.HBox({margin: 10, spacing: 20, hexpand: true});
let gHBox = new Gtk.Box({orientation: Gtk.Orientation.HORIZONTAL,
margin_top: 10, margin_end: 10, margin_bottom: 10, margin_start: 10,
spacing: 20, hexpand: true});
let gLabel = new Gtk.Label({label: _(label), halign: Gtk.Align.START});
gHBox.add(gLabel);
gHBox.append(gLabel);

let gCBox = new Gtk.ComboBoxText({halign: Gtk.Align.END});
Object.entries(options).forEach(function(entry) {
const [key, val] = entry;
gCBox.append(key, val);
});
gHBox.add(gCBox);
gHBox.append(gCBox);

this.add(gHBox);

Expand All @@ -256,11 +265,13 @@ class MultiMonitorsPrefsWidget extends Gtk.Grid {
}

_addSettingsBooleanSwitch(label, settings, schema_id) {
let gHBox = new Gtk.HBox({margin: 10, spacing: 20, hexpand: true});
let gHBox = new Gtk.Box({orientation: Gtk.Orientation.HORIZONTAL,
margin_top: 10, margin_end: 10, margin_bottom: 10, margin_start: 10,
spacing: 20, hexpand: true});
let gLabel = new Gtk.Label({label: _(label), halign: Gtk.Align.START});
gHBox.add(gLabel);
gHBox.append(gLabel);
let gSwitch = new Gtk.Switch({halign: Gtk.Align.END});
gHBox.add(gSwitch);
gHBox.append(gSwitch);
this.add(gHBox);

settings.bind(schema_id, gSwitch, 'active', Gio.SettingsBindFlags.DEFAULT);
Expand All @@ -273,7 +284,6 @@ function init() {

function buildPrefsWidget() {
let widget = new MultiMonitorsPrefsWidget();
widget.show_all();

return widget;
}