2 Copyright 1995-2011, The AROS Development Team. All rights reserved.
6 #include <proto/exec.h>
7 #include <proto/intuition.h>
8 #include <proto/alib.h>
9 #include <proto/layers.h>
10 #include <exec/memory.h>
11 #include <exec/alerts.h>
12 #include <exec/interrupts.h>
13 #include <exec/ports.h>
14 #include <intuition/intuition.h>
15 #include <intuition/intuitionbase.h>
16 #include "intuition_intern.h"
18 #include "screennotifytask.h"
22 #include <aros/debug.h>
24 /**************************************************************************************************/
26 /***************************
27 ** DefaultScreennotifyHandler() **
28 ***************************/
29 void DefaultScreennotifyHandler(struct ScreennotifyTaskParams
*taskparams
)
31 struct MsgPort
*port
= NULL
;
34 if ((port
= AllocMem(sizeof(struct MsgPort
), MEMF_PUBLIC
| MEMF_CLEAR
)))
36 port
->mp_Node
.ln_Type
= NT_MSGPORT
;
37 port
->mp_Flags
= PA_SIGNAL
;
38 port
->mp_SigBit
= AllocSignal(-1);
39 port
->mp_SigTask
= FindTask(0);
40 NEWLIST(&port
->mp_MsgList
);
44 } /* if ((mem = AllocMem(sizeof(struct MsgPort), MEMF_PUBLIC | MEMF_CLEAR))) */
48 taskparams
->ScreennotifyHandlerPort
= port
;
49 taskparams
->success
= TRUE
;
52 Signal(taskparams
->Caller
, SIGF_INTUITION
);
56 D(bug("DefaultScreennotifyHandler: initialization failed. waiting for parent task to kill me.\n"));
60 D(bug("DefaultScreennotifyHandler: initialization ok. Now waiting for messages from Intuition.\n"));
64 struct ScreenNotifyMessage
*msg
;
67 while((msg
= (struct ScreenNotifyMessage
*) GetMsg(port
)))
69 FreeMem((APTR
) msg
, sizeof(struct ScreenNotifyMessage
));
70 } /* while((msg = (struct ScreenNotifyMessage *)GetMsg(port))) */
75 /**************************************************************************************************/
77 /*******************************
78 ** InitDefaultScreennotifyHandler() **
79 *******************************/
80 BOOL
InitDefaultScreennotifyHandler(struct IntuitionBase
*IntuitionBase
)
82 struct ScreennotifyTaskParams params
;
86 params
.intuitionBase
= IntuitionBase
;
87 params
.Caller
= FindTask(NULL
);
88 params
.success
= FALSE
;
90 SetSignal(0, SIGF_INTUITION
);
92 task
= NewCreateTask(TASKTAG_NAME
, SCREENNOTIFYTASK_NAME
,
93 TASKTAG_PRI
, SCREENNOTIFYTASK_PRIORITY
,
94 TASKTAG_STACKSIZE
, SCREENNOTIFYTASK_STACKSIZE
,
95 TASKTAG_PC
, DefaultScreennotifyHandler
,
96 TASKTAG_ARG1
, ¶ms
,
101 Wait(SIGF_INTUITION
);
106 GetPrivIBase(IntuitionBase
)->ScreenNotifyReplyPort
= params
.ScreennotifyHandlerPort
;
113 } /* if ((task = CreateScreennotifyHandlerTask(¶ms, IntuitionBase))) */