コード例 #1
0
ファイル: Property.java プロジェクト: imkafo/xhttp
  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();
    }
  }
コード例 #2
0
ファイル: Property.java プロジェクト: imkafo/xhttp
 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);
   }
 }
コード例 #3
0
ファイル: Property.java プロジェクト: imkafo/xhttp
 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;
   }
 }
コード例 #4
0
ファイル: Property.java プロジェクト: imkafo/xhttp
  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);
    }
  }
コード例 #5
0
ファイル: Property.java プロジェクト: imkafo/xhttp
  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];
      }
    }
  }