xrandr를 위해 예시적인 호출이다xrandr를, C 프로그래밍은 여기
가$ xrandr --output LVDS --mode 1680x1050 --pos 0x0 --rotate normal --output S-video --off --output DVI-0 --mode 1024x768 --pos 1680x104 --rotate normal
그 호출 성공을 가지는 시스템에 대해 생각해; 서로 다른 해상도로 작동하는 두 개의 화면 (LVDS 및 DVI-0)이 있습니다. DVI-0 하나가 가운데에 놓인 오른쪽에 있습니다.
C 프로그램에서이 모든 정보를 어떻게 얻을 수 있습니까? xrandr 소스 코드를 검사했지만 읽는 것이 어려워서 --pos 값을 쿼리 할 명백한 방법이 없다는 것을 알았습니다. (편집 : 평범한 광경에 감추어 져 있습니다.
나는 XGetWindowProperty로 _NET_WORKAREA를 물어볼 수 있지만, 내가 본 바로는 화면 위치를 알려주지 않고 모든 것을 포함하는 이상적인 사각형의 크기 만 알 수있다.
xrandr 코드에 대한 다른 연구가 있은 후이 코드는 한 단계 진전 된 것처럼 보입니다. 그러나 2950 줄 주변의 xrandr.c는 crtc_info를 사용할 수 없다고 생각합니다. 나는 여전히 해상도와 위치를 얻는 다른 방법을 놓친다.
#include <stdio.h> #include <X11/extensions/Xrandr.h> int main() { Display *disp; XRRScreenResources *screen; XRROutputInfo *info; XRRCrtcInfo *crtc_info; int iscres; int icrtc; disp = XOpenDisplay(0); screen = XRRGetScreenResources (disp, DefaultRootWindow(disp)); for (iscres = screen->noutput; iscres > 0;) { --iscres; info = XRRGetOutputInfo (disp, screen, screen->outputs[iscres]); if (info->connection == RR_Connected) { for (icrtc = info->ncrtc; icrtc > 0;) { --icrtc; crtc_info = XRRGetCrtcInfo (disp, screen, screen->crtcs[icrtc]); fprintf(stderr, "==> %dx%d+%dx%d\n", crtc_info->x, crtc_info->y, crtc_info->width, crtc_info->height); XRRFreeCrtcInfo(crtc_info); } } XRRFreeOutputInfo (info); } XRRFreeScreenResources(screen); return 0; }
안녕하세요 궁금 라이브러리를 링크 -lX11 -lXrandr 컴파일? 아니면 더 나은 방법을 찾았습니까? – yatg
xrandr을 사용할 수없는 경우 xinerma와 combination을 사용하려고 생각했습니다. http://stackoverflow.com/a/836376/5062337 – yatg