File:
[local] /
rpl /
src /
encart.c
Revision
1.21:
download - view:
text,
annotated -
select for diffs -
revision graph
Tue Jun 21 15:26:28 2011 UTC (12 years, 10 months ago) by
bertrand
Branches:
MAIN
CVS tags:
HEAD
Correction d'une réinitialisation sauvage de la pile des variables par niveau
dans la copie de la structure de description du processus. Cela corrige
la fonction SPAWN qui échouait sur un segmentation fault car la pile des
variables par niveau était vide alors même que l'arbre des variables contenait
bien les variables. Passage à la prerelease 2.
1: /*
2: ================================================================================
3: RPL/2 (R) version 4.1.0.prerelease.2
4: Copyright (C) 1989-2011 Dr. BERTRAND Joël
5:
6: This file is part of RPL/2.
7:
8: RPL/2 is free software; you can redistribute it and/or modify it
9: under the terms of the CeCILL V2 License as published by the french
10: CEA, CNRS and INRIA.
11:
12: RPL/2 is distributed in the hope that it will be useful, but WITHOUT
13: ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14: FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL V2 License
15: for more details.
16:
17: You should have received a copy of the CeCILL License
18: along with RPL/2. If not, write to info@cecill.info.
19: ================================================================================
20: */
21:
22:
23: #include "rpl-conv.h"
24:
25: #ifdef MOTIF_SUPPORT
26: # include <X11/Xlib.h>
27: # include <Xm/XmAll.h>
28: # include <X11/xpm.h>
29: #endif
30:
31:
32: void
33: encart(struct_processus *s_etat_processus, unsigned long duree)
34: {
35: # ifdef MOTIF_SUPPORT
36: # include "rpl.xpm"
37:
38: Display *display;
39:
40: int argc;
41: int erreur;
42: int hauteur;
43: int hauteur_xpm;
44: int largeur;
45: int largeur_xpm;
46:
47: Pixel couleur_arriere_plan;
48: Pixel couleur_avant_plan;
49:
50: Pixmap pixmap_rpl;
51: Pixmap pixmap_rpl_masque;
52:
53: Position hauteur_popup;
54: Position largeur_popup;
55:
56: String *argv;
57:
58: struct timespec attente;
59:
60: struct timeval temps_ecoule;
61: struct timeval horodatage_initial;
62: struct timeval horodatage_final;
63:
64: unsigned long decor;
65: unsigned long fonctions;
66:
67: Widget cadre;
68: Widget form;
69: Widget objet_principal;
70: Widget pixmap;
71:
72: XEvent evenement;
73:
74: XtAppContext app;
75:
76: if (strstr(XmVERSION_STRING, "LessTif") != NULL)
77: {
78: printf("Lesstif is broken, please consider an upgrade to OpenMotif.\n");
79: return;
80: }
81:
82: argc = 0;
83: argv = NULL;
84:
85: display = XOpenDisplay(NULL);
86:
87: // Si display est nul, il n'y pas de serveur X.
88:
89: if (display != NULL)
90: {
91: XCloseDisplay(display);
92:
93: objet_principal = XtVaOpenApplication(&app, "rpl",
94: NULL, 0, &argc, argv, NULL, topLevelShellWidgetClass, NULL);
95: XSynchronize(XtDisplay(objet_principal), False);
96:
97: form = XtVaCreateManagedWidget("rplSplashScreen",
98: xmFormWidgetClass, objet_principal,
99: NULL);
100:
101: cadre = XtVaCreateManagedWidget("rplExternalFrame",
102: xmFrameWidgetClass, form,
103: XmNtopAttachment, XmATTACH_FORM,
104: XmNbottomAttachment, XmATTACH_FORM,
105: XmNleftAttachment, XmATTACH_FORM,
106: XmNrightAttachment, XmATTACH_FORM,
107: XmNtopOffset, 5,
108: XmNleftOffset, 5,
109: XmNrightOffset, 5,
110: XmNbottomOffset, 5,
111: XmNmarginWidth, 5,
112: XmNmarginHeight, 5,
113: NULL);
114:
115: XtVaGetValues(form,
116: XmNforeground, &couleur_avant_plan,
117: XmNbackground, &couleur_arriere_plan,
118: NULL);
119:
120: if ((erreur = XCreatePixmapFromData(XtDisplay(form),
121: DefaultRootWindow(XtDisplay(form)), rpl_xpm,
122: &pixmap_rpl, &pixmap_rpl_masque, NULL)) != 0)
123: {
124: (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;
125: return;
126: }
127:
128: pixmap = XtVaCreateManagedWidget("rplPixmap",
129: xmLabelWidgetClass, cadre,
130: XmNlabelType, XmPIXMAP,
131: XmNlabelPixmap, pixmap_rpl,
132: NULL);
133:
134: XtVaGetValues(objet_principal,
135: XmNmwmDecorations, &decor,
136: XmNmwmFunctions, &fonctions,
137: NULL);
138:
139: decor &= ~(MWM_DECOR_ALL + MWM_DECOR_MAXIMIZE + MWM_DECOR_RESIZEH
140: + MWM_DECOR_TITLE + MWM_DECOR_MENU + MWM_DECOR_BORDER);
141: fonctions &= ~(MWM_FUNC_ALL + MWM_FUNC_RESIZE + MWM_FUNC_CLOSE
142: + MWM_FUNC_MINIMIZE + MWM_FUNC_MAXIMIZE);
143:
144: largeur = WidthOfScreen(XtScreen(form));
145: hauteur = HeightOfScreen(XtScreen(form));
146:
147: XtVaSetValues(objet_principal,
148: XmNmwmDecorations, decor,
149: XmNmwmFunctions, fonctions,
150: NULL);
151:
152: #if 0
153: XtRealizeWidget(objet_principal);
154:
155: XtVaGetValues(objet_principal,
156: XmNheight, &hauteur_popup,
157: XmNwidth, &largeur_popup,
158: NULL);
159:
160: XtVaSetValues(objet_principal,
161: XmNx, (largeur - largeur_popup) / 2,
162: XmNy, (hauteur - hauteur_popup) / 2,
163: NULL);
164: #else
165: sscanf(rpl_xpm[0], "%d %d", &largeur_xpm, &hauteur_xpm);
166:
167: largeur_popup = largeur_xpm + 28;
168: hauteur_popup = hauteur_xpm + 28;
169:
170: XtVaSetValues(objet_principal,
171: XmNx, (largeur - largeur_popup) / 2,
172: XmNy, (hauteur - hauteur_popup) / 2,
173: NULL);
174:
175: XtRealizeWidget(objet_principal);
176: #endif
177:
178: XFlush(XtDisplay(form));
179:
180: attente.tv_sec = 0;
181: attente.tv_nsec = 1000;
182:
183: gettimeofday(&horodatage_initial, NULL);
184:
185: do
186: {
187: if (XtAppPending(app) != 0)
188: {
189: XtAppNextEvent(app, &evenement);
190: XtDispatchEvent(&evenement);
191: }
192:
193: nanosleep(&attente, NULL);
194: gettimeofday(&horodatage_final, NULL);
195:
196: temps_ecoule.tv_sec = horodatage_final.tv_sec
197: - horodatage_initial.tv_sec;
198: temps_ecoule.tv_usec = horodatage_final.tv_usec
199: - horodatage_initial.tv_usec;
200:
201: if (temps_ecoule.tv_usec < 0)
202: {
203: temps_ecoule.tv_usec += 1000000;
204: temps_ecoule.tv_sec--;
205: }
206: } while (((temps_ecoule.tv_usec / ((double) 1000000))
207: + temps_ecoule.tv_sec) < (duree / ((double) 1000000)));
208:
209: XtUnrealizeWidget(objet_principal);
210:
211: XmDestroyPixmap(XtScreen(form), pixmap_rpl);
212: XmDestroyPixmap(XtScreen(form), pixmap_rpl_masque);
213:
214: XtDestroyWidget(pixmap);
215: XtDestroyWidget(cadre);
216: XtDestroyWidget(form);
217: XtDestroyWidget(objet_principal);
218:
219: while(XtAppPending(app) == 0)
220: {
221: nanosleep(&attente, NULL);
222: }
223:
224: while(XtAppPending(app) != 0)
225: {
226: XtAppNextEvent(app, &evenement);
227: XtDispatchEvent(&evenement);
228: nanosleep(&attente, NULL);
229: }
230:
231: XtDestroyApplicationContext(app);
232: }
233: # endif
234:
235: return;
236: }
237:
238: // vim: ts=4
CVSweb interface <joel.bertrand@systella.fr>