6 #include <exec/types.h>
7 #include <graphics/rastport.h>
8 #include <utility/hooks.h>
12 #include <proto/exec.h>
13 #include <proto/intuition.h>
15 #include <proto/scalos.h>
16 #include <clib/alib_protos.h>
19 #include <scalos/scalos.h>
21 #include "scalos_structures.h"
22 #include "functions.h"
23 #include "Variables.h"
25 //----------------------------------------------------------------------------
27 // local data structures
31 struct internalScaWindowTask
*pod_ParentWindowTask
;
32 struct DragHandle
*pod_DragHandle
;
35 //----------------------------------------------------------------------------
39 static SAVEDS(ULONG
) PopOpenProcess(struct PopOpenData
*sMsg
, struct SM_RunProcess
*msg
);
41 //----------------------------------------------------------------------------
43 void PopOpenWindow(struct internalScaWindowTask
*iwt
, struct DragHandle
*dh
)
45 struct ScaPopChildWindow
*spcw
= NULL
;
48 struct PopOpenData pod
;
50 pod
.pod_ParentWindowTask
= iwt
;
51 pod
.pod_DragHandle
= dh
;
53 if (iwt
->iwt_CloseWindow
)
56 spcw
= ScalosAlloc(sizeof(struct ScaPopChildWindow
));
60 d1(KPrintF("%s/%s/%ld: before SuspendDrag\n", __FILE__
, __FUNC__
, __LINE__
));
61 d1(KPrintF("%s/%s/%ld: Task=%08lx <%s>\n", __FILE__
, __FUNC__
, __LINE__
, FindTask(NULL
), FindTask(NULL
)->tc_Node
.ln_Name
));
63 spcw
->spcw_DragHandle
= dh
;
64 spcw
->spcw_WasLocked
= SuspendDrag(dh
, iwt
);
65 spcw
->spcw_DestWindowTask
= dh
->drgh_PopOpenDestWindow
;
67 spcw
->spcw_EventHandle
= (APTR
) DoMethod(spcw
->spcw_DestWindowTask
->iwt_WindowTask
.mt_MainObject
,
69 SCCM_WindowStartComplete
,
70 iwt
->iwt_WindowTask
.wt_IconPort
,
72 d1(KPrintF("%s/%s/%ld: spcw_EventHandle=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, spcw
->spcw_EventHandle
));
73 if (NULL
== spcw
->spcw_EventHandle
)
76 ScalosObtainSemaphore(&iwt
->iwt_PopChildListSemaphore
);
77 AddTail(&iwt
->iwt_PopChildList
, &spcw
->spcw_Node
);
79 ScalosReleaseSemaphore(&iwt
->iwt_PopChildListSemaphore
);
81 DoMethod(dh
->drgh_PopOpenDestWindow
->iwt_WindowTask
.mt_MainObject
,
86 dh
->drgh_PopOpenDestWindow
->iwt_WindowTask
.wt_IconPort
);
90 PopChildWindowDispose(iwt
, spcw
);
93 //----------------------------------------------------------------------------
95 void PopChildWindowDispose(struct internalScaWindowTask
*iwt
, struct ScaPopChildWindow
*spcw
)
97 d1(KPrintF("%s/%s/%ld: START iwt=%08lx spcw=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, spcw
));
101 d1(KPrintF("%s/%s/%ld: spcw_EventHandle=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, spcw
->spcw_EventHandle
));
102 if (spcw
->spcw_EventHandle
)
104 DoMethod(spcw
->spcw_DestWindowTask
->iwt_WindowTask
.mt_MainObject
,
106 spcw
->spcw_EventHandle
);
108 d1(KPrintF("%s/%s/%ld: spcw_WasLocked=%ld\n", __FILE__
, __FUNC__
, __LINE__
, spcw
->spcw_WasLocked
));
109 if (spcw
->spcw_WasLocked
)
111 d1(KPrintF("%s/%s/%ld: xii_GlobalDragHandle=%08lx spcw_DragHandle=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iInfos
.xii_GlobalDragHandle
, spcw
->spcw_DragHandle
));
113 if (iInfos
.xii_GlobalDragHandle
!= spcw
->spcw_DragHandle
)
114 spcw
->spcw_DragHandle
= NULL
;
116 ResumeDrag(spcw
->spcw_DragHandle
, iwt
, spcw
->spcw_WasLocked
);
121 d1(KPrintF("%s/%s/%ld: END iwt=%08lx spcw=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, spcw
));
124 //----------------------------------------------------------------------------
126 static SAVEDS(ULONG
) PopOpenProcess(struct PopOpenData
*pod
, struct SM_RunProcess
*msg
)
129 d1(KPrintF("%s/%s/%ld: START\n", __FILE__
, __FUNC__
, __LINE__
));
134 d1(KPrintF("%s/%s/%ld: before SCCM_AddListener\n", __FILE__
, __FUNC__
, __LINE__
));
136 Success
= DoMethod(pod
->pod_DragHandle
->drgh_PopOpenDestWindow
->iwt_WindowTask
.mt_MainObject
,
138 pod
->pod_DragHandle
->drgh_PopOpenIcon
,
139 ICONWINOPENF_DoNotActivateWindow
| ICONWINOPENF_NewWindow
140 | ICONWINOPENF_IgnoreFileTypes
| ICONWINOPENF_DdPopupWindow
);
142 d1(KPrintF("%s/%s/%ld: Success=%ld\n", __FILE__
, __FUNC__
, __LINE__
, Success
));
147 d1(KPrintF("%s/%s/%ld: END\n", __FILE__
, __FUNC__
, __LINE__
));
152 //----------------------------------------------------------------------------
154 // If CloseAll is FALSE, window under mouse pointer will not be closed
155 // If CloseAll is TRUE, all popup windows are closed
157 void ClosePopupWindows(BOOL CloseAll
)
159 struct ScaWindowStruct
*ws
, *wsNext
;
160 struct internalScaWindowTask
*iwtUnderMouse
;
161 struct ScaIconNode
*in
;
162 struct ScaIconNode
*inOuterBounds
;
163 struct Window
*foreignWin
;
165 d1(kprintf("%s/%s/%ld: START CloseAll=%ld\n", __FILE__
, __FUNC__
, __LINE__
, CloseAll
));
167 QueryObjectUnderPointer(&iwtUnderMouse
, &in
, &inOuterBounds
, &foreignWin
);
169 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
171 // Close all windows that have popped up during D&D
172 if (NULL
== iwtUnderMouse
)
174 SCA_LockWindowList(SCA_LockWindowList_Exclusiv
);
179 ScalosUnLockIconList(iwtUnderMouse
);
182 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
184 for (ws
= winlist
.wl_WindowStruct
; ws
; ws
= wsNext
)
186 wsNext
= (struct ScaWindowStruct
*) ws
->ws_Node
.mln_Succ
;
188 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
190 if ((CloseAll
|| (NULL
== iwtUnderMouse
) || (ws
!= iwtUnderMouse
->iwt_WindowTask
.mt_WindowStruct
)) && (ws
->ws_Flags
& WSV_FlagF_DdPopupWindow
))
192 struct SM_CloseWindow
*msg
;
194 msg
= (struct SM_CloseWindow
*) SCA_AllocMessage(MTYP_CloseWindow
, 0);
197 msg
->ScalosMessage
.sm_Message
.mn_ReplyPort
= iInfos
.xii_iinfos
.ii_MainMsgPort
;
198 PutMsg(ws
->ws_MessagePort
, &msg
->ScalosMessage
.sm_Message
);
201 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
204 SCA_UnLockWindowList();
206 d1(kprintf("%s/%s/%ld: END\n", __FILE__
, __FUNC__
, __LINE__
));
209 //----------------------------------------------------------------------------