com.github.moaxcp.x11client.protocol.xproto.Depth Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of x11-client Show documentation
Show all versions of x11-client Show documentation
An x11 client implemented in java
package com.github.moaxcp.x11client.protocol.xproto;
import com.github.moaxcp.x11client.protocol.X11Input;
import com.github.moaxcp.x11client.protocol.X11Output;
import com.github.moaxcp.x11client.protocol.XObject;
import com.github.moaxcp.x11client.protocol.XStruct;
import java.io.IOException;
import java.lang.Override;
import java.util.ArrayList;
import java.util.List;
import lombok.Builder;
import lombok.NonNull;
import lombok.Value;
@Value
@Builder
public class Depth implements XStruct {
private byte depth;
private short visualsLen;
@NonNull
private List visuals;
public static Depth readDepth(X11Input in) throws IOException {
byte depth = in.readCard8();
in.readPad(1);
short visualsLen = in.readCard16();
in.readPad(4);
List visuals = new ArrayList<>(Short.toUnsignedInt(visualsLen));
for(int i = 0; i < Short.toUnsignedInt(visualsLen); i++) {
visuals.add(Visualtype.readVisualtype(in));
}
Depth.DepthBuilder javaBuilder = Depth.builder();
javaBuilder.depth(depth);
javaBuilder.visualsLen(visualsLen);
javaBuilder.visuals(visuals);
return javaBuilder.build();
}
@Override
public void write(X11Output out) throws IOException {
out.writeCard8(depth);
out.writePad(1);
out.writeCard16(visualsLen);
out.writePad(4);
for(Visualtype t : visuals) {
t.write(out);
}
}
@Override
public int getSize() {
return 8 + XObject.sizeOf(visuals);
}
public static class DepthBuilder {
public int getSize() {
return 8 + XObject.sizeOf(visuals);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy