Exemplo n.º 1
0
 static void delProperty(Client c, Window w, int name, int type) throws IOException {
   Property p;
   synchronized (w) {
     p = w.getProperty();
     Property prev = null;
     while (p != null) {
       if (p.propertyName == name) break;
       prev = p;
       p = p.next;
     }
     if (p != null) {
       if (prev == null) { // head !!
         w.setProperty(p.next);
         if (p.next == null) {
           // checkWindowOptionalNeed();
         }
       } else {
         prev.next = p.next;
       }
       c.cevent.mkPropertyNotify(
           w.id,
           p.propertyName,
           (int) System.currentTimeMillis(),
           // Property.PropertyDelete
           1);
     }
   }
   if (p != null) {
     w.sendEvent(c.cevent, 1, null);
   }
 }
Exemplo n.º 2
0
  void test3(Window owner, Window child1, Window child2) {
    System.out.println("* * * STAGE 3 * * *\nWidow owner: " + owner);

    owner.setFocusableWindowState(true);
    owner.setVisible(true);

    child1.setFocusableWindowState(false);
    child1.setVisible(true);

    child2.setFocusableWindowState(true);
    child2.add(button);
    child2.setVisible(true);

    Util.waitTillShown(child2);

    Util.clickOnComp(button, robot);
    System.err.println(
        "focus owner: " + KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner());
    if (button != KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner()) {
      throw new RuntimeException("Test failed.");
    }
    child1.dispose();
    child2.dispose();
    owner.dispose();
  }
Exemplo n.º 3
0
  static void reqListProperties(Client c) throws IOException {
    int foo, n;
    IO io = c.client;

    foo = io.readInt();
    Window w = c.lookupWindow(foo);
    c.length -= 2;
    if (w == null) {
      c.errorValue = foo;
      c.errorReason = 3; // BadWindow;
      return;
    }
    synchronized (io) {
      io.writeByte(1);
      Property p = w.getProperty();
      int i = 0;
      while (p != null) {
        i++;
        p = p.next;
      }

      io.writePad(1);
      io.writeShort(c.seq);
      io.writeInt(i);
      io.writeShort(i);
      io.writePad(22);

      p = w.getProperty();
      while (p != null) {
        io.writeInt(p.propertyName);
        p = p.next;
      }
      io.flush();
    }
  }
Exemplo n.º 4
0
  /**
   * Tries to load/restore the window state of the given window.
   *
   * @param aNamespace the namespace to use for the window state;
   * @param aProperties the properties to read from;
   * @param aWindow the window to load the state for.
   */
  public static void loadWindowState(final Preferences aProperties, final Window aWindow) {
    // Special case: for FileDialog/JFileChooser we also should restore the
    // properties...
    loadFileDialogState(aProperties, aWindow);

    try {
      final int xPos = aProperties.getInt("winXpos", -1);
      final int yPos = aProperties.getInt("winYpos", -1);
      if ((xPos >= 0) && (yPos >= 0)) {
        aWindow.setLocation(xPos, yPos);
      }
    } catch (NumberFormatException exception) {
      // Ignore...
    }

    if (isNonResizableWindow(aWindow)) {
      // In case the window cannot be resized, don't restore its width &
      // height...
      return;
    }

    try {
      final int width = aProperties.getInt("winWidth", -1);
      final int height = aProperties.getInt("winHeight", -1);
      if ((width >= 0) && (height >= 0)) {
        aWindow.setSize(width, height);
      }
    } catch (NumberFormatException exception) {
      // Ignore...
    }
  }
Exemplo n.º 5
0
    public void mouseMoved(MouseEvent ev) {
      JRootPane root = getRootPane();

      if (root.getWindowDecorationStyle() == JRootPane.NONE) {
        return;
      }

      Window w = (Window) ev.getSource();

      Frame f = null;
      Dialog d = null;

      if (w instanceof Frame) {
        f = (Frame) w;
      } else if (w instanceof Dialog) {
        d = (Dialog) w;
      }

      // Update the cursor
      int cursor = getCursor(calculateCorner(w, ev.getX(), ev.getY()));

      if (cursor != 0
          && ((f != null && (f.isResizable() && (f.getExtendedState() & Frame.MAXIMIZED_BOTH) == 0))
              || (d != null && d.isResizable()))) {
        w.setCursor(Cursor.getPredefinedCursor(cursor));
      } else {
        w.setCursor(lastCursor);
      }
    }
