< prev index next >

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

Print this page




  78 }
  79 
  80 /*
  81  * Class:     sun_awt_Win32GraphicsConfig
  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         if (TRUE == MonitorBounds(AwtWin32GraphicsDevice::GetMonitor(screen), &rRW)) {
  99             bounds = env->NewObject(clazz, mid,
 100                                     rRW.left, rRW.top,
 101                                     rRW.right - rRW.left,
 102                                     rRW.bottom - rRW.top);






 103         }
 104         else {
 105             // 4910760 - don't return a null bounds, return the bounds of the
 106             // primary screen



 107             bounds = env->NewObject(clazz, mid,
 108                                     0, 0,
 109                                     ::GetSystemMetrics(SM_CXSCREEN),
 110                                     ::GetSystemMetrics(SM_CYSCREEN));
 111         }
 112         if (safe_ExceptionOccurred(env)) {
 113            return 0;
 114         }
 115     }
 116     return bounds;
 117 }


  78 }
  79 
  80 /*
  81  * Class:     sun_awt_Win32GraphicsConfig
  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 }
< prev index next >