Re: gui de xrandr
Bernard Siaud alias Troumad <[email protected]>
| Newsgroups | gmane.linux.mandrake.expert.french |
|---|---|
| Message-ID | <[email protected]> |
Petit Eric a écrit :
> Hum, l'idée de réunir ne fait pas la force ?
>
Oui 8-)
> Tu exprimes le besoin de rajouter des fonctionalité, grandr-applet ,
> si tu utilises Gnome,
Non, kde ou iceWM, mais iceWM est devenu inapte à fonctionner
correctement avec xrandr :(
> est écrit en C/C++, un patch peut etre ?
Je peux ! Mais, je me faudrais un interlocuteur parlant français :-[
Tu connais des gens dans ce projet ?
Un nouvelle fonctionnalité encore. Mais, le problème, c'est que chaque
nouvelle fonctionnalité rajoute des questions à poser >:o
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
struct mode
{
char nom[16];
struct mode * suiv;
};
struct ecran
{
char nom[16];
char mode_ac[16];
char mode_op[16];
unsigned short x,y;
struct mode * mode;
struct ecran * suiv;
};
int main()
{
FILE * sortie;
char ch[1024],nom[16];
unsigned short i,j;
unsigned short xv,yv,xp,yp;
unsigned short x,y;
struct ecran * debut = NULL, *actuelle;
struct mode * mode;
char c;
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]!=' ') // Pas les modes
{
sscanf(ch,"%s",nom);
if (strcmp(nom,"Screen")!=0) // Pas la ligne de présentation de la carte
{
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);
actuelle->mode_ac[0]=0;
actuelle->mode_op[0]=0;
}
}
else // Les modes
{
if (actuelle->mode==NULL)
{
mode=(struct mode *)malloc(sizeof(struct mode));
actuelle->mode=mode;
}
else
{
mode->suiv=(struct mode *)malloc(sizeof(struct mode));
mode=mode->suiv;
}
mode->suiv=NULL;
for(i=0;ch[i]==' ';i++);
sscanf(ch+i,"%s",mode->nom);
if (strstr(ch+i,"+")!=NULL)
{
strncpy(actuelle->mode_op,mode->nom,15);
sscanf(mode->nom,"%hux%hu",&actuelle->x,&actuelle->y);
}
if (strstr(ch+i,"*")!=NULL)
{
strncpy(actuelle->mode_ac,mode->nom,15);
sscanf(mode->nom,"%hux%hu",&actuelle->x,&actuelle->y);
}
}
}
printf("Configurations possibles pour les écrans\n");
actuelle=debut;
do
{
if (actuelle->x!=0)
{
i=0;
printf ("\n Liste des modes pour l'écran %s\n",actuelle->nom);
mode=actuelle->mode;
do
{
i++;
printf(" %hu) %s %s
%s\n",i,mode->nom,(strcmp(actuelle->mode_ac,mode->nom)==0)?", mode
actuel":" ",(strcmp(actuelle->mode_op,mode->nom)==0)?", mode optimal":" ");
if (strcmp(actuelle->mode_ac,mode->nom)==0) j=i;
mode=mode->suiv;
}
while (mode!=NULL);
do
{
printf("Quel choix voulez-vous ? de 0 à %hu (0 pour conserver le
mode actuel) : ",i);
scanf("%hu",&x);
}
while (x>i);
if (x==0) x=j;
i=0;
mode=actuelle->mode;
do
{
i++;
if (i!=x) mode=mode->suiv;
}
while (i!=x);
if (strcmp(mode->nom,actuelle->mode_ac)!=0)
{
sprintf(ch,"xrandr --output %s --mode %s",actuelle->nom,mode->nom);
system(ch);
strcpy(actuelle->mode_ac,mode->nom);
}
sscanf(actuelle->mode_ac,"%hux%hu",&actuelle->x,&actuelle->y);
}
actuelle=actuelle->suiv;
}
while (actuelle != NULL);
printf("\n\nChoix de vos écrans\n");
actuelle=debut;
i=0;
do
{
if (actuelle->x!=0)
{
i++;
printf ("%hu) sortie %s mode %s\n",i,actuelle->nom,actuelle->mode);
}
actuelle=actuelle->suiv;
}
while (actuelle != NULL);
if (i>1)
{
printf("Choix de l'écran du vidéo projecteur de 0 à %hu (0 pour aucun)
: ",i);
scanf("%hu",&j);
while (j>i)
{
printf("Mauvais choix : %hu !\nChoix de l'écran du vidéo projecteur
de 0 à %hu (0 pour aucun) : ",j,i);
scanf("%hu",&j);
}
if (j!=0)
{
if (i>2)
{
printf("Choix de l'écran du portable (de 1 à %hu, mais pas %hu)",i,j);
scanf("%hu",&x);
while (x>i || x==0 || x==j)
{
printf("Mauvais choix : %hu !\nChoix de l'écran du vidéo projecteur
(de 1 à %hu pas %hu)",x,i,j);
scanf("%hu",&x);
}
}
else
{
if (j==1) x=2;
else x=1;
}
actuelle=debut;
i=0;
do
{
/* printf("Retour\n"); */
/* printf("%hu %s\n",i,actuelle->nom); */
if (actuelle->x!=0)
{
i++;
//printf("i=%hu j=%hu et x=%hu\n",i,j,x);
if (i==j) // vidéoprojecteur
{
xv=actuelle->x;
yv=actuelle->y;
}
else if (i==x) // écran
{
xp=actuelle->x;
yp=actuelle->y;
strcpy(nom,actuelle->nom);
}
}
actuelle=actuelle->suiv;
}
while (actuelle!=NULL);
// printf("Fin\n");
//sprintf(ch,"xrandr --output %s --pos 0x0 --panning 0x0 --transform
none --output LVDS1 --pos 0x0 --panning 0x0 --transform none",nom);
//printf("%s\n",ch);
//system(ch);
//sprintf(ch,"xrandr --output %s --scale 1x1",nom); /* Je ne
comprends pas pourquoi je dois mettre cette ligne ! Bug de xrandr ? */
//printf("%s\n",ch);
system(ch);
do
{
printf(" Vous voulez faire :\n 0) une mise à l'échelle
(conseillé)\n 1) Un suivit de la souris (mode panorama)\n Choix du mode
0 ou 1 ? : ");
scanf("%hu",&i);
}
while (i>1);
if (i==0)
{
sprintf(ch,"xrandr --output %s --pos 0x0 --panning 0x0 --transform
none --output LVDS1 --pos 0x0 --panning 0x0 --transform none;xrandr
--output %s --scale 1x1;xrandr --output %s --scale
%fx%f",nom,nom,nom,(float)xv/xp,(float)yv/yp);
//printf("%s\n",ch);
system(ch);
//printf("%s par xp=%hu, yp=%hu, xv=%hu et yv=%hu\n",nom,xp,yp,xv,yv);
}
else
{
do
{
printf(" Voulez-vous avoir une avance pour le suivi ? (o/n) : ");
fflush(stdin);
scanf("%c",&c);
c=toupper(c);
}
while(c!='O' && c!='N');
sprintf(ch,"xrandr --output %s --pos 0x0 --panning 0x0 --transform
none --output LVDS1 --pos 0x0 --panning 0x0 --transform none;xrandr
--output %s --scale 1x1;xrandr --output %s --panning
%hux%hu",nom,nom,nom,xv,yv);
if (c=='N')
sprintf(ch,"%s+0+0/%hux%hu+0+0/100/100/100/100",ch,xv,yv);
}
printf("%s\n",ch);
system(ch);
//printf("%s par xp=%hu, yp=%hu, xv=%hu et yv=%hu\n",nom,xp,yp,xv,yv);
}
else
printf("Aucun vidéo projecteur de sélectionné\n");
}
else
printf("Je n'ai trouvé qu'une seule sortie écran\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/ =================================