Skip to content

Instantly share code, notes, and snippets.

@yajd
Created July 17, 2015 01:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yajd/55441c9c3d0711ee4a38 to your computer and use it in GitHub Desktop.
Save yajd/55441c9c3d0711ee4a38 to your computer and use it in GitHub Desktop.
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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment