wrapper for Window.title property -> ChangeProperty/WM_NAME

This commit is contained in:
sidorares 2011-07-22 16:14:29 +10:00
parent 04744a4a4c
commit 71f6317e92
4 changed files with 28 additions and 5 deletions

View file

@ -162,7 +162,7 @@ XClient.prototype.unpackEvent = function(type, seq, extra, raw)
event.type = type;
event.seq = seq;
if (type == 6) { // motion event
if (type == 4 || type == 5 || type == 6) { // motion event
var values = raw.unpack('LLLSSSSSC'); //TODO: should be LLLLsssssSC
//event.raw = values;
// TODO: use unpackTo???

View file

@ -2,6 +2,19 @@ var x11 = require('../lib/x11');
var xclient = x11.createClient();
var PointerMotion = x11.eventMask.PointerMotion;
var Button1Motion = x11.eventMask.Button1Motion;
var Button2Motion = x11.eventMask.Button2Motion;
var Button3Motion = x11.eventMask.Button3Motion;
var Button4Motion = x11.eventMask.Button4Motion;
var Button5Motion = x11.eventMask.Button5Motion;
var ButtonPress = x11.eventMask.ButtonPress;
var ButtonRelease = x11.eventMask.ButtonRelease;
var EnterWindow = x11.eventMask.EnterWindow;
var LeaveWindow = x11.eventMask.LeaveWindow;
//var mask = PointerMotion|Button1Motion|Button2Motion|Button3Motion|Button4Motion|Button5Motion|ButtonPress|ButtonRelease;
//var mask = Button1Motion|Button2Motion|Button3Motion|Button4Motion|Button5Motion|ButtonPress|ButtonRelease;
var mask = Button1Motion|ButtonPress|EnterWindow|LeaveWindow;
xclient.on('connect', function(display) {
var X = this;
@ -10,10 +23,10 @@ xclient.on('connect', function(display) {
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, 10, 10, 400, 300, 1, 1, 0, { backgroundPixel: white, eventMask: mask });
X.MapWindow(wid);
});
var wid1 = X.AllocID();
X.CreateWindow(wid1, root, 10, 10, 40, 30, 1, 1, 0, { backgroundPixel: black, eventMask: PointerMotion });
X.MapWindow(wid1);
xclient.on('event', function(ev) {
console.log(ev);
});

View file

@ -15,6 +15,7 @@ xclient.on('connect', function(display) {
pts.push(ev.x);
pts.push(ev.y);
this.gc.drawText(ev.x, ev.y, 'Hello, NodeJS!');
mainwnd.title = ev.x + ' ' + ev.y;
});
mainwnd.on('expose', function(ev) {
for (var i=0; i < pts.length/2 ; ++i)

View file

@ -89,6 +89,15 @@ function Window(parent, x, y, w, h)
wnd.emit(eventType2eventName[ev.type], ev); // convert to mousemove? (ev is already event-spacific)
});
// TODO: track delete events and remove wmd from consumers list
this.__defineSetter__('title', function(title) {
this._title = title;
this.xclient.ChangeProperty(0, this.id, this.xclient.atoms.WM_NAME, this.xclient.atoms.STRING, 8, title);
});
this.__defineGetter__('title', function() {
return this._title;
});
this.__defineGetter__('gc', function()
{