Esempio n. 1
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;
    }
  }
Esempio n. 2
0
 static synchronized void delete(Window w) {
   Selection s;
   int len = currentSelection.length;
   for (int i = 0; i < len && (s = currentSelection[i]) != null; i++) {
     if (s.window == w) {
       if (i + 1 == len) {
         currentSelection[i] = null;
       } else {
         for (int j = i + 1; j < len; j++) {
           currentSelection[j - 1] = currentSelection[j];
           if (currentSelection[j] == null) break;
         }
       }
       s.window = null;
       s.client = null;
     }
   }
 }