Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build/
node_modules/
node_modules/
.idea/
47 changes: 47 additions & 0 deletions @types/gnome-shell/extensions/extension.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright Sebastian Wiesner <sebastian@swsnr.de>
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0.If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
//
// Alternatively, the contents of this file may be used under the terms
// of the GNU General Public License Version 2 or later, as described below:
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

import type Gio from "@gi-types/gio2";

// See https://gjs.guide/extensions/topics/extension.html#types
export declare interface ExtensionMetadata {
readonly uuid: string;
readonly name: string;
readonly description: string;
readonly "shell-version": readonly string[];
readonly dir: Gio.File;
readonly path: string;
readonly url: string;
}

declare class ExtensionBase {
constructor(metadata: ExtensionMetadata);

get metadata(): ExtensionMetadata;
getSettings(schema?: string): Gio.Settings;
public static lookupByUUID(uuid: string): ExtensionBase;
}

export declare class Extension extends ExtensionBase {
constructor(metadata: ExtensionMetadata);

enable(): void;

disable(): void;
}
2 changes: 2 additions & 0 deletions @types/gnome-shell/extensions/misc/util.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export declare function spawn(argv: string[]): void;
export declare function lerp(start: number, end: number, progress: number): number;
29 changes: 29 additions & 0 deletions @types/gnome-shell/extensions/prefs.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright Sebastian Wiesner <sebastian@swsnr.de>
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0.If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
//
// Alternatively, the contents of this file may be used under the terms
// of the GNU General Public License Version 2 or later, as described below:
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

import type Gtk from "@gi-types/gtk4";
import type Adw from "@gi-types/adw1";
import { ExtensionBase } from "./extension";
// import { ExtensionBase } from "resource:///org/gnome/shell/extensions/extension.js";

export declare class ExtensionPreferences extends ExtensionBase {
getPreferencesWidget(): Gtk.Widget;

fillPreferencesWindow(window: Adw.PreferencesWindow): void;
}
26 changes: 26 additions & 0 deletions @types/gnome-shell/extensions/ui/altTab.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Meta from '../../../meta12';
import St from '../../../st12';

declare class WindowSwitcherPopup extends St.Widget {
_items: St.Widget & {
window: Meta.Window
}[];

_switcherList: St.Widget & {
_scrollView: {
hscroll: {
adjustment: St.Adjustment
}
}
};

_select(n: number): void;
_resetNoModsTimeout(): void;
_popModal(): void;

_noModsTimeoutId: number;
_initialDelayTimeoutId: number;
_selectedIndex: number;

show(backward: boolean, binding: string, mask: number);
}
5 changes: 5 additions & 0 deletions @types/gnome-shell/extensions/ui/layout.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Clutter from '../../../clutter12';

declare class MonitorConstraint extends Clutter.Constraint {
constructor(params: Partial<{ primary: boolean, index: number }>);
}
58 changes: 58 additions & 0 deletions @types/gnome-shell/extensions/ui/main.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import Clutter from '../../../clutter12';
import Gio from '@gi-types/gio2';
import GObject from '@gi-types/gobject2';
import Meta from '../../../meta12';
import Shell from '../../../shell12';
import St from '../../../st12';

const actionMode: Shell.ActionMode;
function notify(message: string): void;
function activateWindow(window: Meta.Window, time?: number, workspaceNum?: number): void;

const panel: {
addToStatusArea(role: string, indicator: Clutter.Actor, position?: number, box?: string): void,
} & Clutter.Actor;

const overview: {
dash: {
showAppsButton: St.Button
};
searchEntry: St.Entry,
shouldToggleByCornerOrButton(): boolean,
visible: boolean,
show(): void,
hide(): void,
showApps(): void,
connect(signal: 'showing' | 'hiding' | 'hidden' | 'shown', callback: () => void): number,
disconnect(id: number): void,
_overview: {
_controls: overviewControls.OverviewControlsManager
} & St.Widget
_gestureBegin(tracker: {
confirmSwipe: typeof swipeTracker.SwipeTracker.prototype.confirmSwipe;
}): void;
_gestureUpdate(tracker: swipeTracker.SwipeTracker, progress: number);
_gestureEnd(tracker: swipeTracker.SwipeTracker, duration: number, endProgress: number);

_swipeTracker: swipeTracker.SwipeTracker;
};

