1 /*
2 * Copyright (c) 1996, 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
614
615 AwtToolkit::GetInstance().SyncCall(AwtFileDialog::_ToFront,
616 (void *)(env->NewGlobalRef(peer)));
617 // global ref is deleted in _ToFront
618
619 CATCH_BAD_ALLOC;
620 }
621
622 JNIEXPORT void JNICALL
623 Java_sun_awt_windows_WFileDialogPeer_toBack(JNIEnv *env, jobject peer)
624 {
625 TRY;
626
627 AwtToolkit::GetInstance().SyncCall(AwtFileDialog::_ToBack,
628 (void *)(env->NewGlobalRef(peer)));
629 // global ref is deleted in _ToBack
630
631 CATCH_BAD_ALLOC;
632 }
633
634 int ScaleDownX(int x, HWND hwnd) {
635 int screen = AwtWin32GraphicsDevice::DeviceIndexForWindow(hwnd);
636 Devices::InstanceAccess devices;
637 AwtWin32GraphicsDevice* device = devices->GetDevice(screen);
638 return device == NULL ? x : device->ScaleDownX(x);
639 }
640
641 int ScaleDownY(int y, HWND hwnd) {
642 int screen = AwtWin32GraphicsDevice::DeviceIndexForWindow(hwnd);
643 Devices::InstanceAccess devices;
644 AwtWin32GraphicsDevice* device = devices->GetDevice(screen);
645 return device == NULL ? y : device->ScaleDownY(y);
646 }
647
648 jobject AwtFileDialog::_GetLocationOnScreen(void *param)
649 {
650 JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
651
652 jobject result = NULL;
653 HWND hwnd = (HWND)env->GetLongField((jobject)param, AwtComponent::hwndID);
654
655 if (::IsWindow(hwnd))
656 {
657 RECT rect;
658 VERIFY(::GetWindowRect(hwnd, &rect));
659 result = JNU_NewObjectByName(env, "java/awt/Point", "(II)V",
660 ScaleDownX(rect.left, hwnd), ScaleDownY(rect.top, hwnd));
661 }
662
663 if (result != NULL)
664 {
665 jobject resultRef = env->NewGlobalRef(result);
666 env->DeleteLocalRef(result);
667 return resultRef;
668 }
669 else
670 {
671 return NULL;
672 }
673 }
674
675 /*
676 * Class: sun_awt_windows_WFileDialogPeer
677 * Method: getLocationOnScreen
678 * Signature: ()Ljava/awt/Point;
679 */
680 JNIEXPORT jobject JNICALL
|
1 /*
2 * Copyright (c) 1996, 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
614
615 AwtToolkit::GetInstance().SyncCall(AwtFileDialog::_ToFront,
616 (void *)(env->NewGlobalRef(peer)));
617 // global ref is deleted in _ToFront
618
619 CATCH_BAD_ALLOC;
620 }
621
622 JNIEXPORT void JNICALL
623 Java_sun_awt_windows_WFileDialogPeer_toBack(JNIEnv *env, jobject peer)
624 {
625 TRY;
626
627 AwtToolkit::GetInstance().SyncCall(AwtFileDialog::_ToBack,
628 (void *)(env->NewGlobalRef(peer)));
629 // global ref is deleted in _ToBack
630
631 CATCH_BAD_ALLOC;
632 }
633
634 int ScaleDownAbsX(int x, HWND hwnd) {
635 int screen = AwtWin32GraphicsDevice::DeviceIndexForWindow(hwnd);
636 Devices::InstanceAccess devices;
637 AwtWin32GraphicsDevice* device = devices->GetDevice(screen);
638 return device == NULL ? x : device->ScaleDownAbsX(x);
639 }
640
641 int ScaleDownAbsY(int y, HWND hwnd) {
642 int screen = AwtWin32GraphicsDevice::DeviceIndexForWindow(hwnd);
643 Devices::InstanceAccess devices;
644 AwtWin32GraphicsDevice* device = devices->GetDevice(screen);
645 return device == NULL ? y : device->ScaleDownAbsY(y);
646 }
647
648 jobject AwtFileDialog::_GetLocationOnScreen(void *param)
649 {
650 JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
651
652 jobject result = NULL;
653 HWND hwnd = (HWND)env->GetLongField((jobject)param, AwtComponent::hwndID);
654
655 if (::IsWindow(hwnd))
656 {
657 RECT rect;
658 VERIFY(::GetWindowRect(hwnd, &rect));
659 result = JNU_NewObjectByName(env, "java/awt/Point", "(II)V",
660 ScaleDownAbsX(rect.left, hwnd),
661 ScaleDownAbsY(rect.top, hwnd));
662 }
663
664 if (result != NULL)
665 {
666 jobject resultRef = env->NewGlobalRef(result);
667 env->DeleteLocalRef(result);
668 return resultRef;
669 }
670 else
671 {
672 return NULL;
673 }
674 }
675
676 /*
677 * Class: sun_awt_windows_WFileDialogPeer
678 * Method: getLocationOnScreen
679 * Signature: ()Ljava/awt/Point;
680 */
681 JNIEXPORT jobject JNICALL
|