2 Copyright © 1995-2015, The AROS Development Team. All rights reserved.
9 #define USE_BOOPSI_STUBS
10 #include <utility/tagitem.h>
11 #include <dos/dostags.h>
12 #include <dos/dosextens.h>
13 #include <proto/dos.h>
14 #include <proto/intuition.h>
15 #include <intuition/intuition.h>
16 #include <intuition/gadgetclass.h>
17 #include <intuition/cghooks.h>
18 #include <clib/boopsistubs.h>
19 #include "datatypes_intern.h"
23 struct Message lm_Msg
;
24 struct DataTypesBase
*lm_dtb
;
26 struct Window
*lm_window
;
27 struct gpLayout lm_gplayout
;
28 struct GadgetInfo lm_ginfo
;
32 void AsyncLayouter(void)
34 struct DataTypesBase
*dtb
;
35 struct LayoutMessage
*lm
;
36 struct DTSpecialInfo
*dtsi
;
40 struct Process
*MyProc
= (struct Process
*)FindTask(NULL
);
42 WaitPort(&MyProc
->pr_MsgPort
);
43 lm
= (struct LayoutMessage
*)GetMsg(&MyProc
->pr_MsgPort
);
47 object
= lm
->lm_object
;
48 dtsi
= ((struct Gadget
*)object
)->SpecialInfo
;
50 ObtainSemaphore(&dtsi
->si_Lock
);
52 lm
->lm_gplayout
.MethodID
= DTM_ASYNCLAYOUT
;
56 DoMethodA(object
, (Msg
)&lm
->lm_gplayout
);
58 ObtainSemaphore(&(GPB(dtb
)->dtb_Semaphores
[SEM_ASYNC
]));
59 if (dtsi
->si_Flags
& DTSIF_NEWSIZE
)
61 /* Ensure the method is only called once more unless there's
62 another request to restart it */
63 dtsi
->si_Flags
&= ~DTSIF_NEWSIZE
;
65 /* Ensure Ctrl-C is cleared in case it was set again after the
66 method saw it, or the method finished without seeing it */
67 CheckSignal(SIGBREAKF_CTRL_C
);
72 dtsi
->si_Flags
&= ~DTSIF_LAYOUT
;
73 setattrs((struct Library
*)dtb
, object
, DTA_LayoutProc
, NULL
,
77 ReleaseSemaphore(&(GPB(dtb
)->dtb_Semaphores
[SEM_ASYNC
]));
80 ReleaseSemaphore(&dtsi
->si_Lock
);
82 DoGad_OM_NOTIFY((struct Library
*)dtb
, object
, lm
->lm_window
, NULL
, 0,
83 GA_ID
, (ULONG
)((struct Gadget
*)object
)->GadgetID
,
85 DTA_TopVert
, dtsi
->si_TopVert
,
86 DTA_VisibleVert
, dtsi
->si_VisVert
,
87 DTA_TotalVert
, dtsi
->si_TotVert
,
88 DTA_TopHoriz
, dtsi
->si_TopHoriz
,
89 DTA_VisibleHoriz
, dtsi
->si_VisHoriz
,
90 DTA_TotalHoriz
, dtsi
->si_TotHoriz
,
97 dtsi
->si_Flags
&= ~DTSIF_LAYOUTPROC
;
103 /*****************************************************************************
106 #include <proto/datatypes.h>
108 AROS_LH2(ULONG
, DoAsyncLayout
,
111 AROS_LHA(Object
* , object
, A0
),
112 AROS_LHA(struct gpLayout
*, gpl
, A1
),
115 struct Library
*, DataTypesBase
, 14, DataTypes
)
119 Perform an object's DTM_ASYNCLAYOUT method -- doing it asynchronously
120 off loads the input.device. The method should exit when a SIGBREAK_CTRL_C
121 is received; this signal means that the data is obsolete and the
122 method will be called again.
126 object -- pointer to data type object
127 gpl -- gpLayout message pointer
141 *****************************************************************************/
145 ULONG retval
= FALSE
;
146 struct DTSpecialInfo
*dtsi
=((struct Gadget
*)object
)->SpecialInfo
;
147 struct Process
*LayoutProc
;
149 ObtainSemaphore(&(GPB(DataTypesBase
)->dtb_Semaphores
[SEM_ASYNC
]));
151 if(dtsi
->si_Flags
& DTSIF_LAYOUT
)
153 dtsi
->si_Flags
|= DTSIF_NEWSIZE
;
155 if(GetAttr(DTA_LayoutProc
, object
, (IPTR
*)&LayoutProc
))
157 if(LayoutProc
!= NULL
)
158 Signal((struct Task
*)LayoutProc
, SIGBREAKF_CTRL_C
);
165 struct LayoutMessage
*lm
;
167 dtsi
->si_Flags
|= (DTSIF_LAYOUT
| DTSIF_LAYOUTPROC
);
169 Do_OM_NOTIFY(DataTypesBase
, object
, gpl
->gpl_GInfo
, 0, DTA_Data
, NULL
,
172 if((lm
= AllocVec(sizeof(struct LayoutMessage
),
173 MEMF_PUBLIC
| MEMF_CLEAR
)))
175 struct TagItem Tags
[5];
177 lm
->lm_Msg
.mn_Node
.ln_Type
= NT_MESSAGE
;
178 lm
->lm_Msg
.mn_Length
= sizeof(struct LayoutMessage
);
179 lm
->lm_dtb
= (struct DataTypesBase
*)DataTypesBase
;
180 lm
->lm_object
= object
;
181 lm
->lm_window
= gpl
->gpl_GInfo
->gi_Window
;
182 lm
->lm_gplayout
= *gpl
;
183 lm
->lm_ginfo
= *gpl
->gpl_GInfo
;
184 lm
->lm_gplayout
.gpl_GInfo
= &lm
->lm_ginfo
;
186 Tags
[0].ti_Tag
= NP_StackSize
;
187 Tags
[0].ti_Data
= AROS_STACKSIZE
;
188 Tags
[1].ti_Tag
= NP_Entry
;
189 Tags
[1].ti_Data
= (IPTR
)&AsyncLayouter
;
190 Tags
[2].ti_Tag
= NP_Priority
;
192 Tags
[3].ti_Tag
= NP_Name
;
193 Tags
[3].ti_Data
= (IPTR
)"AsyncLayoutDaemon";
194 Tags
[4].ti_Tag
= TAG_DONE
;
196 if((LayoutProc
= CreateNewProc(Tags
)))
198 PutMsg(&LayoutProc
->pr_MsgPort
, &lm
->lm_Msg
);
200 setattrs(DataTypesBase
, object
, DTA_LayoutProc
, LayoutProc
, TAG_DONE
);
207 if (!retval
) dtsi
->si_Flags
&= ~(DTSIF_LAYOUT
| DTSIF_LAYOUTPROC
);
210 ReleaseSemaphore(&(GPB(DataTypesBase
)->dtb_Semaphores
[SEM_ASYNC
]));
216 } /* DoAsyncLayout */