mirror of
https://github.com/danbulant/node-x11
synced 2026-05-22 05:49:11 +00:00
new argument depth in CreateWindow
This commit is contained in:
parent
779da87017
commit
29a04525af
9 changed files with 36 additions and 38 deletions
|
|
@ -1,22 +1,23 @@
|
|||
var x11 = require('../lib/x11');
|
||||
|
||||
var xclient = x11.createClient();
|
||||
var PointerMotion = x11.eventMask.PointerMotion;
|
||||
|
||||
xclient.on('connect', function(display) {
|
||||
var X = this;
|
||||
x11.createClient(function(display) {
|
||||
var X = display.client;
|
||||
var root = display.screen[0].root;
|
||||
var wid = X.AllocID();
|
||||
var white = display.screen[0].white_pixel;
|
||||
var black = display.screen[0].black_pixel;
|
||||
|
||||
X.CreateWindow(wid, root, 10, 10, 400, 300, 1, 1, 0, { backgroundPixel: white, eventMask: PointerMotion });
|
||||
X.CreateWindow(wid, root, 0, 0, 400, 300, 0, 0, 0, 0, { backgroundPixel: white, eventMask: PointerMotion });
|
||||
X.MapWindow(wid);
|
||||
|
||||
// mode: 0 replace, 1 prepend, 2 append
|
||||
// mode, wid, name, type, format, data
|
||||
X.ChangeProperty(0, wid, xclient.atoms.WM_NAME, xclient.atoms.STRING, 8, 'Hello, NodeJS');
|
||||
setInterval(function() {
|
||||
X.ChangeProperty(0, wid, xclient.atoms.WM_NAME, xclient.atoms.STRING, 8, 'Hello, NodeJS ' + new Date());
|
||||
X.ChangeProperty(0, wid, X.atoms.WM_NAME, X.atoms.STRING, 8, 'Hello, NodeJS');
|
||||
var interval = setInterval(function() {
|
||||
X.ChangeProperty(0, wid, X.atoms.WM_NAME, X.atoms.STRING, 8, 'Hello, NodeJS ' + new Date());
|
||||
}, 100);
|
||||
});
|
||||
X.on('end', function() {
|
||||
clearInterval(interval);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ x11.createClient(function(display) {
|
|||
var X = display.client;
|
||||
var min = display.min_keycode;
|
||||
var max = display.max_keycode;
|
||||
X.GetKeyboardMapping(min, max-min, function(list) {
|
||||
X.GetKeyboardMapping(min, max-min, function(err, list) {
|
||||
for (var i=0; i < list.length; ++i)
|
||||
{
|
||||
var name = kk2Name[i+min] = [];
|
||||
|
|
@ -23,11 +23,11 @@ x11.createClient(function(display) {
|
|||
var wid = X.AllocID();
|
||||
var white = display.screen[0].white_pixel;
|
||||
var black = display.screen[0].black_pixel;
|
||||
X.CreateWindow(wid, root, 10, 10, 400, 300, 1, 1, 0, { backgroundPixel: white, eventMask: x11.eventMask.KeyPress});
|
||||
X.CreateWindow(wid, root, 10, 10, 400, 300, 0, 0, 0, 0, { backgroundPixel: white, eventMask: x11.eventMask.KeyPress});
|
||||
X.MapWindow(wid);
|
||||
|
||||
X.on('event', function(ev) {
|
||||
console.log(kk2Name[ev.keycode]);
|
||||
console.log([ev.keycode, kk2Name[ev.keycode]]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
var x11 = require('../lib/x11');
|
||||
var X = x11.createClient();
|
||||
X.on('connect', function(display) {
|
||||
X.ListExtensions(function(list) {
|
||||
X.ListExtensions(function(err, list) {
|
||||
list.forEach(function(ext) {
|
||||
console.log(ext);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
var x11 = require('../lib/x11');
|
||||
|
||||
var xclient = x11.createClient();
|
||||
var Exposure = x11.eventMask.Exposure;
|
||||
var PointerMotion = x11.eventMask.PointerMotion;
|
||||
var pts = [];
|
||||
|
||||
xclient.on('connect', function(display) {
|
||||
var X = this;
|
||||
x11.createClient(function(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;
|
||||
|
|
@ -14,8 +13,8 @@ xclient.on('connect', function(display) {
|
|||
var wid = X.AllocID();
|
||||
X.CreateWindow(
|
||||
wid, root,
|
||||
10, 10, 400, 300,
|
||||
1, 1, 0,
|
||||
0, 0, 400, 300,
|
||||
0, 0, 0, 0,
|
||||
{
|
||||
backgroundPixel: white, eventMask: Exposure|PointerMotion
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@ var x11 = require('../lib/x11');
|
|||
var X = x11.createClient();
|
||||
var numExt = 0;
|
||||
X.on('connect', function(display) {
|
||||
X.ListExtensions(function(list) {
|
||||
X.ListExtensions(function(err, list) {
|
||||
console.log(list);
|
||||
list.forEach(function(ext) {
|
||||
numExt++;
|
||||
X.QueryExtension(ext, function(e) {
|
||||
X.QueryExtension(ext, function(err, e) {
|
||||
e.name = ext;
|
||||
console.log(e);
|
||||
if (--numExt == 0)
|
||||
|
|
|
|||
|
|
@ -1,20 +1,19 @@
|
|||
var x11 = require('../lib/x11');
|
||||
var X = x11.createClient();
|
||||
|
||||
X.on('connect', function(display) {
|
||||
|
||||
x11.createClient(function(display) {
|
||||
var X = display.client;
|
||||
var screen = display.screen[0];
|
||||
var wid = X.AllocID();
|
||||
X.CreateWindow(wid, screen.root, 10, 10, 400, 300, 1, 1, 0, { backgroundPixel: screen.white_pixel });
|
||||
X.CreateWindow(wid, screen.root, 0, 0, 400, 300);
|
||||
X.MapWindow(wid);
|
||||
setInterval( function() {
|
||||
X.QueryPointer(wid, function(res) {
|
||||
var interval = setInterval( function() {
|
||||
X.QueryPointer(wid, function(err, res) {
|
||||
console.log(res);
|
||||
});
|
||||
}, 1000);
|
||||
|
||||
X.on('error', function(err) {
|
||||
console.log(err);
|
||||
});
|
||||
X.on('end', function () { clearInterval(interval); });
|
||||
});
|
||||
|
||||
X.on('error', function(err) {
|
||||
console.log(err);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ var wids = [];
|
|||
x11.createClient(function(display) {
|
||||
var X = display.client;
|
||||
var root = display.screen[0].root;
|
||||
X.QueryTree(wid ? wid : root, function(tree) {
|
||||
X.QueryTree(wid ? wid : root, function(err, tree) {
|
||||
console.log(tree);
|
||||
X.terminate();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,12 +4,10 @@ var Window = require('./wndwrap');
|
|||
var width = 700;
|
||||
var height = 500;
|
||||
|
||||
var xclient = x11.createClient();
|
||||
var pts = [];
|
||||
x11.createClient(function(display) {
|
||||
|
||||
xclient.on('connect', function(display) {
|
||||
|
||||
var mainwnd = new Window(xclient, 0, 0, width, height);
|
||||
var mainwnd = new Window(display.client, 0, 0, width, height);
|
||||
mainwnd.on('mousemove', function(ev)
|
||||
{
|
||||
pts.push(ev.x);
|
||||
|
|
@ -22,5 +20,4 @@ xclient.on('connect', function(display) {
|
|||
ev.gc.drawText(pts[i], pts[i+1], 'Hello, NodeJS!');
|
||||
});
|
||||
mainwnd.map();
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -97,9 +97,10 @@ function Window(parent, x, y, w, h, bg)
|
|||
var borderWidth = 1;
|
||||
var _class = 1; // InputOutput
|
||||
var visual = 0; // CopyFromParent
|
||||
var depth = 0;
|
||||
this.xclient.CreateWindow(
|
||||
this.id, this.parent.id, this.x, this.y, this.w, this.h,
|
||||
borderWidth, _class, visual,
|
||||
borderWidth, depth, _class, visual,
|
||||
{
|
||||
backgroundPixel: bg,
|
||||
eventMask: Exposure|PointerMotion|ButtonPress|ButtonRelease|SubstructureNotify|StructureNotify
|
||||
|
|
@ -196,4 +197,4 @@ Window.prototype.createPixmap = function(width, height)
|
|||
return pixmap;
|
||||
}
|
||||
|
||||
module.exports = Window;
|
||||
module.exports = Window;
|
||||
|
|
|
|||
Loading…
Reference in a new issue