mirror of
https://github.com/danbulant/node-x11
synced 2026-06-16 13:11:11 +00:00
python-xlib link
This commit is contained in:
parent
ac65378885
commit
20c969d9f7
5 changed files with 64 additions and 5 deletions
|
|
@ -113,5 +113,6 @@ Core requsests usage:
|
|||
|
||||
- C: XLib - http://codesearch.google.com/codesearch/p?hl=en#xEHUuo8Crmg/sites/ftp.x.org/pub/X11R7.2/src/update/everything/libX11-X11R7.2-1.1.1.tar.bz2%7CnOqwAyDlYlo/libX11-X11R7.2-1.1.1/src/OpenDis.c&q=XOpenDisplay&d=3
|
||||
- C: XCB - http://xcb.freedesktop.org/
|
||||
- Python: http://sourceforge.net/projects/python-xlib/ ( github fork: https://github.com/Ademan/python-xlib-branch )
|
||||
- Python/twisted: https://launchpad.net/twisted-x11
|
||||
- Perl: http://search.cpan.org/~smccam/X11-Protocol-0.56/Protocol.pm
|
||||
|
|
|
|||
|
|
@ -758,6 +758,7 @@ var FlateStream = (function() {
|
|||
return decodingMap;
|
||||
};
|
||||
PNG.prototype.copyToImageData = function(imageData, pixels) {
|
||||
//console.log(this);
|
||||
var alpha, byte, colors, data, i, palette, pixel, row, v, _i, _j, _k, _len, _len2, _len3, _ref;
|
||||
colors = this.colors;
|
||||
palette = null;
|
||||
|
|
@ -783,6 +784,8 @@ var FlateStream = (function() {
|
|||
data[i++] = v;
|
||||
data[i++] = pixel[1] || 255;
|
||||
} else {
|
||||
if (pixel.length == 4 && pixel[3] != 0)
|
||||
console.log(pixel);
|
||||
for (_k = 0, _len3 = pixel.length; _k < _len3; _k++) {
|
||||
byte = pixel[_k];
|
||||
data[i++] = byte;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
//var logo = require('./node-png').readPng('./node-logo.png');
|
||||
var logo = require('./node-png').readPng(process.argv[2]);
|
||||
var x11 = require('../../lib/x11');
|
||||
|
||||
var Exposure = x11.eventMask.Exposure;
|
||||
|
|
@ -23,7 +22,15 @@ x11.createClient(function(display)
|
|||
var white = display.screen[0].white_pixel;
|
||||
var black = display.screen[0].black_pixel;
|
||||
|
||||
var win = X.AllocID();
|
||||
var win, picWin, piclogoi, logo;
|
||||
|
||||
function showpic(path)
|
||||
{
|
||||
|
||||
console.log(path);
|
||||
|
||||
logo = require('./node-png').readPng(path);
|
||||
win = X.AllocID();
|
||||
X.CreateWindow(
|
||||
win, root,
|
||||
0, 0, logo.width, logo.height,
|
||||
|
|
@ -42,19 +49,45 @@ x11.createClient(function(display)
|
|||
X.PolyFillRectangle(pixmaplogo, gc, [0, 0, 1000, 1000]);
|
||||
X.PutImage(2, pixmaplogo, gc, logo.width, logo.height, 0, 0, 0, 24, logo.data);
|
||||
|
||||
var piclogo = X.AllocID();
|
||||
piclogo = X.AllocID();
|
||||
Render.CreatePicture(piclogo, pixmaplogo, Render.rgb24);
|
||||
|
||||
var picWin = X.AllocID();
|
||||
picWin = X.AllocID();
|
||||
Render.CreatePicture(picWin, win, Render.rgb24);
|
||||
|
||||
}
|
||||
|
||||
var idx = 10000;
|
||||
//showpic('/Applications/iTunes.app/Contents/Resources/FolderAnimationLinenIPadLandscape.png');
|
||||
//showpic('./node-logo.png');
|
||||
showpic('/Applications/iPhoto.app/Contents/Resources/Themes/Assets/Mistletoe/Mistletoe-Outside-200dpi.png');
|
||||
var files = require('fs').readFileSync('./qqq').toString().split('\n');
|
||||
|
||||
|
||||
X.on('event', function(ev) {
|
||||
if (ev.type == 12) // expose
|
||||
{
|
||||
Render.Composite(3, piclogo, 0, picWin, 0, 0, 0, 0, 0, 0, logo.width, logo.height);
|
||||
}
|
||||
if (ev.type == 2)
|
||||
{
|
||||
switch(ev.keycode)
|
||||
{
|
||||
case 131:
|
||||
idx -= 10; break;
|
||||
case 132:
|
||||
idx += 10; break;
|
||||
case 133:
|
||||
idx -= 1; break;
|
||||
case 134:
|
||||
idx += 1; break;
|
||||
}
|
||||
console.log(idx);
|
||||
if (idx < 0) idx = 0;
|
||||
X.DestroyWindow(win);
|
||||
showpic(files[idx]);
|
||||
}
|
||||
});
|
||||
|
||||
X.on('error', function(err) {
|
||||
console.log(err);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -156,6 +156,10 @@ module.exports = {
|
|||
|
||||
],
|
||||
|
||||
DestroyWindow: [
|
||||
[ 'CxSL', [4, 2] ]
|
||||
],
|
||||
|
||||
MapWindow: [
|
||||
// 8 - opcode, 2 - length, wid added as parameter
|
||||
[ 'CxSL', [8, 2] ]
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ for (var i=0; i < bitmap.length; ++i)
|
|||
bitmap[i] = parseInt((i/2048)%256);
|
||||
if (byteNum == 2)
|
||||
bitmap[i] = parseInt((i/256)%256);
|
||||
if (byteNum == 2)
|
||||
bitmap[i] = parseInt((i/1024)%256);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -25,6 +27,8 @@ xclient.on('connect', function(display) {
|
|||
|
||||
BigReq.Enable(function(maxLen) { console.log( maxLen ); });
|
||||
|
||||
X.require('render', function(Render) {
|
||||
|
||||
var root = display.screen[0].root;
|
||||
var white = display.screen[0].white_pixel;
|
||||
var black = display.screen[0].black_pixel;
|
||||
|
|
@ -44,15 +48,29 @@ xclient.on('connect', function(display) {
|
|||
var gc = X.AllocID();
|
||||
X.CreateGC(gc, wid, { foreground: black, background: white } );
|
||||
|
||||
var pixmap1 = X.AllocID();
|
||||
X.CreatePixmap(pixmap1, wid, 32, 128, 128);
|
||||
var pic = X.AllocID();
|
||||
Render.CreatePicture(pic, pixmap1, Render.rgba32);
|
||||
|
||||
|
||||
var pic1 = X.AllocID();
|
||||
Render.CreatePicture(pic1, wid, Render.rgb24);
|
||||
|
||||
X.on('event', function(ev) {
|
||||
if (ev.type == 12) // expose
|
||||
{
|
||||
X.PutImage(2, wid, gc, 128, 128, 0, 0, 0, 24, bitmap);
|
||||
X.PutImage(2, pixmap1, gc, 128, 128, 0, 0, 0, 32, bitmap);
|
||||
//Render.Composite(3, pic1, 0, pic, 0, 0, 0, 0, 30, 40, 128, 128);
|
||||
|
||||
}
|
||||
});
|
||||
X.on('error', function(e) {
|
||||
console.log(e);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue