Skip to content

Commit

Permalink
Merge pull request #278 from mzur/gnome-46
Browse files Browse the repository at this point in the history
Gnome 46
  • Loading branch information
mzur authored Apr 13, 2024
2 parents bfcc56b + f33dd77 commit ec99a87
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 111 deletions.
2 changes: 1 addition & 1 deletion [email protected]/metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"shell-version": [
"45"
"46"
],
"uuid": "[email protected]",
"url": "https://github.com/mzur/gnome-shell-wsmatrix",
Expand Down
15 changes: 7 additions & 8 deletions [email protected]/overview/controlsManagerLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import {SMALL_WORKSPACE_RATIO, ControlsState} from 'resource:///org/gnome/shell/
const _computeWorkspacesBoxForState = function(state, box, searchHeight, dashHeight, thumbnailsHeight) {
const workspaceBox = box.copy();
const [width, height] = workspaceBox.get_size();
const { y1: startY } = this._workAreaBox;
const {spacing} = this;
const {y1: startY} = this._workAreaBox;
const {expandFraction} = this._workspacesThumbnails;

const workspaceManager = global.workspace_manager;
Expand All @@ -19,16 +18,16 @@ const _computeWorkspacesBoxForState = function(state, box, searchHeight, dashHei
break;
case ControlsState.WINDOW_PICKER:
workspaceBox.set_origin(0,
startY + searchHeight + spacing +
thumbnailsHeight * rows + spacing * expandFraction);
startY + searchHeight + this._spacing +
thumbnailsHeight * rows + this._spacing * expandFraction);
workspaceBox.set_size(width,
height -
dashHeight - spacing -
searchHeight - spacing -
thumbnailsHeight * rows - spacing * expandFraction);
dashHeight - this._spacing -
searchHeight - this._spacing -
thumbnailsHeight * rows - this._spacing * expandFraction);
break;
case ControlsState.APP_GRID:
workspaceBox.set_origin(0, startY + searchHeight + spacing);
workspaceBox.set_origin(0, startY + searchHeight + this._spacing);
workspaceBox.set_size(
width,
Math.round(height * rows * SMALL_WORKSPACE_RATIO));
Expand Down
31 changes: 8 additions & 23 deletions [email protected]/overview/overviewManager.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,23 @@
// import ControlsManagerLayout from './controlsManagerLayout.js';
import ControlsManagerLayout from './controlsManagerLayout.js';
import SecondaryMonitorDisplay from './secondaryMonitorDisplay.js';
// import ThumbnailsBox from './thumbnailsBox.js';
import ThumbnailsBox from './thumbnailsBox.js';
import WorkspacesView from './workspacesView.js';
import {GNOMEversionCompare} from 'resource:///org/gnome/shell/misc/util.js';
import {PACKAGE_VERSION} from 'resource:///org/gnome/shell/misc/config.js';

