Fix caching of backend object, copy SystemBackground from GNOME magnifier implemenation
This commit is contained in:
parent
529e40a91e
commit
69d40e2640
|
|
@ -9,6 +9,7 @@ import { CursorManager } from './cursormanager.js';
|
||||||
import Globals from './globals.js';
|
import Globals from './globals.js';
|
||||||
import { Logger } from './logger.js';
|
import { Logger } from './logger.js';
|
||||||
import { MonitorManager } from './monitormanager.js';
|
import { MonitorManager } from './monitormanager.js';
|
||||||
|
import { SystemBackground } from './systembackground.js';
|
||||||
import { isValidKeepAlive } from './time.js';
|
import { isValidKeepAlive } from './time.js';
|
||||||
import { IPC_FILE_PATH, XREffect } from './xrEffect.js';
|
import { IPC_FILE_PATH, XREffect } from './xrEffect.js';
|
||||||
|
|
||||||
|
|
@ -250,24 +251,25 @@ export default class BreezyDesktopExtension extends Extension {
|
||||||
this._cursor_manager = new CursorManager(Main.layoutManager.uiGroup, refreshRate);
|
this._cursor_manager = new CursorManager(Main.layoutManager.uiGroup, refreshRate);
|
||||||
this._cursor_manager.enable();
|
this._cursor_manager.enable();
|
||||||
|
|
||||||
this._overlay = new St.Bin();
|
const overlayContent = new Clutter.Actor({clip_to_allocation: true});
|
||||||
this._overlay.opacity = 255;
|
|
||||||
|
this._overlay = new St.Bin({
|
||||||
|
child: overlayContent
|
||||||
|
});
|
||||||
this._overlay.set_position(targetMonitor.x, targetMonitor.y);
|
this._overlay.set_position(targetMonitor.x, targetMonitor.y);
|
||||||
this._overlay.set_size(targetMonitor.width, targetMonitor.height);
|
this._overlay.set_size(targetMonitor.width, targetMonitor.height);
|
||||||
Globals.logger.log_debug(`BreezyDesktopExtension _effect_enable overlay size: \
|
|
||||||
${targetMonitor.width}x${targetMonitor.height} at ${targetMonitor.x},${targetMonitor.y}`);
|
|
||||||
|
|
||||||
const overlayContent = new Clutter.Actor({clip_to_allocation: true});
|
global.stage.add_child(this._overlay);
|
||||||
|
Shell.util_set_hidden_from_pick(this._overlay, true);
|
||||||
|
|
||||||
|
this._background = new SystemBackground();
|
||||||
|
overlayContent.add_child(this._background);
|
||||||
|
|
||||||
const uiClone = new Clutter.Clone({ source: Main.layoutManager.uiGroup, clip_to_allocation: true });
|
const uiClone = new Clutter.Clone({ source: Main.layoutManager.uiGroup, clip_to_allocation: true });
|
||||||
uiClone.x = -targetMonitor.x;
|
uiClone.x = -targetMonitor.x;
|
||||||
uiClone.y = -targetMonitor.y;
|
uiClone.y = -targetMonitor.y;
|
||||||
overlayContent.add_child(uiClone);
|
overlayContent.add_child(uiClone);
|
||||||
|
|
||||||
this._overlay.set_child(overlayContent);
|
|
||||||
|
|
||||||
Shell.util_set_hidden_from_pick(this._overlay, true);
|
|
||||||
global.stage.add_child(this._overlay);
|
|
||||||
|
|
||||||
// In GS 45, use of "actor" was renamed to "child".
|
// In GS 45, use of "actor" was renamed to "child".
|
||||||
const clutterContainer = Clutter.Container !== undefined;
|
const clutterContainer = Clutter.Container !== undefined;
|
||||||
this._actor_added_connection = global.stage.connect(
|
this._actor_added_connection = global.stage.connect(
|
||||||
|
|
|
||||||
|
|
@ -280,7 +280,6 @@ export const MonitorManager = GObject.registerClass({
|
||||||
|
|
||||||
this._monitorsChangedConnection = null;
|
this._monitorsChangedConnection = null;
|
||||||
this._displayConfigProxy = null;
|
this._displayConfigProxy = null;
|
||||||
this._backendManager = null;
|
|
||||||
this._monitorProperties = null;
|
this._monitorProperties = null;
|
||||||
this._changeHookFn = null;
|
this._changeHookFn = null;
|
||||||
this._needsConfigCheck = this.use_optimal_monitor_config;
|
this._needsConfigCheck = this.use_optimal_monitor_config;
|
||||||
|
|
@ -292,7 +291,6 @@ export const MonitorManager = GObject.registerClass({
|
||||||
|
|
||||||
enable() {
|
enable() {
|
||||||
Globals.logger.log_debug('MonitorManager enable');
|
Globals.logger.log_debug('MonitorManager enable');
|
||||||
this._backendManager = global.backend.get_monitor_manager();
|
|
||||||
newDisplayConfig(this.extension_path, ((proxy, error) => {
|
newDisplayConfig(this.extension_path, ((proxy, error) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -310,7 +308,6 @@ export const MonitorManager = GObject.registerClass({
|
||||||
|
|
||||||
this._monitorsChangedConnection = null;
|
this._monitorsChangedConnection = null;
|
||||||
this._displayConfigProxy = null;
|
this._displayConfigProxy = null;
|
||||||
this._backendManager = null;
|
|
||||||
this._monitorProperties = null;
|
this._monitorProperties = null;
|
||||||
this._changeHookFn = null;
|
this._changeHookFn = null;
|
||||||
}
|
}
|
||||||
|
|
@ -402,7 +399,7 @@ export const MonitorManager = GObject.registerClass({
|
||||||
const monitorProperties = [];
|
const monitorProperties = [];
|
||||||
for (let i = 0; i < result.length; i++) {
|
for (let i = 0; i < result.length; i++) {
|
||||||
const [monitorName, connectorName, vendor, product, serial, refreshRate] = result[i];
|
const [monitorName, connectorName, vendor, product, serial, refreshRate] = result[i];
|
||||||
const monitorIndex = this._backendManager.get_monitor_for_connector(connectorName);
|
const monitorIndex = global.backend.get_monitor_manager().get_monitor_for_connector(connectorName);
|
||||||
Globals.logger.log_debug(`Found monitor ${monitorName}, vendor ${vendor}, product ${product}, serial ${serial}, connector ${connectorName}, index ${monitorIndex}`);
|
Globals.logger.log_debug(`Found monitor ${monitorName}, vendor ${vendor}, product ${product}, serial ${serial}, connector ${connectorName}, index ${monitorIndex}`);
|
||||||
if (monitorIndex >= 0) {
|
if (monitorIndex >= 0) {
|
||||||
monitorProperties[monitorIndex] = {
|
monitorProperties[monitorIndex] = {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
import Cogl from 'gi://Cogl';
|
||||||
|
import GLib from 'gi://GLib';
|
||||||
|
import GObject from 'gi://GObject';
|
||||||
|
import Meta from 'gi://Meta';
|
||||||
|
|
||||||
|
const DEFAULT_BACKGROUND_COLOR = new Cogl.Color({red: 40, green: 40, blue: 40, alpha: 255});
|
||||||
|
|
||||||
|
let _systemBackground;
|
||||||
|
|
||||||
|
export const SystemBackground = GObject.registerClass({
|
||||||
|
Signals: {'loaded': {}},
|
||||||
|
}, class SystemBackground extends Meta.BackgroundActor {
|
||||||
|
_init() {
|
||||||
|
if (_systemBackground == null) {
|
||||||
|
_systemBackground = new Meta.Background({meta_display: global.display});
|
||||||
|
_systemBackground.set_color(DEFAULT_BACKGROUND_COLOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
super._init({
|
||||||
|
meta_display: global.display,
|
||||||
|
monitor: 0,
|
||||||
|
});
|
||||||
|
this.content.background = _systemBackground;
|
||||||
|
|
||||||
|
let id = GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
|
||||||
|
this.emit('loaded');
|
||||||
|
return GLib.SOURCE_REMOVE;
|
||||||
|
});
|
||||||
|
GLib.Source.set_name_by_id(id, '[gnome-shell] SystemBackground.loaded');
|
||||||
|
}
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue