Re: gui de xrandr

Bernard Siaud alias Troumad <[email protected]>
Newsgroups gmane.linux.mandrake.expert.french
Message-ID <[email protected]>
jipe a écrit :
> Le Tue, 17 Nov 2009 16:45:12 +0100 (CET),
> "Francois-Xavier Pasquier" <[email protected]> a écrit :
>
>   
>> C'est un peu de la mauvaise foi que de dire que
>> xterm (ou n'importe quel term) soit une "Graphical User Interface"
>> même si le term se lance sous X...
>>
>>     
>
> non, c'est de l'ironie ...
>
>
>   
À propos du man... Juste une question : qui peut corriger la version 
française actuelle ?
http://forum.mandriva.com/viewtopic.php?p=740928#740928

Il y aura sûrement une modification pour l'option --transform, je suis 
en discussion avec les auteurs de la version anglaise.

Le shell, c'est le top, mais ma femme ne gère pas trop... Je lui est 
concocté (enfin, elle a utilisé la version précédente, celle-ci est en 
cours d'amélioration ) :

#include <stdio.h>
#include <stdlib.h>
#include <string.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[512],nom[16];
 unsigned short i,j;
 unsigned short xv,yv,xp,yp;
 unsigned short x,y;
 struct ecran * debut = NULL, *actuelle;
 struct mode * mode;
 
 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 ":" ");
    mode=mode->suiv;
   }
   while (mode!=NULL);
  }
  actuelle=actuelle->suiv;
 }
 while (actuelle != NULL);
 
 
 
 printf("Choix 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);
    }
   }
   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 --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",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);
   sprintf(ch,"xrandr --output %s --scale 
%fx%f",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
   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/
=================================
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.