2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
6 // Opens a PubScreen. The name can be given as argument.
7 // Default name is "MYPUBSCREEN".
9 #include <proto/intuition.h>
10 #include <proto/dos.h>
11 #include <proto/exec.h>
16 struct Screen
*myscreen
;
17 struct Window
*mywindow
;
20 void clean_exit(STRPTR txt
)
22 if (mywindow
) CloseWindow(mywindow
);
23 if (myscreen
) CloseScreen(myscreen
);
24 FreeSignal(signalnum
);
34 int main(int argc
, char **argv
)
37 BOOL closewindow
= FALSE
;
38 ULONG signals
, winsig
, pubsig
;
39 struct IntuiMessage
*message
;
51 if ((signalnum
= AllocSignal(-1)) == -1)
53 clean_exit("Can't allocate signal\n");
59 myscreen
= OpenScreenTags
64 SA_LikeWorkbench
, TRUE
,
71 clean_exit("Can't open screen\n");
77 mywindow
= OpenWindowTags
88 WA_Title
, "Close me to close the screen",
89 WA_IDCMP
, IDCMP_CLOSEWINDOW
,
90 WA_PubScreen
, myscreen
,
96 clean_exit("Can't open window\n");
99 if ((PubScreenStatus(myscreen
, 0) & 1) == 0)
101 clean_exit("Can't make screen public");
104 winsig
= 1L << mywindow
->UserPort
->mp_SigBit
;
105 pubsig
= 1L << signalnum
;
109 signals
= Wait(winsig
| pubsig
);
111 if (mywindow
&& (signals
& winsig
))
113 while (NULL
!= (message
= (struct IntuiMessage
*)GetMsg(mywindow
->UserPort
)))
115 if (message
->Class
== IDCMP_CLOSEWINDOW
)
119 ReplyMsg((struct Message
*)message
);
122 if (signals
& pubsig
)
124 if (PubScreenStatus(myscreen
, PSNF_PRIVATE
) & 1)
130 PutStr("Failed to make screen private\n");
136 if (mywindow
) CloseWindow(mywindow
);