Exemplo n.º 6
0
  /*
   * Places the Window object at the center of the screen
   */
  public static void centerWindow(Window win) {
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

    Dimension dlgSize = win.getSize();

    win.setLocation(
        (screenSize.width - dlgSize.width) / 2, (screenSize.height - dlgSize.height) / 2);
  }
Exemplo n.º 7
0
  /**
   * Returns whether the given component is "actively" shown in screen, that is, it or any of its
   * ancestors is focused.
   *
   * @param aComponent the component to determine whether it is actively shown on screen, may be
   *     <code>null</code>.
   * @return <code>true</code> if the given component is actively shown, <code>false</code>
   *     otherwise.
   */
  public static final boolean isActivelyShown(final Component aComponent) {
    final KeyboardFocusManager kbdFocusManager =
        KeyboardFocusManager.getCurrentKeyboardFocusManager();
    final Window owner = kbdFocusManager.getFocusedWindow();

    return ((aComponent != null)
        && (owner != null)
        && ((owner == aComponent) || owner.isAncestorOf(aComponent)));
  }
Exemplo n.º 8
0
    /**
     * Returns the corner that contains the point <code>x</code>, <code>y</code>, or -1 if the
     * position doesn't match a corner.
     */
    private int calculateCorner(Window w, int x, int y) {
      Insets insets = w.getInsets();
      int xPosition = calculatePosition(x - insets.left, w.getWidth() - insets.left - insets.right);
      int yPosition = calculatePosition(y - insets.top, w.getHeight() - insets.top - insets.bottom);

      if (xPosition == -1 || yPosition == -1) {
        return -1;
      }
      return yPosition * 5 + xPosition;
    }
Exemplo n.º 9
0
 /**
  * Installs the necessary Listeners on the parent <code>Window</code>, if there is one.
  *
  * <p>This takes the parent so that cleanup can be done from <code>removeNotify</code>, at which
  * point the parent hasn't been reset yet.
  *
  * @param parent The parent of the JRootPane
  */
 private void installWindowListeners(JRootPane root, Component parent) {
   if (parent instanceof Window) {
     window = (Window) parent;
   } else {
     window = SwingUtilities.getWindowAncestor(parent);
   }
   if (window != null) {
     if (mouseInputListener == null) {
       mouseInputListener = createWindowMouseInputListener(root);
     }
     window.addMouseListener(mouseInputListener);
     window.addMouseMotionListener(mouseInputListener);
   }
 }
Exemplo n.º 10
0
 @Override
 public void actionPerformed(ActionEvent e) {
   actionPerformedUpdates(_parent);
   _imgBtn.getWindow().close();
   _parent.dispose();
   SikuliIDE.getInstance().getCurrentCodePane().setDirty(setDirty(false));
 }
Exemplo n.º 11
0
 /**
  * Gets most recent focus owner component associated with the given window. It does that without
  * calling Window.getMostRecentFocusOwner since it provides its own logic contradicting with
  * setDefautlFocus. Instead, it calls KeyboardFocusManager directly.
  */
 private Component getMostRecentFocusOwnerForWindow(Window w) {
   Method meth =
       AccessController.doPrivileged(
           new PrivilegedAction<Method>() {
             @Override
             public Method run() {
               Method meth = null;
               try {
                 meth =
                     KeyboardFocusManager.class.getDeclaredMethod(
                         "getMostRecentFocusOwner", new Class<?>[] {Window.class});
                 meth.setAccessible(true);
               } catch (Exception e) {
                 // Must never happen
                 e.printStackTrace();
               }
               return meth;
             }
           });
   if (meth != null) {
     // Meth refers static method
     try {
       return (Component) meth.invoke(null, new Object[] {w});
     } catch (Exception e) {
       // Must never happen
       e.printStackTrace();
     }
   }
   // Will get here if exception was thrown or meth is null
   return w.getMostRecentFocusOwner();
 }
Exemplo n.º 12
0
 @Override
 public void actionPerformed(ActionEvent e) {
   if (isDirty()) {
     _imgBtn.resetParameters();
   }
   _imgBtn.getWindow().close();
   _parent.dispose();
 }
