Re: gui de xrandr
Bernard Siaud alias Troumad <[email protected]>
| Newsgroups | gmane.linux.mandrake.expert.french |
|---|---|
| Message-ID | <[email protected]> |
Sinon, un petit programme pour mettre l'écran du portable comme celui du
vidéo projecteur.
>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
FILE * sortie;
char ch[128],mode[16],nom[16];
unsigned char i,j;
unsigned short xv,yv,xp,yp;
struct ecran
{
char nom[16];
char mode[16];
unsigned short x;
unsigned short y;
struct ecran * suiv;
} * debut = NULL, *actuelle;
system("/usr/bin/xrandr > /tmp/xrandr.sortie");
sortie=fopen("/tmp/xrandr.sortie","r");
while( fgets(ch,127,sortie)!=NULL)
{
/* printf("%hu => ",ch[0]);
printf("%s",ch); */
if (ch[0]!=' ')
{
sscanf(ch,"%s",nom);
if (strcmp(ch,"Screen")!=0)
{
if (debut==NULL)
{
actuelle=(struct ecran *)malloc(sizeof(struct ecran));
debut=actuelle;
}
else
{
actuelle->suiv=(struct ecran *)malloc(sizeof(struct ecran));
actuelle=actuelle->suiv;
}
actuelle->suiv=NULL;
actuelle->x=0;
strncpy(actuelle->nom,nom,15);
}
}
else
{
for(i=0;ch[i]==' ';i++);
sscanf(ch+i,"%s",mode);
/* printf("mode = %s\n",mode); */
if (strstr(ch+i,"+")!=NULL)
{
strncpy(actuelle->mode,mode,15);
sscanf(mode,"%hux%hu",&actuelle->x,&actuelle->y);
if (strstr(ch+i,"*")==NULL)
{
sprintf(ch,"xrandr --output %s --mode %s",nom,mode);
system(ch);
}
printf(ch);printf("\n");
if (strcmp(nom,"VGA1")!=0)
{
xv=actuelle->x;
yv=actuelle->y;
}
else if (strcmp(nom,"LVDS1")!=0)
{
xp=actuelle->x;
yp=actuelle->y;
}
}
if (actuelle->x==0)
if (strstr(ch+i,"*")!=NULL)
{
strncpy(actuelle->mode,mode,15);
sscanf(mode,"%hux%hu",&actuelle->x,&actuelle->y);
if (strcmp(nom,"VGA1")!=0)
{
xv=actuelle->x;
yv=actuelle->y;
}
else if (strcmp(nom,"LVDS1")!=0)
{
xp=actuelle->x;
yp=actuelle->y;
}
}
}
}
sprintf(ch,"xrandr --output LVDS1 --scale
%fx%f",(float)xp/xv,(float)yp/yv);
system("xrandr --output VGA1 --pos 0x0 --panning 0x0 --scale 1x1
--transform 1,0,0,0,1,0,0,0,1 --output LVDS1 --pos 0x0 --panning 0x0
--scale 1x1 --transform 1,0,0,0,1,0,0,0,1");
//system(ch);
system("xrandr --output LVDS1 --scale 1x1"); /* Je ne comprends pas
pourquoi je dois mettre cette ligne ! Bug de xrandr ? */
system(ch);
printf(ch);printf("\n");
}
--
Amicalement vOOotre, Troumad Alias Bernard SIAUD, http://troumad.org
N'envoyez que des documents avec des formats ouverts, comme
http://fr.openoffice.org
Adresse electronique speciale liste
message-footer.txt
(text/plain, 150 B)
================================= http://www.mandriva.com/linux/ Services & cert. hw on http://store.mandriva.com/ =================================