Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

x11

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

x11

A pure node.js JavaScript client implementing X Window (X11) protocol.

  • 0.0.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.6K
increased by2.88%
Maintainers
1
Weekly downloads
 
Created
Source

About

X11 protocol client for node.js

install

npm install x11

Windows users:

  1. install XMing or Cygwin/X
  2. get node-x11 copy (using git or from Github)

status

implemented requests documentation

example

Core requsests usage:

var x11 = require('../lib/x11');

var xclient = x11.createClient();
var Exposure = x11.eventMask.Exposure;
var PointerMotion = x11.eventMask.PointerMotion;

xclient.on('connect', function(display) {
    var X = this;
    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, 100, 100, 
       1, 1, 0,
       { 
           backgroundPixel: white, eventMask: Exposure|PointerMotion  
       }
    );
    X.MapWindow(wid);
  
    var gc = X.AllocID();
    X.CreateGC(gc, wid, { foreground: black, background: white } );

    X.on('event', function(ev) {
        if (ev.type == 12)
        {
            X.PolyText8(wid, gc, 50, 50, ['Hello, Node.JS!']); 
        } 
    });
    X.on('error', function(e) {
        console.log(e);
    });
});

'click&draw' demo using simple Window wrapper:

var x11 = require('../lib/x11');
var Window = require('./wndwrap');

x11.createClient(function(display) {

    var pts = [];
    new Window(display.client, 0, 0, 700, 500)
        .handle({

            mousemove: function(ev) {
                if (this.pressed)
                {
                    var lastpoly = pts[pts.length - 1];
                    lastpoly.push(ev.x); 
                    lastpoly.push(ev.y);
                    if (lastpoly.length > 3)
                        this.gc.polyLine(lastpoly.slice(-4));
                }
            },

            mousedown: function(ev) {
                if (ev.keycode == 1) { // left button                    
                    this.pressed = true;
                    pts.push([]);    // start next polyline
		    }            
            },

            mouseup: function(ev) {
                if (ev.keycode == 1) // left button
                   this.pressed = false;
            },

            expose: function(ev) {        
                for (var i=0; i < pts.length ; ++i)
                    this.gc.polyLine(pts[i]);
            }

        })
       .map()
       .title = 'Hello, world!';
});

Screenshots

tetris game XRENDER gradients

Protocol documentation

Other implementations

Keywords

FAQs

Package last updated on 15 Dec 2011

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc