Example #1
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();
    }
  }
Example #2
0
  static void reqGetSelectionOwner(Client c) throws IOException {
    int foo;
    int selection;
    IO io = c.client;
    selection = io.readInt();

    c.length -= 2;

    if (!Atom.valid(selection)) {
      c.errorValue = selection;
      c.errorReason = 5; // BadAtom
      return;
    }

    synchronized (io) {
      io.writeByte(1);
      Selection s = getSelection(selection);
      io.writePad(1);
      io.writeShort(c.seq);
      io.writeInt(0);
      if (s != null) {
        io.writeInt(s.wid);
      } else {
        io.writeInt(0);
      }
      io.writePad(20);
      io.flush();
    }
  }
Example #3
0
 void writeByte(IO out) throws java.io.IOException {
   out.writeInt(id);
   out.writeByte(clss);
   out.writeByte(bitsPerRGB);
   out.writeShort(colormapEntries);
   out.writeInt(redMask);
   out.writeInt(greenMask);
   out.writeInt(blueMask);
   out.writePad(4);
 }
Example #4
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);
    }
  }