GUACAMOLE-462: Allow pending display frames to be cancelled.

This commit is contained in:
Michael Jumper
2022-03-02 17:31:53 +00:00
parent 402197863f
commit a27bd2694a

View File

@@ -201,6 +201,22 @@ Guacamole.Display = function() {
*/ */
function Frame(callback, tasks) { function Frame(callback, tasks) {
/**
* Cancels rendering of this frame and all associated tasks. The
* callback provided at construction time, if any, is not invoked.
*/
this.cancel = function cancel() {
callback = null;
tasks.forEach(function cancelTask(task) {
task.cancel();
});
tasks = [];
};
/** /**
* Returns whether this frame is ready to be rendered. This function * Returns whether this frame is ready to be rendered. This function
* returns true if and only if ALL underlying tasks are unblocked. * returns true if and only if ALL underlying tasks are unblocked.
@@ -271,6 +287,16 @@ Guacamole.Display = function() {
*/ */
this.blocked = blocked; this.blocked = blocked;
/**
* Cancels this task such that it will not run. The task handler
* provided at construction time, if any, is not invoked. Calling
* execute() after calling this function has no effect.
*/
this.cancel = function cancel() {
task.blocked = false;
taskHandler = null;
};
/** /**
* Unblocks this Task, allowing it to run. * Unblocks this Task, allowing it to run.
*/ */
@@ -417,6 +443,27 @@ Guacamole.Display = function() {
}; };
/**
* Cancels rendering of all pending frames and associated rendering
* operations. The callbacks provided to outstanding past calls to flush(),
* if any, are not invoked.
*/
this.cancel = function cancel() {
frames.forEach(function cancelFrame(frame) {
frame.cancel();
});
frames = [];
tasks.forEach(function cancelTask(task) {
task.cancel();
});
tasks = [];
};
/** /**
* Sets the hotspot and image of the mouse cursor displayed within the * Sets the hotspot and image of the mouse cursor displayed within the
* Guacamole display. * Guacamole display.