1 /*
2 * Copyright (c) 1999, 2014, 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
82 * Method: getBounds
83 * Signature: ()Ljava/awt/Rectangle
84 */
85 JNIEXPORT jobject JNICALL
86 Java_sun_awt_Win32GraphicsConfig_getBounds(JNIEnv *env, jobject thisobj,
87 jint screen)
88 {
89 jclass clazz;
90 jmethodID mid;
91 jobject bounds = NULL;
92
93 clazz = env->FindClass("java/awt/Rectangle");
94 CHECK_NULL_RETURN(clazz, NULL);
95 mid = env->GetMethodID(clazz, "<init>", "(IIII)V");
96 if (mid != 0) {
97 RECT rRW = {0, 0, 0, 0};
98 Devices::InstanceAccess devices;
99 AwtWin32GraphicsDevice *device = devices->GetDevice(screen);
100
101 if (TRUE == MonitorBounds(AwtWin32GraphicsDevice::GetMonitor(screen), &rRW)) {
102
103 int x = (device == NULL) ? rRW.left : device->ScaleDownX(rRW.left);
104 int y = (device == NULL) ? rRW.top : device->ScaleDownY(rRW.top);
105 int w = (device == NULL) ? rRW.right - rRW.left
106 : device->ScaleDownX(rRW.right - rRW.left);
107 int h = (device == NULL) ? rRW.bottom - rRW.top
108 : device->ScaleDownY(rRW.bottom - rRW.top);
109
110 bounds = env->NewObject(clazz, mid, x, y, w, h);
111
112 }
113 else {
114 // 4910760 - don't return a null bounds, return the bounds of the
115 // primary screen
116 int w = ::GetSystemMetrics(SM_CXSCREEN);
117 int h = ::GetSystemMetrics(SM_CYSCREEN);
118
119 bounds = env->NewObject(clazz, mid,
120 0, 0,
121 device == NULL ? w : device->ScaleDownX(w),
122 device == NULL ? h : device->ScaleDownY(h));
123 }
124 if (safe_ExceptionOccurred(env)) {
125 return 0;
126 }
127 }
128 return bounds;
129 }
|
1 /*
2 * Copyright (c) 1999, 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
82 * Method: getBounds
83 * Signature: ()Ljava/awt/Rectangle
84 */
85 JNIEXPORT jobject JNICALL
86 Java_sun_awt_Win32GraphicsConfig_getBounds(JNIEnv *env, jobject thisobj,
87 jint screen)
88 {
89 jclass clazz;
90 jmethodID mid;
91 jobject bounds = NULL;
92
93 clazz = env->FindClass("java/awt/Rectangle");
94 CHECK_NULL_RETURN(clazz, NULL);
95 mid = env->GetMethodID(clazz, "<init>", "(IIII)V");
96 if (mid != 0) {
97 RECT rRW = {0, 0, 0, 0};
98 Devices::InstanceAccess devices;
99 AwtWin32GraphicsDevice *device = devices->GetDevice(screen);
100
101 if (TRUE == MonitorBounds(AwtWin32GraphicsDevice::GetMonitor(screen), &rRW)) {
102 int w = (device == NULL) ? rRW.right - rRW.left
103 : device->ScaleDownX(rRW.right - rRW.left);
104 int h = (device == NULL) ? rRW.bottom - rRW.top
105 : device->ScaleDownY(rRW.bottom - rRW.top);
106
107 bounds = env->NewObject(clazz, mid, rRW.left, rRW.top, w, h);
108 }
109 else {
110 // 4910760 - don't return a null bounds, return the bounds of the
111 // primary screen
112 int w = ::GetSystemMetrics(SM_CXSCREEN);
113 int h = ::GetSystemMetrics(SM_CYSCREEN);
114
115 bounds = env->NewObject(clazz, mid,
116 0, 0,
117 device == NULL ? w : device->ScaleDownX(w),
118 device == NULL ? h : device->ScaleDownY(h));
119 }
120 if (safe_ExceptionOccurred(env)) {
121 return 0;
122 }
123 }
124 return bounds;
125 }
|