Reputation: 914
In Linux, one can use xwininfo
to get the location of a window. When the location of window is changed, one can run the command again. However, it's not very efficient to put the command in a loop, and run it all the time. Is that possible to get notified when the location is changed in order to run the command less time?
Upvotes: 0
Views: 302
Reputation: 25456
You need to listen for ConfigureNotify event of that window. To subscribe, set StructureNotify
using xlib XSelectInput (or low level - ConfigureWindow
X11 request)
Example using JavaScript / node-x11 (exits immediately after location or geometry of window is changed)
var x11 = require('x11');
var wid = Number(process.argv[2]);
x11.createClient(function(err, display) {
var X = display.client;
X.ChangeWindowAttributes(wid, { eventMask: x11.eventMask.StructureNotify });
X.on('event', function(ev) {
if (ev.name === 'ConfigureNotify') {
console.log(ev.x, ev.y, ev.width, ev.height);
X.close();
}
});
});
Upvotes: 2