add unused IDs buffer

This commit is contained in:
Andrey Sidorov 2016-05-18 20:22:24 +10:00
parent 1d77f21ec7
commit 60f8b08037

View file

@ -119,6 +119,7 @@ XClient.prototype.init = function(stream)
this.startHandshake();
this._closing = false;
this._unusedIds = [];
}
// TODO: close() = set 'closing' flag, watch it in replies and writeQueue, terminate if empty
@ -247,12 +248,17 @@ XClient.prototype.importRequestsFromTemplates = function(target, reqs)
XClient.prototype.AllocID = function()
{
// TODO: handle overflow (XCMiscGetXIDRange from XC_MISC ext)
// TODO: unused id buffer
this.display.rsrc_id++;
return (this.display.rsrc_id << this.display.rsrc_shift) + this.display.resource_base;
}
if (this._unusedIds.length > 0) {
return this._unusedIds.pop();
}
// TODO: handle overflow (XCMiscGetXIDRange from XC_MISC ext)
this.display.rsrc_id++;
return (this.display.rsrc_id << this.display.rsrc_shift) + this.display.resource_base;
};
XClient.prototype.ReleaseID = function(id) {
this._unusedIds.push(id);
};
// TODO: move core events unpackers to corereqs.js
XClient.prototype.unpackEvent = function(type, seq, extra, code, raw, headerBuf)