src/windows/native/sun/windows/awt_Dialog.cpp

Print this page




 447         jobject target = w->GetTarget(env);
 448         env->CallVoidMethod(target, AwtFrame::activateEmbeddingTopLevelMID);
 449         env->DeleteLocalRef(target);
 450     } else {
 451         ::BringWindowToTop(hWnd);
 452         ::SetForegroundWindow(hWnd);
 453     }
 454 }
 455 
 456 void AwtDialog::ModalActivateNextWindow(HWND dialogHWnd,
 457                                         jobject dialogTarget, jobject dialogPeer)
 458 {
 459     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 460 
 461     jboolean exc;
 462     jlongArray windows = (jlongArray) JNU_CallStaticMethodByName
 463                                             (env,
 464                                              &exc,
 465                                              "sun/awt/windows/WWindowPeer",
 466                                              "getActiveWindowHandles",
 467                                              "()[J").l;

 468     if (exc == JNI_TRUE) {
 469         throw std::bad_alloc();
 470     }
 471     if (windows == NULL) {
 472         return;
 473     }
 474 
 475     jboolean isCopy;
 476     jlong *ws = env->GetLongArrayElements(windows, &isCopy);
 477     if (ws == NULL) {
 478         throw std::bad_alloc();
 479     }
 480     int windowsCount = env->GetArrayLength(windows);
 481     for (int i = windowsCount - 1; i >= 0; i--) {
 482         HWND w = (HWND)ws[i];
 483         if ((w != dialogHWnd) && ModalCanBeActivated(w)) {
 484             AwtDialog::ModalPerformActivation(w);
 485             break;
 486         }
 487     }




 447         jobject target = w->GetTarget(env);
 448         env->CallVoidMethod(target, AwtFrame::activateEmbeddingTopLevelMID);
 449         env->DeleteLocalRef(target);
 450     } else {
 451         ::BringWindowToTop(hWnd);
 452         ::SetForegroundWindow(hWnd);
 453     }
 454 }
 455 
 456 void AwtDialog::ModalActivateNextWindow(HWND dialogHWnd,
 457                                         jobject dialogTarget, jobject dialogPeer)
 458 {
 459     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 460 
 461     jboolean exc;
 462     jlongArray windows = (jlongArray) JNU_CallStaticMethodByName
 463                                             (env,
 464                                              &exc,
 465                                              "sun/awt/windows/WWindowPeer",
 466                                              "getActiveWindowHandles",
 467                                              "(Ljava/awt/Component;)[J",
 468                                              dialogTarget).l;
 469     if (exc == JNI_TRUE) {
 470         throw std::bad_alloc();
 471     }
 472     if (windows == NULL) {
 473         return;
 474     }
 475 
 476     jboolean isCopy;
 477     jlong *ws = env->GetLongArrayElements(windows, &isCopy);
 478     if (ws == NULL) {
 479         throw std::bad_alloc();
 480     }
 481     int windowsCount = env->GetArrayLength(windows);
 482     for (int i = windowsCount - 1; i >= 0; i--) {
 483         HWND w = (HWND)ws[i];
 484         if ((w != dialogHWnd) && ModalCanBeActivated(w)) {
 485             AwtDialog::ModalPerformActivation(w);
 486             break;
 487         }
 488     }