Minor fixes to comments.
[AROS.git] / rom / intuition / screennotifytask.c
blob43032a15ac3eef81ea8631f5271c919b8cbe42eb
1 /*
2 Copyright 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
4 */
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"
20 #undef DEBUG
21 #define DEBUG 0
22 #include <aros/debug.h>
24 /**************************************************************************************************/
26 /***************************
27 ** DefaultScreennotifyHandler() **
28 ***************************/
29 void DefaultScreennotifyHandler(struct ScreennotifyTaskParams *taskparams)
31 struct MsgPort *port = NULL;
32 BOOL success = FALSE;
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);
42 success = TRUE;
44 } /* if ((mem = AllocMem(sizeof(struct MsgPort), MEMF_PUBLIC | MEMF_CLEAR))) */
46 if (success)
48 taskparams->ScreennotifyHandlerPort = port;
49 taskparams->success = TRUE;
52 Signal(taskparams->Caller, SIGF_INTUITION);
54 if (!success)
56 D(bug("DefaultScreennotifyHandler: initialization failed. waiting for parent task to kill me.\n"));
57 Wait(0);
60 D(bug("DefaultScreennotifyHandler: initialization ok. Now waiting for messages from Intuition.\n"));
62 for(;;)
64 struct ScreenNotifyMessage *msg;
66 WaitPort(port);
67 while((msg = (struct ScreenNotifyMessage *) GetMsg(port)))
69 FreeMem((APTR) msg, sizeof(struct ScreenNotifyMessage));
70 } /* while((msg = (struct ScreenNotifyMessage *)GetMsg(port))) */
72 } /* for(;;) */
75 /**************************************************************************************************/
77 /*******************************
78 ** InitDefaultScreennotifyHandler() **
79 *******************************/
80 BOOL InitDefaultScreennotifyHandler(struct IntuitionBase *IntuitionBase)
82 struct ScreennotifyTaskParams params;
83 struct Task *task;
84 BOOL result = FALSE;
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 , &params,
97 TAG_DONE);
99 if (task)
101 Wait(SIGF_INTUITION);
103 if (params.success)
105 result = TRUE;
106 GetPrivIBase(IntuitionBase)->ScreenNotifyReplyPort = params.ScreennotifyHandlerPort;
108 else
110 RemTask(task);
113 } /* if ((task = CreateScreennotifyHandlerTask(&params, IntuitionBase))) */
115 return result;