< prev index next >

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

Print this page


   1 /*
   2  * Copyright (c) 1996, 2015, 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


 147 struct RepositionSecurityWarningStruct {
 148     jobject window;
 149 };
 150 
 151 struct SetFullScreenExclusiveModeStateStruct {
 152     jobject window;
 153     jboolean isFSEMState;
 154 };
 155 
 156 // struct for _WindowDPIChange() method
 157 struct ScaleStruct {
 158     jobject window;
 159     jint prevScreen;
 160     jfloat prevScaleX;
 161     jfloat prevScaleY;
 162     jint screen;
 163     jfloat scaleX;
 164     jfloat scaleY;
 165 };
 166 





 167 /************************************************************************
 168  * AwtWindow fields
 169  */
 170 
 171 jfieldID AwtWindow::warningStringID;
 172 jfieldID AwtWindow::locationByPlatformID;
 173 jfieldID AwtWindow::autoRequestFocusID;
 174 jfieldID AwtWindow::securityWarningWidthID;
 175 jfieldID AwtWindow::securityWarningHeightID;
 176 
 177 jfieldID AwtWindow::sysXID;
 178 jfieldID AwtWindow::sysYID;
 179 jfieldID AwtWindow::sysWID;
 180 jfieldID AwtWindow::sysHID;
 181 jfieldID AwtWindow::windowTypeID;
 182 
 183 jmethodID AwtWindow::getWarningStringMID;
 184 jmethodID AwtWindow::calculateSecurityWarningPositionMID;
 185 jmethodID AwtWindow::windowTypeNameMID;
 186 


 225 
 226 
 227     warningString = NULL;
 228     warningWindow = NULL;
 229     securityTooltipWindow = NULL;
 230     securityWarningAnimationStage = 0;
 231     currentWmSizeState = SIZE_RESTORED;
 232 
 233     hContentBitmap = NULL;
 234 
 235     ::InitializeCriticalSection(&contentBitmapCS);
 236 
 237     m_windowType = NORMAL;
 238     m_alwaysOnTop = false;
 239 
 240     fullScreenExclusiveModeState = FALSE;
 241     m_winSizeMove = FALSE;
 242     prevScaleRec.screen = -1;
 243     prevScaleRec.scaleX = -1.0f;
 244     prevScaleRec.scaleY = -1.0f;

 245 }
 246 
 247 AwtWindow::~AwtWindow()
 248 {
 249     if (warningString != NULL) {
 250         delete [] warningString;
 251     }
 252     DeleteContentBitmap();
 253     ::DeleteCriticalSection(&contentBitmapCS);
 254 }
 255 
 256 void AwtWindow::Dispose()
 257 {
 258     // Fix 4745575 GDI Resource Leak
 259     // MSDN
 260     // Before a window is destroyed (that is, before it returns from processing
 261     // the WM_NCDESTROY message), an application must remove all entries it has
 262     // added to the property list. The application must use the RemoveProp function
 263     // to remove the entries.
 264 


2554 
2555             // After the input method window shown, the dimension & position may not
2556             // be valid until this method is called. So we need to adjust the
2557             // IME candidate window position for the same reason as commented on
2558             // awt_Frame.cpp Show() method.
2559             if (p->isInputMethodWindow() && ::IsWindowVisible(p->GetHWnd())) {
2560               p->AdjustCandidateWindowPos();
2561             }
2562         }
2563         else
2564         {
2565             JNU_ThrowNullPointerException(env, "null target");
2566         }
2567     }
2568 ret:
2569    env->DeleteGlobalRef(self);
2570 
2571    delete rfs;
2572 }
2573 


















2574 /*
2575  * This is AwtWindow-specific function that is not intended for reusing
2576  */
2577 HICON CreateIconFromRaster(JNIEnv* env, jintArray iconRaster, jint w, jint h)
2578 {
2579     HBITMAP mask = NULL;
2580     HBITMAP image = NULL;
2581     HICON icon = NULL;
2582     if (iconRaster != NULL) {
2583         int* iconRasterBuffer = NULL;
2584         try {
2585             iconRasterBuffer = (int *)env->GetPrimitiveArrayCritical(iconRaster, 0);
2586 
2587             JNI_CHECK_NULL_GOTO(iconRasterBuffer, "iconRaster data", done);
2588 
2589             mask = BitmapUtil::CreateTransparencyMaskFromARGB(w, h, iconRasterBuffer);
2590             image = BitmapUtil::CreateV4BitmapFromARGB(w, h, iconRasterBuffer);
2591         } catch (...) {
2592             if (iconRasterBuffer != NULL) {
2593                 env->ReleasePrimitiveArrayCritical(iconRaster, iconRasterBuffer, 0);


3932 Java_sun_awt_windows_WWindowPeer_windowDPIChange(JNIEnv *env, jobject self,
3933     jint prevScreen, jfloat prevScaleX, jfloat prevScaleY,
3934     jint screen, jfloat scaleX, jfloat scaleY)
3935 {
3936     TRY;
3937 
3938     ScaleStruct *ss = new ScaleStruct;
3939     ss->window = env->NewGlobalRef(self);
3940     ss->prevScreen = prevScreen;
3941     ss->prevScaleX = prevScaleX;
3942     ss->prevScaleY = prevScaleY;
3943     ss->screen = screen;
3944     ss->scaleX = scaleX;
3945     ss->scaleY = scaleY;
3946 
3947     AwtToolkit::GetInstance().InvokeFunction(AwtWindow::_WindowDPIChange, ss);
3948     // global refs and ss are deleted in _WindowDPIChange
3949 
3950     CATCH_BAD_ALLOC;
3951 }





















3952 } /* extern "C" */
   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


 147 struct RepositionSecurityWarningStruct {
 148     jobject window;
 149 };
 150 
 151 struct SetFullScreenExclusiveModeStateStruct {
 152     jobject window;
 153     jboolean isFSEMState;
 154 };
 155 
 156 // struct for _WindowDPIChange() method
 157 struct ScaleStruct {
 158     jobject window;
 159     jint prevScreen;
 160     jfloat prevScaleX;
 161     jfloat prevScaleY;
 162     jint screen;
 163     jfloat scaleX;
 164     jfloat scaleY;
 165 };
 166 
 167 struct OverrideHandle {
 168     jobject frame;
 169     HWND handle;
 170 };
 171 
 172 /************************************************************************
 173  * AwtWindow fields
 174  */
 175 
 176 jfieldID AwtWindow::warningStringID;
 177 jfieldID AwtWindow::locationByPlatformID;
 178 jfieldID AwtWindow::autoRequestFocusID;
 179 jfieldID AwtWindow::securityWarningWidthID;
 180 jfieldID AwtWindow::securityWarningHeightID;
 181 
 182 jfieldID AwtWindow::sysXID;
 183 jfieldID AwtWindow::sysYID;
 184 jfieldID AwtWindow::sysWID;
 185 jfieldID AwtWindow::sysHID;
 186 jfieldID AwtWindow::windowTypeID;
 187 
 188 jmethodID AwtWindow::getWarningStringMID;
 189 jmethodID AwtWindow::calculateSecurityWarningPositionMID;
 190 jmethodID AwtWindow::windowTypeNameMID;
 191 


 230 
 231 
 232     warningString = NULL;
 233     warningWindow = NULL;
 234     securityTooltipWindow = NULL;
 235     securityWarningAnimationStage = 0;
 236     currentWmSizeState = SIZE_RESTORED;
 237 
 238     hContentBitmap = NULL;
 239 
 240     ::InitializeCriticalSection(&contentBitmapCS);
 241 
 242     m_windowType = NORMAL;
 243     m_alwaysOnTop = false;
 244 
 245     fullScreenExclusiveModeState = FALSE;
 246     m_winSizeMove = FALSE;
 247     prevScaleRec.screen = -1;
 248     prevScaleRec.scaleX = -1.0f;
 249     prevScaleRec.scaleY = -1.0f;
 250     m_overridenHwnd = NULL;
 251 }
 252 
 253 AwtWindow::~AwtWindow()
 254 {
 255     if (warningString != NULL) {
 256         delete [] warningString;
 257     }
 258     DeleteContentBitmap();
 259     ::DeleteCriticalSection(&contentBitmapCS);
 260 }
 261 
 262 void AwtWindow::Dispose()
 263 {
 264     // Fix 4745575 GDI Resource Leak
 265     // MSDN
 266     // Before a window is destroyed (that is, before it returns from processing
 267     // the WM_NCDESTROY message), an application must remove all entries it has
 268     // added to the property list. The application must use the RemoveProp function
 269     // to remove the entries.
 270 


2560 
2561             // After the input method window shown, the dimension & position may not
2562             // be valid until this method is called. So we need to adjust the
2563             // IME candidate window position for the same reason as commented on
2564             // awt_Frame.cpp Show() method.
2565             if (p->isInputMethodWindow() && ::IsWindowVisible(p->GetHWnd())) {
2566               p->AdjustCandidateWindowPos();
2567             }
2568         }
2569         else
2570         {
2571             JNU_ThrowNullPointerException(env, "null target");
2572         }
2573     }
2574 ret:
2575    env->DeleteGlobalRef(self);
2576 
2577    delete rfs;
2578 }
2579 
2580 void AwtWindow::_OverrideHandle(void *param)
2581 {
2582     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
2583 
2584     OverrideHandle* oh = (OverrideHandle *) param;
2585     jobject self = oh->frame;
2586     AwtWindow *f = NULL;
2587 
2588     PDATA pData;
2589     JNI_CHECK_PEER_GOTO(self, ret);
2590     f = (AwtWindow *)pData;
2591     f->OverrideHWnd(oh->handle);
2592 ret:
2593     env->DeleteGlobalRef(self);
2594 
2595     delete oh;
2596 }
2597 
2598 /*
2599  * This is AwtWindow-specific function that is not intended for reusing
2600  */
2601 HICON CreateIconFromRaster(JNIEnv* env, jintArray iconRaster, jint w, jint h)
2602 {
2603     HBITMAP mask = NULL;
2604     HBITMAP image = NULL;
2605     HICON icon = NULL;
2606     if (iconRaster != NULL) {
2607         int* iconRasterBuffer = NULL;
2608         try {
2609             iconRasterBuffer = (int *)env->GetPrimitiveArrayCritical(iconRaster, 0);
2610 
2611             JNI_CHECK_NULL_GOTO(iconRasterBuffer, "iconRaster data", done);
2612 
2613             mask = BitmapUtil::CreateTransparencyMaskFromARGB(w, h, iconRasterBuffer);
2614             image = BitmapUtil::CreateV4BitmapFromARGB(w, h, iconRasterBuffer);
2615         } catch (...) {
2616             if (iconRasterBuffer != NULL) {
2617                 env->ReleasePrimitiveArrayCritical(iconRaster, iconRasterBuffer, 0);


3956 Java_sun_awt_windows_WWindowPeer_windowDPIChange(JNIEnv *env, jobject self,
3957     jint prevScreen, jfloat prevScaleX, jfloat prevScaleY,
3958     jint screen, jfloat scaleX, jfloat scaleY)
3959 {
3960     TRY;
3961 
3962     ScaleStruct *ss = new ScaleStruct;
3963     ss->window = env->NewGlobalRef(self);
3964     ss->prevScreen = prevScreen;
3965     ss->prevScaleX = prevScaleX;
3966     ss->prevScaleY = prevScaleY;
3967     ss->screen = screen;
3968     ss->scaleX = scaleX;
3969     ss->scaleY = scaleY;
3970 
3971     AwtToolkit::GetInstance().InvokeFunction(AwtWindow::_WindowDPIChange, ss);
3972     // global refs and ss are deleted in _WindowDPIChange
3973 
3974     CATCH_BAD_ALLOC;
3975 }
3976 
3977 /*
3978  * Class:     sun_awt_windows_WLightweightFramePeer
3979  * Method:    overrideNativeHandle
3980  * Signature: (J)V
3981  */
3982 JNIEXPORT void JNICALL Java_sun_awt_windows_WLightweightFramePeer_overrideNativeHandle
3983   (JNIEnv *env, jobject self, jlong hwnd)
3984 {
3985     TRY;
3986 
3987     OverrideHandle *oh = new OverrideHandle;
3988     oh->frame = env->NewGlobalRef(self);
3989     oh->handle = (HWND) hwnd;
3990 
3991     AwtToolkit::GetInstance().SyncCall(AwtFrame::_OverrideHandle, oh);
3992     // global ref and oh are deleted in _OverrideHandle()
3993 
3994     CATCH_BAD_ALLOC;
3995 }
3996 
3997 } /* extern "C" */
< prev index next >