--- rpl/src/encart.c 2017/08/23 09:29:15 1.62 +++ rpl/src/encart.c 2018/12/24 15:55:01 1.69 @@ -1,7 +1,7 @@ /* ================================================================================ - RPL/2 (R) version 4.1.28 - Copyright (C) 1989-2017 Dr. BERTRAND Joël + RPL/2 (R) version 4.1.30 + Copyright (C) 1989-2018 Dr. BERTRAND Joël This file is part of RPL/2. @@ -29,9 +29,21 @@ # 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; } @@ -72,15 +84,14 @@ encart(struct_processus *s_etat_processu int y_max; int y_min; - Pixel couleur_arriere_plan; - Pixel couleur_avant_plan; - Pixmap pixmap_rpl; Pixmap pixmap_rpl_masque; Position hauteur_popup; Position largeur_popup; + Screen *screen; + String *argv; struct timespec attente; @@ -135,6 +146,21 @@ encart(struct_processus *s_etat_processu xmFormWidgetClass, objet_principal, NULL); + XtVaGetValues(objet_principal, + XmNmwmDecorations, &decor, + XmNmwmFunctions, &fonctions, + NULL); + + decor &= ~(MWM_DECOR_ALL + MWM_DECOR_MAXIMIZE + MWM_DECOR_RESIZEH + + MWM_DECOR_TITLE + MWM_DECOR_MENU + MWM_DECOR_BORDER); + fonctions &= ~(MWM_FUNC_ALL + MWM_FUNC_RESIZE + MWM_FUNC_CLOSE + + MWM_FUNC_MINIMIZE + MWM_FUNC_MAXIMIZE); + + XtVaSetValues(objet_principal, + XmNmwmDecorations, decor, + XmNmwmFunctions, fonctions, + NULL); + cadre = XtVaCreateManagedWidget("rplExternalFrame", xmFrameWidgetClass, form, XmNtopAttachment, XmATTACH_FORM, @@ -149,14 +175,9 @@ encart(struct_processus *s_etat_processu XmNmarginHeight, 5, NULL); - XtVaGetValues(form, - XmNforeground, &couleur_avant_plan, - XmNbackground, &couleur_arriere_plan, - NULL); - - if ((erreur = XCreatePixmapFromData(XtDisplay(form), + if ((erreur = XpmCreatePixmapFromData(XtDisplay(form), DefaultRootWindow(XtDisplay(form)), rpl_xpm, - &pixmap_rpl, &pixmap_rpl_masque, NULL)) != 0) + &pixmap_rpl, &pixmap_rpl_masque, NULL)) != XpmSuccess) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; @@ -168,21 +189,6 @@ encart(struct_processus *s_etat_processu XmNlabelPixmap, pixmap_rpl, NULL); - XtVaGetValues(objet_principal, - XmNmwmDecorations, &decor, - XmNmwmFunctions, &fonctions, - NULL); - - decor &= ~(MWM_DECOR_ALL + MWM_DECOR_MAXIMIZE + MWM_DECOR_RESIZEH - + MWM_DECOR_TITLE + MWM_DECOR_MENU + MWM_DECOR_BORDER); - fonctions &= ~(MWM_FUNC_ALL + MWM_FUNC_RESIZE + MWM_FUNC_CLOSE - + MWM_FUNC_MINIMIZE + MWM_FUNC_MAXIMIZE); - - XtVaSetValues(objet_principal, - XmNmwmDecorations, decor, - XmNmwmFunctions, fonctions, - NULL); - if (XineramaIsActive(display) == True) { // Récupération de la localisation des différents écrans @@ -190,7 +196,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)); @@ -202,10 +208,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; } @@ -330,14 +342,6 @@ encart(struct_processus *s_etat_processu XtUnrealizeWidget(objet_principal); - XmDestroyPixmap(XtScreen(form), pixmap_rpl); - XmDestroyPixmap(XtScreen(form), pixmap_rpl_masque); - - XtDestroyWidget(pixmap); - XtDestroyWidget(cadre); - XtDestroyWidget(form); - XtDestroyWidget(objet_principal); - while(XtAppPending(app) == 0) { nanosleep(&attente, NULL); @@ -350,9 +354,19 @@ encart(struct_processus *s_etat_processu nanosleep(&attente, NULL); } - XCloseDisplay(display); + screen = XtScreen(form); + + XtDestroyWidget(pixmap); + XtDestroyWidget(cadre); + XtDestroyWidget(form); + XtDestroyWidget(objet_principal); + + XmDestroyPixmap(screen, pixmap_rpl); + XmDestroyPixmap(screen, pixmap_rpl_masque); + XtAppSetWarningHandler(app, old_message_handler); XtDestroyApplicationContext(app); + XCloseDisplay(display); } # endif