disable changefrequency code temporarily since it is leaving the controller in an...
[AROS.git] / test / pubscreen.c
blob86acf8c34ccc04ae78fb431c4def9acb61ecc6ed
1 // Opens a PubScreen. The name can be given as argument.
2 // Default name is "MYPUBSCREEN".
4 #include <proto/intuition.h>
5 #include <proto/dos.h>
6 #include <proto/exec.h>
8 #include <stdlib.h>
9 #include <stdio.h>
11 struct Screen *myscreen;
12 struct Window *mywindow;
13 BYTE signalnum;
15 void clean_exit(STRPTR txt)
17 if (mywindow) CloseWindow(mywindow);
18 if (myscreen) CloseScreen(myscreen);
19 FreeSignal(signalnum);
21 if (txt)
23 PutStr(txt);
24 exit(RETURN_FAIL);
26 exit(RETURN_OK);
29 int main(int argc, char **argv)
31 BOOL done = FALSE;
32 BOOL closewindow = FALSE;
33 ULONG signals, winsig, pubsig;
34 struct IntuiMessage *message;
35 char *name;
37 if (argc == 2)
39 name = argv[1];
41 else
43 name = "MYPUBSCREEN";
46 if ((signalnum = AllocSignal(-1)) == -1)
48 clean_exit("Can't allocate signal\n");
54 myscreen = OpenScreenTags
56 NULL,
57 SA_PubName, name,
58 SA_PubSig, signalnum,
59 SA_LikeWorkbench, TRUE,
60 SA_Title, name,
61 TAG_DONE
63 ) == NULL
66 clean_exit("Can't open screen\n");
72 mywindow = OpenWindowTags
74 NULL,
75 WA_Left, 30,
76 WA_Top, 30,
77 WA_Width, 250,
78 WA_Height, 100,
79 WA_DragBar, TRUE,
80 WA_DepthGadget, TRUE,
81 WA_CloseGadget, TRUE,
82 WA_Activate, TRUE,
83 WA_Title, "Close me to close the screen",
84 WA_IDCMP, IDCMP_CLOSEWINDOW,
85 WA_PubScreen, myscreen,
86 TAG_DONE
88 ) == NULL
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;
102 while (!done)
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)
112 closewindow = TRUE;
114 ReplyMsg((struct Message *)message);
117 if (signals & pubsig)
119 if (PubScreenStatus(myscreen, PSNF_PRIVATE) & 1)
121 done = TRUE;
123 else
125 PutStr("Failed to make screen private\n");
129 if (closewindow)
131 if (mywindow) CloseWindow(mywindow);
132 winsig = 0;
133 mywindow = NULL;
134 closewindow = FALSE;
138 clean_exit(NULL);
139 return 0;