Exemplo n.º 1
0
 @Override
 public void keyPressed(KeyEvent e) {
   if (!e.isPrintableKey() || e.isAutoRepeat()) {
     return;
   }
   if (e.getKeyChar() == 'd') {
     glWindow.setUndecorated(!glWindow.isUndecorated());
   }
   if (e.getKeyChar() == 'f') {
     glWindow.setFullscreen(!glWindow.isFullscreen());
   } else if (e.getKeyChar() == 'a') {
     glWindow.setAlwaysOnTop(!glWindow.isAlwaysOnTop());
   } else if (e.getKeyChar() == 'r' && null != awtParent) {
     if (null == glWindow.getParent()) {
       glWindow.reparentWindow(awtParent);
     } else {
       final InsetsImmutable insets = glWindow.getInsets();
       final int x, y;
       if (0 >= insets.getTopHeight()) {
         // fail safe ..
         x = 32;
         y = 32;
       } else {
         x = insets.getLeftWidth();
         y = insets.getTopHeight();
       }
       glWindow.reparentWindow(null, x, y, false /* forceDestroyCreate */);
       glWindow.setDefaultCloseOperation(
           glClosable
               ? WindowClosingMode.DISPOSE_ON_CLOSE
               : WindowClosingMode.DO_NOTHING_ON_CLOSE);
     }
   }
 }
Exemplo n.º 2
0
  protected boolean reconfigureWindowImpl(
      final int x, final int y, final int width, final int height, final int flags) {
    if (DEBUG_IMPLEMENTATION) {
      System.err.println(
          "X11Window reconfig: "
              + x
              + "/"
              + y
              + " "
              + width
              + "x"
              + height
              + ", "
              + getReconfigureFlagsAsString(null, flags));
    }
    final int _x, _y;
    if (0 == (FLAG_IS_UNDECORATED & flags)) {
      final InsetsImmutable i = getInsets();

      // client position -> top-level window position
      _x = x - i.getLeftWidth();
      _y = y - i.getTopHeight();
    } else {
      _x = x;
      _y = y;
    }
    final DisplayDriver display = (DisplayDriver) getScreen().getDisplay();
    runWithLockedDisplayDevice(
        new DisplayImpl.DisplayRunnable<Object>() {
          public Object run(long dpy) {
            reconfigureWindow0(
                dpy,
                getScreenIndex(),
                getParentWindowHandle(),
                getWindowHandle(),
                display.getWindowDeleteAtom(),
                _x,
                _y,
                width,
                height,
                flags);
            return null;
          }
        });
    return true;
  }