--- rpl/src/encart.c 2017/08/21 09:06:02 1.61 +++ rpl/src/encart.c 2017/08/24 07:07:38 1.65 @@ -29,13 +29,31 @@ # include #endif +static logical1 +valeur_erreur(logical1 nouvelle_valeur) +{ + static logical1 erreur = d_faux; + logical1 registre; + + registre = erreur; + erreur = nouvelle_valeur; + return(registre); +} + static int _XlibErrorHandler(Display *display, XErrorEvent *event) { + valeur_erreur(d_vrai); uprintf("An error occured detecting the mouse position\n"); return True; } +static void +_XtWarningHandler(String message) +{ + return; +} + void encart(struct_processus *s_etat_processus, integer8 duree) { @@ -102,6 +120,8 @@ encart(struct_processus *s_etat_processu XtAppContext app; + XtErrorHandler old_message_handler; + if (strstr(XmVERSION_STRING, "LessTif") != NULL) { printf("Lesstif is broken, please consider an upgrade to OpenMotif.\n"); @@ -118,9 +138,11 @@ encart(struct_processus *s_etat_processu if (display != NULL) { objet_principal = XtVaOpenApplication(&app, "rpl", - NULL, 0, &argc, argv, NULL, topLevelShellWidgetClass, NULL); + NULL, 0, &argc, argv, NULL, overrideShellWidgetClass, NULL); XSynchronize(XtDisplay(objet_principal), False); + old_message_handler = XtAppSetWarningHandler(app, _XtWarningHandler); + form = XtVaCreateManagedWidget("rplSplashScreen", xmFormWidgetClass, objet_principal, NULL); @@ -144,7 +166,8 @@ encart(struct_processus *s_etat_processu XmNbackground, &couleur_arriere_plan, NULL); - if ((erreur = XCreatePixmapFromData(XtDisplay(form), +uprintf("0\n"); + if ((erreur = XpmCreatePixmapFromData(XtDisplay(form), DefaultRootWindow(XtDisplay(form)), rpl_xpm, &pixmap_rpl, &pixmap_rpl_masque, NULL)) != 0) { @@ -173,6 +196,7 @@ encart(struct_processus *s_etat_processu XmNmwmFunctions, fonctions, NULL); +uprintf("1\n"); if (XineramaIsActive(display) == True) { // Récupération de la localisation des différents écrans @@ -180,7 +204,7 @@ encart(struct_processus *s_etat_processu ts = XineramaQueryScreens(display, &ns); - XSetErrorHandler(_XlibErrorHandler); + //XSetErrorHandler(_XlibErrorHandler); nb_screens = XScreenCount(display); root_windows = sys_malloc(((unsigned) nb_screens) * sizeof(Window)); @@ -192,10 +216,16 @@ encart(struct_processus *s_etat_processu 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) + valeur_erreur(d_faux); + + do + { + mouse_found = XQueryPointer(display, root_windows[i], + &window_returned, &window_returned, + &root_x, &root_y, &win_x, &win_y, &mask_return); + } while(valeur_erreur(d_faux) == d_vrai); + + if (mouse_found == True) { break; } @@ -259,8 +289,7 @@ encart(struct_processus *s_etat_processu offset_x = 0; offset_y = 0; } - - XCloseDisplay(display); +uprintf("2\n"); #if 0 XtRealizeWidget(objet_principal); @@ -287,8 +316,10 @@ encart(struct_processus *s_etat_processu XtRealizeWidget(objet_principal); #endif +uprintf("3\n"); XFlush(XtDisplay(form)); +uprintf("3a\n"); attente.tv_sec = 0; attente.tv_nsec = 1000; @@ -297,11 +328,16 @@ encart(struct_processus *s_etat_processu do { +uprintf("3b\n"); if (XtAppPending(app) != 0) { +uprintf("3c\n"); XtAppNextEvent(app, &evenement); +uprintf("3d\n"); XtDispatchEvent(&evenement); +uprintf("3e\n"); } +uprintf("3f\n"); nanosleep(&attente, NULL); gettimeofday(&horodatage_final, NULL); @@ -320,15 +356,9 @@ encart(struct_processus *s_etat_processu + ((double) temps_ecoule.tv_sec)) < (((double) duree) / ((double) 1000000))); +uprintf("4\n"); XtUnrealizeWidget(objet_principal); - - XmDestroyPixmap(XtScreen(form), pixmap_rpl); - XmDestroyPixmap(XtScreen(form), pixmap_rpl_masque); - - XtDestroyWidget(pixmap); - XtDestroyWidget(cadre); - XtDestroyWidget(form); - XtDestroyWidget(objet_principal); +uprintf("5\n"); while(XtAppPending(app) == 0) { @@ -342,7 +372,19 @@ encart(struct_processus *s_etat_processu nanosleep(&attente, NULL); } + XtDestroyWidget(pixmap); + XtDestroyWidget(cadre); + XtDestroyWidget(form); + XtDestroyWidget(objet_principal); + +uprintf("6\n"); + XmDestroyPixmap(XtScreen(form), pixmap_rpl); + XmDestroyPixmap(XtScreen(form), pixmap_rpl_masque); + + XCloseDisplay(display); + XtAppSetWarningHandler(app, old_message_handler); XtDestroyApplicationContext(app); +uprintf("7\n"); } # endif