Exemplo n.º 13
0
  /**
   * Saves the window state to the given properties map.
   *
   * @param aNamespace the namespace to use for the window state;
   * @param aProperties the properties to fill;
   * @param aWindow the window to save the state for.
   */
  public static void saveWindowState(final Preferences aProperties, final Window aWindow) {
    // Special case: for FileDialog/JFileChooser we also store the properties...
    saveFileDialogState(aProperties, aWindow);

    final Point location = aWindow.getLocation();
    aProperties.put("winXpos", Integer.toString(location.x));
    aProperties.put("winYpos", Integer.toString(location.y));

    if (isNonResizableWindow(aWindow)) {
      // In case the window cannot be resized, don't restore its width &
      // height...
      return;
    }

    final Dimension dims = aWindow.getSize();
    aProperties.put("winWidth", Integer.toString(dims.width));
    aProperties.put("winHeight", Integer.toString(dims.height));
  }
Exemplo n.º 14
0
    public void mousePressed(MouseEvent ev) {
      JRootPane rootPane = getRootPane();

      if (rootPane.getWindowDecorationStyle() == JRootPane.NONE) {
        return;
      }
      Point dragWindowOffset = ev.getPoint();
      Window w = (Window) ev.getSource();
      if (w != null) {
        w.toFront();
      }
      Point convertedDragWindowOffset =
          SwingUtilities.convertPoint(w, dragWindowOffset, getTitlePane());

      Frame f = null;
      Dialog d = null;

      if (w instanceof Frame) {
        f = (Frame) w;
      } else if (w instanceof Dialog) {
        d = (Dialog) w;
      }

      int frameState = (f != null) ? f.getExtendedState() : 0;

      if (getTitlePane() != null && getTitlePane().contains(convertedDragWindowOffset)) {
        if ((f != null && ((frameState & Frame.MAXIMIZED_BOTH) == 0) || (d != null))
            && dragWindowOffset.y >= BORDER_DRAG_THICKNESS
            && dragWindowOffset.x >= BORDER_DRAG_THICKNESS
            && dragWindowOffset.x < w.getWidth() - BORDER_DRAG_THICKNESS) {
          isMovingWindow = true;
          dragOffsetX = dragWindowOffset.x;
          dragOffsetY = dragWindowOffset.y;
        }
      } else if (f != null && f.isResizable() && ((frameState & Frame.MAXIMIZED_BOTH) == 0)
          || (d != null && d.isResizable())) {
        dragOffsetX = dragWindowOffset.x;
        dragOffsetY = dragWindowOffset.y;
        dragWidth = w.getWidth();
        dragHeight = w.getHeight();
        dragCursor = getCursor(calculateCorner(w, dragWindowOffset.x, dragWindowOffset.y));
      }
    }
Exemplo n.º 15
0
    public WindowMenuItem(final Window window, String title) {
      super(title, window.isVisible());
      addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              // window.pack();
              window.setVisible(!window.isVisible());
            }
          });

      window.addWindowListener(
          new WindowAdapter() {

            public void windowClosing(WindowEvent e) {
              WindowMenuItem.this.setSelected(false);
            }

            public void windowOpened(WindowEvent e) {
              WindowMenuItem.this.setSelected(USE_SYSTEM_UI);
            }
          });
    }
Exemplo n.º 16
0
 static Property getProperty(Window w, int name, int type) {
   synchronized (w) {
     Property p = w.getProperty();
     while (p != null) {
       if (p.propertyName == name) break;
       p = p.next;
     }
     if (p != null) {
       return p;
     }
     return null;
   }
 }
Exemplo n.º 17
0
  public void start() {
    Toolkit.getDefaultToolkit()
        .addAWTEventListener(
            new AWTEventListener() {
              public void eventDispatched(AWTEvent e) {
                System.out.println(e.toString());
              }
            },
            FocusEvent.FOCUS_EVENT_MASK
                | WindowEvent.WINDOW_FOCUS_EVENT_MASK
                | WindowEvent.WINDOW_EVENT_MASK);

    frame = new Frame("Frame");
    frame.setName("Frame-owner");
    frame.setBounds(100, 0, 100, 100);
    dialog = new Dialog(frame, "Dialog");
    dialog.setName("Dialog-owner");
    dialog.setBounds(100, 0, 100, 100);

    window1 = new Window(frame);
    window1.setName("1st child");
    window1.setBounds(100, 300, 100, 100);
    window2 = new Window(window1);
    window2.setName("2nd child");
    window2.setBounds(100, 500, 100, 100);

    test1(frame, window1);
    test2(frame, window1, window2);
    test3(frame, window1, window2);

    window1 = new Window(dialog);
    window1.setBounds(100, 300, 100, 100);
    window1.setName("1st child");
    window2 = new Window(window1);
    window2.setName("2nd child");
    window2.setBounds(100, 500, 100, 100);

    test1(dialog, window1);
    test2(dialog, window1, window2);
    test3(dialog, window1, window2);

    System.out.println("Test passed.");
  }
Exemplo n.º 18
0
 void saveWindowLocations() {
   Window win = WindowManager.getWindow("B&C");
   if (win != null) Prefs.saveLocation(ContrastAdjuster.LOC_KEY, win.getLocation());
   win = WindowManager.getWindow("Threshold");
   if (win != null) Prefs.saveLocation(ThresholdAdjuster.LOC_KEY, win.getLocation());
   win = WindowManager.getWindow("Results");
   if (win != null) {
     Prefs.saveLocation(TextWindow.LOC_KEY, win.getLocation());
     Dimension d = win.getSize();
     Prefs.set(TextWindow.WIDTH_KEY, d.width);
     Prefs.set(TextWindow.HEIGHT_KEY, d.height);
   }
   win = WindowManager.getWindow("Log");
   if (win != null) {
     Prefs.saveLocation(TextWindow.LOG_LOC_KEY, win.getLocation());
     Dimension d = win.getSize();
     Prefs.set(TextWindow.LOG_WIDTH_KEY, d.width);
     Prefs.set(TextWindow.LOG_HEIGHT_KEY, d.height);
   }
   win = WindowManager.getWindow("ROI Manager");
   if (win != null) Prefs.saveLocation(RoiManager.LOC_KEY, win.getLocation());
 }
Exemplo n.º 19
0
 /**
  * Uninstalls any state that <code>installClientDecorations</code> has installed.
  *
  * <p>NOTE: This may be called if you haven't installed client decorations yet (ie before <code>
  * installClientDecorations</code> has been invoked).
  */
 private void uninstallClientDecorations(JRootPane root) {
   uninstallBorder(root);
   uninstallWindowListeners(root);
   setTitlePane(root, null);
   uninstallLayout(root);
   // We have to revalidate/repaint root if the style is JRootPane.NONE
   // only. When we needs to call revalidate/repaint with other styles
   // the installClientDecorations is always called after this method
   // imediatly and it will cause the revalidate/repaint at the proper
   // time.
   int style = root.getWindowDecorationStyle();
   if (style == JRootPane.NONE) {
     root.repaint();
     root.revalidate();
   }
   // Reset the cursor, as we may have changed it to a resize cursor
   if (window != null) {
     window.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
   }
   window = null;
 }
Exemplo n.º 20
0
  void test1(Window owner, Window child) {
    System.out.println("* * * STAGE 1 * * *\nWindow owner: " + owner);

    owner.setFocusableWindowState(false);
    owner.setVisible(true);

    child.add(button);
    child.setVisible(true);

    Util.waitTillShown(child);

    Util.clickOnComp(button, robot);
    if (button == KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner()) {
      throw new RuntimeException("Test Failed.");
    }
    child.dispose();
    owner.dispose();
  }
Exemplo n.º 21
0
 /*
 	This could live in the desktop script.
 	However we'd like to get it on the screen as quickly as possible.
 */
 public static void startSplashScreen() {
   int width = 275, height = 148;
   Window win = new Window(new Frame());
   win.pack();
   BshCanvas can = new BshCanvas();
   can.setSize(width, height); // why is this necessary?
   Toolkit tk = Toolkit.getDefaultToolkit();
   Dimension dim = tk.getScreenSize();
   win.setBounds(dim.width / 2 - width / 2, dim.height / 2 - height / 2, width, height);
   win.add("Center", can);
   Image img = tk.getImage(Interpreter.class.getResource("/bsh/util/lib/splash.gif"));
   MediaTracker mt = new MediaTracker(can);
   mt.addImage(img, 0);
   try {
     mt.waitForAll();
   } catch (Exception e) {
   }
   Graphics gr = can.getBufferedGraphics();
   gr.drawImage(img, 0, 0, can);
   win.setVisible(true);
   win.toFront();
   splashScreen = win;
 }
