Skip to content
Draft
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: 2 additions & 0 deletions extension/common/prefs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ export function getPrefsWidget<T extends Gtk.Box = Gtk.Box>(settings: Gio.Settin

showEnableMinimizeButton('allow-minimize-window', 'allow-minimize-window_box-row', settings, builder);

bind_boolean_value('enable-move-window-to-workspace', settings, builder, { sensitiveRowKeys: ['animate-panel_box-row'] });
bind_combo_box('animate-panel', settings, builder);
bind_combo_box('pinch-3-finger-gesture', settings, builder);
bind_combo_box('pinch-4-finger-gesture', settings, builder);

Expand Down
16 changes: 14 additions & 2 deletions extension/common/settings.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import Gio from '@gi-types/gio2';

// define enum
export enum AnimatePanel {
NONE = 0,
SWITCH_WORKSPACE = 1,
MOVE_WINDOW = 2,
SWITCH_WORKSPACE_AND_MOVE_WINDOW = 3,
}

// define enum
export enum PinchGestureType {
NONE = 0,
Expand All @@ -12,7 +20,8 @@ export type BooleanSettingsKeys =
'allow-minimize-window' |
'follow-natural-scroll' |
'enable-alttab-gesture' |
'enable-window-manipulation-gesture'
'enable-window-manipulation-gesture' |
'enable-move-window-to-workspace'
;

export type IntegerSettingsKeys =
Expand All @@ -24,6 +33,7 @@ export type DoubleSettingsKeys =
;

export type EnumSettingsKeys =
'animate-panel' |
'pinch-3-finger-gesture' |
'pinch-4-finger-gesture'
;
Expand All @@ -41,7 +51,8 @@ export type AllUIObjectKeys =
'touchpad-speed_scale_display-value' |
'touchpad-pinch-speed_display-value' |
'allow-minimize-window_box-row' |
'alttab-delay_box-row'
'alttab-delay_box-row' |
'animate-panel_box-row'
;

type Enum_Functions<K extends EnumSettingsKeys, T> = {
Expand All @@ -50,6 +61,7 @@ type Enum_Functions<K extends EnumSettingsKeys, T> = {
}

type SettingsEnumFunctions =
Enum_Functions<'animate-panel', AnimatePanel> &
Enum_Functions<'pinch-3-finger-gesture' | 'pinch-4-finger-gesture', PinchGestureType>
;

Expand Down
11 changes: 11 additions & 0 deletions extension/common/utils/clutter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { EventType, Event } from '@gi-types/clutter8';

export const ClutterEventType = { TOUCHPAD_HOLD: 1234, ...EventType };

export type CustomEventType = Pick<
Copy link
Owner Author

Choose a reason for hiding this comment

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

Move to gnome-shell

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'
>;
92 changes: 46 additions & 46 deletions extension/common/utils/gobject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,71 +15,71 @@ const OGRegisterClass = GObject.registerClass;
type ConstructorType = new (...args: any[]) => any;
Copy link
Owner Author

Choose a reason for hiding this comment

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

Convert indetation to tabs


type IFaces<Interfaces extends { $gtype: GObject.GType<any> }[]> = {
[key in keyof Interfaces]: Interfaces[key] extends { $gtype: GObject.GType<infer I> } ? I : never;
[key in keyof Interfaces]: Interfaces[key] extends { $gtype: GObject.GType<infer I> } ? I : never;
};

type _TupleOf<T, N extends number, R extends T[]> = R['length'] extends N ? R : _TupleOf<T, N, [T, ...R]>;
/** Tuple of Type T, and of length N */
type Tuple<T, N extends number> = _TupleOf<T, N, []>;

type GObjectSignalDefinition<N extends number = 32> = {
param_types?: Partial<Tuple<GObject.GType, N>>;
[key: string]: any;
param_types?: Partial<Tuple<GObject.GType, N>>;
[key: string]: any;
};

/** Get typescript type for {@link GObjectSignalDefinition.param_types} */
type CallBackTypeTuple<T> = T extends any[] ? { [P in keyof T]: T[P] extends GObject.GType<infer R> ? R : never } : [];

export type RegisteredPrototype<
P extends {},
Props extends { [key: string]: GObject.ParamSpec },
Interfaces extends any[],
Sigs extends { [key: string]: GObjectSignalDefinition }
> = {
/// This is one of modification done by this file
connect<K extends keyof Sigs>(
key: K,
callback: (
_source: RegisteredPrototype<P, Props, Interfaces, Sigs>,
...args: CallBackTypeTuple<Sigs[K]['param_types']>
) => void,
): number,
} & GObject.RegisteredPrototype<P, Props, Interfaces>;
P extends {},
Props extends { [key: string]: GObject.ParamSpec },
Interfaces extends any[],
Sigs extends { [key: string]: GObjectSignalDefinition }
> = {
/// This is one of modification done by this file
connect<K extends keyof Sigs>(
key: K,
callback: (
_source: RegisteredPrototype<P, Props, Interfaces, Sigs>,
...args: CallBackTypeTuple<Sigs[K]['param_types']>
) => void,
): number,
} & GObject.RegisteredPrototype<P, Props, Interfaces>;

export type RegisteredClass<
T extends ConstructorType,
Props extends { [key: string]: GObject.ParamSpec },
Interfaces extends { $gtype: GObject.GType<any> }[],
Sigs extends { [key: string]: GObjectSignalDefinition }
> = T extends { prototype: infer P }
? {
$gtype: GObject.GType<RegisteredClass<T, Props, IFaces<Interfaces>, Sigs>>;
prototype: RegisteredPrototype<P, Props, IFaces<Interfaces>, Sigs>;
/// use constructor parameter instead of '_init' parameters
new(...args: ConstructorParameters<T>): RegisteredPrototype<P, Props, IFaces<Interfaces>, Sigs>;
}
: never;
T extends ConstructorType,
Props extends { [key: string]: GObject.ParamSpec },
Interfaces extends { $gtype: GObject.GType<any> }[],
Sigs extends { [key: string]: GObjectSignalDefinition }
> = T extends { prototype: infer P }
? {
$gtype: GObject.GType<RegisteredClass<T, Props, IFaces<Interfaces>, Sigs>>;
prototype: RegisteredPrototype<P, Props, IFaces<Interfaces>, Sigs>;
/// use constructor parameter instead of '_init' parameters
new(...args: ConstructorParameters<T>): RegisteredPrototype<P, Props, IFaces<Interfaces>, Sigs>;
}
: never;

export function registerClass<T extends ConstructorType>(klass: T): RegisteredClass<T, {}, [], {}>;
export function registerClass<
T extends ConstructorType,
Props extends { [key: string]: GObject.ParamSpec },
Interfaces extends { $gtype: GObject.GType }[],
Sigs extends { [key: string]: GObjectSignalDefinition }
T extends ConstructorType,
Props extends { [key: string]: GObject.ParamSpec },
Interfaces extends { $gtype: GObject.GType }[],
Sigs extends { [key: string]: GObjectSignalDefinition }
>(
options: {
GTypeName?: string;
GTypeFlags?: GObject.TypeFlags;
/// Make properties mandatory
Properties: Props;
Signals?: Sigs;
Implements?: Interfaces;
CssName?: string;
Template?: string;
Children?: string[];
InternalChildren?: string[];
},
klass: T
options: {
GTypeName?: string;
GTypeFlags?: GObject.TypeFlags;
/// Make properties mandatory
Properties: Props;
Signals?: Sigs;
Implements?: Interfaces;
CssName?: string;
Template?: string;
Children?: string[];
InternalChildren?: string[];
},
klass: T
): RegisteredClass<T, Props, Interfaces, Sigs>;

export function registerClass(...args: any[]): any {
Expand Down
5 changes: 5 additions & 0 deletions extension/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@

import { AnimatePanel } from './common/settings';

// FIXME: ideally these values matches physical touchpad size. We can get the
// correct values for gnome-shell specifically, since mutter uses libinput
// directly, but GTK apps cannot get it, so use an arbitrary value so that
Expand Down Expand Up @@ -33,6 +36,8 @@ export const ExtSettings = {
DEFAULT_OVERVIEW_GESTURE: false,
ALLOW_MINIMIZE_WINDOW: false,
FOLLOW_NATURAL_SCROLL: true,
ENABLE_MOVE_WINDOW_TO_WORKSPACE: true,
ANIMATE_PANEL: AnimatePanel.MOVE_WINDOW,
};

export const RELOAD_DELAY = 150; // reload extension delay in ms
8 changes: 7 additions & 1 deletion extension/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { OverviewRoundTripGestureExtension } from './src/overviewRoundTrip';
import { SnapWindowExtension } from './src/snapWindow';
import * as DBusUtils from './src/utils/dbus';
import { imports } from 'gnome-shell';
import { AllSettingsKeys, GioSettings, PinchGestureType } from './common/settings';
import { AllSettingsKeys, AnimatePanel, GioSettings, PinchGestureType } from './common/settings';
import { AltTabConstants, ExtSettings, TouchpadConstants } from './constants';
import { ShowDesktopExtension } from './src/pinchGestures/showDesktop';

Expand Down Expand Up @@ -108,6 +108,12 @@ class Extension {
ExtSettings.DEFAULT_OVERVIEW_GESTURE = this.settings.get_boolean('default-overview');
ExtSettings.ALLOW_MINIMIZE_WINDOW = this.settings.get_boolean('allow-minimize-window');
ExtSettings.FOLLOW_NATURAL_SCROLL = this.settings.get_boolean('follow-natural-scroll');
ExtSettings.ENABLE_MOVE_WINDOW_TO_WORKSPACE = this.settings.get_boolean('enable-move-window-to-workspace');

if (ExtSettings.ENABLE_MOVE_WINDOW_TO_WORKSPACE)
ExtSettings.ANIMATE_PANEL = this.settings.get_enum('animate-panel');
else
ExtSettings.ANIMATE_PANEL = AnimatePanel.NONE;

TouchpadConstants.SWIPE_MULTIPLIER = Constants.TouchpadConstants.DEFAULT_SWIPE_MULTIPLIER * this.settings.get_double('touchpad-speed-scale');
TouchpadConstants.PINCH_MULTIPLIER = Constants.TouchpadConstants.DEFAULT_PINCH_MULTIPLIER * this.settings.get_double('touchpad-pinch-speed');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist>
<enum id='org.gnome.shell.extensions.gestureImprovements.animate-panel'>
<value value='0' nick='NONE' />
<value value='2' nick='MOVE_WINDOW' />
<value value='3' nick='SWITCH_WORKSPACE_AND_MOVE_WINDOW' />
</enum>
<enum id='org.gnome.shell.extensions.gestureImprovements.pinch-gestures'>
<value value='0' nick='NONE' />
<value value='1' nick='SHOW_DESKTOP' />
Expand Down Expand Up @@ -39,6 +44,14 @@
<default>true</default>
<description>Enable Window manipulation gesture</description>
</key>
<key name='enable-move-window-to-workspace' type='b'>
<default>true</default>
<description>Enable move window to workspace gesture</description>
</key>
<key name="animate-panel" enum="org.gnome.shell.extensions.gestureImprovements.animate-panel">
<default>'MOVE_WINDOW'</default>
<description>When to animate panel</description>
</key>
<key name="pinch-3-finger-gesture" enum="org.gnome.shell.extensions.gestureImprovements.pinch-gestures">
<default>'SHOW_DESKTOP'</default>
<description>Gesture for 3 finger pinch</description>
Expand Down
2 changes: 1 addition & 1 deletion extension/src/altTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export class AltTabGestureExtension implements ISubExtension {
if (this._extState === AltTabExtState.DEFAULT) {
this._switcher = new WindowSwitcherPopup();
// remove timeout entirely
this._switcher._resetNoModsTimeout = function () {
this._switcher._resetNoModsTimeout = function() {
Copy link
Owner Author

Choose a reason for hiding this comment

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

format file

if (this._noModsTimeoutId) {
GLib.source_remove(this._noModsTimeoutId);
this._noModsTimeoutId = 0;
Expand Down
Loading