js: Queue 'later' via MetaLaters

This replaces the meta_later_add() API which used now removed global
singletons under the hood.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2557>
This commit is contained in:
Jonas Ådahl 2022-09-07 20:23:38 +02:00
parent 387317aadc
commit 8d68bdaaa1
18 changed files with 66 additions and 33 deletions

View File

@ -112,7 +112,8 @@ var AuthList = GObject.registerClass({
let focusSet = this.navigate_focus(null, St.DirectionType.TAB_FORWARD, false);
if (!focusSet) {
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
const laters = global.compositor.get_laters();
laters.add(Meta.LaterType.BEFORE_REDRAW, () => {
this._moveFocusToItems();
return false;
});

View File

@ -191,7 +191,8 @@ var UserList = GObject.registerClass({
let focusSet = this.navigate_focus(null, St.DirectionType.TAB_FORWARD, false);
if (!focusSet) {
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
const laters = global.compositor.get_laters();
laters.add(Meta.LaterType.BEFORE_REDRAW, () => {
this._moveFocusToItems();
return false;
});

View File

@ -249,7 +249,8 @@ var AppMenu = class AppMenu extends PopupMenu.PopupMenu {
if (this._updateWindowsLaterId)
return;
this._updateWindowsLaterId = Meta.later_add(
const laters = global.compositor.get_laters();
this._updateWindowsLaterId = laters.add(
Meta.LaterType.BEFORE_REDRAW, () => {
this._updateWindowsSection();
return GLib.SOURCE_REMOVE;
@ -257,8 +258,10 @@ var AppMenu = class AppMenu extends PopupMenu.PopupMenu {
}
_updateWindowsSection() {
if (this._updateWindowsLaterId)
Meta.later_remove(this._updateWindowsLaterId);
if (this._updateWindowsLaterId) {
const laters = global.compositor.get_laters();
laters.remove(this._updateWindowsLaterId);
}
this._updateWindowsLaterId = 0;
this._windowSection.removeAll();

View File

@ -95,7 +95,8 @@ var AudioDeviceSelectionDialog = GObject.registerClass({
vertical: true,
});
box.connect('notify::height', () => {
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
const laters = global.compositor.get_laters();
laters.add(Meta.LaterType.BEFORE_REDRAW, () => {
box.width = box.height;
return GLib.SOURCE_REMOVE;
});

View File

@ -265,7 +265,8 @@ class ShowAppsIcon extends DashItemContainer {
let id = app.get_id();
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
const laters = global.compositor.get_laters();
laters.add(Meta.LaterType.BEFORE_REDRAW, () => {
AppFavorites.getAppFavorites().removeFavorite(id);
return false;
});
@ -967,7 +968,8 @@ var Dash = GObject.registerClass({
if (!this._dragPlaceholder)
return true;
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
const laters = global.compositor.get_laters();
laters.add(Meta.LaterType.BEFORE_REDRAW, () => {
let appFavorites = AppFavorites.getAppFavorites();
if (srcIsFavorite)
appFavorites.moveFavoriteToPos(id, favPos);

View File

@ -188,7 +188,8 @@ var MessageDialogContent = GObject.registerClass({
_onDestroy() {
if (this._updateTitleStyleLater) {
Meta.later_remove(this._updateTitleStyleLater);
const laters = global.compositor.get_laters();
laters.remove(this._updateTitleStyleLater);
delete this._updateTitleStyleLater;
}
}
@ -212,7 +213,8 @@ var MessageDialogContent = GObject.registerClass({
if (this._updateTitleStyleLater)
return;
this._updateTitleStyleLater = Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
const laters = global.compositor.get_laters();
this._updateTitleStyleLater = laters.add(Meta.LaterType.BEFORE_REDRAW, () => {
this._updateTitleStyleLater = 0;
this._title.add_style_class_name('lightweight');
return GLib.SOURCE_REMOVE;

View File

@ -677,7 +677,8 @@ var IconGridLayout = GObject.registerClass({
_onDestroy() {
if (this._updateIconSizesLaterId >= 0) {
Meta.later_remove(this._updateIconSizesLaterId);
const laters = global.compositor.get_laters();
laters.remove(this._updateIconSizesLaterId);
this._updateIconSizesLaterId = 0;
}
}
@ -962,8 +963,9 @@ var IconGridLayout = GObject.registerClass({
this._pageSizeChanged = true;
if (this._updateIconSizesLaterId === 0) {
const laters = global.compositor.get_laters();
this._updateIconSizesLaterId =
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
laters.add(Meta.LaterType.BEFORE_REDRAW, () => {
const iconSize = this._findBestIconSize();
if (this._iconSize !== iconSize) {

View File

@ -982,8 +982,9 @@ var LayoutManager = GObject.registerClass({
_queueUpdateRegions() {
if (!this._updateRegionIdle) {
this._updateRegionIdle = Meta.later_add(Meta.LaterType.BEFORE_REDRAW,
this._updateRegions.bind(this));
const laters = global.compositor.get_laters();
this._updateRegionIdle = laters.add(
Meta.LaterType.BEFORE_REDRAW, this._updateRegions.bind(this));
}
}
@ -1006,7 +1007,8 @@ var LayoutManager = GObject.registerClass({
_updateRegions() {
if (this._updateRegionIdle) {
Meta.later_remove(this._updateRegionIdle);
const laters = global.compositor.get_laters();
laters.remove(this._updateRegionIdle);
delete this._updateRegionIdle;
}

View File

@ -1558,7 +1558,8 @@ class LookingGlass extends St.BoxLayout {
}
_queueResize() {
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
const laters = global.compositor.get_laters();
laters.add(Meta.LaterType.BEFORE_REDRAW, () => {
this._resize();
return GLib.SOURCE_REMOVE;
});

View File

@ -814,7 +814,8 @@ function _runBeforeRedrawQueue() {
function _queueBeforeRedraw(workId) {
_beforeRedrawQueue.push(workId);
if (_beforeRedrawQueue.length == 1) {
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
const laters = global.compositor.get_laters();
laters.add(Meta.LaterType.BEFORE_REDRAW, () => {
_runBeforeRedrawQueue();
return false;
});

View File

@ -626,7 +626,8 @@ var QuickSettingsMenu = class extends PopupMenu.PopupMenu {
// Pick up additional spacing from any intermediate actors
const updateOffset = () => {
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
const laters = global.compositor.get_laters();
laters.add(Meta.LaterType.BEFORE_REDRAW, () => {
const offset = this._grid.apply_relative_transform_to_point(
this._boxPointer, new Graphene.Point3D());
yConstraint.offset = offset.y;

View File

@ -678,7 +678,8 @@ var ScreenShield = class extends Signals.EventEmitter {
let wasLocked = global.get_runtime_state('b', LOCKED_STATE_STR);
if (wasLocked === null)
return;
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
const laters = global.compositor.get_laters();
laters.add(Meta.LaterType.BEFORE_REDRAW, () => {
this.lock(false);
return GLib.SOURCE_REMOVE;
});

View File

@ -470,7 +470,8 @@ class GridSearchResults extends SearchResultsBase {
_onDestroy() {
if (this._updateSearchLater) {
Meta.later_remove(this._updateSearchLater);
const laters = global.compositor.get_laters();
laters.remove(this._updateSearchLater);
delete this._updateSearchLater;
}
@ -481,7 +482,8 @@ class GridSearchResults extends SearchResultsBase {
if (this._notifyAllocationId)
this.disconnect(this._notifyAllocationId);
if (this._updateSearchLater) {
Meta.later_remove(this._updateSearchLater);
const laters = global.compositor.get_laters();
laters.remove(this._updateSearchLater);
delete this._updateSearchLater;
}
@ -490,7 +492,8 @@ class GridSearchResults extends SearchResultsBase {
this._notifyAllocationId = this.connect('notify::allocation', () => {
if (this._updateSearchLater)
return;
this._updateSearchLater = Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
const laters = global.compositor.get_laters();
this._updateSearchLater = laters.add(Meta.LaterType.BEFORE_REDRAW, () => {
delete this._updateSearchLater;
super.updateSearch(...args);
return GLib.SOURCE_REMOVE;

View File

@ -107,7 +107,8 @@ class ScreenshotItem extends QuickSettingsItem {
this.connect('clicked', () => {
const topMenu = Main.panel.statusArea.quickSettings.menu;
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
const laters = global.compositor.get_laters();
laters.add(Meta.LaterType.BEFORE_REDRAW, () => {
Main.screenshotUI.open().catch(logError);
return GLib.SOURCE_REMOVE;
});

View File

@ -327,8 +327,11 @@ var WorkspaceTracker = class {
}
_queueCheckWorkspaces() {
if (this._checkWorkspacesId == 0)
this._checkWorkspacesId = Meta.later_add(Meta.LaterType.BEFORE_REDRAW, this._checkWorkspaces.bind(this));
if (this._checkWorkspacesId === 0) {
const laters = global.compositor.get_laters();
this._checkWorkspacesId =
laters.add(Meta.LaterType.BEFORE_REDRAW, this._checkWorkspaces.bind(this));
}
}
_nWorkspacesChanged() {

View File

@ -527,7 +527,8 @@ var WindowPreview = GObject.registerClass({
this._delegate = null;
if (this._longPressLater) {
Meta.later_remove(this._longPressLater);
const laters = global.compositor.get_laters();
laters.remove(this._longPressLater);
delete this._longPressLater;
}
@ -615,7 +616,8 @@ var WindowPreview = GObject.registerClass({
// A click cancels a long-press before any click handler is
// run - make sure to not start a drag in that case
this._longPressLater = Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
const laters = global.compositor.get_laters();
this._longPressLater = laters.add(Meta.LaterType.BEFORE_REDRAW, () => {
delete this._longPressLater;
if (this._selected) {
this._selected = false;

View File

@ -1187,13 +1187,16 @@ var ThumbnailsBox = GObject.registerClass({
if (this._updateStateId > 0)
return;
this._updateStateId = Meta.later_add(
const laters = global.compositor.get_laters();
this._updateStateId = laters.add(
Meta.LaterType.BEFORE_REDRAW, () => this._updateStates());
}
_unqueueUpdateStates() {
if (this._updateStateId)
Meta.later_remove(this._updateStateId);
if (this._updateStateId) {
const laters = global.compositor.get_laters();
laters.remove(this._updateStateId);
}
this._updateStateId = 0;
}
@ -1329,7 +1332,8 @@ var ThumbnailsBox = GObject.registerClass({
this._dropPlaceholder.allocate_preferred_size(
...this._dropPlaceholder.get_position());
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
const laters = global.compositor.get_laters();
laters.add(Meta.LaterType.BEFORE_REDRAW, () => {
this._dropPlaceholder.hide();
});
}
@ -1359,7 +1363,8 @@ var ThumbnailsBox = GObject.registerClass({
this._dropPlaceholder.allocate(childBox);
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
const laters = global.compositor.get_laters();
laters.add(Meta.LaterType.BEFORE_REDRAW, () => {
this._dropPlaceholder.show();
});
x += placeholderWidth + spacing;

View File

@ -860,7 +860,8 @@ class WorkspacesDisplay extends St.Widget {
_onDestroy() {
if (this._parentSetLater) {
Meta.later_remove(this._parentSetLater);
const laters = global.compositor.get_laters();
laters.remove(this._parentSetLater);
this._parentSetLater = 0;
}
}