com.github.moaxcp.x11client.protocol.xf86vidmode.ModeInfo 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.xf86vidmode;
import com.github.moaxcp.x11client.protocol.X11Input;
import com.github.moaxcp.x11client.protocol.X11Output;
import com.github.moaxcp.x11client.protocol.XStruct;
import java.io.IOException;
import java.lang.Override;
import lombok.Builder;
import lombok.NonNull;
import lombok.Value;
@Value
@Builder
public class ModeInfo implements XStruct {
private int dotclock;
private short hdisplay;
private short hsyncstart;
private short hsyncend;
private short htotal;
private int hskew;
private short vdisplay;
private short vsyncstart;
private short vsyncend;
private short vtotal;
private int flags;
private int privsize;
public static ModeInfo readModeInfo(X11Input in) throws IOException {
int dotclock = in.readCard32();
short hdisplay = in.readCard16();
short hsyncstart = in.readCard16();
short hsyncend = in.readCard16();
short htotal = in.readCard16();
int hskew = in.readCard32();
short vdisplay = in.readCard16();
short vsyncstart = in.readCard16();
short vsyncend = in.readCard16();
short vtotal = in.readCard16();
in.readPad(4);
int flags = in.readCard32();
in.readPad(12);
int privsize = in.readCard32();
ModeInfo.ModeInfoBuilder javaBuilder = ModeInfo.builder();
javaBuilder.dotclock(dotclock);
javaBuilder.hdisplay(hdisplay);
javaBuilder.hsyncstart(hsyncstart);
javaBuilder.hsyncend(hsyncend);
javaBuilder.htotal(htotal);
javaBuilder.hskew(hskew);
javaBuilder.vdisplay(vdisplay);
javaBuilder.vsyncstart(vsyncstart);
javaBuilder.vsyncend(vsyncend);
javaBuilder.vtotal(vtotal);
javaBuilder.flags(flags);
javaBuilder.privsize(privsize);
return javaBuilder.build();
}
@Override
public void write(X11Output out) throws IOException {
out.writeCard32(dotclock);
out.writeCard16(hdisplay);
out.writeCard16(hsyncstart);
out.writeCard16(hsyncend);
out.writeCard16(htotal);
out.writeCard32(hskew);
out.writeCard16(vdisplay);
out.writeCard16(vsyncstart);
out.writeCard16(vsyncend);
out.writeCard16(vtotal);
out.writePad(4);
out.writeCard32(flags);
out.writePad(12);
out.writeCard32(privsize);
}
public boolean isFlagsEnabled(@NonNull ModeFlag... maskEnums) {
for(ModeFlag m : maskEnums) {
if(!m.isEnabled(flags)) {
return false;
}
}
return true;
}
@Override
public int getSize() {
return 48;
}
public static class ModeInfoBuilder {
public boolean isFlagsEnabled(@NonNull ModeFlag... maskEnums) {
for(ModeFlag m : maskEnums) {
if(!m.isEnabled(flags)) {
return false;
}
}
return true;
}
public ModeInfo.ModeInfoBuilder flagsEnable(ModeFlag... maskEnums) {
for(ModeFlag m : maskEnums) {
flags((int) m.enableFor(flags));
}
return this;
}
public ModeInfo.ModeInfoBuilder flagsDisable(ModeFlag... maskEnums) {
for(ModeFlag m : maskEnums) {
flags((int) m.disableFor(flags));
}
return this;
}
public int getSize() {
return 48;
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy