Register nameservers dynamically instead of writing them to disk. It is
[AROS.git] / rom / intuition / changedecorationa.c
blobffca01378f5d4bde6a9c58fc025eb945487ea9d6
1 /*
2 Copyright 1995-2011, 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 struct RemoveDecoratorMsg
19 struct IntuiActionMsg msg;
20 struct NewDecorator *nd;
23 static VOID int_removedecorator(struct RemoveDecoratorMsg *m, struct IntuitionBase *IntuitionBase);
25 /*****************************************************************************
27 NAME */
28 #include <proto/intuition.h>
30 AROS_LH2(void, ChangeDecoration,
32 /* SYNOPSIS */
33 AROS_LHA(ULONG, ID, D0),
34 AROS_LHA(struct NewDecorator *, nd, A0),
36 /* LOCATION */
37 struct IntuitionBase *, IntuitionBase, 152, Intuition)
39 /* FUNCTION
40 Setup a new decorator for intuition windows, screens or menus.
42 INPUTS
43 ID - identifier for decorations, see screens.h
44 nd - an ID dependent NewDecorator structure
46 RESULT
47 void - this Function cannot fail,
49 NOTES
50 The function fails if screens are open, use ChangeIntuition() to notify applications that
51 the UI will be changed.
53 This function is private and AROS-specific. Do not use it in regular applications.
55 EXAMPLE
57 BUGS
59 SEE ALSO
60 intuition/screens.h
62 INTERNALS
64 *****************************************************************************/
66 AROS_LIBFUNC_INIT
68 ObtainSemaphore(&((struct IntIntuitionBase *)(IntuitionBase))->ScrDecorSem);
69 if (ID == DECORATION_SET)
73 /* if the current decorator isnĀ“t used remove it */
75 struct NewDecorator * tnd;
76 tnd = ((struct IntIntuitionBase *)(IntuitionBase))->Decorator;
77 if ((tnd != NULL) && (tnd != nd))
79 if ((tnd->nd_cnt == 0) && (tnd->nd_Port != NULL))
81 struct RemoveDecoratorMsg msg;
82 msg.nd = tnd;
83 DoASyncAction((APTR)int_removedecorator, &msg.msg, sizeof(msg), IntuitionBase);
88 nd->nd_cnt = 0;
90 BOOL global = TRUE;
92 if (nd->nd_Pattern != NULL)
94 nd->nd_IntPattern = AllocVec(strlen(nd->nd_Pattern) * 2 + 1, MEMF_CLEAR);
95 if (nd->nd_IntPattern)
97 struct DosLibrary *DOSBase = GetPrivIBase(IntuitionBase)->DOSBase;
98 if (!DOSBase)
99 GetPrivIBase(IntuitionBase)->DOSBase = DOSBase = (struct DosLibrary *)OpenLibrary("dos.library", 36);
101 if (DOSBase)
103 if (ParsePattern(nd->nd_Pattern, nd->nd_IntPattern, strlen(nd->nd_Pattern) * 2 + 1) == -1)
105 FreeVec(nd->nd_IntPattern);
106 nd->nd_IntPattern = NULL;
108 else
109 global = FALSE;
114 Enqueue(&((struct IntIntuitionBase *)(IntuitionBase))->Decorations, (struct Node *)nd);
116 if (global)
118 ((struct IntIntuitionBase *)(IntuitionBase))->Decorator = nd;
119 ((struct IntIntuitionBase *)(IntuitionBase))->WinDecorObj = nd->nd_Window;
120 ((struct IntIntuitionBase *)(IntuitionBase))->MenuDecorObj = nd->nd_Menu;
121 ((struct IntIntuitionBase *)(IntuitionBase))->ScrDecorObj = nd->nd_Screen;
124 ReleaseSemaphore(&((struct IntIntuitionBase *)(IntuitionBase))->ScrDecorSem);
126 AROS_LIBFUNC_EXIT
129 /* This is called on the input.device's context */
131 static VOID int_removedecorator(struct RemoveDecoratorMsg *m,
132 struct IntuitionBase *IntuitionBase)
134 struct DecoratorMessage msg;
135 struct MsgPort *port = CreateMsgPort();
136 if (port)
138 Remove((struct Node *)m->nd);
139 if (m->nd->nd_IntPattern) FreeVec(m->nd->nd_IntPattern);
140 msg.dm_Message.mn_ReplyPort = port;
141 msg.dm_Message.mn_Magic = MAGIC_DECORATOR;
142 msg.dm_Message.mn_Version = DECORATOR_VERSION;
143 msg.dm_Class = DM_CLASS_DESTROYDECORATOR;
144 msg.dm_Code = 0;
145 msg.dm_Flags = 0;
146 msg.dm_Object = (IPTR) m->nd;
147 PutMsg(m->nd->nd_Port, (struct Message *) &msg);
148 WaitPort(port);
149 GetMsg(port);
150 DeleteMsgPort(port);