Skip to content
Merged
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
4 changes: 2 additions & 2 deletions src/components/panoItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { DBItem } from '@pano/utils/db';
import { registerGObjectClass, SignalRepresentationType, SignalsDefinition } from '@pano/utils/gjs';
import { getPanoItemTypes } from '@pano/utils/panoItemType';
import { getCurrentExtensionSettings } from '@pano/utils/shell';
import { orientationCompatibility } from '@pano/utils/shell_compatibility';
import { MetaCursorPointer, orientationCompatibility } from '@pano/utils/shell_compatibility';
import { getVirtualKeyboard, WINDOW_POSITIONS } from '@pano/utils/ui';

export type PanoItemSignalType = 'on-remove' | 'on-favorite' | 'activated';
Expand Down Expand Up @@ -68,7 +68,7 @@ export class PanoItem extends St.BoxLayout {
this.connect('key-focus-in', () => this.setSelected(true));
this.connect('key-focus-out', () => this.setSelected(false));
this.connect('enter-event', () => {
Shell.Global.get().display.set_cursor(Meta.Cursor.POINTING_HAND);
Shell.Global.get().display.set_cursor(MetaCursorPointer);
if (!this.selected) {
this.set_style(`border: 4px solid ${this.settings.get_string('hovered-item-border-color')}`);
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/searchBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ItemType } from '@pano/utils/db';
import { registerGObjectClass, SignalRepresentationType, SignalsDefinition } from '@pano/utils/gjs';
import { getPanoItemTypes, ICON_PACKS } from '@pano/utils/panoItemType';
import { getCurrentExtensionSettings, gettext } from '@pano/utils/shell';
import { orientationCompatibility } from '@pano/utils/shell_compatibility';
import { MetaCursorPointer, orientationCompatibility } from '@pano/utils/shell_compatibility';

export type SearchBoxSignalType =
| 'search-text-changed'
Expand Down Expand Up @@ -224,10 +224,10 @@ export class SearchBox extends St.BoxLayout {
}

icon.connect('enter-event', () => {
Shell.Global.get().display.set_cursor(Meta.Cursor.POINTING_HAND);
Shell.Global.get().display.set_cursor(MetaCursorPointer);
});
icon.connect('motion-event', () => {
Shell.Global.get().display.set_cursor(Meta.Cursor.POINTING_HAND);
Shell.Global.get().display.set_cursor(MetaCursorPointer);
});
icon.connect('leave-event', () => {
Shell.Global.get().display.set_cursor(Meta.Cursor.DEFAULT);
Expand Down
4 changes: 2 additions & 2 deletions src/prefs/prefs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Gtk4 from '@girs/gtk-4.0';
import { CustomizationPage } from '@pano/prefs/customization';
import { DangerZonePage } from '@pano/prefs/dangerZone';
import { GeneralPage } from '@pano/prefs/general';
import { isGnome47OrHigher } from '@pano/utils/compatibility';
import { isGnomeVersionOrHigher } from '@pano/utils/compatibility';

export default class PanoExtensionPreferences extends ExtensionPreferences {
override fillPreferencesWindow(window: Adw.PreferencesWindow): Promise<void> | void {
Expand All @@ -23,7 +23,7 @@ export default class PanoExtensionPreferences extends ExtensionPreferences {
* gnome 47 explicitly states, that we need to return a Promise, so we check the version at runtime and decide what to return, to support older versions of gnome shell, that don't expected a promise here
* @see https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/main/js/extensions/prefs.js#L34
*/
if (isGnome47OrHigher()) {
if (isGnomeVersionOrHigher(47)) {
return Promise.resolve();
}
return;
Expand Down
41 changes: 16 additions & 25 deletions src/utils/compatibility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,29 @@ import { Notification, Source as MessageTraySource } from '@girs/gnome-shell/dis
import St from '@girs/st-16';

// compatibility functions to check if a specific gnome-shell is used
export function isGnomeVersion(version: number): boolean {
const [major, _minor, _patch, ..._rest]: Array<number | undefined> = PACKAGE_VERSION.split('.').map((num) => {
const result = parseInt(num);
if (isNaN(result)) {
return undefined;
}
return result;
});

if (major === undefined) {
return PACKAGE_VERSION.includes(version.toString());
const GNOME_VERSION = PACKAGE_VERSION.split('.').reduce((acc, str): number[] => {
const result = parseInt(str);
if (isNaN(result)) {
return acc;
}

return major === version;
}
return [...acc, result];
}, [] as number[]);

export function isOneGnomeVersion(versions: number[]): boolean {
for (const version of versions) {
const isVersion = isGnomeVersion(version);
if (isVersion) {
return true;
}
export function isGnomeVersionOrHigher(version: number): boolean {
if (GNOME_VERSION.length < 1) {
console.error('[pano] FATAL ERROR: gnome version not correctly detected (case 1)');
return false;
}

return false;
}
const major = GNOME_VERSION[0];

// compatibility check functions for gnome-shell 47
if (major === undefined) {
console.error('[pano] FATAL ERROR: gnome version not correctly detected (case 2)');
return false;
}

// this check if it is gnome 47 or higher, which includes all supported versions above and inclusive gnome 47
export function isGnome47OrHigher(): boolean {
return isOneGnomeVersion([47, 48]);
return major >= version;
}

// compatibility check functions for gnome-shell 45 / 46
Expand Down
16 changes: 16 additions & 0 deletions src/utils/shell_compatibility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,22 @@ function metaSupportsUnredirectForDisplay() {
);
}

// Meta.Cursor.POINTING_HAND was renamed to Meta.Cursor.POINTER in GNOME 48 (Meta 16)

interface NewMetaCursor {
POINTER: Meta.Cursor | null | undefined;
}

export const MetaCursorPointer: Meta.Cursor = (() => {
const pointer = (Meta.Cursor as unknown as NewMetaCursor).POINTER;

if (pointer !== undefined && pointer !== null) {
return pointer;
}

return Meta.Cursor.POINTING_HAND;
})();

// actual compatibility functions

export type OrientationReturnType = { vertical: boolean } | { orientation: Clutter.Orientation };
Expand Down