Backport to GNOME versions 44 and 43
Works in gnome-shell nested
This commit is contained in:
parent
7369cb0551
commit
048b98ec99
|
|
@ -15,11 +15,11 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import Clutter from 'gi://Clutter';
|
||||
import GObject from 'gi://GObject';
|
||||
const Clutter = imports.gi.Clutter;
|
||||
const GObject = imports.gi.GObject;
|
||||
|
||||
// Copied almost verbatim from ui/magnifier.js.
|
||||
export const MouseSpriteContent = GObject.registerClass({
|
||||
var MouseSpriteContent = GObject.registerClass({
|
||||
Implements: [Clutter.Content],
|
||||
}, class MouseSpriteContent extends GObject.Object {
|
||||
_init() {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,15 @@
|
|||
import Clutter from 'gi://Clutter';
|
||||
import GLib from 'gi://GLib';
|
||||
import Meta from 'gi://Meta';
|
||||
import * as PointerWatcher from 'resource:///org/gnome/shell/ui/pointerWatcher.js';
|
||||
import { MouseSpriteContent } from './cursor.js';
|
||||
import Globals from './globals.js';
|
||||
const Clutter = imports.gi.Clutter;
|
||||
const Meta = imports.gi.Meta;
|
||||
const PointerWatcher = imports.ui.pointerWatcher;
|
||||
|
||||
const ExtensionUtils = imports.misc.extensionUtils;
|
||||
const Me = ExtensionUtils.getCurrentExtension();
|
||||
|
||||
const Globals = Me.imports.globals;
|
||||
const { MouseSpriteContent } = Me.imports.cursor;
|
||||
|
||||
// Taken from https://github.com/jkitching/soft-brightness-plus
|
||||
export class CursorManager {
|
||||
var CursorManager = class CursorManager {
|
||||
constructor(mainActor, refreshRate) {
|
||||
this._mainActor = mainActor;
|
||||
this._refreshRate = refreshRate;
|
||||
|
|
|
|||
|
|
@ -1,19 +1,21 @@
|
|||
import Clutter from 'gi://Clutter'
|
||||
import Gio from 'gi://Gio';
|
||||
import GLib from 'gi://GLib';
|
||||
import Meta from 'gi://Meta';
|
||||
import Shell from 'gi://Shell';
|
||||
import St from 'gi://St';
|
||||
const Clutter = imports.gi.Clutter;
|
||||
const Gio = imports.gi.Gio;
|
||||
const GLib = imports.gi.GLib;
|
||||
const Meta = imports.gi.Meta;
|
||||
const Shell = imports.gi.Shell;
|
||||
const St = imports.gi.St;
|
||||
|
||||
import { CursorManager } from './cursormanager.js';
|
||||
import Globals from './globals.js';
|
||||
import { Logger } from './logger.js';
|
||||
import { MonitorManager } from './monitormanager.js';
|
||||
import { isValidKeepAlive } from './time.js';
|
||||
import { IPC_FILE_PATH, XREffect } from './xrEffect.js';
|
||||
const Main = imports.ui.main;
|
||||
|
||||
import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js';
|
||||
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
|
||||
const ExtensionUtils = imports.misc.extensionUtils;
|
||||
const Me = ExtensionUtils.getCurrentExtension();
|
||||
|
||||
const Globals = Me.imports.globals;
|
||||
const { CursorManager } = Me.imports.cursormanager;
|
||||
const { Logger } = Me.imports.logger;
|
||||
const { MonitorManager } = Me.imports.monitormanager;
|
||||
const { isValidKeepAlive } = Me.imports.time;
|
||||
const { IPC_FILE_PATH, XREffect } = Me.imports.xrEffect;
|
||||
|
||||
const SUPPORTED_MONITOR_PRODUCTS = [
|
||||
'VITURE',
|
||||
|
|
@ -24,11 +26,10 @@ const SUPPORTED_MONITOR_PRODUCTS = [
|
|||
'SmartGlasses' // TCL/RayNeo
|
||||
];
|
||||
|
||||
export default class BreezyDesktopExtension extends Extension {
|
||||
constructor(metadata, uuid) {
|
||||
super(metadata, uuid);
|
||||
|
||||
this.settings = this.getSettings();
|
||||
class BreezyDesktopExtension {
|
||||
constructor(extensionPath) {
|
||||
this.path = extensionPath;
|
||||
this.settings = ExtensionUtils.getSettings();
|
||||
|
||||
// Set/destroyed by enable/disable
|
||||
this._cursor_manager = null;
|
||||
|
|
@ -521,6 +522,6 @@ export default class BreezyDesktopExtension extends Extension {
|
|||
}
|
||||
}
|
||||
|
||||
function init() {
|
||||
return new Extension();
|
||||
function init(meta) {
|
||||
return new BreezyDesktopExtension(meta.path);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,5 +2,4 @@ const Globals = {
|
|||
logger: null,
|
||||
ipc_file: null, // Gio.File instance, file exists if set
|
||||
extension_dir: null // string path
|
||||
}
|
||||
export default Globals;
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
function isGnome45OrLater() {
|
||||
return !imports.gi.versions['GLib'];
|
||||
}
|
||||
|
||||
async function importGiModule(module) {
|
||||
return isGnome45OrLater() ? import(`gi://${module}`) : Promise.resolve(imports.gi[module]);
|
||||
}
|
||||
|
||||
// Function to dynamically import modules based on GJS version
|
||||
async function importGiModules(modules) {
|
||||
return Promise.all(modules.map(importGiModule));
|
||||
|
||||
}
|
||||
|
||||
async function importNativeModule(path, name) {
|
||||
return isGnome45OrLater() ? import(`resource:///org/gnome/shell/${path}/${name}.js`) : Promise.resolve(imports[path][name]);
|
||||
}
|
||||
|
||||
// GNOME 44 and older don't have a base extension class
|
||||
const ExtensionUtils = imports.misc.extensionUtils;
|
||||
class BaseExtension {
|
||||
getSettings() {
|
||||
return ExtensionUtils.getSettings();
|
||||
}
|
||||
}
|
||||
|
||||
var ExtensionClassPromise = isGnome45OrLater() ? import(`resource:///org/gnome/shell/extensions/extension.js`) : Promise.resolve(BaseExtension);
|
||||
|
|
@ -1,30 +1,30 @@
|
|||
export const UINT8_SIZE = 1;
|
||||
export const BOOL_SIZE = UINT8_SIZE;
|
||||
export const UINT_SIZE = 4;
|
||||
export const FLOAT_SIZE = 4;
|
||||
var UINT8_SIZE = 1;
|
||||
var BOOL_SIZE = UINT8_SIZE;
|
||||
var UINT_SIZE = 4;
|
||||
var FLOAT_SIZE = 4;
|
||||
|
||||
export const DATA_VIEW_INFO_OFFSET_INDEX = 0;
|
||||
export const DATA_VIEW_INFO_SIZE_INDEX = 1;
|
||||
export const DATA_VIEW_INFO_COUNT_INDEX = 2;
|
||||
var DATA_VIEW_INFO_OFFSET_INDEX = 0;
|
||||
var DATA_VIEW_INFO_SIZE_INDEX = 1;
|
||||
var DATA_VIEW_INFO_COUNT_INDEX = 2;
|
||||
|
||||
// computes the end offset, exclusive
|
||||
export function dataViewEnd(dataViewInfo) {
|
||||
function dataViewEnd(dataViewInfo) {
|
||||
return dataViewInfo[DATA_VIEW_INFO_OFFSET_INDEX] + dataViewInfo[DATA_VIEW_INFO_SIZE_INDEX] * dataViewInfo[DATA_VIEW_INFO_COUNT_INDEX];
|
||||
}
|
||||
|
||||
export function dataViewUint8(dataView, dataViewInfo) {
|
||||
function dataViewUint8(dataView, dataViewInfo) {
|
||||
return dataView.getUint8(dataViewInfo[DATA_VIEW_INFO_OFFSET_INDEX]);
|
||||
}
|
||||
|
||||
export function dataViewUint(dataView, dataViewInfo) {
|
||||
function dataViewUint(dataView, dataViewInfo) {
|
||||
return dataView.getUint32(dataViewInfo[DATA_VIEW_INFO_OFFSET_INDEX], true);
|
||||
}
|
||||
|
||||
export function dataViewBigUint(dataView, dataViewInfo) {
|
||||
function dataViewBigUint(dataView, dataViewInfo) {
|
||||
return Number(dataView.getBigUint64(dataViewInfo[DATA_VIEW_INFO_OFFSET_INDEX], true));
|
||||
}
|
||||
|
||||
export function dataViewUint32Array(dataView, dataViewInfo) {
|
||||
function dataViewUint32Array(dataView, dataViewInfo) {
|
||||
const uintArray = []
|
||||
let offset = dataViewInfo[DATA_VIEW_INFO_OFFSET_INDEX];
|
||||
for (let i = 0; i < dataViewInfo[DATA_VIEW_INFO_COUNT_INDEX]; i++) {
|
||||
|
|
@ -34,7 +34,7 @@ export function dataViewUint32Array(dataView, dataViewInfo) {
|
|||
return uintArray;
|
||||
}
|
||||
|
||||
export function dataViewUint8Array(dataView, dataViewInfo) {
|
||||
function dataViewUint8Array(dataView, dataViewInfo) {
|
||||
const uintArray = []
|
||||
let offset = dataViewInfo[DATA_VIEW_INFO_OFFSET_INDEX];
|
||||
for (let i = 0; i < dataViewInfo[DATA_VIEW_INFO_SIZE_INDEX] * dataViewInfo[DATA_VIEW_INFO_COUNT_INDEX]; i++) {
|
||||
|
|
@ -44,11 +44,11 @@ export function dataViewUint8Array(dataView, dataViewInfo) {
|
|||
return uintArray;
|
||||
}
|
||||
|
||||
export function dataViewFloat(dataView, dataViewInfo) {
|
||||
function dataViewFloat(dataView, dataViewInfo) {
|
||||
return dataView.getFloat32(dataViewInfo[DATA_VIEW_INFO_OFFSET_INDEX], true);
|
||||
}
|
||||
|
||||
export function dataViewFloatArray(dataView, dataViewInfo) {
|
||||
function dataViewFloatArray(dataView, dataViewInfo) {
|
||||
const floatArray = []
|
||||
let offset = dataViewInfo[DATA_VIEW_INFO_OFFSET_INDEX];
|
||||
for (let i = 0; i < dataViewInfo[DATA_VIEW_INFO_COUNT_INDEX]; i++) {
|
||||
|
|
|
|||
|
|
@ -14,15 +14,15 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import * as Config from 'resource:///org/gnome/shell/misc/config.js';
|
||||
import Gio from 'gi://Gio';
|
||||
import GLib from 'gi://GLib';
|
||||
import GObject from 'gi://GObject';
|
||||
import System from 'system';
|
||||
const Config = imports.misc.config;
|
||||
const Gio = imports.gi.Gio;
|
||||
const GLib = imports.gi.GLib;
|
||||
const GObject = imports.gi.GObject;
|
||||
const System = imports.system;
|
||||
|
||||
const LOG_DIR_NAME = 'breezy_gnome/logs/gjs';
|
||||
|
||||
export const Logger = GObject.registerClass({
|
||||
var Logger = GObject.registerClass({
|
||||
GTypeName: 'Logger',
|
||||
Properties: {
|
||||
'title': GObject.ParamSpec.string(
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
export function degreeToRadian(degree) {
|
||||
function degreeToRadian(degree) {
|
||||
return degree * Math.PI / 180;
|
||||
}
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
"settings-schema": "com.xronlinux.BreezyDesktop",
|
||||
"session-modes": ["user", "unlock-dialog"],
|
||||
"shell-version": [
|
||||
"45", "46"
|
||||
"43", "44"
|
||||
],
|
||||
"url": "https://github.com/wheaney/breezy-desktop"
|
||||
}
|
||||
|
|
@ -16,12 +16,15 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import Gio from 'gi://Gio';
|
||||
import GObject from 'gi://GObject';
|
||||
const Gio = imports.gi.Gio;
|
||||
const GObject = imports.gi.GObject;
|
||||
|
||||
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
|
||||
const Main = imports.ui.main;
|
||||
|
||||
import Globals from './globals.js';
|
||||
const ExtensionUtils = imports.misc.extensionUtils;
|
||||
const Me = ExtensionUtils.getCurrentExtension();
|
||||
|
||||
const Globals = Me.imports.globals;
|
||||
|
||||
let cachedDisplayConfigProxy = null;
|
||||
|
||||
|
|
@ -43,7 +46,7 @@ function getDisplayConfigProxy(extPath) {
|
|||
return cachedDisplayConfigProxy;
|
||||
}
|
||||
|
||||
export function newDisplayConfig(extPath, callback) {
|
||||
function newDisplayConfig(extPath, callback) {
|
||||
const DisplayConfigProxy = getDisplayConfigProxy(extPath);
|
||||
new DisplayConfigProxy(
|
||||
Gio.DBus.session,
|
||||
|
|
@ -190,7 +193,7 @@ function performOptimalModeCheck(displayConfigProxy, connectorName, headsetAsPri
|
|||
}
|
||||
|
||||
// Monitor change handling
|
||||
export const MonitorManager = GObject.registerClass({
|
||||
var MonitorManager = GObject.registerClass({
|
||||
Properties: {
|
||||
'use-optimal-monitor-config': GObject.ParamSpec.boolean(
|
||||
'use-optimal-monitor-config',
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import Gio from 'gi://Gio';
|
||||
const Gio = imports.gi.Gio;
|
||||
|
||||
export function getShaderSource(path) {
|
||||
function getShaderSource(path) {
|
||||
const file = Gio.file_new_for_path(path);
|
||||
const data = file.load_contents(null);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
export function getEpochSec() {
|
||||
function getEpochSec() {
|
||||
return toSec(Date.now());
|
||||
}
|
||||
|
||||
export function toSec(milliseconds) {
|
||||
function toSec(milliseconds) {
|
||||
return Math.floor(milliseconds / 1000);
|
||||
}
|
||||
|
||||
export function isValidKeepAlive(dateSec, strictCheck = false) {
|
||||
function isValidKeepAlive(dateSec, strictCheck = false) {
|
||||
return Math.abs(toSec(Date.now()) - dateSec) <= (strictCheck ? 1 : 5);
|
||||
}
|
||||
|
|
@ -1,13 +1,15 @@
|
|||
import Clutter from 'gi://Clutter';
|
||||
import Cogl from 'gi://Cogl';
|
||||
import GdkPixbuf from 'gi://GdkPixbuf';
|
||||
import GLib from 'gi://GLib';
|
||||
import GObject from 'gi://GObject';
|
||||
import Shell from 'gi://Shell';
|
||||
const Clutter = imports.gi.Clutter;
|
||||
const Cogl = imports.gi.Cogl;
|
||||
const GdkPixbuf = imports.gi.GdkPixbuf;
|
||||
const GLib = imports.gi.GLib;
|
||||
const GObject = imports.gi.GObject;
|
||||
const Shell = imports.gi.Shell;
|
||||
|
||||
import Globals from './globals.js';
|
||||
const ExtensionUtils = imports.misc.extensionUtils;
|
||||
const Me = ExtensionUtils.getCurrentExtension();
|
||||
|
||||
import {
|
||||
const Globals = Me.imports.globals;
|
||||
const {
|
||||
dataViewEnd,
|
||||
dataViewUint8,
|
||||
dataViewBigUint,
|
||||
|
|
@ -21,12 +23,12 @@ import {
|
|||
FLOAT_SIZE,
|
||||
UINT_SIZE,
|
||||
UINT8_SIZE
|
||||
} from "./ipc.js";
|
||||
import { degreeToRadian } from "./math.js";
|
||||
import { getShaderSource } from "./shader.js";
|
||||
import { isValidKeepAlive, toSec } from "./time.js";
|
||||
} = Me.imports.ipc;
|
||||
const { degreeToRadian } = Me.imports.math;
|
||||
const { getShaderSource } = Me.imports.shader;
|
||||
const { isValidKeepAlive, toSec } = Me.imports.time;
|
||||
|
||||
export const IPC_FILE_PATH = "/dev/shm/breezy_desktop_imu";
|
||||
var IPC_FILE_PATH = "/dev/shm/breezy_desktop_imu";
|
||||
|
||||
// the driver should be using the same data layout version
|
||||
const DATA_LAYOUT_VERSION = 3;
|
||||
|
|
@ -220,7 +222,7 @@ function checkParityByte(dataView) {
|
|||
return parityByte === parity;
|
||||
}
|
||||
|
||||
export const XREffect = GObject.registerClass({
|
||||
var XREffect = GObject.registerClass({
|
||||
Properties: {
|
||||
'supported-device-detected': GObject.ParamSpec.boolean(
|
||||
'supported-device-detected',
|
||||
|
|
|
|||
Loading…
Reference in New Issue