export default class OverviewManager {
constructor(settings) {
this._settings = settings;
}

async enable() {
this._connectSettings();
await this._initOverrides();
this._handleShowOverviewGridChanged();
}

// This can be moved to the constructor again if there is no need for the conditional
// import any more.
async _initOverrides() {
this._overrides = [
new WorkspacesView(),
new SecondaryMonitorDisplay(),
// new ThumbnailsBox(),
// new ControlsManagerLayout(),
new ThumbnailsBox(),
new ControlsManagerLayout(),
];
}

// This only works starting in GNOME Shell 45.1 and up.
if (GNOMEversionCompare(PACKAGE_VERSION, '45.1') >= 0) {
const {default: ThumbnailsBox} = await import('./thumbnailsBox.js');
this._overrides.push(new ThumbnailsBox());
const {default: ControlsManagerLayout} = await import('./controlsManagerLayout.js');
this._overrides.push(new ControlsManagerLayout());
}
enable() {
this._connectSettings();
this._handleShowOverviewGridChanged();
}

_connectSettings() {
Expand Down
8 changes: 3 additions & 5 deletions [email protected]/overview/thumbnailsBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const addThumbnails = function (start, count) {
this._porthole.x, this._porthole.y,
this._porthole.width, this._porthole.height);
this._thumbnails.push(thumbnail);
this.add_actor(thumbnail);
this.add_child(thumbnail);

if (this._shouldShow && start > 0 && this._spliceIndex === -1) {
// not the initial fill, and not splicing via DND
Expand Down Expand Up @@ -105,10 +105,8 @@ const vfunc_allocate = function(box) {

let rtl = Clutter.get_default_text_direction() == Clutter.TextDirection.RTL;

if (this._thumbnails.length == 0) {
// not visible
return;
}
if (this._thumbnails.length === 0) // not visible
return;

let themeNode = this.get_theme_node();
box = themeNode.get_content_box(box);
Expand Down
40 changes: 0 additions & 40 deletions [email protected]/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,6 @@ import Adw from 'gi://Adw';
import Gio from 'gi://Gio';
import Gtk from 'gi://Gtk';
import {ExtensionPreferences, gettext as _} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
import {PACKAGE_VERSION} from 'resource:///org/gnome/Shell/Extensions/js/misc/config.js';

// From js/misc/utils.js which can't be imported.
function _GNOMEversionToNumber(version) {
let ret = Number(version);
if (!isNaN(ret))
return ret;
if (version === 'alpha')
return -2;
if (version === 'beta')
return -1;
return ret;
}

function GNOMEversionCompare(version1, version2) {
const v1Array = version1.split('.');
const v2Array = version2.split('.');

for (let i = 0; i < Math.max(v1Array.length, v2Array.length); i++) {
let elemV1 = _GNOMEversionToNumber(v1Array[i] || '0');
let elemV2 = _GNOMEversionToNumber(v2Array[i] || '0');
if (elemV1 < elemV2)
return -1;
if (elemV1 > elemV2)
return 1;
}

return 0;
}

export default class Prefs extends ExtensionPreferences {
fillPreferencesWindow(window) {
Expand All @@ -40,17 +11,6 @@ export default class Prefs extends ExtensionPreferences {

const page = new Adw.PreferencesPage();

if (GNOMEversionCompare(PACKAGE_VERSION, '45.1') < 0) {
// window.add_toast(new Adw.Toast({title: 'Test'}));
let group = new Adw.PreferencesGroup();
let banner = new Adw.Banner({
title: _('Some features of the extension are disabled until GNOME Shell 45.1.'),
revealed: true,
});
group.add(banner);
page.add(group);
}

let group = new Adw.PreferencesGroup({
title: _('General Settings'),
});
Expand Down
39 changes: 9 additions & 30 deletions [email protected]/workspacePopup/workspaceManagerOverride.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,10 @@ import GLib from 'gi://GLib';
import Meta from 'gi://Meta';
import Shell from 'gi://Shell';
import WorkspaceSwitcherPopup from "./workspaceSwitcherPopup.js";
// import {SCROLL_TIMEOUT_TIME} from 'resource:///org/gnome/shell/ui/windowManager.js';
// import {WorkspaceAnimationController} from "./workspaceAnimation.js";
import {GNOMEversionCompare} from 'resource:///org/gnome/shell/misc/util.js';
import {SCROLL_TIMEOUT_TIME} from 'resource:///org/gnome/shell/ui/windowManager.js';
import {WorkspaceAnimationController} from "./workspaceAnimation.js";
import {PACKAGE_VERSION} from 'resource:///org/gnome/shell/misc/config.js';

let SCROLL_TIMEOUT_TIME = 150;
if (GNOMEversionCompare(PACKAGE_VERSION, '45.1') >= 0) {
import('resource:///org/gnome/shell/ui/windowManager.js').then((mod) => {
SCROLL_TIMEOUT_TIME = mod.SCROLL_TIMEOUT_TIME;
});
}

const WraparoundMode = {
NONE: 0,
NEXT_PREV: 1,
Expand All @@ -36,11 +28,15 @@ export default class WorkspaceManagerOverride {
this._keybindings = keybindings;
this._overviewKeybindingActions = {};
this.monitors = [];
}

async enable() {
await this._initOverrides()
this._workspaceAnimation = new WorkspaceAnimationController();
this.overrideProperties = [
'_workspaceAnimation',
'handleWorkspaceScroll',
];
}

enable() {
this._overrideDynamicWorkspaces();
this._overrideKeybindingHandlers();
this._overrideOriginalProperties();
Expand All @@ -53,23 +49,6 @@ export default class WorkspaceManagerOverride {
this._connectLayoutManager();
}

// This can be moved to the constructor again if there is no need for the conditional
// import any more.
async _initOverrides() {
// this._workspaceAnimation = new WorkspaceAnimationController();
this.overrideProperties = [
// '_workspaceAnimation',
'handleWorkspaceScroll',
];

// This only works starting in GNOME Shell 45.1 and up.
if (GNOMEversionCompare(PACKAGE_VERSION, '45.1') >= 0) {
const {WorkspaceAnimationController} = await import("./workspaceAnimation.js");
this._workspaceAnimation = new WorkspaceAnimationController();
this.overrideProperties.push('_workspaceAnimation');
}
}

disable() {
this._destroyWorkspaceSwitcherPopup();
this._restoreLayout();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default GObject.registerClass({
this.redisplay();
});

this.add_actor(workspacesRow);
this.add_child(workspacesRow);
this._lists.push(workspacesRow);
}

Expand Down Expand Up @@ -113,7 +113,7 @@ export default GObject.registerClass({
}

bbox.set_child(container);
list.add_actor(bbox);
list.add_child(bbox);

bbox.connect('clicked', () => this._onItemClicked(bbox));
bbox.connect('motion-event', () => this._onItemEnter(bbox));
Expand Down Expand Up @@ -169,12 +169,12 @@ export default GObject.registerClass({

highlight(index, justOutline) {
if (this._items[this._highlighted]) {
this._items[this._highlighted].remove_style_pseudo_class('outlined');
this._items[this._highlighted].remove_style_pseudo_class('highlighted');
this._items[this._highlighted].remove_style_pseudo_class('selected');
}

if (this._items[index]) {
this._items[index].add_style_pseudo_class(justOutline ? 'outlined' : 'selected');
this._items[index].add_style_pseudo_class(justOutline ? 'highlighted' : 'selected');
}

this._highlighted = index;
Expand Down

0 comments on commit ec99a87

Please sign in to comment.