< prev index next >

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

Print this page


   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


2517         env->DeleteGlobalRef(self);
2518         delete rfs;
2519         return;
2520     }
2521 
2522     AwtFrame *p = NULL;
2523 
2524     PDATA pData;
2525     JNI_CHECK_PEER_GOTO(self, ret);
2526     p = (AwtFrame *)pData;
2527     if (::IsWindow(p->GetHWnd()))
2528     {
2529         jobject target = env->GetObjectField(self, AwtObject::targetID);
2530         if (target != NULL)
2531         {
2532             // enforce tresholds before sending the event
2533             // Fix for 4459064 : do not enforce thresholds for embedded frames
2534             if (!p->IsEmbeddedFrame())
2535             {
2536                 jobject peer = p->GetPeer(env);
2537                 int minWidth = ::GetSystemMetrics(SM_CXMIN);
2538                 int minHeight = ::GetSystemMetrics(SM_CYMIN);
2539                 if (w < minWidth)
2540                 {
2541                     env->SetIntField(target, AwtComponent::widthID,
2542                         w = minWidth);
2543                     env->SetIntField(peer, AwtWindow::sysWID,
2544                         w);
2545                 }
2546                 if (h < minHeight)
2547                 {
2548                     env->SetIntField(target, AwtComponent::heightID,
2549                         h = minHeight);
2550                     env->SetIntField(peer, AwtWindow::sysHID,
2551                         h);
2552                 }
2553             }
2554             env->DeleteLocalRef(target);
2555 
2556             RECT *r = new RECT;
2557             ::SetRect(r, x, y, x + w, y + h);
2558             p->SendMessage(WM_AWT_RESHAPE_COMPONENT, 0, (LPARAM)r);


3809 
3810     CATCH_BAD_ALLOC;
3811 }
3812 
3813 /*
3814  * Class:     sun_awt_windows_WWindowPeer
3815  * Method:    setOpacity
3816  * Signature: (I)V
3817  */
3818 JNIEXPORT void JNICALL
3819 Java_sun_awt_windows_WWindowPeer_setOpacity(JNIEnv *env, jobject self,
3820                                               jint iOpacity)
3821 {
3822     TRY;
3823 
3824     OpacityStruct *os = new OpacityStruct;
3825     os->window = env->NewGlobalRef(self);
3826     os->iOpacity = iOpacity;
3827 
3828     AwtToolkit::GetInstance().SyncCall(AwtWindow::_SetOpacity, os);
3829     // global refs and mds are deleted in _SetMinSize
3830 
3831     CATCH_BAD_ALLOC;
3832 }
3833 
3834 /*
3835  * Class:     sun_awt_windows_WWindowPeer
3836  * Method:    setOpaqueImpl
3837  * Signature: (Z)V
3838  */
3839 JNIEXPORT void JNICALL
3840 Java_sun_awt_windows_WWindowPeer_setOpaqueImpl(JNIEnv *env, jobject self,
3841                                               jboolean isOpaque)
3842 {
3843     TRY;
3844 
3845     OpaqueStruct *os = new OpaqueStruct;
3846     os->window = env->NewGlobalRef(self);
3847     os->isOpaque = isOpaque;
3848 
3849     AwtToolkit::GetInstance().SyncCall(AwtWindow::_SetOpaque, os);
3850     // global refs and mds are deleted in _SetMinSize
3851 
3852     CATCH_BAD_ALLOC;
3853 }
3854 
3855 /*
3856  * Class:     sun_awt_windows_WWindowPeer
3857  * Method:    updateWindowImpl
3858  * Signature: ([III)V
3859  */
3860 JNIEXPORT void JNICALL
3861 Java_sun_awt_windows_WWindowPeer_updateWindowImpl(JNIEnv *env, jobject self,
3862                                                   jintArray data,
3863                                                   jint width, jint height)
3864 {
3865     TRY;
3866 
3867     UpdateWindowStruct *uws = new UpdateWindowStruct;
3868     uws->window = env->NewGlobalRef(self);
3869     uws->data = (jintArray)env->NewGlobalRef(data);
3870     uws->hBitmap = NULL;


   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


2517         env->DeleteGlobalRef(self);
2518         delete rfs;
2519         return;
2520     }
2521 
2522     AwtFrame *p = NULL;
2523 
2524     PDATA pData;
2525     JNI_CHECK_PEER_GOTO(self, ret);
2526     p = (AwtFrame *)pData;
2527     if (::IsWindow(p->GetHWnd()))
2528     {
2529         jobject target = env->GetObjectField(self, AwtObject::targetID);
2530         if (target != NULL)
2531         {
2532             // enforce tresholds before sending the event
2533             // Fix for 4459064 : do not enforce thresholds for embedded frames
2534             if (!p->IsEmbeddedFrame())
2535             {
2536                 jobject peer = p->GetPeer(env);
2537                 int minWidth = p->ScaleDownX(::GetSystemMetrics(SM_CXMIN));
2538                 int minHeight = p->ScaleDownY(::GetSystemMetrics(SM_CYMIN));
2539                 if (w < minWidth)
2540                 {
2541                     env->SetIntField(target, AwtComponent::widthID,
2542                         w = minWidth);
2543                     env->SetIntField(peer, AwtWindow::sysWID,
2544                         w);
2545                 }
2546                 if (h < minHeight)
2547                 {
2548                     env->SetIntField(target, AwtComponent::heightID,
2549                         h = minHeight);
2550                     env->SetIntField(peer, AwtWindow::sysHID,
2551                         h);
2552                 }
2553             }
2554             env->DeleteLocalRef(target);
2555 
2556             RECT *r = new RECT;
2557             ::SetRect(r, x, y, x + w, y + h);
2558             p->SendMessage(WM_AWT_RESHAPE_COMPONENT, 0, (LPARAM)r);


3809 
3810     CATCH_BAD_ALLOC;
3811 }
3812 
3813 /*
3814  * Class:     sun_awt_windows_WWindowPeer
3815  * Method:    setOpacity
3816  * Signature: (I)V
3817  */
3818 JNIEXPORT void JNICALL
3819 Java_sun_awt_windows_WWindowPeer_setOpacity(JNIEnv *env, jobject self,
3820                                               jint iOpacity)
3821 {
3822     TRY;
3823 
3824     OpacityStruct *os = new OpacityStruct;
3825     os->window = env->NewGlobalRef(self);
3826     os->iOpacity = iOpacity;
3827 
3828     AwtToolkit::GetInstance().SyncCall(AwtWindow::_SetOpacity, os);
3829     // global refs and mds are deleted in _SetOpacity
3830 
3831     CATCH_BAD_ALLOC;
3832 }
3833 
3834 /*
3835  * Class:     sun_awt_windows_WWindowPeer
3836  * Method:    setOpaqueImpl
3837  * Signature: (Z)V
3838  */
3839 JNIEXPORT void JNICALL
3840 Java_sun_awt_windows_WWindowPeer_setOpaqueImpl(JNIEnv *env, jobject self,
3841                                               jboolean isOpaque)
3842 {
3843     TRY;
3844 
3845     OpaqueStruct *os = new OpaqueStruct;
3846     os->window = env->NewGlobalRef(self);
3847     os->isOpaque = isOpaque;
3848 
3849     AwtToolkit::GetInstance().SyncCall(AwtWindow::_SetOpaque, os);
3850     // global refs and mds are deleted in _SetOpaque
3851 
3852     CATCH_BAD_ALLOC;
3853 }
3854 
3855 /*
3856  * Class:     sun_awt_windows_WWindowPeer
3857  * Method:    updateWindowImpl
3858  * Signature: ([III)V
3859  */
3860 JNIEXPORT void JNICALL
3861 Java_sun_awt_windows_WWindowPeer_updateWindowImpl(JNIEnv *env, jobject self,
3862                                                   jintArray data,
3863                                                   jint width, jint height)
3864 {
3865     TRY;
3866 
3867     UpdateWindowStruct *uws = new UpdateWindowStruct;
3868     uws->window = env->NewGlobalRef(self);
3869     uws->data = (jintArray)env->NewGlobalRef(data);
3870     uws->hBitmap = NULL;


< prev index next >