Exemplo n.º 22
0
  static void changeWindowProperty(
      Client c,
      Window w,
      int property,
      int type,
      short format,
      byte mode,
      int len,
      byte[] value,
      boolean sendevent)
      throws IOException {
    synchronized (w) {
      Property p;
      int totalSize = len * (format / 8);
      p = w.getProperty();
      while (p != null) {
        if (p.propertyName == property) break;
        p = p.next;
      }

      if (p != null) {
        if ((format != p.format) && (mode != PropModeReplace)) {
          System.err.println("error!");
          c.errorReason = 8; // BadMatch
          return;
        }
        if ((type != p.type) && (mode != PropModeReplace)) {
          System.err.println("error!");
          c.errorReason = 8; // BadMatch
          return;
        }
        if (mode == PropModeReplace) {
          p.data = value;
          p.size = len;
          p.format = format;
          p.type = type;
        } else if (len == 0) {
        } else if (mode == PropModeAppend) {
          byte[] foo = new byte[(format / 8) * (len + p.size)];
          if (p.size > 0) System.arraycopy(p.data, 0, foo, 0, p.size);
          System.arraycopy(value, 0, foo, p.size, totalSize);
          p.size += len;
          p.data = foo;
        } else if (mode == PropModePrepend) {
          byte[] foo = new byte[(format / 8) * (len + p.size)];
          System.arraycopy(value, 0, foo, 0, totalSize);
          if (p.size > 0) System.arraycopy(p.data, 0, foo, totalSize, p.size);
          p.size += len;
          p.data = foo;
        }
        // change;
      } else {
        //    w.setProperty(null);
        p = new Property();
        p.propertyName = property;
        p.type = type;
        p.format = (short) format;
        p.data = value;
        p.size = len;
        p.next = w.getProperty();
        w.setProperty(p);
      }

      if (p != null) {
        if (p.propertyName == 9
            && // CUT_BUFFER0
            w == w.screen.root
            && p.size > 0) {
          CopyPaste.setString(new String(p.data, 0, p.size));
        }
        if (w.screen.windowmode != WeirdX.InBrowser
            && p.propertyName == 39
            && p.type == 31
            && p.size > 0
            && w.ddxwindow != null) {
          java.awt.Window frame = w.getFrame();
          if (frame != null && (frame instanceof java.awt.Frame)) {
            ((java.awt.Frame) frame).setTitle(new String(p.data));
          }
        }
      }
    }

    if (sendevent) {
      c.cevent.mkPropertyNotify(w.id, property, (int) System.currentTimeMillis(), 0);
      w.sendEvent(c.cevent, 1, null);
    }
  }
Exemplo n.º 23
0
 public void mouseExited(MouseEvent ev) {
   Window w = (Window) ev.getSource();
   w.setCursor(lastCursor);
 }
Exemplo n.º 24
0
 public void mouseEntered(MouseEvent ev) {
   Window w = (Window) ev.getSource();
   lastCursor = w.getCursor();
   mouseMoved(ev);
 }
Exemplo n.º 25
0
    public void mouseDragged(MouseEvent ev) {
      Window w = (Window) ev.getSource();
      Point pt = ev.getPoint();

      if (isMovingWindow) {
        Point windowPt;
        try {
          windowPt = (Point) AccessController.doPrivileged(getLocationAction);
          windowPt.x = windowPt.x - dragOffsetX;
          windowPt.y = windowPt.y - dragOffsetY;
          w.setLocation(windowPt);
        } catch (PrivilegedActionException e) {
        }
      } else if (dragCursor != 0) {
        Rectangle r = w.getBounds();
        Rectangle startBounds = new Rectangle(r);
        Dimension min = w.getMinimumSize();

        switch (dragCursor) {
          case Cursor.E_RESIZE_CURSOR:
            adjust(r, min, 0, 0, pt.x + (dragWidth - dragOffsetX) - r.width, 0);
            break;
          case Cursor.S_RESIZE_CURSOR:
            adjust(r, min, 0, 0, 0, pt.y + (dragHeight - dragOffsetY) - r.height);
            break;
          case Cursor.N_RESIZE_CURSOR:
            adjust(r, min, 0, pt.y - dragOffsetY, 0, -(pt.y - dragOffsetY));
            break;
          case Cursor.W_RESIZE_CURSOR:
            adjust(r, min, pt.x - dragOffsetX, 0, -(pt.x - dragOffsetX), 0);
            break;
          case Cursor.NE_RESIZE_CURSOR:
            adjust(
                r,
                min,
                0,
                pt.y - dragOffsetY,
                pt.x + (dragWidth - dragOffsetX) - r.width,
                -(pt.y - dragOffsetY));
            break;
          case Cursor.SE_RESIZE_CURSOR:
            adjust(
                r,
                min,
                0,
                0,
                pt.x + (dragWidth - dragOffsetX) - r.width,
                pt.y + (dragHeight - dragOffsetY) - r.height);
            break;
          case Cursor.NW_RESIZE_CURSOR:
            adjust(
                r,
                min,
                pt.x - dragOffsetX,
                pt.y - dragOffsetY,
                -(pt.x - dragOffsetX),
                -(pt.y - dragOffsetY));
            break;
          case Cursor.SW_RESIZE_CURSOR:
            adjust(
                r,
                min,
                pt.x - dragOffsetX,
                0,
                -(pt.x - dragOffsetX),
                pt.y + (dragHeight - dragOffsetY) - r.height);
            break;
          default:
            break;
        }
        if (!r.equals(startBounds)) {
          w.setBounds(r);
          // Defer repaint/validate on mouseReleased unless dynamic
          // layout is active.
          if (Toolkit.getDefaultToolkit().isDynamicLayoutActive()) {
            w.validate();
            getRootPane().repaint();
          }
        }
      }
    }
Exemplo n.º 26
0
 @Override
 public void init(final WindowBasedTextGUI textGUI) {
   final Window mainWindow = new BasicWindow("Choose test");
   Panel contentArea = new Panel();
   contentArea.setLayoutManager(new LinearLayout(Direction.VERTICAL));
   contentArea.addComponent(
       new Button(
           "Centered window",
           new Runnable() {
             @Override
             public void run() {
               textGUI.addWindow(new CenteredWindow());
             }
           }));
   contentArea.addComponent(
       new Button(
           "Undecorated window",
           new Runnable() {
             @Override
             public void run() {
               textGUI.addWindow(new UndecoratedWindow());
             }
           }));
   contentArea.addComponent(
       new Button(
           "Undecorated + Centered window",
           new Runnable() {
             @Override
             public void run() {
               textGUI.addWindow(new UndecoratedCenteredWindow());
             }
           }));
   contentArea.addComponent(
       new Button(
           "Full-screen window",
           new Runnable() {
             @Override
             public void run() {
               textGUI.addWindow(new FullScreenWindow(true));
             }
           }));
   contentArea.addComponent(
       new Button(
           "Undecorated + Full-screen window",
           new Runnable() {
             @Override
             public void run() {
               textGUI.addWindow(new FullScreenWindow(false));
             }
           }));
   contentArea.addComponent(
       new Button(
           "Expanded window",
           new Runnable() {
             @Override
             public void run() {
               textGUI.addWindow(new ExpandedWindow(true));
             }
           }));
   contentArea.addComponent(
       new Button(
           "Undecorated + Expanded window",
           new Runnable() {
             @Override
             public void run() {
               textGUI.addWindow(new ExpandedWindow(false));
             }
           }));
   contentArea.addComponent(
       new Button(
           "Close",
           new Runnable() {
             @Override
             public void run() {
               mainWindow.close();
             }
           }));
   mainWindow.setComponent(contentArea);
   textGUI.addWindow(mainWindow);
 }
Exemplo n.º 27
0
  static void reqRotateProperties(Client c) throws IOException {
    int foo, propty;
    IO io = c.client;

    foo = io.readInt();
    Window w = c.lookupWindow(foo);
    c.length -= 2;
    if (w == null) {
      c.errorValue = foo;
      c.errorReason = 3; // BadWindow;
      return;
    }
    int n = (short) io.readShort();
    int delta = (short) io.readShort();

    c.length--;

    if (n == 0) {
      return;
    }

    int[] atoms = new int[n];
    Property[] props = new Property[n];
    Property p;
    int i = 0;
    while (n != 0) {
      atoms[i] = io.readInt();
      c.length--;
      if (!Atom.valid(atoms[i])) {
        c.errorValue = atoms[i];
        c.errorReason = 5; // BadAtom
        return;
      }
      p = w.getProperty();
      while (p != null) {
        if (p.propertyName == atoms[i]) {
          props[i] = p;
          break;
        }
        p = p.next;
      }
      if (p == null) {
        c.errorReason = 8; // BadMatch
        return;
      }
      i++;
      n--;
    }
    for (int j = 0; j < atoms.length; j++) {
      for (int k = j + 1; k < atoms.length; k++) {
        if (atoms[j] == atoms[k]) {
          c.errorReason = 8; // BadMatch
          return;
        }
      }
    }
    if (((delta < 0 ? -1 * delta : delta) % atoms.length) != 0) {
      while (delta < 0) {
        delta += atoms.length;
      }
      for (i = 0; i < atoms.length; i++) {
        c.cevent.mkPropertyNotify(
            w.id,
            props[i].propertyName,
            (int) System.currentTimeMillis(),
            // Property.PropertyNewValue
            0);
        w.sendEvent(c.cevent, 1, null);
        props[i].propertyName = atoms[(i + delta) % atoms.length];
      }
    }
  }
Exemplo n.º 28
0
  static void reqGetProperty(Client c) throws IOException {
    int foo;
    int dlt;
    int prprty;
    int typ;
    int ffst, lngth;
    IO io = c.client;
    dlt = c.data;

    foo = io.readInt();
    Window w = c.lookupWindow(foo);
    if (w == null) {
      c.errorValue = foo;
      c.errorReason = 3; // BadWindow;
    }
    prprty = io.readInt();
    typ = io.readInt();
    ffst = io.readInt();
    lngth = io.readInt();
    c.length -= 6;
    if (c.errorReason != 0) {
      return;
    }
    int frmt;
    int seq;
    int ba;
    Property prop;
    prop = Property.getProperty(w, prprty, typ);

    synchronized (io) {
      io.writeByte(1);
      if (prop == null) {
        io.writeByte(0);
        io.writeShort(c.seq);
        io.writeInt(0);
        io.writeInt(0);
        io.writeInt(0);
        io.writeInt(0);
        io.writePad(12);
        io.flush();
        return;
      }

      if ((typ != prop.type) && typ != 0) {
        io.writeByte(prop.format);
        io.writeShort(c.seq);
        io.writeInt(0);
        io.writeInt(prop.type);
        io.writeInt(0);
        io.writeInt(0);
        io.writePad(12);
        io.flush();
        return;
      }

      int n = (prop.format / 8) * prop.size;

      int ind = ffst * 4;
      if (n < ind) {
        // System.err.println("procGetProperty: ind-n="+new Integer((ind-n)));
      }

      int len = ((n - ind) < lngth * 4) ? n - ind : lngth * 4;
      if ((lngth * 4) < 0) len = n - ind;
      ba = n - (ind + len);
      if (dlt != 0 && ba == 0) {
        c.cevent.mkPropertyNotify(w.id, prprty, (int) System.currentTimeMillis(), 1);
        w.sendEvent(c.cevent, 1, null);
      }

      io.writeByte(prop.format);
      io.writeShort(c.seq);
      io.writeInt((len + 3) / 4);
      io.writeInt(prop.type);
      io.writeInt(ba);
      if ((prop.format / 8) == 0) io.writeInt(0);
      else io.writeInt(len / (prop.format / 8));

      io.writePad(12);

      if (len > 0) {
        if (c.swap && (prop.format == 16 || prop.format == 32)) {
          byte[] b = new byte[len];
          System.arraycopy(prop.data, ind, b, 0, len);
          switch (prop.format) {
            case 16:
              swapS(b, 0, len);
              break;
            case 32:
              swapL(b, 0, len);
              break;
            default:
          }
          io.writeByte(b, 0, len);
        } else {
          io.writeByte(prop.data, ind, len);
        }
        if (((-len) & 3) > 0) {
          io.writePad((-len) & 3);
        }
      }
      io.flush();
    }

    if (dlt != 0 && ba == 0) {
      Property.delProperty(c, w, prprty, typ);
    }
  }
Exemplo n.º 29
0
 /**
  * Uninstalls the necessary Listeners on the <code>Window</code> the Listeners were last installed
  * on.
  */
 private void uninstallWindowListeners(JRootPane root) {
   if (window != null) {
     window.removeMouseListener(mouseInputListener);
     window.removeMouseMotionListener(mouseInputListener);
   }
 }
Exemplo n.º 30
0
 public static void endSplashScreen() {
   if (splashScreen != null) splashScreen.dispose();
 }