All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.moaxcp.x11client.protocol.xv.VideoNotifyEvent Maven / Gradle / Ivy

There is a newer version: 0.18.2
Show newest version
package com.github.moaxcp.x11client.protocol.xv;

import com.github.moaxcp.x11client.protocol.X11Input;
import com.github.moaxcp.x11client.protocol.X11Output;
import com.github.moaxcp.x11client.protocol.XEvent;
import java.io.IOException;
import java.lang.Override;
import lombok.Builder;
import lombok.Value;

@Value
@Builder
public class VideoNotifyEvent implements XEvent {
  public static final byte NUMBER = 0;

  private boolean sentEvent;

  private byte reason;

  private short sequenceNumber;

  private int time;

  private int drawable;

  private int port;

  @Override
  public byte getResponseCode() {
    return NUMBER;
  }

  public static VideoNotifyEvent readVideoNotifyEvent(boolean sentEvent, X11Input in) throws
      IOException {
    byte reason = in.readByte();
    short sequenceNumber = in.readCard16();
    int time = in.readCard32();
    int drawable = in.readCard32();
    int port = in.readCard32();
    in.readPad(16);
    VideoNotifyEvent.VideoNotifyEventBuilder javaBuilder = VideoNotifyEvent.builder();
    javaBuilder.reason(reason);
    javaBuilder.sequenceNumber(sequenceNumber);
    javaBuilder.time(time);
    javaBuilder.drawable(drawable);
    javaBuilder.port(port);

    javaBuilder.sentEvent(sentEvent);
    return javaBuilder.build();
  }

  @Override
  public void write(X11Output out) throws IOException {
    out.writeCard8(sentEvent ? 0b10000000 & NUMBER : NUMBER);
    out.writeByte(reason);
    out.writeCard16(sequenceNumber);
    out.writeCard32(time);
    out.writeCard32(drawable);
    out.writeCard32(port);
    out.writePad(16);
  }

  @Override
  public int getSize() {
    return 32;
  }

  public static class VideoNotifyEventBuilder {
    public VideoNotifyEvent.VideoNotifyEventBuilder reason(VideoNotifyReason reason) {
      this.reason = (byte) reason.getValue();
      return this;
    }

    public VideoNotifyEvent.VideoNotifyEventBuilder reason(byte reason) {
      this.reason = reason;
      return this;
    }

    public int getSize() {
      return 32;
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy