mirror of
https://github.com/danbulant/node-x11
synced 2026-06-24 17:21:47 +00:00
DAMAGE and Composite extensions
This commit is contained in:
parent
fd81862722
commit
31194398bc
4 changed files with 228 additions and 0 deletions
115
lib/x11/ext/composite.js
Normal file
115
lib/x11/ext/composite.js
Normal file
|
|
@ -0,0 +1,115 @@
|
||||||
|
// /usr/share/doc/x11proto-composite-dev/compositeproto.txt.gz
|
||||||
|
// http://cgit.freedesktop.org/xorg/proto/compositeproto/plain/compositeproto.txt
|
||||||
|
//
|
||||||
|
// /usr/include/X11/extensions/Xcomposite.h Xlib
|
||||||
|
// /usr/include/X11/extensions/composite.h constants
|
||||||
|
// /usr/include/X11/extensions/compositeproto.h structs
|
||||||
|
//
|
||||||
|
// http://ktown.kde.org/~fredrik/composite_howto.html
|
||||||
|
//
|
||||||
|
// server side source:
|
||||||
|
// http://cgit.freedesktop.org/xorg/xserver/tree/composite/compext.c
|
||||||
|
//
|
||||||
|
|
||||||
|
var x11 = require('..');
|
||||||
|
// TODO: move to templates
|
||||||
|
|
||||||
|
exports.requireExt = function(display, callback)
|
||||||
|
{
|
||||||
|
var X = display.client;
|
||||||
|
X.QueryExtension('Composite', function(err, ext) {
|
||||||
|
|
||||||
|
if (!ext.present)
|
||||||
|
callback(new Error('extension not available'));
|
||||||
|
|
||||||
|
ext.Redirect = {
|
||||||
|
Automatic: 0,
|
||||||
|
Manual: 1
|
||||||
|
};
|
||||||
|
|
||||||
|
ext.QueryVersion = function(clientMaj, clientMin, callback)
|
||||||
|
{
|
||||||
|
X.seq_num++;
|
||||||
|
X.pack_stream.pack('CCSLL', [ext.majorOpcode, 0, 3, clientMaj, clientMin]);
|
||||||
|
X.replies[X.seq_num] = [
|
||||||
|
function(buf, opt) {
|
||||||
|
var res = buf.unpack('LL');
|
||||||
|
return res;
|
||||||
|
},
|
||||||
|
callback
|
||||||
|
];
|
||||||
|
X.pack_stream.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
ext.RedirectWindow = function( window, updateType )
|
||||||
|
{
|
||||||
|
X.seq_num++;
|
||||||
|
console.log("ext.RedirectWindow", X.seq_num);
|
||||||
|
X.pack_stream.pack('CCSLLCxxx', [ext.majorOpcode, 1, 4, window, updateType]);
|
||||||
|
X.pack_stream.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
ext.RedirectSubwindows = function( window, updateType )
|
||||||
|
{
|
||||||
|
X.seq_num++;
|
||||||
|
X.pack_stream.pack('CCSLLCxxx', [ext.majorOpcode, 2, 4, window, updateType]);
|
||||||
|
X.pack_stream.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
ext.UnredirectWindow = function(window)
|
||||||
|
{
|
||||||
|
X.seq_num++;
|
||||||
|
X.pack_stream.pack('CCSLL', [ext.majorOpcode, 3, 3, window]);
|
||||||
|
X.pack_stream.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
ext.UnredirectSubwindows = function(window)
|
||||||
|
{
|
||||||
|
X.seq_num++;
|
||||||
|
X.pack_stream.pack('CCSLL', [ext.majorOpcode, 4, 3, window]);
|
||||||
|
X.pack_stream.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
ext.CreateRegionFromBorderClip = function(region, window)
|
||||||
|
{
|
||||||
|
X.seq_num++;
|
||||||
|
X.pack_stream.pack('CCSLLL', [ext.majorOpcode, 5, 4, damage, region]);
|
||||||
|
X.pack_stream.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
ext.NameWindowPixmap = function(window, pixmap)
|
||||||
|
{
|
||||||
|
X.seq_num++;
|
||||||
|
X.pack_stream.pack('CCSLLL', [ext.majorOpcode, 6, 4, window, pixmap]);
|
||||||
|
X.pack_stream.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
ext.GetOverlayWindow = function(window)
|
||||||
|
{
|
||||||
|
X.seq_num++;
|
||||||
|
X.pack_stream.pack('CCSLL', [ext.majorOpcode, 7, 3]);
|
||||||
|
X.replies[X.seq_num] = [
|
||||||
|
function(buf, opt) {
|
||||||
|
var res = buf.unpack('L');
|
||||||
|
return res[0];
|
||||||
|
},
|
||||||
|
callback
|
||||||
|
];
|
||||||
|
X.pack_stream.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
ext.ReleaseOverlayWindow = function(window)
|
||||||
|
{
|
||||||
|
X.seq_num++;
|
||||||
|
X.pack_stream.pack('CCSLL', [ext.majorOpcode, 8, 3, window]);
|
||||||
|
X.pack_stream.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
// currently version 0.4 TODO: bump up with coordinate translations
|
||||||
|
ext.QueryVersion(0, 4, function(err, vers) {
|
||||||
|
ext.major = vers[0];
|
||||||
|
ext.minor = vers[1];
|
||||||
|
callback(ext);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
77
lib/x11/ext/damage.js
Normal file
77
lib/x11/ext/damage.js
Normal file
|
|
@ -0,0 +1,77 @@
|
||||||
|
// http://www.x.org/releases/X11R7.6/doc/damageproto/damageproto.txt
|
||||||
|
|
||||||
|
var x11 = require('..');
|
||||||
|
// TODO: move to templates
|
||||||
|
|
||||||
|
/*
|
||||||
|
#define X_DamageQueryVersion 0
|
||||||
|
#define X_DamageCreate 1
|
||||||
|
#define X_DamageDestroy 2
|
||||||
|
#define X_DamageSubtract 3
|
||||||
|
#define X_DamageAdd 4
|
||||||
|
*/
|
||||||
|
|
||||||
|
exports.requireExt = function(display, callback)
|
||||||
|
{
|
||||||
|
var X = display.client;
|
||||||
|
X.QueryExtension('DAMAGE', function(err, ext) {
|
||||||
|
|
||||||
|
if (!ext.present)
|
||||||
|
callback(new Error('extension not available'));
|
||||||
|
|
||||||
|
ext.ReportLevel = {
|
||||||
|
RawRectangles: 0,
|
||||||
|
DeltaRectangles: 1,
|
||||||
|
BoundingBox: 2,
|
||||||
|
NonEmpty: 3
|
||||||
|
};
|
||||||
|
|
||||||
|
ext.QueryVersion = function(clientMaj, clientMin, callback)
|
||||||
|
{
|
||||||
|
X.seq_num++;
|
||||||
|
X.pack_stream.pack('CCSLL', [ext.majorOpcode, 0, 3, clientMaj, clientMin]);
|
||||||
|
X.replies[X.seq_num] = [
|
||||||
|
function(buf, opt) {
|
||||||
|
var res = buf.unpack('LL');
|
||||||
|
return res;
|
||||||
|
},
|
||||||
|
callback
|
||||||
|
];
|
||||||
|
X.pack_stream.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
ext.Create = function( damage, drawable, reportlevel )
|
||||||
|
{
|
||||||
|
X.seq_num++;
|
||||||
|
X.pack_stream.pack('CCSLLCxxx', [ext.majorOpcode, 1, 4, damage, drawable, reportlevel]);
|
||||||
|
X.pack_stream.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
ext.Destroy = function( damage )
|
||||||
|
{
|
||||||
|
X.seq_num++;
|
||||||
|
X.pack_stream.pack('CCSLL', [ext.majorOpcode, 2, 3, damage]);
|
||||||
|
X.pack_stream.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
ext.Subtract = function(damage, repair, parts)
|
||||||
|
{
|
||||||
|
X.seq_num++;
|
||||||
|
X.pack_stream.pack('CCSLLL', [ext.majorOpcode, 3, 4, damage, repair, parts]);
|
||||||
|
X.pack_stream.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
ext.Add = function(damage, region)
|
||||||
|
{
|
||||||
|
X.seq_num++;
|
||||||
|
X.pack_stream.pack('CCSLL', [ext.majorOpcode, 4, 3, damage, region]);
|
||||||
|
X.pack_stream.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
ext.QueryVersion(1, 1, function(err, vers) {
|
||||||
|
ext.major = vers[0];
|
||||||
|
ext.minor = vers[1];
|
||||||
|
callback(ext);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
18
test/compositetest.js
Normal file
18
test/compositetest.js
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
var x11 = require('../lib/x11');
|
||||||
|
|
||||||
|
x11.createClient(function(display) {
|
||||||
|
var X = display.client;
|
||||||
|
var root = display.screen[0].root;
|
||||||
|
X.require('composite', function(Composite) {
|
||||||
|
console.log(Composite);
|
||||||
|
//Composite.GetOverlayWindow(root, function(overleyid) {
|
||||||
|
// console.log(overlayid);
|
||||||
|
//});
|
||||||
|
Composite.RedirectWindow(root, Composite.Redirect.Automatic);
|
||||||
|
X.on('event', function(ev) {
|
||||||
|
console.log(ev);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
X.on('error', function(err) { console.log(err); });
|
||||||
|
|
||||||
|
});
|
||||||
18
test/damagetest.js
Normal file
18
test/damagetest.js
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
var x11 = require('../lib/x11');
|
||||||
|
|
||||||
|
x11.createClient(function(display) {
|
||||||
|
var X = display.client;
|
||||||
|
var root = display.screen[0].root;
|
||||||
|
X.require('damage', function(Damage) {
|
||||||
|
console.log(Damage);
|
||||||
|
var id = parseInt(process.argv[2]);
|
||||||
|
var damage = X.AllocID();
|
||||||
|
Damage.Create(damage, id, Damage.ReportLevel.NonEmpty);
|
||||||
|
X.on('event', function(ev) {
|
||||||
|
Damage.Subtract(damage, 0, 0);
|
||||||
|
console.log(ev);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
X.on('error', function(err) { console.log(err); });
|
||||||
|
|
||||||
|
});
|
||||||
Loading…
Reference in a new issue