mirror of
https://github.com/danbulant/node-x11
synced 2026-05-27 05:52:02 +00:00
add unused IDs buffer
This commit is contained in:
parent
1d77f21ec7
commit
60f8b08037
1 changed files with 11 additions and 5 deletions
10
lib/xcore.js
10
lib/xcore.js
|
|
@ -119,6 +119,7 @@ XClient.prototype.init = function(stream)
|
||||||
|
|
||||||
this.startHandshake();
|
this.startHandshake();
|
||||||
this._closing = false;
|
this._closing = false;
|
||||||
|
this._unusedIds = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: close() = set 'closing' flag, watch it in replies and writeQueue, terminate if empty
|
// 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()
|
XClient.prototype.AllocID = function()
|
||||||
{
|
{
|
||||||
|
if (this._unusedIds.length > 0) {
|
||||||
|
return this._unusedIds.pop();
|
||||||
|
}
|
||||||
// TODO: handle overflow (XCMiscGetXIDRange from XC_MISC ext)
|
// TODO: handle overflow (XCMiscGetXIDRange from XC_MISC ext)
|
||||||
// TODO: unused id buffer
|
|
||||||
this.display.rsrc_id++;
|
this.display.rsrc_id++;
|
||||||
return (this.display.rsrc_id << this.display.rsrc_shift) + this.display.resource_base;
|
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
|
// TODO: move core events unpackers to corereqs.js
|
||||||
XClient.prototype.unpackEvent = function(type, seq, extra, code, raw, headerBuf)
|
XClient.prototype.unpackEvent = function(type, seq, extra, code, raw, headerBuf)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue