< prev index next >

src/java.desktop/windows/native/libawt/windows/awt_DnDDS.cpp

Print this page
rev 60071 : 8211999: Window positioning bugs due to overlapping GraphicsDevice bounds (Windows/HiDPI)
Reviewed-by: XXX


1157     DWORD id = ::CoGetCurrentProcess();
1158 
1159     HGLOBAL copy = ::GlobalAlloc(GALLOCFLG, sizeof(id));
1160 
1161     if (copy == NULL) {
1162         throw std::bad_alloc();
1163     }
1164 
1165     char *dataout = (char *)::GlobalLock(copy);
1166 
1167     memcpy(dataout, &id, sizeof(id));
1168     ::GlobalUnlock(copy);
1169 
1170     pmedium->tymed = TYMED_HGLOBAL;
1171     pmedium->hGlobal = copy;
1172     pmedium->pUnkForRelease = (IUnknown *)NULL;
1173 
1174     return S_OK;
1175 }
1176 
1177 static void ScaleDown(POINT &pt) {
1178     HMONITOR monitor = MonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY);
1179     int screen = AwtWin32GraphicsDevice::GetScreenFromHMONITOR(monitor);
1180     Devices::InstanceAccess devices;
1181     AwtWin32GraphicsDevice *device = devices->GetDevice(screen);
1182     if (device) {
1183         pt.x = device->ScaleDownX(pt.x);
1184         pt.y = device->ScaleDownY(pt.y);
1185     }
1186 }
1187 
1188 DECLARE_JAVA_CLASS(dSCClazz, "sun/awt/windows/WDragSourceContextPeer")
1189 
1190 void
1191 AwtDragSource::call_dSCenter(JNIEnv* env, jobject self, jint targetActions,
1192                              jint modifiers, POINT pt) {
1193     ScaleDown(pt);
1194     DECLARE_VOID_JAVA_METHOD(dSCenter, dSCClazz, "dragEnter", "(IIII)V");
1195     DASSERT(!JNU_IsNull(env, self));
1196     env->CallVoidMethod(self, dSCenter, targetActions, modifiers, pt.x, pt.y);
1197     if (!JNU_IsNull(env, safe_ExceptionOccurred(env))) {
1198         env->ExceptionDescribe();
1199         env->ExceptionClear();
1200     }
1201 }
1202 
1203 void
1204 AwtDragSource::call_dSCmotion(JNIEnv* env, jobject self, jint targetActions,
1205                               jint modifiers, POINT pt) {
1206     ScaleDown(pt);
1207     DECLARE_VOID_JAVA_METHOD(dSCmotion, dSCClazz, "dragMotion", "(IIII)V");
1208     DASSERT(!JNU_IsNull(env, self));
1209     env->CallVoidMethod(self, dSCmotion, targetActions, modifiers, pt.x, pt.y);
1210     if (!JNU_IsNull(env, safe_ExceptionOccurred(env))) {
1211         env->ExceptionDescribe();
1212         env->ExceptionClear();
1213     }
1214 }
1215 
1216 void
1217 AwtDragSource::call_dSCchanged(JNIEnv* env, jobject self, jint targetActions,
1218                                jint modifiers, POINT pt) {
1219     ScaleDown(pt);
1220     DECLARE_VOID_JAVA_METHOD(dSCchanged, dSCClazz, "operationChanged",
1221                              "(IIII)V");
1222     DASSERT(!JNU_IsNull(env, self));
1223     env->CallVoidMethod(self, dSCchanged, targetActions, modifiers, pt.x, pt.y);
1224     if (!JNU_IsNull(env, safe_ExceptionOccurred(env))) {
1225         env->ExceptionDescribe();
1226         env->ExceptionClear();
1227     }
1228 }
1229 
1230 void
1231 AwtDragSource::call_dSCexit(JNIEnv* env, jobject self, POINT pt) {
1232     ScaleDown(pt);
1233     DECLARE_VOID_JAVA_METHOD(dSCexit, dSCClazz, "dragExit", "(II)V");
1234     DASSERT(!JNU_IsNull(env, self));
1235     env->CallVoidMethod(self, dSCexit, pt.x, pt.y);
1236     if (!JNU_IsNull(env, safe_ExceptionOccurred(env))) {
1237         env->ExceptionDescribe();
1238         env->ExceptionClear();
1239     }
1240 }
1241 
1242 void
1243 AwtDragSource::call_dSCddfinished(JNIEnv* env, jobject self, jboolean success,
1244                                   jint operations, POINT pt) {
1245     ScaleDown(pt);
1246     DECLARE_VOID_JAVA_METHOD(dSCddfinished, dSCClazz, "dragDropFinished", "(ZIII)V");
1247     DASSERT(!JNU_IsNull(env, self));
1248     env->CallVoidMethod(self, dSCddfinished, success, operations, pt.x, pt.y);
1249     if (!JNU_IsNull(env, safe_ExceptionOccurred(env))) {
1250         env->ExceptionDescribe();
1251         env->ExceptionClear();
1252     }
1253 }
1254 
1255 void
1256 AwtDragSource::call_dSCmouseMoved(JNIEnv* env, jobject self, jint targetActions,
1257                                   jint modifiers, POINT pt) {
1258     ScaleDown(pt);
1259     DECLARE_VOID_JAVA_METHOD(dSCmouseMoved, dSCClazz, "dragMouseMoved",
1260                              "(IIII)V");
1261     DASSERT(!JNU_IsNull(env, self));
1262     env->CallVoidMethod(self, dSCmouseMoved, targetActions, modifiers, pt.x, pt.y);
1263     if (!JNU_IsNull(env, safe_ExceptionOccurred(env))) {
1264         env->ExceptionDescribe();
1265         env->ExceptionClear();
1266     }
1267 }
1268 
1269 DECLARE_JAVA_CLASS(awtIEClazz, "java/awt/event/InputEvent")
1270 
1271 /**
1272  * Constructor
1273  */
1274 
1275 AwtDragSource::ADSIEnumFormatEtc::ADSIEnumFormatEtc(AwtDragSource* parent) {
1276     m_parent = parent;
1277     m_idx    = 0;
1278 




1157     DWORD id = ::CoGetCurrentProcess();
1158 
1159     HGLOBAL copy = ::GlobalAlloc(GALLOCFLG, sizeof(id));
1160 
1161     if (copy == NULL) {
1162         throw std::bad_alloc();
1163     }
1164 
1165     char *dataout = (char *)::GlobalLock(copy);
1166 
1167     memcpy(dataout, &id, sizeof(id));
1168     ::GlobalUnlock(copy);
1169 
1170     pmedium->tymed = TYMED_HGLOBAL;
1171     pmedium->hGlobal = copy;
1172     pmedium->pUnkForRelease = (IUnknown *)NULL;
1173 
1174     return S_OK;
1175 }
1176 
1177 static void ScaleDownAbs(POINT &pt) {
1178     HMONITOR monitor = MonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY);
1179     int screen = AwtWin32GraphicsDevice::GetScreenFromHMONITOR(monitor);
1180     Devices::InstanceAccess devices;
1181     AwtWin32GraphicsDevice *device = devices->GetDevice(screen);
1182     if (device) {
1183         pt.x = device->ScaleDownAbsX(pt.x);
1184         pt.y = device->ScaleDownAbsY(pt.y);
1185     }
1186 }
1187 
1188 DECLARE_JAVA_CLASS(dSCClazz, "sun/awt/windows/WDragSourceContextPeer")
1189 
1190 void
1191 AwtDragSource::call_dSCenter(JNIEnv* env, jobject self, jint targetActions,
1192                              jint modifiers, POINT pt) {
1193     ScaleDownAbs(pt);
1194     DECLARE_VOID_JAVA_METHOD(dSCenter, dSCClazz, "dragEnter", "(IIII)V");
1195     DASSERT(!JNU_IsNull(env, self));
1196     env->CallVoidMethod(self, dSCenter, targetActions, modifiers, pt.x, pt.y);
1197     if (!JNU_IsNull(env, safe_ExceptionOccurred(env))) {
1198         env->ExceptionDescribe();
1199         env->ExceptionClear();
1200     }
1201 }
1202 
1203 void
1204 AwtDragSource::call_dSCmotion(JNIEnv* env, jobject self, jint targetActions,
1205                               jint modifiers, POINT pt) {
1206     ScaleDownAbs(pt);
1207     DECLARE_VOID_JAVA_METHOD(dSCmotion, dSCClazz, "dragMotion", "(IIII)V");
1208     DASSERT(!JNU_IsNull(env, self));
1209     env->CallVoidMethod(self, dSCmotion, targetActions, modifiers, pt.x, pt.y);
1210     if (!JNU_IsNull(env, safe_ExceptionOccurred(env))) {
1211         env->ExceptionDescribe();
1212         env->ExceptionClear();
1213     }
1214 }
1215 
1216 void
1217 AwtDragSource::call_dSCchanged(JNIEnv* env, jobject self, jint targetActions,
1218                                jint modifiers, POINT pt) {
1219     ScaleDownAbs(pt);
1220     DECLARE_VOID_JAVA_METHOD(dSCchanged, dSCClazz, "operationChanged",
1221                              "(IIII)V");
1222     DASSERT(!JNU_IsNull(env, self));
1223     env->CallVoidMethod(self, dSCchanged, targetActions, modifiers, pt.x, pt.y);
1224     if (!JNU_IsNull(env, safe_ExceptionOccurred(env))) {
1225         env->ExceptionDescribe();
1226         env->ExceptionClear();
1227     }
1228 }
1229 
1230 void
1231 AwtDragSource::call_dSCexit(JNIEnv* env, jobject self, POINT pt) {
1232     ScaleDownAbs(pt);
1233     DECLARE_VOID_JAVA_METHOD(dSCexit, dSCClazz, "dragExit", "(II)V");
1234     DASSERT(!JNU_IsNull(env, self));
1235     env->CallVoidMethod(self, dSCexit, pt.x, pt.y);
1236     if (!JNU_IsNull(env, safe_ExceptionOccurred(env))) {
1237         env->ExceptionDescribe();
1238         env->ExceptionClear();
1239     }
1240 }
1241 
1242 void
1243 AwtDragSource::call_dSCddfinished(JNIEnv* env, jobject self, jboolean success,
1244                                   jint operations, POINT pt) {
1245     ScaleDownAbs(pt);
1246     DECLARE_VOID_JAVA_METHOD(dSCddfinished, dSCClazz, "dragDropFinished", "(ZIII)V");
1247     DASSERT(!JNU_IsNull(env, self));
1248     env->CallVoidMethod(self, dSCddfinished, success, operations, pt.x, pt.y);
1249     if (!JNU_IsNull(env, safe_ExceptionOccurred(env))) {
1250         env->ExceptionDescribe();
1251         env->ExceptionClear();
1252     }
1253 }
1254 
1255 void
1256 AwtDragSource::call_dSCmouseMoved(JNIEnv* env, jobject self, jint targetActions,
1257                                   jint modifiers, POINT pt) {
1258     ScaleDownAbs(pt);
1259     DECLARE_VOID_JAVA_METHOD(dSCmouseMoved, dSCClazz, "dragMouseMoved",
1260                              "(IIII)V");
1261     DASSERT(!JNU_IsNull(env, self));
1262     env->CallVoidMethod(self, dSCmouseMoved, targetActions, modifiers, pt.x, pt.y);
1263     if (!JNU_IsNull(env, safe_ExceptionOccurred(env))) {
1264         env->ExceptionDescribe();
1265         env->ExceptionClear();
1266     }
1267 }
1268 
1269 DECLARE_JAVA_CLASS(awtIEClazz, "java/awt/event/InputEvent")
1270 
1271 /**
1272  * Constructor
1273  */
1274 
1275 AwtDragSource::ADSIEnumFormatEtc::ADSIEnumFormatEtc(AwtDragSource* parent) {
1276     m_parent = parent;
1277     m_idx    = 0;
1278 


< prev index next >