Java Code Examples for java.awt.Window#getPeer()

The following examples show how to use java.awt.Window#getPeer() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Win32GraphicsDevice.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public synchronized void setDisplayMode(DisplayMode dm) {
    if (!isDisplayChangeSupported()) {
        super.setDisplayMode(dm);
        return;
    }
    if (dm == null || (dm = getMatchingDisplayMode(dm)) == null) {
        throw new IllegalArgumentException("Invalid display mode");
    }
    if (getDisplayMode().equals(dm)) {
        return;
    }
    Window w = getFullScreenWindow();
    if (w != null) {
        WWindowPeer peer = (WWindowPeer)w.getPeer();
        configDisplayMode(screen, peer, dm.getWidth(), dm.getHeight(),
            dm.getBitDepth(), dm.getRefreshRate());
        // resize the fullscreen window to the dimensions of the new
        // display mode
        Rectangle screenBounds = getDefaultConfiguration().getBounds();
        w.setBounds(screenBounds.x, screenBounds.y,
                    dm.getWidth(), dm.getHeight());
        // Note: no call to replaceSurfaceData is required here since
        // replacement will be caused by an upcoming display change event
    } else {
        throw new IllegalStateException("Must be in fullscreen mode " +
                                        "in order to set display mode");
    }
}
 
Example 2
Source File: Win32GraphicsDevice.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public synchronized void setDisplayMode(DisplayMode dm) {
    if (!isDisplayChangeSupported()) {
        super.setDisplayMode(dm);
        return;
    }
    if (dm == null || (dm = getMatchingDisplayMode(dm)) == null) {
        throw new IllegalArgumentException("Invalid display mode");
    }
    if (getDisplayMode().equals(dm)) {
        return;
    }
    Window w = getFullScreenWindow();
    if (w != null) {
        WWindowPeer peer = (WWindowPeer)w.getPeer();
        configDisplayMode(screen, peer, dm.getWidth(), dm.getHeight(),
            dm.getBitDepth(), dm.getRefreshRate());
        // resize the fullscreen window to the dimensions of the new
        // display mode
        Rectangle screenBounds = getDefaultConfiguration().getBounds();
        w.setBounds(screenBounds.x, screenBounds.y,
                    dm.getWidth(), dm.getHeight());
        // Note: no call to replaceSurfaceData is required here since
        // replacement will be caused by an upcoming display change event
    } else {
        throw new IllegalStateException("Must be in fullscreen mode " +
                                        "in order to set display mode");
    }
}
 
Example 3
Source File: X11GraphicsDevice.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void exitFullScreenExclusive(Window w) {
    X11ComponentPeer peer = (X11ComponentPeer)w.getPeer();
    if (peer != null) {
        peer.setFullScreenExclusiveModeState(false);
        exitFullScreenExclusive(peer.getWindow());
    }
}
 
Example 4
Source File: X11GraphicsDevice.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static void enterFullScreenExclusive(Window w) {
    X11ComponentPeer peer = (X11ComponentPeer)w.getPeer();
    if (peer != null) {
        enterFullScreenExclusive(peer.getWindow());
        peer.setFullScreenExclusiveModeState(true);
    }
}
 
Example 5
Source File: Win32GraphicsDevice.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public synchronized void setDisplayMode(DisplayMode dm) {
    if (!isDisplayChangeSupported()) {
        super.setDisplayMode(dm);
        return;
    }
    if (dm == null || (dm = getMatchingDisplayMode(dm)) == null) {
        throw new IllegalArgumentException("Invalid display mode");
    }
    if (getDisplayMode().equals(dm)) {
        return;
    }
    Window w = getFullScreenWindow();
    if (w != null) {
        WWindowPeer peer = (WWindowPeer)w.getPeer();
        configDisplayMode(screen, peer, dm.getWidth(), dm.getHeight(),
            dm.getBitDepth(), dm.getRefreshRate());
        // resize the fullscreen window to the dimensions of the new
        // display mode
        Rectangle screenBounds = getDefaultConfiguration().getBounds();
        w.setBounds(screenBounds.x, screenBounds.y,
                    dm.getWidth(), dm.getHeight());
        // Note: no call to replaceSurfaceData is required here since
        // replacement will be caused by an upcoming display change event
    } else {
        throw new IllegalStateException("Must be in fullscreen mode " +
                                        "in order to set display mode");
    }
}
 
Example 6
Source File: X11GraphicsDevice.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static void enterFullScreenExclusive(Window w) {
    X11ComponentPeer peer = (X11ComponentPeer)w.getPeer();
    if (peer != null) {
        enterFullScreenExclusive(peer.getWindow());
        peer.setFullScreenExclusiveModeState(true);
    }
}
 
Example 7
Source File: X11GraphicsDevice.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void enterFullScreenExclusive(Window w) {
    X11ComponentPeer peer = (X11ComponentPeer)w.getPeer();
    if (peer != null) {
        enterFullScreenExclusive(peer.getWindow());
        peer.setFullScreenExclusiveModeState(true);
    }
}
 
Example 8
Source File: X11GraphicsDevice.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void exitFullScreenExclusive(Window w) {
    X11ComponentPeer peer = (X11ComponentPeer)w.getPeer();
    if (peer != null) {
        peer.setFullScreenExclusiveModeState(false);
        exitFullScreenExclusive(peer.getContentWindow());
    }
}
 
Example 9
Source File: X11GraphicsDevice.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void enterFullScreenExclusive(Window w) {
    X11ComponentPeer peer = (X11ComponentPeer)w.getPeer();
    if (peer != null) {
        enterFullScreenExclusive(peer.getWindow());
        peer.setFullScreenExclusiveModeState(true);
    }
}
 
Example 10
Source File: X11GraphicsDevice.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void enterFullScreenExclusive(Window w) {
    X11ComponentPeer peer = (X11ComponentPeer)w.getPeer();
    if (peer != null) {
        enterFullScreenExclusive(peer.getWindow());
        peer.setFullScreenExclusiveModeState(true);
    }
}
 
Example 11
Source File: XComponentPeer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
final public boolean requestFocus(Component lightweightChild, boolean temporary,
                                  boolean focusedWindowChangeAllowed, long time,
                                  CausedFocusEvent.Cause cause)
{
    if (XKeyboardFocusManagerPeer.
        processSynchronousLightweightTransfer(target, lightweightChild, temporary,
                                              focusedWindowChangeAllowed, time))
    {
        return true;
    }

    int result = XKeyboardFocusManagerPeer.
        shouldNativelyFocusHeavyweight(target, lightweightChild,
                                       temporary, focusedWindowChangeAllowed,
                                       time, cause);

    switch (result) {
      case XKeyboardFocusManagerPeer.SNFH_FAILURE:
          return false;
      case XKeyboardFocusManagerPeer.SNFH_SUCCESS_PROCEED:
          // Currently we just generate focus events like we deal with lightweight instead of calling
          // XSetInputFocus on native window
          if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
              focusLog.finer("Proceeding with request to " +
                             lightweightChild + " in " + target);
          }
          /**
           * The problems with requests in non-focused window arise because shouldNativelyFocusHeavyweight
           * checks that native window is focused while appropriate WINDOW_GAINED_FOCUS has not yet
           * been processed - it is in EventQueue. Thus, SNFH allows native request and stores request record
           * in requests list - and it breaks our requests sequence as first record on WGF should be the last
           * focus owner which had focus before WLF. So, we should not add request record for such requests
           * but store this component in mostRecent - and return true as before for compatibility.
           */
          Window parentWindow = SunToolkit.getContainingWindow(target);
          if (parentWindow == null) {
              return rejectFocusRequestHelper("WARNING: Parent window is null");
          }
          XWindowPeer wpeer = (XWindowPeer)parentWindow.getPeer();
          if (wpeer == null) {
              return rejectFocusRequestHelper("WARNING: Parent window's peer is null");
          }
          /*
           * Passing null 'actualFocusedWindow' as we don't want to restore focus on it
           * when a component inside a Frame is requesting focus.
           * See 6314575 for details.
           */
          boolean res = wpeer.requestWindowFocus(null);

          if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
              focusLog.finer("Requested window focus: " + res);
          }
          // If parent window can be made focused and has been made focused(synchronously)
          // then we can proceed with children, otherwise we retreat.
          if (!(res && parentWindow.isFocused())) {
              return rejectFocusRequestHelper("Waiting for asynchronous processing of the request");
          }
          return XKeyboardFocusManagerPeer.deliverFocus(lightweightChild,
                                                        (Component)target,
                                                        temporary,
                                                        focusedWindowChangeAllowed,
                                                        time, cause);
          // Motif compatibility code
      case XKeyboardFocusManagerPeer.SNFH_SUCCESS_HANDLED:
          // Either lightweight or excessive request - all events are generated.
          return true;
    }
    return false;
}
 
Example 12
Source File: XComponentPeer.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
final public boolean requestFocus(Component lightweightChild, boolean temporary,
                                  boolean focusedWindowChangeAllowed, long time,
                                  CausedFocusEvent.Cause cause)
{
    if (XKeyboardFocusManagerPeer.
        processSynchronousLightweightTransfer(target, lightweightChild, temporary,
                                              focusedWindowChangeAllowed, time))
    {
        return true;
    }

    int result = XKeyboardFocusManagerPeer.
        shouldNativelyFocusHeavyweight(target, lightweightChild,
                                       temporary, focusedWindowChangeAllowed,
                                       time, cause);

    switch (result) {
      case XKeyboardFocusManagerPeer.SNFH_FAILURE:
          return false;
      case XKeyboardFocusManagerPeer.SNFH_SUCCESS_PROCEED:
          // Currently we just generate focus events like we deal with lightweight instead of calling
          // XSetInputFocus on native window
          if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
              focusLog.finer("Proceeding with request to " +
                             lightweightChild + " in " + target);
          }
          /**
           * The problems with requests in non-focused window arise because shouldNativelyFocusHeavyweight
           * checks that native window is focused while appropriate WINDOW_GAINED_FOCUS has not yet
           * been processed - it is in EventQueue. Thus, SNFH allows native request and stores request record
           * in requests list - and it breaks our requests sequence as first record on WGF should be the last
           * focus owner which had focus before WLF. So, we should not add request record for such requests
           * but store this component in mostRecent - and return true as before for compatibility.
           */
          Window parentWindow = SunToolkit.getContainingWindow(target);
          if (parentWindow == null) {
              return rejectFocusRequestHelper("WARNING: Parent window is null");
          }
          XWindowPeer wpeer = (XWindowPeer)parentWindow.getPeer();
          if (wpeer == null) {
              return rejectFocusRequestHelper("WARNING: Parent window's peer is null");
          }
          /*
           * Passing null 'actualFocusedWindow' as we don't want to restore focus on it
           * when a component inside a Frame is requesting focus.
           * See 6314575 for details.
           */
          boolean res = wpeer.requestWindowFocus(null);

          if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
              focusLog.finer("Requested window focus: " + res);
          }
          // If parent window can be made focused and has been made focused(synchronously)
          // then we can proceed with children, otherwise we retreat.
          if (!(res && parentWindow.isFocused())) {
              return rejectFocusRequestHelper("Waiting for asynchronous processing of the request");
          }
          return XKeyboardFocusManagerPeer.deliverFocus(lightweightChild,
                                                        (Component)target,
                                                        temporary,
                                                        focusedWindowChangeAllowed,
                                                        time, cause);
          // Motif compatibility code
      case XKeyboardFocusManagerPeer.SNFH_SUCCESS_HANDLED:
          // Either lightweight or excessive request - all events are generated.
          return true;
    }
    return false;
}
 
Example 13
Source File: CGraphicsDevice.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
private static void enterFullScreenExclusive(Window w) {
    FullScreenCapable peer = (FullScreenCapable)w.getPeer();
    if (peer != null) {
        peer.enterFullScreenMode();
    }
}
 
Example 14
Source File: CGraphicsDevice.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
private static void exitFullScreenExclusive(Window w) {
    FullScreenCapable peer = (FullScreenCapable)w.getPeer();
    if (peer != null) {
        peer.exitFullScreenMode();
    }
}
 
Example 15
Source File: CGraphicsDevice.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private static void enterFullScreenExclusive(Window w) {
    FullScreenCapable peer = (FullScreenCapable)w.getPeer();
    if (peer != null) {
        peer.enterFullScreenMode();
    }
}
 
