[prev in list] [next in list] [prev in thread] [next in thread]
List: freedesktop-xorg
Subject: XF86VidModeGetAllModeLines() returns fewer modes each time
From: Basin Ilya <basinilya () gmail ! com>
Date: 2017-04-03 19:56:22
Message-ID: 327e4231-c41f-f4b5-3b37-cb60c57c8b27 () gmail ! com
[Download RAW message or body]
Hi list.
I wrote a test program to list available screen resolutions and maybe switch to one \
of them. Apparently, my program is incomplete and I have to restore the resolution \
using my DE settings, but after I restore it and run my program again, that mode \
disappears from the output of `XF86VidModeGetAllModeLines()`. Originally it contained \
`1400x1050`, `1600x900`, and `1440x900`, but each time I repeat my actions, the \
function returns fewer results. Why is that?
$ gcc -o test test.c -lX11 -lXxf86vm
$ ./test
1920x1080
1680x1050
1920x1080
1920x1080
1280x1024
1280x1024
1280x800
1280x720
1152x864
1024x768
1024x768
800x600
800x600
800x600
640x480
640x480
1366x768
_
#include <stdio.h>
#include <sys/types.h>
#include <string.h>
#include <X11/Xlib.h>
#include <X11/extensions/xf86vmode.h>
static Bool b;
static Display* display = NULL;
void dostuff(int screen)
{
int flag = 0;
int modeCount;
XF86VidModeModeInfo** modes;
if (XF86VidModeGetAllModeLines(display, screen, &modeCount, &modes))
{
for(int i = 0; i < modeCount; i ++)
{
printf("%hdx%hd\n", modes[i]->hdisplay, modes[i]->vdisplay);
//continue;
if (!flag && 1600 == modes[i]->hdisplay && 900 == modes[i]->vdisplay) {
flag = 1;
b = XF86VidModeSwitchToMode(display, screen, modes[i]);
printf("%d\n", b);
b = XF86VidModeSetViewPort(display, screen, 0, 0);
printf("%d\n", b);
XFlush(display);
}
}
XFree(modes);
}
}
int main(int argc, char *argv[]) {
if (display == NULL) {
display = XOpenDisplay(NULL);
}
if (display == NULL) {
return 1;
}
dostuff(0);
XCloseDisplay(display);
return 0;
}
My card is GeForce 9600, driver version: 340.101.
_______________________________________________
xorg@lists.x.org: X.Org support
Archives: http://lists.freedesktop.org/archives/xorg
Info: https://lists.x.org/mailman/listinfo/xorg
Your subscription address: %(user_address)s
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic