Revert "Update how we force a repaint, try to more consistently hit the ideal refresh rate of the glasses"
This reverts commit 88e3692cca.
This commit is contained in:
parent
a0f84554bb
commit
3924600130
|
|
@ -20,14 +20,15 @@ export class CursorManager {
|
||||||
this._cursorTrackerSetPointerVisibleBound = null;
|
this._cursorTrackerSetPointerVisibleBound = null;
|
||||||
this._cursorSprite = null;
|
this._cursorSprite = null;
|
||||||
this._cursorActor = null;
|
this._cursorActor = null;
|
||||||
|
this._cursorWatcher = null;
|
||||||
this._cursorSeat = null;
|
this._cursorSeat = null;
|
||||||
this._cursorUnfocusInhibited = false;
|
this._cursorUnfocusInhibited = false;
|
||||||
|
|
||||||
// Set/destroyed by _startCloningMouse / _stopCloningMouse
|
// Set/destroyed by _startCloningMouse / _stopCloningMouse
|
||||||
|
this._cursorWatch = null;
|
||||||
this._cursorChangedConnection = null;
|
this._cursorChangedConnection = null;
|
||||||
this._cursorVisibilityChangedConnection = null;
|
this._cursorVisibilityChangedConnection = null;
|
||||||
this._moveToTopTimeout = null;
|
this._moveToTopTimeout = null;
|
||||||
this._redraw_timeline = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enable() {
|
enable() {
|
||||||
|
|
@ -77,6 +78,7 @@ export class CursorManager {
|
||||||
} else {
|
} else {
|
||||||
this._cursorActor.add_actor(this._cursorSprite);
|
this._cursorActor.add_actor(this._cursorSprite);
|
||||||
}
|
}
|
||||||
|
this._cursorWatcher = PointerWatcher.getPointerWatcher();
|
||||||
this._cursorSeat = Clutter.get_default_backend().get_default_seat();
|
this._cursorSeat = Clutter.get_default_backend().get_default_seat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -98,6 +100,7 @@ export class CursorManager {
|
||||||
this._cursorTrackerSetPointerVisibleBound = null;
|
this._cursorTrackerSetPointerVisibleBound = null;
|
||||||
this._cursorSprite = null;
|
this._cursorSprite = null;
|
||||||
this._cursorActor = null;
|
this._cursorActor = null;
|
||||||
|
this._cursorWatcher = null;
|
||||||
this._cursorSeat = null;
|
this._cursorSeat = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -122,41 +125,31 @@ export class CursorManager {
|
||||||
// prereqs: setup in _enableCloningMouse, _cursorWantedVisible is true
|
// prereqs: setup in _enableCloningMouse, _cursorWantedVisible is true
|
||||||
_startCloningMouse() {
|
_startCloningMouse() {
|
||||||
Globals.logger.log_debug('CursorManager _startCloningMouse');
|
Globals.logger.log_debug('CursorManager _startCloningMouse');
|
||||||
if (Clutter.Container === undefined) {
|
if (this._cursorWatch == null) {
|
||||||
this._mainActor.add_child(this._cursorActor);
|
if (Clutter.Container === undefined) {
|
||||||
} else {
|
this._mainActor.add_child(this._cursorActor);
|
||||||
this._mainActor.add_actor(this._cursorActor);
|
} else {
|
||||||
}
|
this._mainActor.add_actor(this._cursorActor);
|
||||||
this._cursorChangedConnection = this._cursorTracker.connect('cursor-changed', this._updateMouseSprite.bind(this));
|
}
|
||||||
this._cursorVisibilityChangedConnection = this._cursorTracker.connect('visibility-changed', this._handleVisibilityChanged.bind(this));
|
this._cursorChangedConnection = this._cursorTracker.connect('cursor-changed', this._updateMouseSprite.bind(this));
|
||||||
|
this._cursorVisibilityChangedConnection = this._cursorTracker.connect('visibility-changed', this._handleVisibilityChanged.bind(this));
|
||||||
|
|
||||||
// Some elements will occasionally appear above the cursor, so we periodically reset the actor stacking.
|
// Some elements will occasionally appear above the cursor, so we periodically reset the actor stacking.
|
||||||
// This could theoretically be fixed "better" by attaching to all events that might affect actor ordering,
|
// This could theoretically be fixed "better" by attaching to all events that might affect actor ordering,
|
||||||
// but finding a comprehensive list is difficult and not future proof. So this ugly solution helps us
|
// but finding a comprehensive list is difficult and not future proof. So this ugly solution helps us
|
||||||
// catch everything.
|
// catch everything.
|
||||||
this._moveToTopTimeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 500, (() => {
|
this._moveToTopTimeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 500, (() => {
|
||||||
this._moveToTop()
|
this._moveToTop()
|
||||||
return GLib.SOURCE_CONTINUE;
|
return GLib.SOURCE_CONTINUE;
|
||||||
}).bind(this));
|
}).bind(this));
|
||||||
|
|
||||||
const refreshInterval = 1000 / this._refreshRate;
|
const interval = 1000 / this._refreshRate;
|
||||||
|
this._cursorWatch = this._cursorWatcher.addWatch(interval, this._updateMousePosition.bind(this));
|
||||||
|
|
||||||
// we'll force repaint the cursor every frame,
|
|
||||||
// this keeps the cursor up-to-date and is sort of a hack that's a critical part of making sure
|
|
||||||
// the XR Effect refreshes even if nothing on-screen has changed (bypass the texture caching)
|
|
||||||
this._redraw_timeline = Clutter.Timeline.new_for_actor(this._cursorActor, refreshInterval);
|
|
||||||
this._redraw_timeline.set_repeat_count(-1);
|
|
||||||
|
|
||||||
var on = false;
|
|
||||||
this._redraw_timeline.connect('completed', (() => {
|
|
||||||
this._cursorActor.set_opacity(this._cursorActor.opacity + (on ? 1 : -1));
|
|
||||||
const [x, y] = global.get_pointer();
|
const [x, y] = global.get_pointer();
|
||||||
this._cursorActor.set_position(x, y);
|
this._updateMousePosition(x, y);
|
||||||
on = !on;
|
this._updateMouseSprite();
|
||||||
}).bind(this));
|
}
|
||||||
this._redraw_timeline.start();
|
|
||||||
|
|
||||||
this._updateMouseSprite();
|
|
||||||
|
|
||||||
if (this._cursorTracker.set_keep_focus_while_hidden) {
|
if (this._cursorTracker.set_keep_focus_while_hidden) {
|
||||||
this._cursorTracker.set_keep_focus_while_hidden(true);
|
this._cursorTracker.set_keep_focus_while_hidden(true);
|
||||||
|
|
@ -177,30 +170,30 @@ export class CursorManager {
|
||||||
// completely reverts _startCloningMouse
|
// completely reverts _startCloningMouse
|
||||||
_stopCloningMouse() {
|
_stopCloningMouse() {
|
||||||
Globals.logger.log_debug('CursorManager _stopCloningMouse');
|
Globals.logger.log_debug('CursorManager _stopCloningMouse');
|
||||||
if (this._redraw_timeline) {
|
if (this._cursorWatch != null) {
|
||||||
this._redraw_timeline.stop();
|
this._cursorWatch.remove();
|
||||||
this._redraw_timeline = null;
|
this._cursorWatch = null;
|
||||||
}
|
|
||||||
|
|
||||||
if (this._cursorChangedConnection) {
|
if (this._cursorChangedConnection) {
|
||||||
this._cursorTracker.disconnect(this._cursorChangedConnection);
|
this._cursorTracker.disconnect(this._cursorChangedConnection);
|
||||||
this._cursorChangedConnection = null;
|
this._cursorChangedConnection = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._cursorVisibilityChangedConnection) {
|
if (this._cursorVisibilityChangedConnection) {
|
||||||
this._cursorTracker.disconnect(this._cursorVisibilityChangedConnection);
|
this._cursorTracker.disconnect(this._cursorVisibilityChangedConnection);
|
||||||
this._cursorVisibilityChangedConnection = null;
|
this._cursorVisibilityChangedConnection = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Clutter.Container === undefined) {
|
if (Clutter.Container === undefined) {
|
||||||
this._mainActor.remove_child(this._cursorActor);
|
this._mainActor.remove_child(this._cursorActor);
|
||||||
} else {
|
} else {
|
||||||
this._mainActor.remove_actor(this._cursorActor);
|
this._mainActor.remove_actor(this._cursorActor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._moveToTopTimeout) {
|
if (this._moveToTopTimeout) {
|
||||||
GLib.source_remove(this._moveToTopTimeout);
|
GLib.source_remove(this._moveToTopTimeout);
|
||||||
this._moveToTopTimeout = null;
|
this._moveToTopTimeout = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._cursorUnfocusInhibited) {
|
if (this._cursorUnfocusInhibited) {
|
||||||
|
|
@ -210,6 +203,10 @@ export class CursorManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_updateMousePosition(x, y) {
|
||||||
|
this._cursorActor.set_position(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
_updateMouseSprite() {
|
_updateMouseSprite() {
|
||||||
const sprite = this._cursorTracker.get_sprite();
|
const sprite = this._cursorTracker.get_sprite();
|
||||||
if (sprite) {
|
if (sprite) {
|
||||||
|
|
|
||||||
|
|
@ -316,6 +316,8 @@ export const XREffect = GObject.registerClass({
|
||||||
}
|
}
|
||||||
|
|
||||||
vfunc_paint_target(node, paintContext) {
|
vfunc_paint_target(node, paintContext) {
|
||||||
|
var now = Date.now();
|
||||||
|
var lastPaint = this._last_paint || 0;
|
||||||
var frametime = this._frametime;
|
var frametime = this._frametime;
|
||||||
var calibratingImage = this.calibratingImage;
|
var calibratingImage = this.calibratingImage;
|
||||||
var customBannerImage = this.customBannerImage;
|
var customBannerImage = this.customBannerImage;
|
||||||
|
|
@ -337,6 +339,11 @@ export const XREffect = GObject.registerClass({
|
||||||
this.setIntermittentUniformVariables = setIntermittentUniformVariables.bind(this);
|
this.setIntermittentUniformVariables = setIntermittentUniformVariables.bind(this);
|
||||||
this.setIntermittentUniformVariables();
|
this.setIntermittentUniformVariables();
|
||||||
|
|
||||||
|
this._redraw_timeout_id = GLib.timeout_add(GLib.PRIORITY_DEFAULT, this._frametime, () => {
|
||||||
|
if ((now - lastPaint) > frametime) global.stage.queue_redraw();
|
||||||
|
return GLib.SOURCE_CONTINUE;
|
||||||
|
});
|
||||||
|
|
||||||
this._uniforms_timeout_id = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 250, (() => {
|
this._uniforms_timeout_id = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 250, (() => {
|
||||||
this.setIntermittentUniformVariables();
|
this.setIntermittentUniformVariables();
|
||||||
return GLib.SOURCE_CONTINUE;
|
return GLib.SOURCE_CONTINUE;
|
||||||
|
|
@ -376,11 +383,16 @@ export const XREffect = GObject.registerClass({
|
||||||
Cogl.PipelineFilter.LINEAR_MIPMAP_LINEAR,
|
Cogl.PipelineFilter.LINEAR_MIPMAP_LINEAR,
|
||||||
Cogl.PipelineFilter.LINEAR
|
Cogl.PipelineFilter.LINEAR
|
||||||
);
|
);
|
||||||
|
|
||||||
|
super.vfunc_paint_target(node, paintContext);
|
||||||
|
} else {
|
||||||
|
super.vfunc_paint_target(node, paintContext);
|
||||||
}
|
}
|
||||||
super.vfunc_paint_target(node, paintContext);
|
this._last_paint = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
|
if (this._redraw_timeout_id) GLib.source_remove(this._redraw_timeout_id);
|
||||||
if (this._uniforms_timeout_id) GLib.source_remove(this._uniforms_timeout_id);
|
if (this._uniforms_timeout_id) GLib.source_remove(this._uniforms_timeout_id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Loading…
Reference in New Issue