1 #include <proto/intuition.h>
3 #include <proto/exec.h>
8 struct Screen
*myscreen
;
9 struct Window
*mywindow
;
12 void clean_exit(STRPTR txt
)
14 if (mywindow
) CloseWindow(mywindow
);
15 if (myscreen
) CloseScreen(myscreen
);
16 FreeSignal(signalnum
);
29 BOOL closewindow
= FALSE
;
30 ULONG signals
, winsig
, pubsig
;
31 struct IntuiMessage
*message
;
33 if ((signalnum
= AllocSignal(-1)) == -1)
35 clean_exit("Can't allocate signal\n");
41 myscreen
= OpenScreenTags
44 SA_PubName
, "MYPUBSCREEN",
46 SA_LikeWorkbench
, TRUE
,
47 SA_Title
, "Pubscreenname: MYPUBSCREEN",
53 clean_exit("Can't open screen\n");
59 mywindow
= OpenWindowTags
70 WA_Title
, "Close me to close the screen",
71 WA_IDCMP
, IDCMP_CLOSEWINDOW
,
72 WA_PubScreen
, myscreen
,
78 clean_exit("Can't open window\n");
81 if ((PubScreenStatus(myscreen
, 0) & 1) == 0)
83 clean_exit("Can't make screen public");
86 winsig
= 1L << mywindow
->UserPort
->mp_SigBit
;
87 pubsig
= 1L << signalnum
;
91 signals
= Wait(winsig
| pubsig
);
93 if (mywindow
&& (signals
& winsig
))
95 while (NULL
!= (message
= (struct IntuiMessage
*)GetMsg(mywindow
->UserPort
)))
97 if (message
->Class
== IDCMP_CLOSEWINDOW
)
101 ReplyMsg((struct Message
*)message
);
104 if (signals
& pubsig
)
106 if (PubScreenStatus(myscreen
, PSNF_PRIVATE
) & 1)
112 PutStr("Failed to make screen private\n");
118 if (mywindow
) CloseWindow(mywindow
);