const layoutManager: GObject.Object & {
uiGroup: St.Widget,
panelBox: St.BoxLayout,
monitors: __shell_private_types.IMonitorState[],
primaryMonitor: __shell_private_types.IMonitorState,
currentMonitor: __shell_private_types.IMonitorState,
getWorkAreaForMonitor: (index: number) => Meta.Rectangle,

connect(id: 'monitors-changed', callback: () => void);
};

const wm: {
skipNextEffect(actor: Meta.WindowActor): void;
_workspaceAnimation: workspaceAnimation.WorkspaceAnimationController;
};

const osdWindowManager: {
hideAll(): void;
};
39 changes: 39 additions & 0 deletions @types/gnome-shell/extensions/ui/overviewControlsManager.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import Clutter from '../../../clutter12';
import St from '../../../st12';
import { SwipeTracker } from './swipeTracker';

export enum ControlsState {
HIDDEN,
WINDOW_PICKER,
APP_GRID
}

declare class OverviewAdjustment extends St.Adjustment {
getStateTransitionParams(): {
initialState: ControlsState,
finalState: ControlsState
currentState: number,
progress: number
}
}

declare class OverviewControlsManager extends St.Widget {
_stateAdjustment: OverviewAdjustment;
glayoutManager: Clutter.BoxLayout & {
_searchEntry: St.Bin
};

_toggleAppsPage(): void

_workspacesDisplay: {
_swipeTracker: SwipeTracker
};

_appDisplay: {
_swipeTracker: SwipeTracker
};

_searchController: {
searchActive: boolean
};
}
54 changes: 54 additions & 0 deletions @types/gnome-shell/extensions/ui/swipeTracker.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import Clutter from '@gi-types/clutter';
import GObject from '@gi-types/gobject2';
import Shell from '@gi-types/shell';

const global: import('@gi-types/shell').Global;

// types
export type CustomEventType = Pick<
import('../../../clutter12').Event,
'type' | 'get_gesture_phase' |
'get_touchpad_gesture_finger_count' | 'get_time' |
'get_coords' | 'get_gesture_motion_delta_unaccelerated' |
'get_gesture_pinch_scale' | 'get_gesture_pinch_angle_delta'
>;

declare namespace __shell_private_types {
class TouchpadGesture extends GObject.Object {
destroy(): void;
_handleEvent(actor: Clutter.Actor | undefined, event: CustomEventType): boolean;
}

interface IMonitorState {
x: number,
y: number,
width: number,
height: number,
geometry_scale: number,
index: number,
inFullscreen: () => boolean,
}
}

declare class SwipeTracker extends GObject.Object {
orientation: Clutter.Orientation;
enabled: boolean;
allowLongSwipes: boolean;
confirmSwipe(distance: number, snapPoints: number[], currentProgress: number, cancelProgress: number): void;
destroy(): void;

_touchGesture?: Clutter.GestureAction;
_touchpadGesture?: __shell_private_types.TouchpadGesture;
// custom
__oldTouchpadGesture?: __shell_private_types.TouchpadGesture;
//
_allowedModes: Shell.ActionMode;

_progress: number;
_beginGesture(): void;
_updateGesture(): void;
_endTouchpadGesture(): void;
_history: {
reset(): void;
};
}
16 changes: 16 additions & 0 deletions @types/gnome-shell/extensions/ui/workspaceAnimation.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Clutter from '../../../clutter12';
import Meta from '../../../meta12';
import { SwipeTracker } from './swipeTracker';

declare class WorkspaceAnimationController {
_swipeTracker: SwipeTracker;
_switchWorkspaceBegin(tracker: {
orientation: Clutter.Orientation,
confirmSwipe: typeof SwipeTracker.prototype.confirmSwipe
}, monitor: number);

_switchWorkspaceUpdate(tracker: SwipeTracker, progress: number);
_switchWorkspaceEnd(tracker: SwipeTracker, duration: number, progress: number);

movingWindow: Meta.Window | undefined;
}
11 changes: 6 additions & 5 deletions extension/extension.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import GLib from '@gi-types/glib2';
import { imports } from 'gnome-shell';
import { Extension } from 'resource:///org/gnome/shell/extensions/extension';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

