I am writing a function to get x, y, width, and height of all the monitors of the multi moniotr setup.
I found this solution: https://stackoverflow.com/a/23608025/5062337
So I implemented it with jsctypes:
var collMonInfos = [];
var rootGdkWin = ostypes.API('gdk_get_default_root_window')();
console.info('rootGdkWin:', rootGdkWin.toString(), uneval(rootGdkWin), cutils.jscGetDeepest(rootGdkWin));
var rootGtkWin = ostypes.HELPER.gdkWinPtrToGtkWinPtr(rootGdkWin);
// the screen contains all monitors
var gdkScreen = ostypes.API('gtk_window_get_screen')(rootGtkWin);
var fullWidth = ostypes.API('gdk_screen_get_width')(gdkScreen);
var fullHeight = ostypes.API('gdk_screen_get_height')(gdkScreen);
console.info('fullWidth:', fullWidth.toString(), 'fullHeight:', fullHeight.toString());
// collect data about each monitor
var monitors = [];
var nmons = ostypes.API('gdk_screen_get_n_monitors')(gdkScreen);
console.info('number of monitors:', nmons);
nmons = cutils.jscGetDeepest(nmons);
var rect = ostypes.TYPE.GdkRectangle();
for (var i=0; i<nmons; i++) {
var mg = ostypes.API('gdk_screen_get_monitor_geometry')(gdkScreen, i, rect.address());
collMonInfos.push({
x: cutils.jscGetDeepest(rect.x),
y: cutils.jscGetDeepest(rect.y),
w: cutils.jscGetDeepest(rect.width),
h: cutils.jscGetDeepest(rect.height)
})
}
return collMonInfos;
However this tells me I have 0 monitors.
So I was wondering, starting with gdk_default_root_window, how to get info on all the monitors?
I know I can get the union of all monitors with gdk_drawable_get_size
but i need individual monitor information please.
Thanks