forcing device into host mode requires a full config - which we will do in opendevice...
[AROS.git] / rom / intuition / changedecorationa.c
blob594e8ca5a8260ba24f4b3f5442d6ac5a3b39d3f1
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)
72 /* if the current decorator isnĀ“t used remove it */
74 struct NewDecorator * tnd;
75 tnd = ((struct IntIntuitionBase *)(IntuitionBase))->Decorator;
76 if ((tnd != NULL) && (tnd != nd))
78 if ((tnd->nd_cnt == 0) && (tnd->nd_Port != NULL))
80 struct RemoveDecoratorMsg msg;
81 msg.nd = tnd;
82 DoASyncAction((APTR)int_removedecorator, &msg.msg, sizeof(msg), IntuitionBase);
87 nd->nd_cnt = 0;
89 BOOL global = TRUE;
91 if (nd->nd_Pattern != NULL)
93 nd->nd_IntPattern = AllocVec(strlen(nd->nd_Pattern) * 2 + 1, MEMF_CLEAR);
94 if (nd->nd_IntPattern)
96 struct DosLibrary *DOSBase = GetPrivIBase(IntuitionBase)->DOSBase;
97 if (!DOSBase)
98 GetPrivIBase(IntuitionBase)->DOSBase = DOSBase = (struct DosLibrary *)OpenLibrary("dos.library", 36);
100 if (DOSBase)
102 if (ParsePattern(nd->nd_Pattern, nd->nd_IntPattern, strlen(nd->nd_Pattern) * 2 + 1) == -1)
104 FreeVec(nd->nd_IntPattern);
105 nd->nd_IntPattern = NULL;
107 else
108 global = FALSE;
113 nd->nd_ScreenObjOffset = ((IPTR) ( (char *)&((struct IntScreen *)0)->ScrDecorObj - (char *)0 ));
114 nd->nd_ScreenMenuObjOffset = ((IPTR) ( (char *)&((struct IntScreen *)0)->MenuDecorObj - (char *)0 ));
115 nd->nd_ScreenWindowObjOffset = ((IPTR) ( (char *)&((struct IntScreen *)0)->WinDecorObj - (char *)0 ));
117 bug("intuition.decor: offsets titleobj = %d, menuobj = %d, winobj = %d\n", nd->nd_ScreenObjOffset, nd->nd_ScreenMenuObjOffset, nd->nd_ScreenWindowObjOffset);
118 Enqueue(&((struct IntIntuitionBase *)(IntuitionBase))->Decorations, (struct Node *)nd);
120 if (global)
122 ((struct IntIntuitionBase *)(IntuitionBase))->Decorator = nd;
123 ((struct IntIntuitionBase *)(IntuitionBase))->ScrDecorClass = nd->nd_ScreenClass;
124 ((struct IntIntuitionBase *)(IntuitionBase))->ScrDecorTags = nd->nd_ScreenTags;
125 ((struct IntIntuitionBase *)(IntuitionBase))->MenuDecorClass = nd->nd_MenuClass;
126 ((struct IntIntuitionBase *)(IntuitionBase))->MenuDecorTags = nd->nd_MenuTags;
127 ((struct IntIntuitionBase *)(IntuitionBase))->WinDecorClass = nd->nd_WindowClass;
128 ((struct IntIntuitionBase *)(IntuitionBase))->WinDecorTags = nd->nd_WindowTags;
131 ReleaseSemaphore(&((struct IntIntuitionBase *)(IntuitionBase))->ScrDecorSem);
133 AROS_LIBFUNC_EXIT
136 /* This is called on the input.device's context */
138 static VOID int_removedecorator(struct RemoveDecoratorMsg *m,
139 struct IntuitionBase *IntuitionBase)
141 struct DecoratorMessage msg;
142 struct MsgPort *port = CreateMsgPort();
143 if (port)
145 Remove((struct Node *)m->nd);
146 if (m->nd->nd_IntPattern) FreeVec(m->nd->nd_IntPattern);
147 msg.dm_Message.mn_ReplyPort = port;
148 msg.dm_Message.mn_Magic = MAGIC_DECORATOR;
149 msg.dm_Message.mn_Version = DECORATOR_VERSION;
150 msg.dm_Class = DM_CLASS_DESTROYDECORATOR;
151 msg.dm_Code = 0;
152 msg.dm_Flags = 0;
153 msg.dm_Object = (IPTR) m->nd;
154 PutMsg(m->nd->nd_Port, (struct Message *) &msg);
155 WaitPort(port);
156 GetMsg(port);
157 DeleteMsgPort(port);