( Extension, ExtensionMetadata} from ....

import { AllSettingsKeys, GioSettings, PinchGestureType } from './common/settings';
import * as Constants from './constants';
import { AltTabConstants, ExtSettings, TouchpadConstants } from './constants';
Expand All @@ -13,16 +13,17 @@ import { SnapWindowExtension } from './src/snapWindow';
import * as DBusUtils from './src/utils/dbus';
import * as VKeyboard from './src/utils/keyboard';

const ExtensionUtils = imports.misc.extensionUtils;
const extensionObject = Extension.lookupByUUID('gestureImprovements@gestures');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not necessary


class Extension {
class GNOMEGestureImprovementsExtension extends Extension {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

export default class GnomeGestureImprovements extends Extension {

line 156 is not necessary??

private _extensions: ISubExtension[];
settings?: GioSettings;
private _settingChangedId = 0;
private _reloadWaitId = 0;
private _addReloadDelayFor: AllSettingsKeys[];

constructor() {
super(extensionObject.metadata);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

constructor(metadata: ExtensionMetadata) {
super(metadata)

this._extensions = [];
this._addReloadDelayFor = [
'touchpad-speed-scale',
Expand All @@ -32,7 +33,7 @@ class Extension {
}

enable() {
this.settings = ExtensionUtils.getSettings();
this.settings = this.getSettings();
this._settingChangedId = this.settings.connect('changed', this.reload.bind(this));
this._enable();
}
Expand Down Expand Up @@ -152,5 +153,5 @@ class Extension {
}

export function init(): IExtension {
return new Extension();
return new GNOMEGestureImprovementsExtension();
}
27 changes: 18 additions & 9 deletions extension/prefs.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
// import Gtk from '@gi-types/gtk4';
import Adw from '@gi-types/adw1';
import Gio from '@gi-types/gio2';

import { imports } from 'gnome-shell';
// import { imports } from 'gnome-shell';
import { buildPrefsWidget } from './common/prefs';

const ExtensionUtils = imports.misc.extensionUtils;
const ExtMe = ExtensionUtils.getCurrentExtension();
import { ExtensionPreferences } from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';

// eslint-disable-next-line @typescript-eslint/no-empty-function
export function init(): void { }
interface TracksSettings {
/**
* The settings object backing the settings window.
*/
_settings?: Gio.Settings;
}

export function fillPreferencesWindow(prefsWindow: Adw.PreferencesWindow) {
const UIDirPath = ExtMe.dir.get_child('ui').get_path() ?? '';
const settings = ExtensionUtils.getSettings();
buildPrefsWidget(prefsWindow, settings, UIDirPath);
// const ExtensionUtils = imports.misc.extensionUtils;
// const ExtMe = ExtensionUtils.getCurrentExtension();

export default class GNOMEGestureImprovementsPreferences extends ExtensionPreferences {
override fillPreferencesWindow(prefsWindow: Adw.PreferencesWindow & TracksSettings) {
const UIDirPath = this.metadata.dir.get_child('ui').get_path() ?? '';
const settings = this.getSettings();
buildPrefsWidget(prefsWindow, settings, UIDirPath);
}
}
8 changes: 4 additions & 4 deletions extension/src/altTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import Clutter from '@gi-types/clutter';
import GLib from '@gi-types/glib2';
import Shell from '@gi-types/shell';
import St from '@gi-types/st';
import { imports } from 'gnome-shell';
import Main from 'resource:///org/gnome/Shell/Extensions/js/extensions/ui/main';
import { WindowSwitcherPopup } from 'resource:///org/gnome/Shell/Extensions/js/extensions/ui/altTab';
import { __shell_private_types } from 'resource:///org/gnome/Shell/Extensions/js/extensions/ui/swipeTracker';

import { AltTabConstants, ExtSettings } from '../constants';
import { TouchpadSwipeGesture } from './swipeTracker';

const Main = imports.ui.main;
const { WindowSwitcherPopup } = imports.ui.altTab;

let dummyWinCount = AltTabConstants.DUMMY_WIN_COUNT;

function getIndexForProgress(progress: number, nelement: number): number {
Expand Down
Loading