Programmatically determining individual screen widths/heights in Linux (w/Xinerama, TwinView, and/or BigDesktop)?

It looks like there's a libXinerama API that can retrieve that information. I haven't found any detailed information on it yet though General X. Org programming information can be found here (PDF file).

Information on the functions provided by libXinerama can be found here (online copy of a manpage, not a lot of information in it) Here's a small C++ program that I whipped up from those references to retrieve the dimensions and offsets of each of the monitors hooked into Xinerama. It also works for nVidia TwinView; I don't presently have an ATI card to test it on their BigDesktop system, but I suspect it would work on it as well include #include #include using std::cout; using std::endl; int main(int argc, char *argv) { bool success=false; Display *d=XOpenDisplay(NULL); if (d) { int dummy1, dummy2; if (XineramaQueryExtension(d, &dummy1, &dummy2)) { if (XineramaIsActive(d)) { int heads=0; XineramaScreenInfo *p=XineramaQueryScreens(d, &heads); if (heads>0) { for (int x=0; xHeight EXIT_SUCCESS : EXIT_FAILURE); }.

It looks like there's a libXinerama API that can retrieve that information. I haven't found any detailed information on it yet though. General X.Org programming information can be found here (PDF file).

Information on the functions provided by libXinerama can be found here (online copy of a manpage, not a lot of information in it). Here's a small C++ program that I whipped up from those references to retrieve the dimensions and offsets of each of the monitors hooked into Xinerama.It also works for nVidia TwinView; I don't presently have an ATI card to test it on their BigDesktop system, but I suspect it would work on it as well. #include #include #include using std::cout; using std::endl; int main(int argc, char *argv) { bool success=false; Display *d=XOpenDisplay(NULL); if (d) { int dummy1, dummy2; if (XineramaQueryExtension(d, &dummy1, &dummy2)) { if (XineramaIsActive(d)) { int heads=0; XineramaScreenInfo *p=XineramaQueryScreens(d, &heads); if (heads>0) { for (int x=0; xHeight EXIT_SUCCESS : EXIT_FAILURE); }.

Try something like GdkScreen *screen; int num_monitors; int i; screen = gdk_screen_get_default (); num_monitors = gdk_screen_get_n_monitors (); for (i = 0; I Width, rect. Height); } Internally this uses the libXrandr API. Xinerama is more or less deprecated, but still works; RANDR is the new way to handle multiple monitors in X.

Thanks, I'll give that a try the next time I have a chance. – Head Geek Jul 16 '09 at 16:38.

I always use the "xdpyinfo" command to determine the screen size; run the command, then look at the second or third page of output for where it says something like: screen #0: dimensions: 1280x800 pixels (339x212 millimeters) resolution: 96x96 dots per inch depths (7): 24, 1, 4, 8, 15, 16, 32 root window id: 0xac depth of root window: 24 planes ... You can either run this command externally and grab the dimensions via text processing, or you could quickly download xdpyinfo's code and copy the C calls that it makes to produce that line of output. Good luck!

Fraid that doesn't do the trick, at least under TwinView. When I try it here, the dimensions of screen #0 are the combined dimensions of both screens. – Head Geek May 8 '09 at 18:01.

This works for TwinView, I haven't tested the others: #! /usr/bin/python # Print some information about the X environment, the monitor setup, currently active window and cursor position import gtk. Gdk screen = gtk.gdk.

Screen_get_default() print "X default screen size: %d x %d" % (screen. Get_width(), screen. Get_height()) print "xid of root window: %d" % screen.

Get_root_window(). Xid monitors = int(screen. Get_n_monitors()) print "== %d monitors ==" % monitors for m in range(0, monitors): print " - geometry of monitor %d: %s" % (m, screen.

Get_monitor_geometry(m)) window = screen. Get_active_window() win_x, win_y, win_w, win_h, win_bit_depth = window. Get_geometry() print "active window on monitor: %d" % screen.

Get_monitor_at_point((win_x+(win_w/2)),(win_y+(win_h/2))) print "window geometry (x,y,w,h): %d, %d, %d, %d" % (win_x,win_y,win_w,win_h) display = gtk.gdk. Display_get_default() pointer = display. Get_pointer() print "cursor position (x, y): %d, %d" % (pointer1, pointer2) print "cursor on monitor: %d" % screen.

Get_monitor_at_point(pointer1,pointer2).

Screen = gtk.gdk. Print "X default screen size: %d x %d" % (screen. Print "xid of root window: %d" % screen.

Monitors = int(screen. Print " - geometry of monitor %d: %s" % (m, screen. Window = screen.

Win_x, win_y, win_w, win_h, win_bit_depth = window. Print "active window on monitor: %d" % screen. Display = gtk.gdk.

Pointer = display. Print "cursor on monitor: %d" % screen.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions