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

com.github.moaxcp.x11client.protocol.xf86vidmode.GetGammaRampReply Maven / Gradle / Ivy

There is a newer version: 0.18.2
Show newest version
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.XReply;
import java.io.IOException;
import java.lang.Override;
import java.lang.Short;
import java.util.List;
import lombok.Builder;
import lombok.NonNull;
import lombok.Value;

@Value
@Builder
public class GetGammaRampReply implements XReply {
  private short sequenceNumber;

  @NonNull
  private List red;

  @NonNull
  private List green;

  @NonNull
  private List blue;

  public static GetGammaRampReply readGetGammaRampReply(byte pad, short sequenceNumber, X11Input in)
      throws IOException {
    int length = in.readCard32();
    short size = in.readCard16();
    in.readPad(22);
    List red = in.readCard16((Short.toUnsignedInt(size) + 1) & (~ (1)));
    List green = in.readCard16((Short.toUnsignedInt(size) + 1) & (~ (1)));
    List blue = in.readCard16((Short.toUnsignedInt(size) + 1) & (~ (1)));
    GetGammaRampReply.GetGammaRampReplyBuilder javaBuilder = GetGammaRampReply.builder();
    javaBuilder.sequenceNumber(sequenceNumber);
    javaBuilder.red(red);
    javaBuilder.green(green);
    javaBuilder.blue(blue);
    if(javaBuilder.getSize() < 32) {
      in.readPad(32 - javaBuilder.getSize());
    }
    return javaBuilder.build();
  }

  @Override
  public void write(X11Output out) throws IOException {
    out.writeCard8(getResponseCode());
    out.writePad(1);
    out.writeCard16(sequenceNumber);
    out.writeCard32(getLength());
    short size = (short) blue.size();
    out.writeCard16(size);
    out.writePad(22);
    out.writeCard16(red);
    out.writeCard16(green);
    out.writeCard16(blue);
    out.writePadAlign(getSize());
  }

  @Override
  public int getSize() {
    return 32 + 2 * red.size() + 2 * green.size() + 2 * blue.size();
  }

  public static class GetGammaRampReplyBuilder {
    public int getSize() {
      return 32 + 2 * red.size() + 2 * green.size() + 2 * blue.size();
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy