2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
6 #include <proto/exec.h>
7 #include <proto/intuition.h>
8 #include <proto/arossupport.h>
9 #include <proto/alib.h>
11 #include <exec/memory.h>
12 #include <exec/tasks.h>
13 #include <exec/ports.h>
19 // #include <oop/oop.h>
21 /* Hack: prevent hidd/graphics.h from beeing included */
22 // #include "graphics_internal.h"
25 VOID
activescreen_taskentry();
27 struct activescreen_msg
{
28 struct Message message
;
33 static struct Task
*activescreen_task
= NULL
;
34 static struct Task
*parent_task
= NULL
;
35 static struct MsgPort
*activescreen_msgport
= NULL
;
37 static ULONG oksig
= SIGBREAKF_CTRL_E
;
38 static ULONG failsig
= SIGBREAKF_CTRL_D
;
39 static ULONG killsig
= SIGBREAKF_CTRL_C
;
41 static struct ExecBase
*sysbase
= NULL
;
44 static BOOL
send_activescreen_msg( Object
*bmobj
, struct ExecBase
*SysBase
)
46 /* Allocate a new message */
47 struct activescreen_msg
*msg
;
49 msg
= AllocMem(sizeof (*msg
), MEMF_PUBLIC
| MEMF_CLEAR
);
54 PutMsg(activescreen_msgport
, (struct Message
*)msg
);
60 VOID
activatebm_callback(APTR data
, OOP_Object
*bmobj
, BOOL activated
)
63 struct GfxBase
*GfxBase
;
65 GfxBase
= (struct GfxBase
*)data
;
70 /* We must send it to some task that can handle this.
71 We should NOT use LockIBase() inside here, since we might
72 have locked layers also. So we instead send it to some othe task
75 if (!send_activescreen_msg(bmobj
, SysBase
)) {
76 kprintf("!!! activatebm_callback: Could not send activatescreen message !!!!\n");
83 BOOL
init_activescreen_stuff(struct GfxBase
*GfxBase
)
89 kprintf("init_activescreen_stuff\n");
91 parent_task
= FindTask(NULL
);
94 activescreen_task
= CreateTask("Active screen updating task"
96 , activescreen_taskentry
100 if (NULL
!= activescreen_task
) {
103 kprintf("Task created\n");
105 sigs
= Wait(oksig
| failsig
);
106 kprintf("Got sig: %d\n", sigs
);
116 VOID
cleanup_activescreen_stuff(struct GfxBase
*GfxBase
)
118 /* Kill the task. Note that this
119 may cause race condition problems
120 if some task continues to send messages to the task
122 Signal(activescreen_task
, killsig
);
127 #define SysBase sysbase
129 VOID
activescreen_taskentry()
131 /* Create the msg port */
132 struct IntuitionBase
*IntuitionBase
= NULL
;
135 activescreen_msgport
= CreateMsgPort();
136 if (NULL
!= activescreen_msgport
) {
137 IntuitionBase
= (struct IntuitionBase
*)OpenLibrary("intuition.library", 0);
138 if (NULL
!= IntuitionBase
) {
141 kprintf("activescreen_task: Could not open intuition\n");
144 kprintf("activescreen_task: Could not create msgport\n");
148 /* Signal failure to the creating task */
149 Signal(parent_task
, failsig
);
155 Signal(parent_task
, oksig
);
157 portsig
= 1L << activescreen_msgport
->mp_SigBit
;
159 /* Go into endeless loop handling the messages */
162 struct activescreen_msg
*msg
;
166 if ((msg
= (struct activescreen_msg
*)GetMsg(activescreen_msgport
))) {
169 /* Handle the message. Go through the screen list
170 and find the screen that uses the supplied HIDD bitmap
175 for (scr
= IntuitionBase
->FirstScreen
; NULL
!= scr
; scr
= scr
->NextScreen
) {
177 /* Get the hidd object */
178 if (msg
->bmobj
== HIDD_BM_OBJ(scr
->RastPort
.BitMap
)) {
180 kprintf("Active screen found: %s\n", scr
->Title
);
182 IntuitionBase
->ActiveScreen
= scr
;
189 /* We do not reply the message, but instead free it here. */
190 FreeMem(msg
, sizeof (*msg
));
193 sigs
= Wait(portsig
| killsig
);
195 if (sigs
& killsig
) {
196 /* Get outstanding messages */
197 while ((msg
= (struct activescreen_msg
*)GetMsg(activescreen_msgport
)))
198 FreeMem(msg
, sizeof (*msg
));
206 if (NULL
!= IntuitionBase
)
207 CloseLibrary((struct Library
*)IntuitionBase
);
209 if (NULL
!= activescreen_msgport
)
210 DeleteMsgPort(activescreen_msgport
);