1 // Opens a PubScreen. The name can be given as argument.
2 // Default name is "MYPUBSCREEN".
4 #include <proto/intuition.h>
6 #include <proto/exec.h>
11 struct Screen
*myscreen
;
12 struct Window
*mywindow
;
15 void clean_exit(STRPTR txt
)
17 if (mywindow
) CloseWindow(mywindow
);
18 if (myscreen
) CloseScreen(myscreen
);
19 FreeSignal(signalnum
);
29 int main(int argc
, char **argv
)
32 BOOL closewindow
= FALSE
;
33 ULONG signals
, winsig
, pubsig
;
34 struct IntuiMessage
*message
;
46 if ((signalnum
= AllocSignal(-1)) == -1)
48 clean_exit("Can't allocate signal\n");
54 myscreen
= OpenScreenTags
59 SA_LikeWorkbench
, TRUE
,
66 clean_exit("Can't open screen\n");
72 mywindow
= OpenWindowTags
83 WA_Title
, "Close me to close the screen",
84 WA_IDCMP
, IDCMP_CLOSEWINDOW
,
85 WA_PubScreen
, myscreen
,
91 clean_exit("Can't open window\n");
94 if ((PubScreenStatus(myscreen
, 0) & 1) == 0)
96 clean_exit("Can't make screen public");
99 winsig
= 1L << mywindow
->UserPort
->mp_SigBit
;
100 pubsig
= 1L << signalnum
;
104 signals
= Wait(winsig
| pubsig
);
106 if (mywindow
&& (signals
& winsig
))
108 while (NULL
!= (message
= (struct IntuiMessage
*)GetMsg(mywindow
->UserPort
)))
110 if (message
->Class
== IDCMP_CLOSEWINDOW
)
114 ReplyMsg((struct Message
*)message
);
117 if (signals
& pubsig
)
119 if (PubScreenStatus(myscreen
, PSNF_PRIVATE
) & 1)
125 PutStr("Failed to make screen private\n");
131 if (mywindow
) CloseWindow(mywindow
);