GCFunction shortcuts

This commit is contained in:
Svetlana Linuxenko 2016-11-18 14:50:10 +02:00
parent 9ff1b645d1
commit 9e967b9734
No known key found for this signature in database
GPG key ID: E8CE83DCDAB1509B
3 changed files with 63 additions and 0 deletions

View file

@ -0,0 +1,36 @@
/*
* GCFunction usage example
*/
var x11 = require('../../lib');
x11.createClient(function(err, display) {
var X = display.client;
var root = display.screen[0].root;
var white = display.screen[0].white_pixel;
var black = display.screen[0].black_pixel;
var wid = X.AllocID();
X.CreateWindow(wid, root, 0, 0, 400, 300, 0, 0, 0, 0, {
backgroundPixel: black,
eventMask: x11.eventMask.ButtonPress|x11.eventMask.Exposure });
var gc = X.AllocID();
X.CreateGC(gc, wid, {foreground : white, 'function' : x11.gcFunction.GXinvert});
X.MapWindow(wid);
X.on('event', function(ev) {
if (ev.type === 12) {
X.PolyFillRectangle(wid, gc, [0, 0, 400, 300]);
}
if (ev.type === 4) {
var x = ev.x;
var y = ev.y;
X.PolyFillRectangle(wid, gc, [x - 25, y - 25, 50, 50]);
}
});
});

22
lib/gcfunction.js Normal file
View file

@ -0,0 +1,22 @@
/*
* GCFunction named shortcuts
*/
module.exports = {
GXclear : 0x0,
GXand : 0x1,
GXandReverse : 0x2,
GXcopy : 0x3,
GXandInverted : 0x4,
GXnoop : 0x5,
GXxor : 0x6,
GXor : 0x7,
GXnor : 0x8,
GXequiv : 0x9,
GXinvert : 0xa,
GXorReverse : 0xb,
GXcopyInverted : 0xc,
GXorInverted : 0xd,
GXnand : 0xe,
GXset : 0xf
};

View file

@ -11,6 +11,11 @@ Object.defineProperty(module.exports, 'keySyms', {
get: function() { return require('./keysyms'); }
});
Object.defineProperty(module.exports, 'gcFunction', {
enumerable: true,
get: function() { return require('./gcfunction'); }
});
//TODO:
// keepe everything in namespace for consistensy (eventMask, keySyms, class, destination ...
// or put most used constants to top namespace? (currently class and destination in top)