Changeset 21556 for trunk/src/user32/pmwindow.cpp
- Timestamp:
- Jan 12, 2011, 4:13:08 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/pmwindow.cpp
r21543 r21556 1110 1110 dprintf(("OS2: DM_DRAGOVER %x (%d,%d)", win32wnd->getWindowHandle(), sxDrop, syDrop)); 1111 1111 1112 if(fDragDropDisabled) { 1112 /* Get access to the DRAGINFO data structure */ 1113 if(!DrgAccessDraginfo(pDragInfo)) { 1113 1114 rc = (MRFROM2SHORT (DOR_NEVERDROP, 0)); 1114 1115 break; 1115 1116 } 1116 1117 1117 //does this window accept dropped files? 1118 if(!DragDropAccept(win32wnd->getWindowHandle())) { 1119 rc = (MRFROM2SHORT (DOR_NEVERDROP, 0)); 1120 break; 1121 } 1122 1123 if(PMDragValidate(pDragInfo) == FALSE) { 1124 rc = (MRFROM2SHORT (DOR_NEVERDROP, 0)); 1125 break; 1126 } 1127 if(win32wnd->isDragDropActive() == FALSE) { 1128 ULONG ulBytes, cItems; 1129 char *pszFiles; 1130 1131 pszFiles = PMDragExtractFiles(pDragInfo, &cItems, &ulBytes); 1132 if(pszFiles) { 1133 POINT point = {sxDrop, syDrop}; 1134 if(DragDropDragEnter(win32wnd->getWindowHandle(), point, cItems, pszFiles, ulBytes, DROPEFFECT_COPY_W) == FALSE) { 1118 /* We send DM_DRAGOVER/DM_DROP events to ourselves using WinSendMsg() 1119 * in OSLibDragOver()/OSLibDragDrop() but this is not correct to the 1120 * extent that it does not set up some internal PM structures so that 1121 * DrgFreeDraginfo() called to pair DrgAccessDraginfo() in this message 1122 * handler actually frees the structure whilie it is still in use by 1123 * DoDragDrop() and causes a crash upon the next access. We avoid to 1124 * do a free call in this case. This solution may have side effects... 1125 */ 1126 BOOL freeDragInfo = TRUE; 1127 PID pid; 1128 TID tid; 1129 if (WinQueryWindowProcess(pDragInfo->hwndSource, &pid, &tid)) { 1130 PPIB ppib; 1131 DosGetInfoBlocks(0, &ppib); 1132 dprintf(("OS2: DM_DRAGOVER source PID %d, this PID %d", pid, ppib->pib_ulpid)); 1133 if (ppib->pib_ulpid == pid) 1134 freeDragInfo = FALSE; 1135 } 1136 1137 do { 1138 if(fDragDropDisabled) { 1139 rc = (MRFROM2SHORT (DOR_NEVERDROP, 0)); 1140 break; 1141 } 1142 1143 //does this window accept dropped files? 1144 if(!DragDropAccept(win32wnd->getWindowHandle())) { 1145 rc = (MRFROM2SHORT (DOR_NEVERDROP, 0)); 1146 break; 1147 } 1148 1149 if(PMDragValidate(pDragInfo) == FALSE) { 1150 rc = (MRFROM2SHORT (DOR_NEVERDROP, 0)); 1151 break; 1152 } 1153 if(win32wnd->isDragDropActive() == FALSE) { 1154 ULONG ulBytes, cItems; 1155 char *pszFiles; 1156 1157 pszFiles = PMDragExtractFiles(pDragInfo, &cItems, &ulBytes); 1158 if(pszFiles) { 1159 POINT point = {sxDrop, syDrop}; 1160 if(DragDropDragEnter(win32wnd->getWindowHandle(), point, cItems, pszFiles, ulBytes, DROPEFFECT_COPY_W) == FALSE) { 1161 rc = (MRFROM2SHORT (DOR_NEVERDROP, 0)); 1162 } 1163 else { 1164 fDragDropActive = TRUE; 1165 rc = (MRFROM2SHORT(DOR_DROP, DO_MOVE)); 1166 win32wnd->setDragDropActive(TRUE); 1167 } 1168 free(pszFiles); 1169 } 1170 else { 1135 1171 rc = (MRFROM2SHORT (DOR_NEVERDROP, 0)); 1136 1172 } 1137 else {1138 fDragDropActive = TRUE;1139 rc = (MRFROM2SHORT(DOR_DROP, DO_MOVE));1140 win32wnd->setDragDropActive(TRUE);1173 } 1174 else { 1175 if(DragDropDragOver(win32wnd->getWindowHandle(), DROPEFFECT_COPY_W) == FALSE) { 1176 rc = (MRFROM2SHORT (DOR_NEVERDROP, 0)); 1141 1177 } 1142 free(pszFiles); 1143 } 1144 else { 1145 rc = (MRFROM2SHORT (DOR_NEVERDROP, 0)); 1146 } 1147 } 1148 else { 1149 if(DragDropDragOver(win32wnd->getWindowHandle(), DROPEFFECT_COPY_W) == FALSE) { 1150 rc = (MRFROM2SHORT (DOR_NEVERDROP, 0)); 1151 } 1152 else rc = (MRFROM2SHORT(DOR_DROP, DO_MOVE)); 1153 } 1178 else rc = (MRFROM2SHORT(DOR_DROP, DO_MOVE)); 1179 } 1180 break; 1181 } while (0); 1182 1183 /* Release the draginfo data structure */ 1184 if (freeDragInfo) 1185 DrgFreeDraginfo(pDragInfo); 1186 1154 1187 break; 1155 1188 } … … 1185 1218 dprintf(("OS2: DM_DROP %x (%d,%d)", win32wnd->getWindowHandle(), sxDrop, syDrop)); 1186 1219 1187 fDragDropActive = FALSE; 1188 rc = (MRFROM2SHORT (DOR_NODROP, 0)); 1189 1190 if(fDragDropDisabled) { 1220 /* Get access to the DRAGINFO data structure */ 1221 if(!DrgAccessDraginfo(pDragInfo)) { 1191 1222 rc = (MRFROM2SHORT (DOR_NODROP, 0)); 1192 1223 break; 1193 1224 } 1194 1225 1195 //does this window accept dropped files? 1196 if(!DragDropAccept(win32wnd->getWindowHandle())) { 1226 /* We send DM_DRAGOVER/DM_DROP events to ourselves using WinSendMsg() 1227 * in OSLibDragOver()/OSLibDragDrop() but this is not correct to the 1228 * extent that it does not set up some internal PM structures so that 1229 * DrgFreeDraginfo() called to pair DrgAccessDraginfo() in this message 1230 * handler actually frees the structure whilie it is still in use by 1231 * DoDragDrop() and causes a crash upon the next access. We avoid to 1232 * do a free call in this case. This solution may have side effects... 1233 */ 1234 BOOL freeDragInfo = TRUE; 1235 PID pid; 1236 TID tid; 1237 if (WinQueryWindowProcess(pDragInfo->hwndSource, &pid, &tid)) { 1238 PPIB ppib; 1239 DosGetInfoBlocks(0, &ppib); 1240 dprintf(("OS2: DM_DRAGOVER source PID %d, this PID %d", pid, ppib->pib_ulpid)); 1241 if (ppib->pib_ulpid == pid) 1242 freeDragInfo = FALSE; 1243 } 1244 1245 do { 1246 fDragDropActive = FALSE; 1247 rc = (MRFROM2SHORT (DOR_NODROP, 0)); 1248 1249 if(fDragDropDisabled) { 1250 rc = (MRFROM2SHORT (DOR_NODROP, 0)); 1251 break; 1252 } 1253 1254 //does this window accept dropped files? 1255 if(!DragDropAccept(win32wnd->getWindowHandle())) { 1256 break; 1257 } 1258 1259 ULONG ulBytes, cItems; 1260 char *pszFiles; 1261 1262 pszFiles = PMDragExtractFiles(pDragInfo, &cItems, &ulBytes); 1263 if(pszFiles) { 1264 POINT point = {sxDrop, syDrop}; 1265 if(DragDropFiles(win32wnd->getWindowHandle(), point, cItems, pszFiles, ulBytes) == FALSE) { 1266 rc = (MRFROM2SHORT (DOR_NEVERDROP, 0)); 1267 } 1268 else { 1269 rc = (MRFROM2SHORT(DOR_DROP, DO_MOVE)); 1270 win32wnd->setDragDropActive(FALSE); 1271 } 1272 free(pszFiles); 1273 } 1274 else { 1275 rc = (MRFROM2SHORT (DOR_NEVERDROP, 0)); 1276 } 1197 1277 break; 1198 } 1199 1200 ULONG ulBytes, cItems; 1201 char *pszFiles; 1202 1203 pszFiles = PMDragExtractFiles(pDragInfo, &cItems, &ulBytes); 1204 if(pszFiles) { 1205 POINT point = {sxDrop, syDrop}; 1206 if(DragDropFiles(win32wnd->getWindowHandle(), point, cItems, pszFiles, ulBytes) == FALSE) { 1207 rc = (MRFROM2SHORT (DOR_NEVERDROP, 0)); 1208 } 1209 else { 1210 rc = (MRFROM2SHORT(DOR_DROP, DO_MOVE)); 1211 win32wnd->setDragDropActive(FALSE); 1212 } 1213 free(pszFiles); 1214 } 1215 else { 1216 rc = (MRFROM2SHORT (DOR_NEVERDROP, 0)); 1217 } 1278 } while (0); 1279 1280 /* Release the draginfo data structure */ 1281 if (freeDragInfo) 1282 DrgFreeDraginfo(pDragInfo); 1283 1218 1284 break; 1219 1285 } … … 2554 2620 char *pszCurFile = NULL; 2555 2621 2556 /* Get access to the DRAGINFO data structure */2557 if(!DrgAccessDraginfo(pDragInfo)) {2558 return NULL;2559 }2560 2561 2622 cItems = DrgQueryDragitemCount(pDragInfo); 2562 2623 … … 2604 2665 } 2605 2666 2606 /* Release the draginfo data structure */2607 DrgFreeDraginfo(pDragInfo);2608 2609 2667 *pulBytes = bufsize; 2610 2668 *pcItems = cItems; … … 2613 2671 2614 2672 failure: 2615 /* Release the draginfo data structure */2616 DrgFreeDraginfo(pDragInfo);2617 2673 if(pszFiles) { 2618 2674 free(pszFiles); … … 2633 2689 2634 2690 /* Get access to the DRAGINFO data structure */ 2635 if(!DrgAccessDraginfo(pDragInfo)) {2636 return FALSE;2637 }2638 2691 2639 2692 /* Can we accept this drop? */ … … 2679 2732 } 2680 2733 /* Release the draginfo data structure */ 2681 DrgFreeDraginfo(pDragInfo);2682 2734 return TRUE; 2683 2735 2684 2736 failure: 2685 DrgFreeDraginfo(pDragInfo);2686 2737 return FALSE; 2687 2738 }
Note:
See TracChangeset
for help on using the changeset viewer.