1 /*
2 * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
89 if (pointClass == NULL) {
90 jclass pointClassLocal = env->FindClass("java/awt/Point");
91 DASSERT(pointClassLocal != NULL);
92 if (pointClassLocal == NULL) {
93 return (jint)0;
94 }
95 pointClass = (jclass)env->NewGlobalRef(pointClassLocal);
96 env->DeleteLocalRef(pointClassLocal);
97 }
98
99 HMONITOR monitor = MonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY);
100 int screen = AwtWin32GraphicsDevice::GetScreenFromHMONITOR(monitor);
101 Devices::InstanceAccess devices;
102 AwtWin32GraphicsDevice *device = devices->GetDevice(screen);
103
104 xID = env->GetFieldID(pointClass, "x", "I");
105 CHECK_NULL_RETURN(xID, (jint)0);
106 yID = env->GetFieldID(pointClass, "y", "I");
107 CHECK_NULL_RETURN(yID, (jint)0);
108
109 int x = (device == NULL) ? pt.x : device->ScaleDownX(pt.x);
110 int y = (device == NULL) ? pt.y : device->ScaleDownY(pt.y);
111
112 env->SetIntField(point, xID, x);
113 env->SetIntField(point, yID, y);
114
115 // Always return 0 on Windows: we assume there's always a
116 // virtual screen device used.
117 return (jint)0;
118 }
119
120 } // extern "C"
|
1 /*
2 * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
89 if (pointClass == NULL) {
90 jclass pointClassLocal = env->FindClass("java/awt/Point");
91 DASSERT(pointClassLocal != NULL);
92 if (pointClassLocal == NULL) {
93 return (jint)0;
94 }
95 pointClass = (jclass)env->NewGlobalRef(pointClassLocal);
96 env->DeleteLocalRef(pointClassLocal);
97 }
98
99 HMONITOR monitor = MonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY);
100 int screen = AwtWin32GraphicsDevice::GetScreenFromHMONITOR(monitor);
101 Devices::InstanceAccess devices;
102 AwtWin32GraphicsDevice *device = devices->GetDevice(screen);
103
104 xID = env->GetFieldID(pointClass, "x", "I");
105 CHECK_NULL_RETURN(xID, (jint)0);
106 yID = env->GetFieldID(pointClass, "y", "I");
107 CHECK_NULL_RETURN(yID, (jint)0);
108
109 int x = (device == NULL) ? pt.x : device->ScaleDownAbsX(pt.x);
110 int y = (device == NULL) ? pt.y : device->ScaleDownAbsY(pt.y);
111
112 env->SetIntField(point, xID, x);
113 env->SetIntField(point, yID, y);
114
115 // Always return 0 on Windows: we assume there's always a
116 // virtual screen device used.
117 return (jint)0;
118 }
119
120 } // extern "C"
|