revert between 56095 -> 55830 in arch
[AROS.git] / rom / intuition / screennotifytask.c
blobba997d362288261d9aa9ef6a8a763b6b51157b6f
1 /*
2 Copyright 1995-2017, 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 = CreateMsgPort()))
36 success = TRUE;
37 } /* if ((mem = AllocMem(sizeof(struct MsgPort), MEMF_PUBLIC | MEMF_CLEAR))) */
39 if (success)
41 taskparams->ScreennotifyHandlerPort = port;
42 taskparams->success = TRUE;
45 Signal(taskparams->Caller, SIGF_INTUITION);
47 if (!success)
49 D(bug("DefaultScreennotifyHandler: initialization failed. waiting for parent task to kill me.\n"));
50 Wait(0);
53 D(bug("DefaultScreennotifyHandler: initialization ok. Now waiting for messages from Intuition.\n"));
55 for(;;)
57 struct ScreenNotifyMessage *msg;
59 WaitPort(port);
60 while((msg = (struct ScreenNotifyMessage *) GetMsg(port)))
62 FreeMem((APTR) msg, sizeof(struct ScreenNotifyMessage));
63 } /* while((msg = (struct ScreenNotifyMessage *)GetMsg(port))) */
65 } /* for(;;) */
67 /* should never reach here but just incase.. */
68 if (port)
69 DeleteMsgPort(port);
72 /**************************************************************************************************/
74 /*******************************
75 ** InitDefaultScreennotifyHandler() **
76 *******************************/
77 BOOL InitDefaultScreennotifyHandler(struct IntuitionBase *IntuitionBase)
79 struct ScreennotifyTaskParams params;
80 struct Task *task;
81 BOOL result = FALSE;
83 params.intuitionBase = IntuitionBase;
84 params.Caller = FindTask(NULL);
85 params.success = FALSE;
87 SetSignal(0, SIGF_INTUITION);
89 task = NewCreateTask(TASKTAG_NAME , SCREENNOTIFYTASK_NAME,
90 TASKTAG_PRI , SCREENNOTIFYTASK_PRIORITY,
91 TASKTAG_STACKSIZE, SCREENNOTIFYTASK_STACKSIZE,
92 TASKTAG_PC , DefaultScreennotifyHandler,
93 TASKTAG_ARG1 , &params,
94 TAG_DONE);
96 if (task)
98 Wait(SIGF_INTUITION);
100 if (params.success)
102 result = TRUE;
103 GetPrivIBase(IntuitionBase)->ScreenNotifyReplyPort = params.ScreennotifyHandlerPort;
105 else
107 RemTask(task);
110 } /* if ((task = CreateScreennotifyHandlerTask(&params, IntuitionBase))) */
112 return result;