• [linux][c++]linux c++ 通过xcb库获取屏幕大小


    linux c++ 通过xcb库获取屏幕大小

    #include <stdio.h>
    #include <xcb/xcb.h>
    /**
    clang++ main.cpp -o main `pkg-config --cflags --libs xcb` -lxcb-randr
    
    landv@win7-pc:~/Desktop$ ./main 
    
    Informations of screen 416:
      width.........: 1920
      height........: 1080
      white pixel...: 16777215
      black pixel...: 0
    
    
    */
    int  main (){
            /* Open the connection to the X server. Use the DISPLAY environment variable */
     
            int i, screenNum;
            xcb_connection_t *connection = xcb_connect (NULL, &screenNum);
    
            /* Get the screen whose number is screenNum */ 
            const xcb_setup_t *setup = xcb_get_setup (connection);
            xcb_screen_iterator_t iter = xcb_setup_roots_iterator (setup);  
    
            // we want the screen at index screenNum of the iterator
            for (i = 0; i < screenNum; ++i) {
                xcb_screen_next (&iter);
            }
     
            xcb_screen_t *screen = iter.data;
     
            /* report */
            printf ("
    ");
            printf ("Informations of screen %u:
    ", screen->root);
            printf ("  width.........: %d
    ", screen->width_in_pixels);
            printf ("  height........: %d
    ", screen->height_in_pixels);
            printf ("  white pixel...: %u
    ", screen->white_pixel);
            printf ("  black pixel...: %u
    ", screen->black_pixel);
            printf ("
    ");
     
            return 0;
        }
     
  • 相关阅读:
    SQL常规查询详解
    WEBGL学习【二】平面图形
    WEBGL学习【一】初识WEBGL
    VS2008集成QT的OpenGL开发(实现二维图形的旋转)
    Window文件路径
    字符串转DateTime
    字符串连接
    String.Split分隔字符串
    使用对象初始值设定项初始化
    表达式树
  • 原文地址:https://www.cnblogs.com/landv/p/11955547.html
Copyright © 2020-2023  润新知