Magellan Linux

Diff of /mcore-src/trunk/mcore-tools/src/xinfo.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2100 by niro, Fri Sep 27 08:40:17 2013 UTC revision 2101 by niro, Fri Sep 27 10:34:07 2013 UTC
# Line 1  Line 1 
1  // code grabbed from:  // original code grabbed from:
2  // http://surfingtroves.blogspot.de/2011/01/how-to-get-screen-resolution-in-linux-c.html  // http://surfingtroves.blogspot.de/2011/01/how-to-get-screen-resolution-in-linux-c.html
3    
4  // -----------------------------------------------------------  // -----------------------------------------------------------
# Line 12  int main() Line 12  int main()
12  {  {
13    
14   Display* pdsp = XOpenDisplay(NULL);   Display* pdsp = XOpenDisplay(NULL);
15     if (! pdsp) {
16       printf("No display found!\n");
17       return 1;
18     }
19   Window wid = DefaultRootWindow(pdsp);   Window wid = DefaultRootWindow(pdsp);
20    
21   Screen* pwnd = DefaultScreenOfDisplay(pdsp);   Screen* pwnd = DefaultScreenOfDisplay(pdsp);
22   int sid = DefaultScreen(pdsp);   int sid = DefaultScreen(pdsp);
23    
24   XWindowAttributes xwAttr;   XWindowAttributes xwAttr;
25   XGetWindowAttributes(pdsp,wid,&xwAttr);   XGetWindowAttributes(pdsp,wid,&xwAttr);
26    
# Line 26  int main() Line 30  int main()
30     xwAttr.x, xwAttr.y, xwAttr.width, xwAttr.height);     xwAttr.x, xwAttr.y, xwAttr.width, xwAttr.height);
31  */  */
32    
33   //printf("%dx%d\n", xwAttr.width, xwAttr.height);   printf("xorg_width=%d\n", xwAttr.width);
  printf("xorg_witdh=%d\n", xwAttr.width);  
34   printf("xorg_height=%d\n", xwAttr.height);   printf("xorg_height=%d\n", xwAttr.height);
35    
36   XCloseDisplay( pdsp );   XCloseDisplay( pdsp );
   
  return 1;  
 }  
37    
38     return 0;
39    }
40    
41  /* gcc -o $@ $< -lX11 */  /* gcc -o $@ $< -lX11 */
42  /* set ts=4 sts=4 tw=100 sw=4 */  /* set ts=4 sts=4 tw=100 sw=4 */
   

Legend:
Removed from v.2100  
changed lines
  Added in v.2101