com.github.moaxcp.x11client.protocol.xproto.MappingNotifyEvent 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.XEvent;
import java.io.IOException;
import java.lang.Override;
import lombok.Builder;
import lombok.Value;
@Value
@Builder
public class MappingNotifyEvent implements XEvent {
public static final byte NUMBER = 34;
private boolean sentEvent;
private short sequenceNumber;
private byte request;
private byte firstKeycode;
private byte count;
@Override
public byte getResponseCode() {
return NUMBER;
}
public static MappingNotifyEvent readMappingNotifyEvent(boolean sentEvent, X11Input in) throws
IOException {
in.readPad(1);
short sequenceNumber = in.readCard16();
byte request = in.readByte();
byte firstKeycode = in.readCard8();
byte count = in.readCard8();
in.readPad(1);
in.readPad(24);
MappingNotifyEvent.MappingNotifyEventBuilder javaBuilder = MappingNotifyEvent.builder();
javaBuilder.sequenceNumber(sequenceNumber);
javaBuilder.request(request);
javaBuilder.firstKeycode(firstKeycode);
javaBuilder.count(count);
javaBuilder.sentEvent(sentEvent);
return javaBuilder.build();
}
@Override
public void write(X11Output out) throws IOException {
out.writeCard8(sentEvent ? 0b10000000 & NUMBER : NUMBER);
out.writePad(1);
out.writeCard16(sequenceNumber);
out.writeByte(request);
out.writeCard8(firstKeycode);
out.writeCard8(count);
out.writePad(1);
out.writePad(24);
}
@Override
public int getSize() {
return 32;
}
public static class MappingNotifyEventBuilder {
public MappingNotifyEvent.MappingNotifyEventBuilder request(Mapping request) {
this.request = (byte) request.getValue();
return this;
}
public MappingNotifyEvent.MappingNotifyEventBuilder request(byte request) {
this.request = request;
return this;
}
public int getSize() {
return 32;
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy