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

ewmh

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ewmh - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

examples/active_window.js

6

examples/example.js

@@ -10,2 +10,6 @@ var x11 = require('x11');

var ewmh = new EWMH(display.client, display.screen[0].root);
ewmh.on('CurrentDesktop', function(d) {
console.log('Client requested current desktop to be: ' + d);
});
ewmh.set_number_of_desktops(4, function(err) {

@@ -18,2 +22,2 @@ if (err) {

});
});
});

@@ -0,8 +1,59 @@

var EventEmitter = require('events').EventEmitter;
var util = require('util');
var os = require('os');
var async = require('async');
var EWMH = function(X, root) {
EventEmitter.call(this);
var self = this;
this.X = X;
this.root = root;
this.X.on('event', this._handle_event.bind(this));
this.X.GrabServer();
X.GetWindowAttributes(root, function(err, attrs) {
if (!(attrs.myEventMask & X.eventMask.SubstructureRedirect)) {
X.ChangeWindowAttributes(root,
{ eventMask: attrs.myEventMask | X.eventMask.SubstructureRedirect },
function(err) {
var error = new Error('Could not set SubstructureRedirect to root window event_mask');
error.x11_error = err;
self.emit('error', error);
return true;
});
self.X.UngrabServer();
}
});
};
util.inherits(EWMH, EventEmitter);
module.exports = EWMH;
EWMH.prototype.set_supported = function(list, cb) {
var self = this;
async.map(
list,
function(prop, cb) {
self.X.InternAtom(false, prop, cb);
},
function(err, results) {
if (err) {
if (cb) {
cb(err);
}
return;
}
var length = results.length * 4;
var raw = new Buffer(new Array(length));
results.forEach(function(p, i) {
raw.writeUInt32LE(p, i * 4);
});
self._change_property(self.root, '_NET_SUPPORTED', self.X.atoms.ATOM, 32, raw, cb);
}
);
};
EWMH.prototype.set_number_of_desktops = function(n, cb) {

@@ -30,3 +81,46 @@ var raw = new Buffer(4);

EWMH.prototype.set_pid = function(wid, cb) {
var raw = new Buffer(4);
raw.writeUInt32LE(process.pid);
this.change_property(wid, '_NET_WM_PID', this.X.atoms.CARDINAL, 32, raw, cb);
};
EWMH.prototype.set_hostname = function(wid, cb) {
var hosname = os.hostname();
this.change_property('WM_CLIENT_MACHINE', X.atoms.STRING, 8, hostname, cb);
};
EWMH.prototype.set_active_window = function(wid, cb) {
var raw = new Buffer(4);
raw.writeUInt32LE(wid, 0);
this._change_property(this.root, '_NET_ACTIVE_WINDOW', this.X.atoms.WINDOW, 32, raw, cb);
};
EWMH.set_composite_manager_owner = function(wid, screenNo, cb) {
var self = this;
self.X.InternAtom(false, '_NET_WM_CM_S' + screenNo, function(err, composite_atom) {
if (err) return cb(err);
X.SetSelectionOwner(wid, composite_atom, cb);
});
}
EWMH.prototype._handle_event = function(ev) {
var self = this;
switch(ev.name) {
case 'ClientMessage':
self.X.GetAtomName(ev.type, function(err, name) {
switch (name) {
case '_NET_ACTIVE_WINDOW':
self.emit('ActiveWindow', ev.wid);
break;
case '_NET_CURRENT_DESKTOP':
self.emit('CurrentDesktop', ev.data[0]);
break;
}
});
break;
}
};
EWMH.prototype._change_property = function(wid, property, type, units, data, cb) {

@@ -33,0 +127,0 @@ var self = this;

14

package.json
{
"name": "ewmh",
"version": "0.0.1",
"version": "0.1.0",
"description": "Implementation of the Extended Window Manager Hints (EWMH)",
"main": "index.js",
"scripts": {
"test": "grunt"
"test": "./node_modules/.bin/mocha"
},

@@ -13,7 +13,13 @@ "repository": {

},
"dependencies": {
"async": "~0.2.9"
},
"devDependencies": {
"mocha": "~1.13.0",
"x11": "~0.4.0",
"should": "~1.3.0"
"should": "~1.3.0",
"x11": ">=0.7"
},
"peerDependencies": {
"x11": ">=0.7"
},
"keywords": [

@@ -20,0 +26,0 @@ "EWMH",

@@ -25,2 +25,6 @@ node-ewmh

var ewmh = new EWMH(display.client, display.screen[0].root);
ewmh.on('CurrentDesktop', function(d) {
console.log('Client requested current desktop to be: ' + d);
});
ewmh.set_number_of_desktops(4, function(err) {

@@ -40,2 +44,4 @@ if (err) {

\_NET\_SUPPORTED - ewmh.set\_supported(hints_list, cb)
\_NET\_NUMBER\_OF\_DESKTOPS - ewmh.set\_number\_of\_desktops

@@ -47,2 +53,21 @@

\_NET\_WM\_PID - emwh.set_pid(windowId, cb)
WM\_CLIENT\_MACHINE - emwh.set_hostname(windowId, cb)
\_NET\_ACTIVE\_WINDOW - ewmh.set_active_window(windowId, cb)
\_NET\_WM\_CM\_S0 - emwh.set_composite_manager_owner(windowId, screenNo, cb)
=======
EVENTS
=======
Events are generated whenever a client requests the modification of a HINT.
**Events - Hint relationship**
*ActiveWindow* - \_NET\_ACTIVE\_WINDOW
*CurrentDesktop* - \_NET\_CURRENT\_DESKTOP
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