Adapt to fixed Meta functions namespace

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3546>
This commit is contained in:
Bilal Elmoussaoui 2024-12-11 12:45:04 +01:00
parent 961075d0e4
commit 4034e69d0d
15 changed files with 60 additions and 44 deletions

View File

@ -1,6 +1,5 @@
import Clutter from 'gi://Clutter'; import Clutter from 'gi://Clutter';
import GObject from 'gi://GObject'; import GObject from 'gi://GObject';
import Meta from 'gi://Meta';
import St from 'gi://St'; import St from 'gi://St';
import * as Main from './main.js'; import * as Main from './main.js';
@ -53,9 +52,9 @@ export const BoxPointer = GObject.registerClass({
this.connect('notify::visible', () => { this.connect('notify::visible', () => {
if (this.visible) if (this.visible)
Meta.disable_unredirect_for_display(global.display); global.compositor.disable_unredirect();
else else
Meta.enable_unredirect_for_display(global.display); global.compositor.enable_unredirect();
}); });
} }

View File

@ -147,7 +147,7 @@ export const CloseDialog = GObject.registerClass({
if (this._dialog != null) if (this._dialog != null)
return; return;
Meta.disable_unredirect_for_display(global.display); global.compositor.disable_unredirect();
this._timeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, ALIVE_TIMEOUT, this._timeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, ALIVE_TIMEOUT,
() => { () => {
@ -182,7 +182,7 @@ export const CloseDialog = GObject.registerClass({
if (this._dialog == null) if (this._dialog == null)
return; return;
Meta.enable_unredirect_for_display(global.display); global.compositor.enable_unredirect();
GLib.source_remove(this._timeoutId); GLib.source_remove(this._timeoutId);
this._timeoutId = 0; this._timeoutId = 0;

View File

@ -126,11 +126,11 @@ function _easeActor(actor, params) {
delete params.mode; delete params.mode;
const prepare = () => { const prepare = () => {
Meta.disable_unredirect_for_display(global.display); global.compositor.disable_unredirect();
global.begin_work(); global.begin_work();
}; };
const cleanup = () => { const cleanup = () => {
Meta.enable_unredirect_for_display(global.display); global.compositor.enable_unredirect();
global.end_work(); global.end_work();
}; };
let callback = _makeEaseCallback(params, cleanup); let callback = _makeEaseCallback(params, cleanup);
@ -202,11 +202,11 @@ function _easeActorProperty(actor, propName, target, params) {
duration = 0; duration = 0;
const prepare = () => { const prepare = () => {
Meta.disable_unredirect_for_display(global.display); global.compositor.disable_unredirect();
global.begin_work(); global.begin_work();
}; };
const cleanup = () => { const cleanup = () => {
Meta.enable_unredirect_for_display(global.display); global.compositor.enable_unredirect();
global.end_work(); global.end_work();
}; };
let callback = _makeEaseCallback(params, cleanup); let callback = _makeEaseCallback(params, cleanup);

View File

@ -1788,7 +1788,7 @@ export const Keyboard = GObject.registerClass({
} }
_animateShow() { _animateShow() {
Meta.disable_unredirect_for_display(global.display); global.compositor.disable_unredirect();
if (this._focusWindow) if (this._focusWindow)
this._animateWindow(this._focusWindow, true); this._animateWindow(this._focusWindow, true);
@ -1844,7 +1844,7 @@ export const Keyboard = GObject.registerClass({
_animateHideComplete() { _animateHideComplete() {
Main.layoutManager.keyboardBox.hide(); Main.layoutManager.keyboardBox.hide();
Meta.enable_unredirect_for_display(global.display); global.compositor.enable_unredirect();
} }
gestureProgress(delta) { gestureProgress(delta) {

View File

@ -5,7 +5,6 @@ import GDesktopEnums from 'gi://GDesktopEnums';
import Gio from 'gi://Gio'; import Gio from 'gi://Gio';
import GLib from 'gi://GLib'; import GLib from 'gi://GLib';
import GObject from 'gi://GObject'; import GObject from 'gi://GObject';
import Meta from 'gi://Meta';
import Shell from 'gi://Shell'; import Shell from 'gi://Shell';
import St from 'gi://St'; import St from 'gi://St';
import * as Signals from '../misc/signals.js'; import * as Signals from '../misc/signals.js';
@ -100,8 +99,7 @@ export class Magnifier extends Signals.EventEmitter {
this._zoomRegions = []; this._zoomRegions = [];
// Create small clutter tree for the magnified mouse. // Create small clutter tree for the magnified mouse.
let cursorTracker = Meta.CursorTracker.get_for_display(global.display); this._cursorTracker = global.backend.get_cursor_tracker();
this._cursorTracker = cursorTracker;
this._mouseSprite = new Clutter.Actor({request_mode: Clutter.RequestMode.CONTENT_SIZE}); this._mouseSprite = new Clutter.Actor({request_mode: Clutter.RequestMode.CONTENT_SIZE});
this._mouseSprite.content = new MouseSpriteContent(); this._mouseSprite.content = new MouseSpriteContent();
@ -188,12 +186,12 @@ export class Magnifier extends Signals.EventEmitter {
this._updateMouseSprite(); this._updateMouseSprite();
this._cursorTracker.connectObject( this._cursorTracker.connectObject(
'cursor-changed', this._updateMouseSprite.bind(this), this); 'cursor-changed', this._updateMouseSprite.bind(this), this);
Meta.disable_unredirect_for_display(global.display); global.display.disable_unredirect();
this.startTrackingMouse(); this.startTrackingMouse();
} else { } else {
this._cursorTracker.disconnectObject(this); this._cursorTracker.disconnectObject(this);
this._mouseSprite.content.texture = null; this._mouseSprite.content.texture = null;
Meta.enable_unredirect_for_display(global.display); global.display.enable_unredirect();
this.stopTrackingMouse(); this.stopTrackingMouse();
} }

View File

@ -688,7 +688,7 @@ export function pushModal(actor, params = {}) {
let grab = global.stage.grab(actor); let grab = global.stage.grab(actor);
if (modalCount === 0) if (modalCount === 0)
Meta.disable_unredirect_for_display(global.display); global.compositor.disable_unredirect();
modalCount += 1; modalCount += 1;
let actorDestroyId = actor.connect('destroy', () => { let actorDestroyId = actor.connect('destroy', () => {
@ -782,7 +782,7 @@ export function popModal(grab) {
return; return;
layoutManager.modalEnded(); layoutManager.modalEnded();
Meta.enable_unredirect_for_display(global.display); global.compositor.enable_unredirect();
actionMode = Shell.ActionMode.NORMAL; actionMode = Shell.ActionMode.NORMAL;
} }

View File

@ -1130,7 +1130,7 @@ export const MessageTray = GObject.registerClass({
this._bannerBin.y = -this._banner.height; this._bannerBin.y = -this._banner.height;
this.show(); this.show();
Meta.disable_unredirect_for_display(global.display); global.compositor.disable_unredirect();
this._updateShowingNotification(); this._updateShowingNotification();
let [x, y] = global.get_pointer(); let [x, y] = global.get_pointer();
@ -1267,7 +1267,7 @@ export const MessageTray = GObject.registerClass({
this._pointerInNotification = false; this._pointerInNotification = false;
this._notificationRemoved = false; this._notificationRemoved = false;
Meta.enable_unredirect_for_display(global.display); global.compositor.enable_unredirect();
this._banner.destroy(); this._banner.destroy();
this._banner = null; this._banner = null;

View File

@ -1,7 +1,6 @@
import Clutter from 'gi://Clutter'; import Clutter from 'gi://Clutter';
import Gio from 'gi://Gio'; import Gio from 'gi://Gio';
import GObject from 'gi://GObject'; import GObject from 'gi://GObject';
import Meta from 'gi://Meta';
import St from 'gi://St'; import St from 'gi://St';
@ -29,9 +28,9 @@ class OsdMonitorLabel extends St.Widget {
Main.uiGroup.set_child_above_sibling(this, null); Main.uiGroup.set_child_above_sibling(this, null);
this._position(); this._position();
Meta.disable_unredirect_for_display(global.display); global.compositor.disable_unredirect();
this.connect('destroy', () => { this.connect('destroy', () => {
Meta.enable_unredirect_for_display(global.display); global.compositor.enable_unredirect();
}); });
} }

View File

@ -1,7 +1,6 @@
import Clutter from 'gi://Clutter'; import Clutter from 'gi://Clutter';
import GLib from 'gi://GLib'; import GLib from 'gi://GLib';
import GObject from 'gi://GObject'; import GObject from 'gi://GObject';
import Meta from 'gi://Meta';
import St from 'gi://St'; import St from 'gi://St';
import * as BarLevel from './barLevel.js'; import * as BarLevel from './barLevel.js';
@ -93,7 +92,7 @@ class OsdWindow extends Clutter.Actor {
return; return;
if (!this.visible) { if (!this.visible) {
Meta.disable_unredirect_for_display(global.display); global.compositor.disable_unredirect();
super.show(); super.show();
this.opacity = 0; this.opacity = 0;
this.get_parent().set_child_above_sibling(this, null); this.get_parent().set_child_above_sibling(this, null);
@ -128,7 +127,7 @@ class OsdWindow extends Clutter.Actor {
mode: Clutter.AnimationMode.EASE_OUT_QUAD, mode: Clutter.AnimationMode.EASE_OUT_QUAD,
onComplete: () => { onComplete: () => {
this._reset(); this._reset();
Meta.enable_unredirect_for_display(global.display); global.compositor.enable_unredirect();
}, },
}); });
return GLib.SOURCE_REMOVE; return GLib.SOURCE_REMOVE;

View File

@ -249,9 +249,9 @@ export class Overview extends Signals.EventEmitter {
} }
if (this._shownState === OverviewShownState.HIDDEN) if (this._shownState === OverviewShownState.HIDDEN)
Meta.disable_unredirect_for_display(global.display); global.compositor.disable_unredirect();
else if (state === OverviewShownState.HIDDEN) else if (state === OverviewShownState.HIDDEN)
Meta.enable_unredirect_for_display(global.display); global.compositor.enable_unredirect();
this._shownState = state; this._shownState = state;
this.emit(OVERVIEW_SHOWN_TRANSITIONS[state].signal); this.emit(OVERVIEW_SHOWN_TRANSITIONS[state].signal);

View File

@ -137,7 +137,7 @@ export class ScreenShield extends Signals.EventEmitter {
this._shortLightbox.connect('notify::active', this._onShortLightbox.bind(this)); this._shortLightbox.connect('notify::active', this._onShortLightbox.bind(this));
this.idleMonitor = global.backend.get_core_idle_monitor(); this.idleMonitor = global.backend.get_core_idle_monitor();
this._cursorTracker = Meta.CursorTracker.get_for_display(global.display); this._cursorTracker = global.backend.get_cursor_tracker();
this._syncInhibitor(); this._syncInhibitor();
} }

View File

@ -373,11 +373,11 @@ export class WorkspaceAnimationController {
switchData.monitors.push(group); switchData.monitors.push(group);
} }
Meta.disable_unredirect_for_display(global.display); global.compositor.disable_unredirect();
} }
_finishWorkspaceSwitch(switchData) { _finishWorkspaceSwitch(switchData) {
Meta.enable_unredirect_for_display(global.display); global.compositor.enable_unredirect();
this._switchData = null; this._switchData = null;

View File

@ -308,10 +308,10 @@ shell_global_get_property(GObject *object,
g_value_set_object (value, global->stage); g_value_set_object (value, global->stage);
break; break;
case PROP_WINDOW_GROUP: case PROP_WINDOW_GROUP:
g_value_set_object (value, meta_get_window_group_for_display (global->meta_display)); g_value_set_object (value, meta_compositor_get_window_group (global->compositor));
break; break;
case PROP_TOP_WINDOW_GROUP: case PROP_TOP_WINDOW_GROUP:
g_value_set_object (value, meta_get_top_window_group_for_display (global->meta_display)); g_value_set_object (value, meta_compositor_get_top_window_group (global->compositor));
break; break;
case PROP_WINDOW_MANAGER: case PROP_WINDOW_MANAGER:
g_value_set_object (value, global->wm); g_value_set_object (value, global->wm);
@ -765,6 +765,17 @@ shell_global_set_stage_input_region (ShellGlobal *global,
#endif #endif
} }
/**
* shell_global_get_backend:
*
* Return value: (transfer none): The #MetaBackend
*/
MetaBackend *
shell_global_get_backend (ShellGlobal *global)
{
return global->backend;
}
/** /**
* shell_global_get_context: * shell_global_get_context:
* *
@ -824,7 +835,7 @@ shell_global_get_window_actors (ShellGlobal *global)
g_return_val_if_fail (SHELL_IS_GLOBAL (global), NULL); g_return_val_if_fail (SHELL_IS_GLOBAL (global), NULL);
for (l = meta_get_window_actors (global->meta_display); l; l = l->next) for (l = meta_compositor_get_window_actors (global->compositor); l; l = l->next)
if (!meta_window_actor_is_destroyed (l->data)) if (!meta_window_actor_is_destroyed (l->data))
filtered = g_list_prepend (filtered, l->data); filtered = g_list_prepend (filtered, l->data);
@ -998,7 +1009,7 @@ _shell_global_set_plugin (ShellGlobal *global,
global->backend = meta_context_get_backend (context); global->backend = meta_context_get_backend (context);
global->workspace_manager = meta_display_get_workspace_manager (display); global->workspace_manager = meta_display_get_workspace_manager (display);
global->stage = CLUTTER_STAGE (meta_get_stage_for_display (display)); global->stage = CLUTTER_STAGE (meta_backend_get_stage (global->backend));
st_entry_set_cursor_func (entry_cursor_func, global); st_entry_set_cursor_func (entry_cursor_func, global);
st_clipboard_set_selection (meta_display_get_selection (display)); st_clipboard_set_selection (meta_display_get_selection (display));
@ -1286,7 +1297,7 @@ shell_global_get_pointer (ShellGlobal *global,
MetaCursorTracker *tracker; MetaCursorTracker *tracker;
graphene_point_t point; graphene_point_t point;
tracker = meta_cursor_tracker_get_for_display (global->meta_display); tracker = meta_backend_get_cursor_tracker (global->backend);
meta_cursor_tracker_get_pointer (tracker, &point, &raw_mods); meta_cursor_tracker_get_pointer (tracker, &point, &raw_mods);
if (x) if (x)

View File

@ -16,7 +16,7 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (ShellGlobal, shell_global, SHELL, GLOBAL, GObject) G_DECLARE_FINAL_TYPE (ShellGlobal, shell_global, SHELL, GLOBAL, GObject)
ShellGlobal *shell_global_get (void); ShellGlobal *shell_global_get (void);
MetaBackend *shell_global_get_backend (ShellGlobal *global);
MetaContext *shell_global_get_context (ShellGlobal *global); MetaContext *shell_global_get_context (ShellGlobal *global);
ClutterStage *shell_global_get_stage (ShellGlobal *global); ClutterStage *shell_global_get_stage (ShellGlobal *global);
MetaDisplay *shell_global_get_display (ShellGlobal *global); MetaDisplay *shell_global_get_display (ShellGlobal *global);

View File

@ -4,6 +4,7 @@
#include <cogl/cogl.h> #include <cogl/cogl.h>
#include <meta/display.h> #include <meta/display.h>
#include <meta/util.h> #include <meta/util.h>
#include <meta/meta-backend.h>
#include <meta/meta-plugin.h> #include <meta/meta-plugin.h>
#include <meta/meta-cursor-tracker.h> #include <meta/meta-cursor-tracker.h>
#include <st/st.h> #include <st/st.h>
@ -360,6 +361,7 @@ draw_cursor_image (cairo_surface_t *surface,
int width, height; int width, height;
int stride; int stride;
guint8 *data; guint8 *data;
MetaBackend *backend;
MetaDisplay *display; MetaDisplay *display;
MetaCursorTracker *tracker; MetaCursorTracker *tracker;
cairo_surface_t *cursor_surface; cairo_surface_t *cursor_surface;
@ -370,7 +372,8 @@ draw_cursor_image (cairo_surface_t *surface,
graphene_point_t point; graphene_point_t point;
display = shell_global_get_display (shell_global_get ()); display = shell_global_get_display (shell_global_get ());
tracker = meta_cursor_tracker_get_for_display (display); backend = shell_global_get_backend (shell_global_get ());
tracker = meta_backend_get_cursor_tracker (backend);
texture = meta_cursor_tracker_get_sprite (tracker); texture = meta_cursor_tracker_get_sprite (tracker);
if (!texture) if (!texture)
@ -455,6 +458,7 @@ grab_screenshot_content (ShellScreenshot *screenshot,
GTask *result) GTask *result)
{ {
MetaDisplay *display; MetaDisplay *display;
MetaBackend *backend;
int width, height; int width, height;
MtkRectangle screenshot_rect; MtkRectangle screenshot_rect;
ClutterStage *stage; ClutterStage *stage;
@ -469,6 +473,7 @@ grab_screenshot_content (ShellScreenshot *screenshot,
int cursor_hot_x, cursor_hot_y; int cursor_hot_x, cursor_hot_y;
display = shell_global_get_display (screenshot->global); display = shell_global_get_display (screenshot->global);
backend = shell_global_get_backend (screenshot->global);
meta_display_get_size (display, &width, &height); meta_display_get_size (display, &width, &height);
screenshot_rect = (MtkRectangle) { screenshot_rect = (MtkRectangle) {
.x = 0, .x = 0,
@ -495,7 +500,7 @@ grab_screenshot_content (ShellScreenshot *screenshot,
return; return;
} }
tracker = meta_cursor_tracker_get_for_display (display); tracker = meta_backend_get_cursor_tracker (backend);
cursor_texture = meta_cursor_tracker_get_sprite (tracker); cursor_texture = meta_cursor_tracker_get_sprite (tracker);
// If the cursor is invisible, the texture is NULL. // If the cursor is invisible, the texture is NULL.
@ -650,6 +655,7 @@ on_after_paint (ClutterStage *stage,
{ {
ShellScreenshot *screenshot = g_task_get_task_data (result); ShellScreenshot *screenshot = g_task_get_task_data (result);
MetaDisplay *display = shell_global_get_display (screenshot->global); MetaDisplay *display = shell_global_get_display (screenshot->global);
MetaCompositor *compositor = meta_display_get_compositor (display);
GTask *task; GTask *task;
g_signal_handlers_disconnect_by_func (stage, on_after_paint, result); g_signal_handlers_disconnect_by_func (stage, on_after_paint, result);
@ -674,7 +680,7 @@ on_after_paint (ClutterStage *stage,
g_signal_emit (screenshot, signals[SCREENSHOT_TAKEN], 0, g_signal_emit (screenshot, signals[SCREENSHOT_TAKEN], 0,
(MtkRectangle *) &screenshot->screenshot_area); (MtkRectangle *) &screenshot->screenshot_area);
meta_enable_unredirect_for_display (display); meta_compositor_enable_unredirect (compositor);
} }
/** /**
@ -737,8 +743,9 @@ shell_screenshot_screenshot (ShellScreenshot *screenshot,
{ {
MetaDisplay *display = shell_global_get_display (screenshot->global); MetaDisplay *display = shell_global_get_display (screenshot->global);
ClutterStage *stage = shell_global_get_stage (screenshot->global); ClutterStage *stage = shell_global_get_stage (screenshot->global);
MetaCompositor *compositor = meta_display_get_compositor (display);
meta_disable_unredirect_for_display (display); meta_compositor_disable_unredirect (compositor);
clutter_actor_queue_redraw (CLUTTER_ACTOR (stage)); clutter_actor_queue_redraw (CLUTTER_ACTOR (stage));
screenshot->flags = flags; screenshot->flags = flags;
screenshot->mode = SHELL_SCREENSHOT_SCREEN; screenshot->mode = SHELL_SCREENSHOT_SCREEN;
@ -782,12 +789,13 @@ screenshot_stage_to_content_on_after_paint (ClutterStage *stage,
{ {
ShellScreenshot *screenshot = g_task_get_task_data (result); ShellScreenshot *screenshot = g_task_get_task_data (result);
MetaDisplay *display = shell_global_get_display (screenshot->global); MetaDisplay *display = shell_global_get_display (screenshot->global);
MetaCompositor *compositor = meta_display_get_compositor (display);
g_signal_handlers_disconnect_by_func (stage, g_signal_handlers_disconnect_by_func (stage,
screenshot_stage_to_content_on_after_paint, screenshot_stage_to_content_on_after_paint,
result); result);
meta_enable_unredirect_for_display (display); meta_compositor_enable_unredirect (compositor);
grab_screenshot_content (screenshot, result); grab_screenshot_content (screenshot, result);
} }
@ -822,9 +830,10 @@ shell_screenshot_screenshot_stage_to_content (ShellScreenshot *screenshot,
else else
{ {
MetaDisplay *display = shell_global_get_display (screenshot->global); MetaDisplay *display = shell_global_get_display (screenshot->global);
MetaCompositor *compositor = meta_display_get_compositor (display);
ClutterStage *stage = shell_global_get_stage (screenshot->global); ClutterStage *stage = shell_global_get_stage (screenshot->global);
meta_disable_unredirect_for_display (display); meta_compositor_disable_unredirect (compositor);
clutter_actor_queue_redraw (CLUTTER_ACTOR (stage)); clutter_actor_queue_redraw (CLUTTER_ACTOR (stage));
g_signal_connect (stage, "after-paint", g_signal_connect (stage, "after-paint",
G_CALLBACK (screenshot_stage_to_content_on_after_paint), G_CALLBACK (screenshot_stage_to_content_on_after_paint),
@ -961,9 +970,10 @@ shell_screenshot_screenshot_area (ShellScreenshot *screenshot,
else else
{ {
MetaDisplay *display = shell_global_get_display (screenshot->global); MetaDisplay *display = shell_global_get_display (screenshot->global);
MetaCompositor *compositor = meta_display_get_compositor (display);
ClutterStage *stage = shell_global_get_stage (screenshot->global); ClutterStage *stage = shell_global_get_stage (screenshot->global);
meta_disable_unredirect_for_display (display); meta_compositor_disable_unredirect (compositor);
clutter_actor_queue_redraw (CLUTTER_ACTOR (stage)); clutter_actor_queue_redraw (CLUTTER_ACTOR (stage));
screenshot->flags = SHELL_SCREENSHOT_FLAG_NONE; screenshot->flags = SHELL_SCREENSHOT_FLAG_NONE;
screenshot->mode = SHELL_SCREENSHOT_AREA; screenshot->mode = SHELL_SCREENSHOT_AREA;