New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.1.0 to 0.2.0

test/properties.js

100

lib/ewmh.js

@@ -5,2 +5,3 @@ var EventEmitter = require('events').EventEmitter;

var async = require('async');
var encoder = require('x11-prop').encoder;

@@ -49,9 +50,4 @@ var EWMH = function(X, root) {

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);
var data = encoder.encode('ATOM', results);
self._change_property(self.root, '_NET_SUPPORTED', self.X.atoms.ATOM, 32, data, cb);
}

@@ -62,38 +58,41 @@ );

EWMH.prototype.set_number_of_desktops = function(n, cb) {
var raw = new Buffer(4);
raw.writeUInt32LE(n, 0);
this._change_property(this.root, '_NET_NUMBER_OF_DESKTOPS', this.X.atoms.CARDINAL, 32, raw, cb);
var data = encoder.encode('CARDINAL', [ n ]);
this._change_property(this.root, '_NET_NUMBER_OF_DESKTOPS', this.X.atoms.CARDINAL, 32, data, cb);
};
EWMH.prototype.set_current_desktop = function(d, cb) {
var raw = new Buffer(4);
raw.writeUInt32LE(d, 0);
this._change_property(this.root, '_NET_CURRENT_DESKTOP', this.X.atoms.CARDINAL, 32, raw, cb);
var data = encoder.encode('CARDINAL', [ d ]);
this._change_property(this.root, '_NET_CURRENT_DESKTOP', this.X.atoms.CARDINAL, 32, data, cb);
};
EWMH.prototype.update_window_list = function(list, cb) {
var length = list.length * 4;
var raw = new Buffer(new Array(length));
list.forEach(function(w, i) {
raw.writeUInt32LE(w, i * 4);
});
this._update_window_list(list, '_NET_CLIENT_LIST', cb);
};
this._change_property(this.root, '_NET_CLIENT_LIST', this.X.atoms.WINDOW, 32, raw, cb);
EWMH.prototype.update_window_list_stacking = function(list, cb) {
this._update_window_list(list, '_NET_CLIENT_LIST_STACKING', cb);
};
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);
var data = encoder.encode('CARDINAL', [ process.pid ]);
this._change_property(wid, '_NET_WM_PID', this.X.atoms.CARDINAL, 32, data, cb);
};
EWMH.prototype.set_hostname = function(wid, cb) {
var hosname = os.hostname();
this.change_property('WM_CLIENT_MACHINE', X.atoms.STRING, 8, hostname, cb);
var data = encoder.encode('STRING', [ os.hostname() ]);
var hostname = os.hostname();
this._change_property(wid, 'WM_CLIENT_MACHINE', this.X.atoms.STRING, 8, data, cb);
};
EWMH.prototype.set_name = function(wid, name, cb) {
this._change_utf8_property(wid, '_NET_WM_NAME', name, cb);
};
EWMH.prototype.set_class = function(wid, _class, cb) {
this._change_utf8_property(wid, 'WM_CLASS', _class, 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);
var data = encoder.encode('WINDOW', [ wid ]);
this._change_property(this.root, '_NET_ACTIVE_WINDOW', this.X.atoms.WINDOW, 32, data, cb);
};

@@ -103,8 +102,27 @@

var self = this;
self.X.InternAtom(false, '_NET_WM_CM_S' + screenNo, function(err, composite_atom) {
this.X.InternAtom(false, '_NET_WM_CM_S' + screenNo, function(err, composite_atom) {
if (err) return cb(err);
X.SetSelectionOwner(wid, composite_atom, cb);
self.X.SetSelectionOwner(wid, composite_atom, cb);
});
}
};
EWMH.set_window_manager_owner = function(wid, name, _class, cb) {
var self = this;
var raw = new Buffer(4);
raw.writeUInt32LE(wid, 0);
async.parallel([
function(cb) {
this._change_property(this.root, '_NET_SUPPORTING_WM_CHECK', self.X.atoms.WINDOW, 32, raw, cb);
}, function(cb) {
this._change_property(wid, '_NET_SUPPORTING_WM_CHECK', self.X.atoms.WINDOW, 32, raw, cb);
}, function(cb) {
self.set_pid(wid, cb);
}, function(cb) {
self.set_name(wid, name, cb);
}, function(cb) {
self.set_class(wid, _class, cb);
}
], cb);
};
EWMH.prototype._handle_event = function(ev) {

@@ -114,3 +132,3 @@ var self = this;

case 'ClientMessage':
self.X.GetAtomName(ev.type, function(err, name) {
this.X.GetAtomName(ev.type, function(err, name) {
switch (name) {

@@ -142,1 +160,21 @@ case '_NET_ACTIVE_WINDOW':

};
EWMH.prototype._change_utf8_property = function(wid, property, value, cb) {
var self = this;
async.map(
[property, 'UTF8_STRING'],
function(prop, cb) {
self.X.InternAtom(false, prop, cb);
},
function(err, results) {
if (err) return cb(err);
self.X.ChangeProperty(0, wid, results[0], results[1], 8, value, cb);
}
);
};
EWMH.prototype._update_window_list = function(list, prop, cb) {
var data = encoder.encode('WINDOW', list);
this._change_property(this.root, prop, this.X.atoms.WINDOW, 32, data, cb);
};
{
"name": "ewmh",
"version": "0.1.0",
"version": "0.2.0",
"description": "Implementation of the Extended Window Manager Hints (EWMH)",

@@ -14,3 +14,4 @@ "main": "index.js",

"dependencies": {
"async": "~0.2.9"
"async": "~0.2.9",
"x11-prop": "~0.0.1"
},

@@ -17,0 +18,0 @@ "devDependencies": {

@@ -49,4 +49,6 @@ node-ewmh

\_NET\_CLIENT\_LIST - ewmh.update\_window\_list
\_NET\_CLIENT\_LIST - ewmh.update\_window\_list(list, cb)
\_NET\_CLIENT\_LIST\_STACKING - ewmh.update_window_list_stacking(list_stacking, cb)
\_NET\_WM\_PID - emwh.set_pid(windowId, cb)

@@ -72,1 +74,5 @@

*CurrentDesktop* - \_NET\_CURRENT\_DESKTOP
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/santigimeno/node-ewmh/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
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