以编程方式确定Linux中的单个屏幕宽度高度(带有Xinerama,TwinView和或BigDesktop)

以编程方式确定Linux中的单个屏幕宽度高度(带有Xinerama,TwinView和或BigDesktop),第1张

以编程方式确定Linux中的单个屏幕宽度/高度(带有Xinerama,TwinView和/或BigDesktop)

看起来好像有一个

libXinerama
API可以检索信息。我还没有找到任何详细的信息。

可以在此处找到X.org常规编程信息(PDF文件)。

libXinerama
可以在此处找到有关提供的功能的信息(联机帮助页的联机帮助,其中没有很多信息)。

这是一个小型的C ++程序,我从这些参考中提取了出来,以检索连接到Xinerama的每个显示器的尺寸和偏移。它也适用于nVidia
TwinView。我目前没有ATI卡在其BigDesktop系统上进行测试,但我怀疑它也可以在其上运行。

#include <cstdlib>#include <iostream>#include <X11/extensions/Xinerama.h>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; x<heads; ++x)  cout << "Head " << x+1 << " of " << heads << ": " <<      p[x].width << "x" << p[x].height << " at " <<      p[x].x_org << "," << p[x].y_org << endl;         success=true;     } else cout << "XineramaQueryScreens says there aren't any" << endl;     XFree(p); } else cout << "Xinerama not active" << endl;        } else cout << "No Xinerama extension" << endl;        XCloseDisplay(d);    } else cout << "Can't open display" << endl;    return (success ? EXIT_SUCCESS : EXIT_FAILURE);}


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/4981959.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-11-14
下一篇2022-11-14

发表评论

登录后才能评论

评论列表(0条)

    保存