Added kernel module for starting the usb stack at boot time. It's not activated thoug...
[cake.git] / rom / intuition / changedecorationa.c
blob535e8b42fce3b658490c6084bb6e42a6a451377b
1 /*
2 Copyright 1995-2007, The AROS Development Team. All rights reserved.
3 Copyright 2001-2003, The MorphOS Development Team. All Rights Reserved.
4 $Id$
5 */
7 #include <proto/utility.h>
8 #include <intuition/windecorclass.h>
9 #include <intuition/scrdecorclass.h>
10 #include <intuition/screens.h>
12 #include <proto/dos.h>
14 #include "intuition_intern.h"
15 #include "inputhandler_actions.h"
17 /*****************************************************************************
19 NAME */
20 #include <proto/intuition.h>
22 struct RemoveDecoratorMsg {
23 struct IntuiActionMsg msg;
24 struct NewDecorator *nd;
27 static VOID int_removedecorator(struct RemoveDecoratorMsg *m, struct IntuitionBase *IntuitionBase);
29 AROS_LH2(void, ChangeDecoration,
31 /* SYNOPSIS */
32 AROS_LHA(ULONG, ID, D0),
33 AROS_LHA(struct NewDecorator *, nd, A0),
35 /* LOCATION */
36 struct IntuitionBase *, IntuitionBase, 153, Intuition)
38 /* FUNCTION
39 Setup a new decorator for intuition windows, screens or menus.
41 INPUTS
42 ID - identifier for decorations, see screens.h
43 nd - an ID dependent NewDecorator structure
45 RESULT
46 void - this Function cannot fail,
48 NOTES
49 The function fails if screens are open, use ChangeIntuition() to notify applications that
50 the UI will be changed.
52 EXAMPLE
54 BUGS
56 SEE ALSO
57 intuition/screens.h
59 INTERNALS
61 *****************************************************************************/
63 AROS_LIBFUNC_INIT
65 ObtainSemaphore(&((struct IntIntuitionBase *)(IntuitionBase))->ScrDecorSem);
66 if (ID == DECORATION_SET)
70 /* if the current decorator isnĀ“t used remove it */
72 struct NewDecorator * tnd;
73 tnd = ((struct IntIntuitionBase *)(IntuitionBase))->Decorator;
74 if ((tnd != NULL) && (tnd != nd))
76 if ((tnd->nd_cnt == 0) && (tnd->nd_Port != NULL))
78 struct RemoveDecoratorMsg msg;
79 msg.nd = tnd;
80 DoASyncAction((APTR)int_removedecorator, &msg.msg, sizeof(msg), IntuitionBase);
85 nd->nd_cnt = 0;
87 BOOL global = TRUE;
89 if (nd->nd_Pattern != NULL)
91 nd->nd_IntPattern = AllocVec(strlen(nd->nd_Pattern) * 2 + 1, MEMF_CLEAR);
92 if (nd->nd_IntPattern) {
93 struct DosLibrary *DOSBase;
94 DOSBase = (struct DOSLibrary *)OpenLibrary("dos.library", 40);
95 if (DOSBase)
97 if (ParsePattern(nd->nd_Pattern, nd->nd_IntPattern, strlen(nd->nd_Pattern) * 2 + 1) == -1) {
98 FreeVec(nd->nd_IntPattern);
99 nd->nd_IntPattern = NULL;
101 else global = FALSE;
102 CloseLibrary((struct Library *) DOSBase);
107 Enqueue(&((struct IntIntuitionBase *)(IntuitionBase))->Decorations, (struct Node *)nd);
109 if (global)
111 ((struct IntIntuitionBase *)(IntuitionBase))->Decorator = nd;
112 ((struct IntIntuitionBase *)(IntuitionBase))->WinDecorObj = nd->nd_Window;
113 ((struct IntIntuitionBase *)(IntuitionBase))->MenuDecorObj = nd->nd_Menu;
114 ((struct IntIntuitionBase *)(IntuitionBase))->ScrDecorObj = nd->nd_Screen;
117 ReleaseSemaphore(&((struct IntIntuitionBase *)(IntuitionBase))->ScrDecorSem);
119 AROS_LIBFUNC_EXIT
122 /* This is called on the input.device's context */
124 static VOID int_removedecorator(struct RemoveDecoratorMsg *m,
125 struct IntuitionBase *IntuitionBase)
127 struct DecoratorMessage msg;
128 struct MsgPort *port = CreateMsgPort();
129 if (port)
131 Remove((struct Node *)m->nd);
132 if (m->nd->nd_IntPattern) FreeVec(m->nd->nd_IntPattern);
133 msg.dm_Message.mn_ReplyPort = port;
134 msg.dm_Message.mn_Magic = MAGIC_DECORATOR;
135 msg.dm_Message.mn_Version = DECORATOR_VERSION;
136 msg.dm_Class = DM_CLASS_DESTROYDECORATOR;
137 msg.dm_Code = 0;
138 msg.dm_Flags = 0;
139 msg.dm_Object = (IPTR) m->nd;
140 PutMsg(m->nd->nd_Port, (struct Message *) &msg);
141 WaitPort(port);
142 GetMsg(port);
143 DeleteMsgPort(port);