Diff for /rpl/src/encart.c between versions 1.60 and 1.61

version 1.60, 2017/08/03 17:17:42 version 1.61, 2017/08/21 09:06:02
Line 26 Line 26
 #   include <X11/Xlib.h>  #   include <X11/Xlib.h>
 #   include "X11/xpm.h"  #   include "X11/xpm.h"
 #   include "Xm/XmAll.h"  #   include "Xm/XmAll.h"
   #   include <X11/extensions/Xinerama.h>
 #endif  #endif
   
   static int
   _XlibErrorHandler(Display *display, XErrorEvent *event)
   {
       uprintf("An error occured detecting the mouse position\n");
       return True;
   }
   
 void  void
 encart(struct_processus *s_etat_processus, integer8 duree)  encart(struct_processus *s_etat_processus, integer8 duree)
Line 35  encart(struct_processus *s_etat_processu Line 42  encart(struct_processus *s_etat_processu
 #   ifdef MOTIF_SUPPORT  #   ifdef MOTIF_SUPPORT
 #   include "rpl.xpm"  #   include "rpl.xpm"
   
       Bool                mouse_found;
   
     Display             *display;      Display             *display;
   
     int                 argc;      int                 argc;
     int                 erreur;      int                 erreur;
     int                 hauteur;      int                 hauteur;
     int                 hauteur_xpm;      int                 hauteur_xpm;
       int                 i;
     int                 largeur;      int                 largeur;
     int                 largeur_xpm;      int                 largeur_xpm;
       int                 ns;
       int                 nb_screens;
       int                 offset_x;
       int                 offset_y;
       int                 root_x;
       int                 root_y;
       int                 win_x;
       int                 win_y;
       int                 x_max;
       int                 x_min;
       int                 y_max;
       int                 y_min;
   
     Pixel               couleur_arriere_plan;      Pixel               couleur_arriere_plan;
     Pixel               couleur_avant_plan;      Pixel               couleur_avant_plan;
Line 64  encart(struct_processus *s_etat_processu Line 86  encart(struct_processus *s_etat_processu
     long                decor;      long                decor;
     long                fonctions;      long                fonctions;
   
       unsigned int        mask_return;
   
       Window              *root_windows;
       Window              window_returned;
   
     Widget              cadre;      Widget              cadre;
     Widget              form;      Widget              form;
     Widget              objet_principal;      Widget              objet_principal;
Line 71  encart(struct_processus *s_etat_processu Line 98  encart(struct_processus *s_etat_processu
   
     XEvent              evenement;      XEvent              evenement;
   
       XineramaScreenInfo  *ts;
   
     XtAppContext        app;      XtAppContext        app;
   
     if (strstr(XmVERSION_STRING, "LessTif") != NULL)      if (strstr(XmVERSION_STRING, "LessTif") != NULL)
Line 88  encart(struct_processus *s_etat_processu Line 117  encart(struct_processus *s_etat_processu
   
     if (display != NULL)      if (display != NULL)
     {      {
         XCloseDisplay(display);  
   
         objet_principal = XtVaOpenApplication(&app, "rpl",          objet_principal = XtVaOpenApplication(&app, "rpl",
                 NULL, 0, &argc, argv, NULL, topLevelShellWidgetClass, NULL);                  NULL, 0, &argc, argv, NULL, topLevelShellWidgetClass, NULL);
         XSynchronize(XtDisplay(objet_principal), False);          XSynchronize(XtDisplay(objet_principal), False);
Line 141  encart(struct_processus *s_etat_processu Line 168  encart(struct_processus *s_etat_processu
         fonctions &= ~(MWM_FUNC_ALL + MWM_FUNC_RESIZE + MWM_FUNC_CLOSE          fonctions &= ~(MWM_FUNC_ALL + MWM_FUNC_RESIZE + MWM_FUNC_CLOSE
                 + MWM_FUNC_MINIMIZE + MWM_FUNC_MAXIMIZE);                  + MWM_FUNC_MINIMIZE + MWM_FUNC_MAXIMIZE);
   
         largeur = WidthOfScreen(XtScreen(form));  
         hauteur = HeightOfScreen(XtScreen(form));  
   
         XtVaSetValues(objet_principal,          XtVaSetValues(objet_principal,
                 XmNmwmDecorations, decor,                  XmNmwmDecorations, decor,
                 XmNmwmFunctions, fonctions,                  XmNmwmFunctions, fonctions,
                 NULL);                  NULL);
   
           if (XineramaIsActive(display) == True)
           {
               // Récupération de la localisation des différents écrans
               // physiques.
   
               ts = XineramaQueryScreens(display, &ns);
   
               XSetErrorHandler(_XlibErrorHandler);
               nb_screens = XScreenCount(display);
   
               root_windows = sys_malloc(((unsigned) nb_screens) * sizeof(Window));
   
               for(i = 0; i < nb_screens; i++)
               {
                   root_windows[i] = XRootWindow(display, i);
               }
   
               for(i = 0; i < nb_screens; i++)
               {
                   if ((mouse_found = XQueryPointer(display, root_windows[i],
                           &window_returned, &window_returned,
                           &root_x, &root_y, &win_x, &win_y, &mask_return))
                           == True)
                   {
                       break;
                   }
               }
   
               if (mouse_found == True)
               {
                   mouse_found = False;
   
                   for(i = 0; i < ns; i++)
                   {
                       x_min = ts[i].x_org;
                       x_max = x_min + ts[i].width;
                       y_min = ts[i].y_org;
                       y_max = y_min + ts[i].height;
   
                       if ((root_x >= x_min) && (root_x <= x_max) &&
                               (root_y >= y_min) && (root_y <= y_max))
                       {
                           largeur = ts[i].width;
                           hauteur = ts[i].height;
                           offset_x = ts[i].x_org;
                           offset_y = ts[i].y_org;
   
                           mouse_found = True;
                           break;
                       }
                   }
   
                   if (mouse_found == False)
                   {
                       // Aucune souris sur un écran physique.
   
                       largeur = ts[0].width;
                       hauteur = ts[0].height;
                       offset_x = 0;
                       offset_y = 0;
                   }
               }
               else
               {
                   // Aucune souris, on considère le premier écran physique
                   // géré par Xinerama.
   
                   largeur = ts[0].width;
                   hauteur = ts[0].height;
                   offset_x = 0;
                   offset_y = 0;
               }
   
               sys_free(root_windows);
               XFree(ts);
           }
           else
           {
               // Xinerama inactif, on considère qu'il n'y a qu'un seul
               // écran physique.
       
               largeur = WidthOfScreen(XtScreen(form));
               hauteur = HeightOfScreen(XtScreen(form));
               offset_x = 0;
               offset_y = 0;
           }
   
           XCloseDisplay(display);
   
 #if 0  #if 0
         XtRealizeWidget(objet_principal);          XtRealizeWidget(objet_principal);
   
Line 158  encart(struct_processus *s_etat_processu Line 271  encart(struct_processus *s_etat_processu
                 NULL);                  NULL);
   
         XtVaSetValues(objet_principal,          XtVaSetValues(objet_principal,
                 XmNx, (largeur - largeur_popup) / 2,                  XmNx, offset_x + ((largeur - largeur_popup) / 2),
                 XmNy, (hauteur - hauteur_popup) / 2,                  XmNy, offset_y + ((hauteur - hauteur_popup) / 2),
                 NULL);                  NULL);
 #else  #else
         sscanf(rpl_xpm[0], "%d %d", &largeur_xpm, &hauteur_xpm);          sscanf(rpl_xpm[0], "%d %d", &largeur_xpm, &hauteur_xpm);
Line 168  encart(struct_processus *s_etat_processu Line 281  encart(struct_processus *s_etat_processu
         hauteur_popup = (Position) (hauteur_xpm + 28);          hauteur_popup = (Position) (hauteur_xpm + 28);
   
         XtVaSetValues(objet_principal,          XtVaSetValues(objet_principal,
                 XmNx, (largeur - largeur_popup) / 2,                  XmNx, offset_x + ((largeur - largeur_popup) / 2),
                 XmNy, (hauteur - hauteur_popup) / 2,                  XmNy, offset_y + ((hauteur - hauteur_popup) / 2),
                 NULL);                  NULL);
   
         XtRealizeWidget(objet_principal);          XtRealizeWidget(objet_principal);

Removed from v.1.60  
changed lines
  Added in v.1.61


CVSweb interface <joel.bertrand@systella.fr>