Example 16
Source File: XComponentPeer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
final public boolean requestFocus(Component lightweightChild, boolean temporary,
                                  boolean focusedWindowChangeAllowed, long time,
                                  CausedFocusEvent.Cause cause)
{
    if (XKeyboardFocusManagerPeer.
        processSynchronousLightweightTransfer(target, lightweightChild, temporary,
                                              focusedWindowChangeAllowed, time))
    {
        return true;
    }

    int result = XKeyboardFocusManagerPeer.
        shouldNativelyFocusHeavyweight(target, lightweightChild,
                                       temporary, focusedWindowChangeAllowed,
                                       time, cause);

    switch (result) {
      case XKeyboardFocusManagerPeer.SNFH_FAILURE:
          return false;
      case XKeyboardFocusManagerPeer.SNFH_SUCCESS_PROCEED:
          // Currently we just generate focus events like we deal with lightweight instead of calling
          // XSetInputFocus on native window
          if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
              focusLog.finer("Proceeding with request to " +
                             lightweightChild + " in " + target);
          }
          /**
           * The problems with requests in non-focused window arise because shouldNativelyFocusHeavyweight
           * checks that native window is focused while appropriate WINDOW_GAINED_FOCUS has not yet
           * been processed - it is in EventQueue. Thus, SNFH allows native request and stores request record
           * in requests list - and it breaks our requests sequence as first record on WGF should be the last
           * focus owner which had focus before WLF. So, we should not add request record for such requests
           * but store this component in mostRecent - and return true as before for compatibility.
           */
          Window parentWindow = SunToolkit.getContainingWindow(target);
          if (parentWindow == null) {
              return rejectFocusRequestHelper("WARNING: Parent window is null");
          }
          XWindowPeer wpeer = (XWindowPeer)parentWindow.getPeer();
          if (wpeer == null) {
              return rejectFocusRequestHelper("WARNING: Parent window's peer is null");
          }
          /*
           * Passing null 'actualFocusedWindow' as we don't want to restore focus on it
           * when a component inside a Frame is requesting focus.
           * See 6314575 for details.
           */
          boolean res = wpeer.requestWindowFocus(null);

          if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
              focusLog.finer("Requested window focus: " + res);
          }
          // If parent window can be made focused and has been made focused(synchronously)
          // then we can proceed with children, otherwise we retreat.
          if (!(res && parentWindow.isFocused())) {
              return rejectFocusRequestHelper("Waiting for asynchronous processing of the request");
          }
          return XKeyboardFocusManagerPeer.deliverFocus(lightweightChild,
                                                        (Component)target,
                                                        temporary,
                                                        focusedWindowChangeAllowed,
                                                        time, cause);
          // Motif compatibility code
      case XKeyboardFocusManagerPeer.SNFH_SUCCESS_HANDLED:
          // Either lightweight or excessive request - all events are generated.
          return true;
    }
    return false;
}
 
Example 17
Source File: XComponentPeer.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
final public boolean requestFocus(Component lightweightChild, boolean temporary,
                                  boolean focusedWindowChangeAllowed, long time,
                                  CausedFocusEvent.Cause cause)
{
    if (XKeyboardFocusManagerPeer.
        processSynchronousLightweightTransfer(target, lightweightChild, temporary,
                                              focusedWindowChangeAllowed, time))
    {
        return true;
    }

    if (WindowStateMachine.get().isWaitingForWindowShow()) {
        return false;
    }

    int result = XKeyboardFocusManagerPeer.
        shouldNativelyFocusHeavyweight(target, lightweightChild,
                                       temporary, focusedWindowChangeAllowed,
                                       time, cause);

    switch (result) {
      case XKeyboardFocusManagerPeer.SNFH_FAILURE:
          return false;
      case XKeyboardFocusManagerPeer.SNFH_SUCCESS_PROCEED:
          // Currently we just generate focus events like we deal with lightweight instead of calling
          // XSetInputFocus on native window
          if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
              focusLog.finer("Proceeding with request to " +
                             lightweightChild + " in " + target);
          }
          /**
           * The problems with requests in non-focused window arise because shouldNativelyFocusHeavyweight
           * checks that native window is focused while appropriate WINDOW_GAINED_FOCUS has not yet
           * been processed - it is in EventQueue. Thus, SNFH allows native request and stores request record
           * in requests list - and it breaks our requests sequence as first record on WGF should be the last
           * focus owner which had focus before WLF. So, we should not add request record for such requests
           * but store this component in mostRecent - and return true as before for compatibility.
           */
          Window parentWindow = SunToolkit.getContainingWindow(target);
          if (parentWindow == null) {
              return rejectFocusRequestHelper("WARNING: Parent window is null");
          }
          XWindowPeer wpeer = (XWindowPeer)parentWindow.getPeer();
          if (wpeer == null) {
              return rejectFocusRequestHelper("WARNING: Parent window's peer is null");
          }
          /*
           * Passing null 'actualFocusedWindow' as we don't want to restore focus on it
           * when a component inside a Frame is requesting focus.
           * See 6314575 for details.
           */

          // If parent window can be made focused and has been made focused(synchronously)
          // then we can proceed with children, otherwise we retreat.

          return wpeer.requestWindowFocus(null, () -> {
              if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
                  focusLog.finer("Requested window focus: true");
              }
              XKeyboardFocusManagerPeer.deliverFocus(lightweightChild,
                      (Component)target,
                      temporary,
                      focusedWindowChangeAllowed,
                      time, cause);
          }, () -> {
              if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
                  focusLog.finer("Requested window focus: false");
              }
              rejectFocusRequestHelper("Waiting for asynchronous processing of the request");
          });


          // Motif compatibility code
      case XKeyboardFocusManagerPeer.SNFH_SUCCESS_HANDLED:
          // Either lightweight or excessive request - all events are generated.
          return true;
    }
    return false;
}
 
Example 18
Source File: XComponentPeer.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
final public boolean requestFocus(Component lightweightChild, boolean temporary,
                                  boolean focusedWindowChangeAllowed, long time,
                                  CausedFocusEvent.Cause cause)
{
    if (XKeyboardFocusManagerPeer.
        processSynchronousLightweightTransfer(target, lightweightChild, temporary,
                                              focusedWindowChangeAllowed, time))
    {
        return true;
    }

    int result = XKeyboardFocusManagerPeer.
        shouldNativelyFocusHeavyweight(target, lightweightChild,
                                       temporary, focusedWindowChangeAllowed,
                                       time, cause);

    switch (result) {
      case XKeyboardFocusManagerPeer.SNFH_FAILURE:
          return false;
      case XKeyboardFocusManagerPeer.SNFH_SUCCESS_PROCEED:
          // Currently we just generate focus events like we deal with lightweight instead of calling
          // XSetInputFocus on native window
          if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
              focusLog.finer("Proceeding with request to " +
                             lightweightChild + " in " + target);
          }
          /**
           * The problems with requests in non-focused window arise because shouldNativelyFocusHeavyweight
           * checks that native window is focused while appropriate WINDOW_GAINED_FOCUS has not yet
           * been processed - it is in EventQueue. Thus, SNFH allows native request and stores request record
           * in requests list - and it breaks our requests sequence as first record on WGF should be the last
           * focus owner which had focus before WLF. So, we should not add request record for such requests
           * but store this component in mostRecent - and return true as before for compatibility.
           */
          Window parentWindow = SunToolkit.getContainingWindow(target);
          if (parentWindow == null) {
              return rejectFocusRequestHelper("WARNING: Parent window is null");
          }
          XWindowPeer wpeer = (XWindowPeer)parentWindow.getPeer();
          if (wpeer == null) {
              return rejectFocusRequestHelper("WARNING: Parent window's peer is null");
          }
          /*
           * Passing null 'actualFocusedWindow' as we don't want to restore focus on it
           * when a component inside a Frame is requesting focus.
           * See 6314575 for details.
           */
          boolean res = wpeer.requestWindowFocus(null);

          if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
              focusLog.finer("Requested window focus: " + res);
          }
          // If parent window can be made focused and has been made focused(synchronously)
          // then we can proceed with children, otherwise we retreat.
          if (!(res && parentWindow.isFocused())) {
              return rejectFocusRequestHelper("Waiting for asynchronous processing of the request");
          }
          return XKeyboardFocusManagerPeer.deliverFocus(lightweightChild,
                                                        (Component)target,
                                                        temporary,
                                                        focusedWindowChangeAllowed,
                                                        time, cause);
          // Motif compatibility code
      case XKeyboardFocusManagerPeer.SNFH_SUCCESS_HANDLED:
          // Either lightweight or excessive request - all events are generated.
          return true;
    }
    return false;
}
 
Example 19
Source File: CGraphicsDevice.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
private static void exitFullScreenExclusive(Window w) {
    FullScreenCapable peer = (FullScreenCapable)w.getPeer();
    if (peer != null) {
        peer.exitFullScreenMode();
    }
}
 
Example 20
Source File: CGraphicsDevice.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
private static void enterFullScreenExclusive(Window w) {
    FullScreenCapable peer = (FullScreenCapable)w.getPeer();
    if (peer != null) {
        peer.enterFullScreenMode();
    }
}