< prev index next >

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

Print this page




 467     /*
 468      * Fix for 6492970.
 469      * When a non-focusable toplevel is shown alone the Java process
 470      * is not foreground. If one shows another (focusable) toplevel
 471      * the native platform not always makes it foreground (see the CR).
 472      * Even worse, sometimes it sends the newly shown toplevel WM_ACTIVATE
 473      * message. This breaks Java focus. To workaround the problem we
 474      * set the toplevel being shown foreground programmatically.
 475      * The fix is localized to non-foreground process case only.
 476      * (See also: 6599270)
 477      */
 478     if (!IsEmbeddedFrame() && show == TRUE && status == 0) {
 479         HWND fgHWnd = ::GetForegroundWindow();
 480         if (fgHWnd != NULL) {
 481             DWORD fgProcessID;
 482             ::GetWindowThreadProcessId(fgHWnd, &fgProcessID);
 483 
 484             if (fgProcessID != ::GetCurrentProcessId()) {
 485                 AwtWindow* window = (AwtWindow*)GetComponent(GetHWnd());
 486 
 487                 if (window != NULL && window->IsFocusableWindow() && window->IsAutoRequestFocus() &&



 488                     !::IsWindow(GetModalBlocker(GetHWnd())))
 489                 {
 490                     // When the Java process is not allowed to set the foreground window
 491                     // (see MSDN) the request below will just have no effect.
 492                     ::SetForegroundWindow(GetHWnd());
 493                 }
 494             }
 495         }
 496     }
 497     return AwtWindow::WmShowWindow(show, status);
 498 }
 499 
 500 MsgRouting AwtFrame::WmMouseUp(UINT flags, int x, int y, int button) {
 501     if (isInManualMoveOrSize) {
 502         isInManualMoveOrSize = FALSE;
 503         ::ReleaseCapture();
 504         return mrConsume;
 505     }
 506     return AwtWindow::WmMouseUp(flags, x, y, button);
 507 }




 467     /*
 468      * Fix for 6492970.
 469      * When a non-focusable toplevel is shown alone the Java process
 470      * is not foreground. If one shows another (focusable) toplevel
 471      * the native platform not always makes it foreground (see the CR).
 472      * Even worse, sometimes it sends the newly shown toplevel WM_ACTIVATE
 473      * message. This breaks Java focus. To workaround the problem we
 474      * set the toplevel being shown foreground programmatically.
 475      * The fix is localized to non-foreground process case only.
 476      * (See also: 6599270)
 477      */
 478     if (!IsEmbeddedFrame() && show == TRUE && status == 0) {
 479         HWND fgHWnd = ::GetForegroundWindow();
 480         if (fgHWnd != NULL) {
 481             DWORD fgProcessID;
 482             ::GetWindowThreadProcessId(fgHWnd, &fgProcessID);
 483 
 484             if (fgProcessID != ::GetCurrentProcessId()) {
 485                 AwtWindow* window = (AwtWindow*)GetComponent(GetHWnd());
 486 
 487                 if (window != NULL &&
 488                     window->IsFocusableWindow() &&
 489                     window->IsAutoRequestFocus() &&
 490                     !::IsWindowVisible(GetHWnd()) && // the window is really showing
 491                     !::IsWindow(GetModalBlocker(GetHWnd())))
 492                 {
 493                     // When the Java process is not allowed to set the foreground window
 494                     // (see MSDN) the request below will just have no effect.
 495                     ::SetForegroundWindow(GetHWnd());
 496                 }
 497             }
 498         }
 499     }
 500     return AwtWindow::WmShowWindow(show, status);
 501 }
 502 
 503 MsgRouting AwtFrame::WmMouseUp(UINT flags, int x, int y, int button) {
 504     if (isInManualMoveOrSize) {
 505         isInManualMoveOrSize = FALSE;
 506         ::ReleaseCapture();
 507         return mrConsume;
 508     }
 509     return AwtWindow::WmMouseUp(flags, x, y, button);
 510 }


< prev index next >