Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.

Commit b4e483b

Browse files
authored
Merge pull request #352 from DaPigGuy/fix/gnome-48
Adjust to MetaCursor changes in GNOME 48
2 parents 5da1eba + 0bc523f commit b4e483b

File tree

5 files changed

+39
-32
lines changed

5 files changed

+39
-32
lines changed

src/components/panoItem.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { DBItem } from '@pano/utils/db';
1313
import { registerGObjectClass, SignalRepresentationType, SignalsDefinition } from '@pano/utils/gjs';
1414
import { getPanoItemTypes } from '@pano/utils/panoItemType';
1515
import { getCurrentExtensionSettings } from '@pano/utils/shell';
16-
import { orientationCompatibility } from '@pano/utils/shell_compatibility';
16+
import { MetaCursorPointer, orientationCompatibility } from '@pano/utils/shell_compatibility';
1717
import { getVirtualKeyboard, WINDOW_POSITIONS } from '@pano/utils/ui';
1818

1919
export type PanoItemSignalType = 'on-remove' | 'on-favorite' | 'activated';
@@ -68,7 +68,7 @@ export class PanoItem extends St.BoxLayout {
6868
this.connect('key-focus-in', () => this.setSelected(true));
6969
this.connect('key-focus-out', () => this.setSelected(false));
7070
this.connect('enter-event', () => {
71-
Shell.Global.get().display.set_cursor(Meta.Cursor.POINTING_HAND);
71+
Shell.Global.get().display.set_cursor(MetaCursorPointer);
7272
if (!this.selected) {
7373
this.set_style(`border: 4px solid ${this.settings.get_string('hovered-item-border-color')}`);
7474
}

src/components/searchBox.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { ItemType } from '@pano/utils/db';
99
import { registerGObjectClass, SignalRepresentationType, SignalsDefinition } from '@pano/utils/gjs';
1010
import { getPanoItemTypes, ICON_PACKS } from '@pano/utils/panoItemType';
1111
import { getCurrentExtensionSettings, gettext } from '@pano/utils/shell';
12-
import { orientationCompatibility } from '@pano/utils/shell_compatibility';
12+
import { MetaCursorPointer, orientationCompatibility } from '@pano/utils/shell_compatibility';
1313

1414
export type SearchBoxSignalType =
1515
| 'search-text-changed'
@@ -224,10 +224,10 @@ export class SearchBox extends St.BoxLayout {
224224
}
225225

226226
icon.connect('enter-event', () => {
227-
Shell.Global.get().display.set_cursor(Meta.Cursor.POINTING_HAND);
227+
Shell.Global.get().display.set_cursor(MetaCursorPointer);
228228
});
229229
icon.connect('motion-event', () => {
230-
Shell.Global.get().display.set_cursor(Meta.Cursor.POINTING_HAND);
230+
Shell.Global.get().display.set_cursor(MetaCursorPointer);
231231
});
232232
icon.connect('leave-event', () => {
233233
Shell.Global.get().display.set_cursor(Meta.Cursor.DEFAULT);

src/prefs/prefs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Gtk4 from '@girs/gtk-4.0';
55
import { CustomizationPage } from '@pano/prefs/customization';
66
import { DangerZonePage } from '@pano/prefs/dangerZone';
77
import { GeneralPage } from '@pano/prefs/general';
8-
import { isGnome47OrHigher } from '@pano/utils/compatibility';
8+
import { isGnomeVersionOrHigher } from '@pano/utils/compatibility';
99

1010
export default class PanoExtensionPreferences extends ExtensionPreferences {
1111
override fillPreferencesWindow(window: Adw.PreferencesWindow): Promise<void> | void {
@@ -23,7 +23,7 @@ export default class PanoExtensionPreferences extends ExtensionPreferences {
2323
* 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
2424
* @see https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/main/js/extensions/prefs.js#L34
2525
*/
26-
if (isGnome47OrHigher()) {
26+
if (isGnomeVersionOrHigher(47)) {
2727
return Promise.resolve();
2828
}
2929
return;

src/utils/compatibility.ts

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,29 @@ import { Notification, Source as MessageTraySource } from '@girs/gnome-shell/dis
44
import St from '@girs/st-16';
55

66
// compatibility functions to check if a specific gnome-shell is used
7-
export function isGnomeVersion(version: number): boolean {
8-
const [major, _minor, _patch, ..._rest]: Array<number | undefined> = PACKAGE_VERSION.split('.').map((num) => {
9-
const result = parseInt(num);
10-
if (isNaN(result)) {
11-
return undefined;
12-
}
13-
return result;
14-
});
15-
16-
if (major === undefined) {
17-
return PACKAGE_VERSION.includes(version.toString());
7+
const GNOME_VERSION = PACKAGE_VERSION.split('.').reduce((acc, str): number[] => {
8+
const result = parseInt(str);
9+
if (isNaN(result)) {
10+
return acc;
1811
}
1912

20-
return major === version;
21-
}
13+
return [...acc, result];
14+
}, [] as number[]);
2215

23-
export function isOneGnomeVersion(versions: number[]): boolean {
24-
for (const version of versions) {
25-
const isVersion = isGnomeVersion(version);
26-
if (isVersion) {
27-
return true;
28-
}
16+
export function isGnomeVersionOrHigher(version: number): boolean {
17+
if (GNOME_VERSION.length < 1) {
18+
console.error('[pano] FATAL ERROR: gnome version not correctly detected (case 1)');
19+
return false;
2920
}
3021

31-
return false;
32-
}
22+
const major = GNOME_VERSION[0];
3323

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

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

4132
// compatibility check functions for gnome-shell 45 / 46

src/utils/shell_compatibility.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,22 @@ function metaSupportsUnredirectForDisplay() {
2222
);
2323
}
2424

25+
// Meta.Cursor.POINTING_HAND was renamed to Meta.Cursor.POINTER in GNOME 48 (Meta 16)
26+
27+
interface NewMetaCursor {
28+
POINTER: Meta.Cursor | null | undefined;
29+
}
30+
31+
export const MetaCursorPointer: Meta.Cursor = (() => {
32+
const pointer = (Meta.Cursor as unknown as NewMetaCursor).POINTER;
33+
34+
if (pointer !== undefined && pointer !== null) {
35+
return pointer;
36+
}
37+
38+
return Meta.Cursor.POINTING_HAND;
39+
})();
40+
2541
// actual compatibility functions
2642

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

0 commit comments

Comments
 (0)