栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

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

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

以编程方式确定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);}


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/393024.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号