Package com.peterhi.net3

Examples of com.peterhi.net3.Remote$Window$Frame


public class Server {

  public static void main(String[] args) throws Exception {
    Local local = new Local(22222);
    local.getSocket().setSoTimeout(10);
    local.addListener(new Listener() {
      @Override
      public void received(SocketAddress address, byte[] data) {
        System.out.println("Received " + new String(data) + " from " + address);
      }
    });
View Full Code Here


        @Override
        public void run() {
          try {
            final X11 x11 = X11.INSTANCE;
            final Display display = x11.XOpenDisplay(null);
            Window window = new Window(nativeHandle);
            x11.XSelectInput(display, window,
                new NativeLong(X11.ExposureMask |
                    X11.VisibilityChangeMask |
                    X11.StructureNotifyMask |
                    X11.FocusChangeMask |
View Full Code Here

        screenVisual = new HashMap<Integer,Visual>();
 
  defaultDepth = display.default_depth;

        atomsWmSelection = new Atom[display.screens.length];
        Window wmSelectionWin = new Window(rootWin, 0,0, 1, 1, 0, new Window.Attributes());

  for (int i = 0; i< display.screens.length; i++) {
      Screen screen = display.screens[i];
      gnu.x11.Enum scrdepths = screen.depths();
      while (scrdepths.more()) {
          Depth depth = (Depth) scrdepths.next();
          screenDepth.put(depth.depth(), depth);
   
    gnu.x11.Enum enm = depth.visuals();       
    while (enm.more()) {
        Visual visual = (Visual) enm.next();             
        screenVisual.put(visual.id(), visual);
    }
      }

      // AWT in Java6u1 requires that the WM acquire these selections.
      // Note: even though the WM conventions recommend that CurrentTime
      // not be used we can use it here because the LG WM is the only one
      // acquiring these selections.

      atomsWmSelection[i] = (Atom)Atom.intern(display, "WM_S" + i);
      wmSelectionWin.set_selection_owner(atomsWmSelection[i], Display.CURRENT_TIME);
      display.check_error();
  }

  atomWmState = (Atom)Atom.intern(display, "WM_STATE");
  atomWmChangeState = (Atom)Atom.intern(display, "WM_CHANGE_STATE");
  atomWmProtocols = (Atom)Atom.intern(display, "WM_PROTOCOLS");
  atomWmDeleteWindow = (Atom)Atom.intern(display, "WM_DELETE_WINDOW");
  atomWmTakeFocus = (Atom)Atom.intern(display, "WM_TAKE_FOCUS");
  atomWmColormapWindows=(Atom)Atom.intern(display,"WM_COLORMAP_WINDOWS");
  atomWmTransientFor = (Atom)Atom.intern(display, "WM_TRANSIENT_FOR");
  atomCompoundText = (Atom)Atom.intern(display, "COMPOUND_TEXT");
  atomServerShutdown = (Atom)Atom.intern(display, "SERVER_SHUTDOWN");

  try {
            selectInput(rootWin);
  } catch (Error err) {
      if (err.code == Error.BAD_ACCESS && err.bad == rootWin.id) {
                logger.severe("Failed to access root window. Another WM is running?");
    throw new RuntimeException ("Failed to access root window\n"
        + "Another WM is running?"); // FIXME
      } else {
    throw err;
      }
  }
       
        // Remote Windows: Automatically composite redirect all root top-level windows
  compositeTopLevelWindows();

  // Init WmNET support for screen 0
  // TODO: multiscreen
  Window[] rootWins = new Window[1];
  Window[] checkWins = new Window[1];
  rootWins[0] = rootWin;
        checkWins[0] = new Window(rootWin, 0,0, 1, 1, 0, new Window.Attributes());
  X11WindowManagerHints.initWmNETSupport(display, rootWins, checkWins);

  // prepare for the event dispatch thread
  Thread eventThread = new Thread( this, "X11WindowManager" );
  // eventThread.setPriority(Thread.NORM_PRIORITY + 2); // FIXME
View Full Code Here

      Animation animation) {
    d.printSection(animation.getName());
    d.printKeyValue("DefaultKeyDuration",""+animation.getDefaultKeyDuration());
    Frame[] frames = animation.getFrames();
    for(int fi=0; fi<frames.length; fi++) {
      Frame f = frames[fi];
      d.printKeyValue("KeyData"+(fi+1),f.getName());
      if(f.getKeyDuration()>0)
        d.printKeyValue("KeyDuration"+(fi+1),""+f.getKeyDuration());
    }
    for(int fi=0; fi<frames.length; fi++) {
      Frame f = frames[fi];
      Point offset = f.getOffset();
      if(offset.x!=0 || offset.y!=0) {
        d.printKeyValue("KeyEventName"+(fi+1),"__"+fi);
        d.printKeyValue("__"+fi, "("+offset.x+","+offset.y+",0)");       
      }
    }
View Full Code Here

    return null;
  }

  @Override
  public long getFrameDelay(int index) {
    Frame frame = getFrame(index);
    return (long) (frame.getFinalFrameDuration()*1000);
  }
 
View Full Code Here

        for(Frame frame: animation.getFrames()) {
          paintFrame(g, frame);
        }
      }
      if (selected instanceof Frame) {
        Frame frame = (Frame) selected;
        paintFrame(g,frame);
      }   
    }
    if(freeOffsetStart != null && freeOffsetEnd != null) {
      Point base = toScreen(freeOffsetStart);
View Full Code Here

  private int snap(int snapMe){
    return java.lang.Math.round( snapMe/parent.SnapSlider.getValue() )*parent.SnapSlider.getValue();
  }
 
  @Override public void mouseDragged(MouseEvent e) {
    Frame selected = getSelectedFrame();
    if(selected==null) return;
    if((e.getModifiersEx() & MouseEvent.BUTTON3_DOWN_MASK) == MouseEvent.BUTTON3_DOWN_MASK) {
      if(parent.isSettingOffsetDirectly())
        handleEditOffset(selected,e);     
      if(parent.isSettingOffsetWithRelativePos())
        freeOffsetEnd = getViewPoint(e);
      if(parent.isSettingPivot()) 
        selected.setPivot(new Point(getViewX(e),getViewY(e)));
      if(parent.isRectangleLocked()) {
        int x = snap(getViewX(e)), y = snap(getViewY(e))

        selected.setRectangle(new Rectangle(x,y,parent.lockRectButton.lastRect.width,parent.lockRectButton.lastRect.height));
        selected.setImageFile(editorFrame.getData().getProject().getRelativeFile(imageFile));

        int PivotDX = parent.lockRectButton.lastPivot.x - parent.lockRectButton.lastRect.x;
        int PivotDY = parent.lockRectButton.lastPivot.y - parent.lockRectButton.lastRect.y;
        selected.setPivot(new Point(x+PivotDX,y+PivotDY));
      }
      if(parent.isEditingRectangle()){
       
        Rectangle rect = selected.getRectangle();
        int x = snap(rect.x), y = snap(rect.y);
        int dx = snap(getViewX(e)-x), dy = snap(getViewY(e)-y);
        Rectangle newRectangle = new Rectangle(x,y,dx,dy);
        selected.setRectangle(newRectangle);
        selected.setImageFile(editorFrame.getData().getProject().getRelativeFile(imageFile));
      }
      if(parent.isSettingOffsetWithTemporaryPivot()) {
        if(parent.temporaryPivotOffsetButton.getPivot2()!=null) {
          parent.temporaryPivotOffsetButton.setPivot2(getViewPoint(e));
          selected.setOffset(parent.temporaryPivotOffsetButton.getOffset());
        }
        else
          parent.temporaryPivotOffsetButton.setPivot1(getViewPoint(e));
      }
    }
View Full Code Here

    repaint(20);
  }

  @Override
  public void mousePressed(MouseEvent e) {
    Frame selected  = getSelectedFrame();
    if(selected==null) return;
 
    if(e.getButton() == MouseEvent.BUTTON3) {
      if(parent.isSettingOffsetDirectly()) {
            handleEditOffset(selected, e);
      }
        if (parent.isSettingOffsetWithRelativePos()) {
          freeOffsetStart = getViewPoint(e);
        }
      if(parent.isSettingPivot()) {
        selected.setPivot(new Point(getViewX(e),getViewY(e)));
      }   
      if (parent.isRectangleLocked()) {
        selected.setRectangle(new Rectangle(getViewX(e),getViewY(e),parent.lockRectButton.lastRect.width,parent.lockRectButton.lastRect.height));
        selected.setImageFile(editorFrame.getData().getProject().getRelativeFile(imageFile));
        int PivotDX = parent.lockRectButton.lastPivot.x - parent.lockRectButton.lastRect.x;
        int PivotDY = parent.lockRectButton.lastPivot.y - parent.lockRectButton.lastRect.y;
        selected.setPivot(new Point(getViewX(e)+PivotDX,getViewY(e)+PivotDY));         
      }
      if(parent.isEditingRectangle()) {
        selected.setRectangle(new Rectangle(getViewX(e),getViewY(e),0,0));
        selected.setImageFile(editorFrame.getData().getProject().getRelativeFile(imageFile));
        selected.setPivot(null);
      }
      if(parent.isSettingOffsetWithTemporaryPivot()) {
        if(parent.temporaryPivotOffsetButton.getPivot1()==null) {
          parent.temporaryPivotOffsetButton.setPivot1(getViewPoint(e));
        } else {
          parent.temporaryPivotOffsetButton.setPivot2(getViewPoint(e));
          selected.setOffset(parent.temporaryPivotOffsetButton.getOffset());
        }
      }
    }
    repaint(20);
  }
View Full Code Here

    return e.getY()/zoom;
 
 
  @Override
  public void mouseReleased(MouseEvent e) {
    Frame frame = getSelectedFrame();
    if(parent.isSettingOffsetWithRelativePos()) {
      if(frame!=null) {
        frame.setOffset(new Point(freeOffsetEnd.x-freeOffsetStart.x, freeOffsetEnd.y-freeOffsetStart.y));
      }
      freeOffsetEnd = null;
      freeOffsetStart = null;
      repaint(20);
    }
View Full Code Here

    JTree.DropLocation loc = (JTree.DropLocation) support.getDropLocation();
    Object parent = loc.getPath().getLastPathComponent();
    int index = loc.getChildIndex();
    if(index==-1) { // We're dropping "ON" something
      if(parent instanceof Frame) {
        Frame frame = (Frame) parent;
        index = frame.getParent().getFrameIndex(frame)+1;
        parent = frame.getParent();
      } else if(parent instanceof Animation) {
        index = ((Animation) parent).getFrameCount();
      }
    }
    if(parent instanceof Animation) {
      try {
        Frame[] frames = (Frame[]) support.getTransferable().getTransferData(FrameFlavor);
        if(support.getDropAction() == COPY)
          for(Frame frame:frames) ((Animation) parent).addFrame(frame.clone(),index++);
        else if (support.getDropAction() == MOVE) {
          index--;
          for(Frame frame:frames) index = frame.move(parent,index);                   
        }
        return true;
      } catch (Exception e) {
          e.printStackTrace();
          return false;
View Full Code Here

TOP

Related Classes of com.peterhi.net3.Remote$Window$Frame

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.