Exemplo n.º 1
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();
    }
  }
Exemplo n.º 2
0
  static void reqConvertSelection(Client c) throws IOException {
    int foo;
    int selection, requestor, target, property, time;
    boolean paramsOkay = true;
    IO io = c.client;
    requestor = io.readInt();
    Window w = c.lookupWindow(requestor);
    if (w == null) {
      c.errorValue = requestor;
      c.errorReason = 3; // BadWindow;
    }
    selection = io.readInt();
    paramsOkay = Atom.valid(selection);
    target = io.readInt();
    paramsOkay &= Atom.valid(target);
    property = io.readInt();
    if (property != 0) {
      paramsOkay &= Atom.valid(property);
    }
    time = io.readInt();
    c.length -= 6;
    if (c.errorReason != 0) {
      return;
    }

    if (paramsOkay) {
      Selection s = getSelection(selection);
      if (s != null && s.client != null) {
        c.cevent.mkSelectionRequest(time, s.wid, requestor, selection, target, property);
        if (s.client.sendEvent(c.cevent, 1, Event.NoEventMask, Event.NoEventMask, null) != 0)
          return;
      }
      c.cevent.mkSelectionNotify(time, requestor, selection, target, 0);
      c.sendEvent(c.cevent, 1, Event.NoEventMask, Event.NoEventMask, null);

      return;
    } else {
      // System.out.println("error!!");
      c.errorValue = property;
      c.errorReason = 5; // BadAtom
      return;
    }
  }
Exemplo n.º 3
0
  static void reqSetSelectionOwner(Client c) throws IOException {
    int foo;
    int selection;
    IO io = c.client;
    foo = io.readInt();
    c.length -= 2;
    Window w = null;
    if (foo != 0) {
      w = c.lookupWindow(foo);
      if (w == null) {
        c.errorValue = foo;
        c.errorReason = 3; // BadWindow
        return;
      }
    }

    selection = io.readInt();
    foo = io.readInt();
    c.length -= 2;
    int time = 0;
    time = (int) System.currentTimeMillis();
    time = foo; // ??

    if (Atom.valid(selection)) {
      int i = 0;
      Selection s = getSelection(selection);
      if (s != null) {
        if (s.client != null && (w == null || (s.client != c))) {
          if (s.client != null) {
            c.cevent.mkSelectionClear(time, s.wid, s.selection);
            s.client.sendEvent(c.cevent, 1, Event.NoEventMask, Event.NoEventMask, null);
          }
        }
        s.window = w;
        s.wid = (w != null ? w.id : 0);
        s.lastTimeChanged = time;
        s.client = (w != null ? c : null);
      } else {
        // System.out.println("add");
        addSelection(selection, time, w, c);
      }
      return;
    } else {
      c.errorValue = selection;
      c.errorReason = 5;
      return;
    }
  }
Exemplo n.º 4
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];
      }
    }
  }