com.github.moaxcp.x11client.protocol.xproto.ChangeWindowAttributes 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.OneWayRequest;
import com.github.moaxcp.x11client.protocol.X11Input;
import com.github.moaxcp.x11client.protocol.X11Output;
import java.io.IOException;
import java.lang.Byte;
import java.lang.Override;
import lombok.Builder;
import lombok.NonNull;
import lombok.Value;
@Value
@Builder
public class ChangeWindowAttributes implements OneWayRequest {
public static final byte OPCODE = 2;
private int window;
private int valueMask;
private int backgroundPixmap;
private int backgroundPixel;
private int borderPixmap;
private int borderPixel;
private int bitGravity;
private int winGravity;
private int backingStore;
private int backingPlanes;
private int backingPixel;
private int overrideRedirect;
private int saveUnder;
private int eventMask;
private int doNotPropogateMask;
private int colormap;
private int cursor;
public byte getOpCode() {
return OPCODE;
}
public static ChangeWindowAttributes readChangeWindowAttributes(X11Input in) throws IOException {
in.readPad(1);
short length = in.readCard16();
int window = in.readCard32();
int valueMask = in.readCard32();
ChangeWindowAttributes.ChangeWindowAttributesBuilder javaBuilder = ChangeWindowAttributes.builder();
javaBuilder.window(window);
javaBuilder.valueMask(valueMask);
if(javaBuilder.isValueMaskEnabled(Cw.BACK_PIXMAP)) {
javaBuilder.backgroundPixmap(in.readCard32());
}
if(javaBuilder.isValueMaskEnabled(Cw.BACK_PIXEL)) {
javaBuilder.backgroundPixel(in.readCard32());
}
if(javaBuilder.isValueMaskEnabled(Cw.BORDER_PIXMAP)) {
javaBuilder.borderPixmap(in.readCard32());
}
if(javaBuilder.isValueMaskEnabled(Cw.BORDER_PIXEL)) {
javaBuilder.borderPixel(in.readCard32());
}
if(javaBuilder.isValueMaskEnabled(Cw.BIT_GRAVITY)) {
javaBuilder.bitGravity(in.readCard32());
}
if(javaBuilder.isValueMaskEnabled(Cw.WIN_GRAVITY)) {
javaBuilder.winGravity(in.readCard32());
}
if(javaBuilder.isValueMaskEnabled(Cw.BACKING_STORE)) {
javaBuilder.backingStore(in.readCard32());
}
if(javaBuilder.isValueMaskEnabled(Cw.BACKING_PLANES)) {
javaBuilder.backingPlanes(in.readCard32());
}
if(javaBuilder.isValueMaskEnabled(Cw.BACKING_PIXEL)) {
javaBuilder.backingPixel(in.readCard32());
}
if(javaBuilder.isValueMaskEnabled(Cw.OVERRIDE_REDIRECT)) {
javaBuilder.overrideRedirect(in.readCard32());
}
if(javaBuilder.isValueMaskEnabled(Cw.SAVE_UNDER)) {
javaBuilder.saveUnder(in.readCard32());
}
if(javaBuilder.isValueMaskEnabled(Cw.EVENT_MASK)) {
javaBuilder.eventMask(in.readCard32());
}
if(javaBuilder.isValueMaskEnabled(Cw.DONT_PROPAGATE)) {
javaBuilder.doNotPropogateMask(in.readCard32());
}
if(javaBuilder.isValueMaskEnabled(Cw.COLORMAP)) {
javaBuilder.colormap(in.readCard32());
}
if(javaBuilder.isValueMaskEnabled(Cw.CURSOR)) {
javaBuilder.cursor(in.readCard32());
}
in.readPadAlign(javaBuilder.getSize());
return javaBuilder.build();
}
@Override
public void write(byte offset, X11Output out) throws IOException {
out.writeCard8((byte)(Byte.toUnsignedInt(OPCODE) + Byte.toUnsignedInt(offset)));
out.writePad(1);
out.writeCard16((short) getLength());
out.writeCard32(window);
out.writeCard32(valueMask);
if(isValueMaskEnabled(Cw.BACK_PIXMAP)) {
out.writeCard32(backgroundPixmap);
}
if(isValueMaskEnabled(Cw.BACK_PIXEL)) {
out.writeCard32(backgroundPixel);
}
if(isValueMaskEnabled(Cw.BORDER_PIXMAP)) {
out.writeCard32(borderPixmap);
}
if(isValueMaskEnabled(Cw.BORDER_PIXEL)) {
out.writeCard32(borderPixel);
}
if(isValueMaskEnabled(Cw.BIT_GRAVITY)) {
out.writeCard32(bitGravity);
}
if(isValueMaskEnabled(Cw.WIN_GRAVITY)) {
out.writeCard32(winGravity);
}
if(isValueMaskEnabled(Cw.BACKING_STORE)) {
out.writeCard32(backingStore);
}
if(isValueMaskEnabled(Cw.BACKING_PLANES)) {
out.writeCard32(backingPlanes);
}
if(isValueMaskEnabled(Cw.BACKING_PIXEL)) {
out.writeCard32(backingPixel);
}
if(isValueMaskEnabled(Cw.OVERRIDE_REDIRECT)) {
out.writeCard32(overrideRedirect);
}
if(isValueMaskEnabled(Cw.SAVE_UNDER)) {
out.writeCard32(saveUnder);
}
if(isValueMaskEnabled(Cw.EVENT_MASK)) {
out.writeCard32(eventMask);
}
if(isValueMaskEnabled(Cw.DONT_PROPAGATE)) {
out.writeCard32(doNotPropogateMask);
}
if(isValueMaskEnabled(Cw.COLORMAP)) {
out.writeCard32(colormap);
}
if(isValueMaskEnabled(Cw.CURSOR)) {
out.writeCard32(cursor);
}
out.writePadAlign(getSize());
}
public boolean isValueMaskEnabled(@NonNull Cw... maskEnums) {
for(Cw m : maskEnums) {
if(!m.isEnabled(valueMask)) {
return false;
}
}
return true;
}
public boolean isEventMaskEnabled(@NonNull EventMask... maskEnums) {
for(EventMask m : maskEnums) {
if(!m.isEnabled(eventMask)) {
return false;
}
}
return true;
}
public boolean isDoNotPropogateMaskEnabled(@NonNull EventMask... maskEnums) {
for(EventMask m : maskEnums) {
if(!m.isEnabled(doNotPropogateMask)) {
return false;
}
}
return true;
}
@Override
public int getSize() {
return 12 + (isValueMaskEnabled(Cw.BACK_PIXMAP) ? 4 : 0) + (isValueMaskEnabled(Cw.BACK_PIXEL) ? 4 : 0) + (isValueMaskEnabled(Cw.BORDER_PIXMAP) ? 4 : 0) + (isValueMaskEnabled(Cw.BORDER_PIXEL) ? 4 : 0) + (isValueMaskEnabled(Cw.BIT_GRAVITY) ? 4 : 0) + (isValueMaskEnabled(Cw.WIN_GRAVITY) ? 4 : 0) + (isValueMaskEnabled(Cw.BACKING_STORE) ? 4 : 0) + (isValueMaskEnabled(Cw.BACKING_PLANES) ? 4 : 0) + (isValueMaskEnabled(Cw.BACKING_PIXEL) ? 4 : 0) + (isValueMaskEnabled(Cw.OVERRIDE_REDIRECT) ? 4 : 0) + (isValueMaskEnabled(Cw.SAVE_UNDER) ? 4 : 0) + (isValueMaskEnabled(Cw.EVENT_MASK) ? 4 : 0) + (isValueMaskEnabled(Cw.DONT_PROPAGATE) ? 4 : 0) + (isValueMaskEnabled(Cw.COLORMAP) ? 4 : 0) + (isValueMaskEnabled(Cw.CURSOR) ? 4 : 0);
}
public static class ChangeWindowAttributesBuilder {
private ChangeWindowAttributes.ChangeWindowAttributesBuilder valueMask(int valueMask) {
this.valueMask = valueMask;
return this;
}
public boolean isValueMaskEnabled(@NonNull Cw... maskEnums) {
for(Cw m : maskEnums) {
if(!m.isEnabled(valueMask)) {
return false;
}
}
return true;
}
private ChangeWindowAttributes.ChangeWindowAttributesBuilder valueMaskEnable(Cw... maskEnums) {
for(Cw m : maskEnums) {
valueMask((int) m.enableFor(valueMask));
}
return this;
}
private ChangeWindowAttributes.ChangeWindowAttributesBuilder valueMaskDisable(Cw... maskEnums) {
for(Cw m : maskEnums) {
valueMask((int) m.disableFor(valueMask));
}
return this;
}
public ChangeWindowAttributes.ChangeWindowAttributesBuilder backgroundPixmap(
int backgroundPixmap) {
this.backgroundPixmap = backgroundPixmap;
valueMaskEnable(Cw.BACK_PIXMAP);
return this;
}
public ChangeWindowAttributes.ChangeWindowAttributesBuilder backgroundPixel(
int backgroundPixel) {
this.backgroundPixel = backgroundPixel;
valueMaskEnable(Cw.BACK_PIXEL);
return this;
}
public ChangeWindowAttributes.ChangeWindowAttributesBuilder borderPixmap(int borderPixmap) {
this.borderPixmap = borderPixmap;
valueMaskEnable(Cw.BORDER_PIXMAP);
return this;
}
public ChangeWindowAttributes.ChangeWindowAttributesBuilder borderPixel(int borderPixel) {
this.borderPixel = borderPixel;
valueMaskEnable(Cw.BORDER_PIXEL);
return this;
}
public ChangeWindowAttributes.ChangeWindowAttributesBuilder bitGravity(int bitGravity) {
this.bitGravity = bitGravity;
valueMaskEnable(Cw.BIT_GRAVITY);
return this;
}
public ChangeWindowAttributes.ChangeWindowAttributesBuilder bitGravity(Gravity bitGravity) {
this.bitGravity = (int) bitGravity.getValue();
valueMaskEnable(Cw.BIT_GRAVITY);
return this;
}
public ChangeWindowAttributes.ChangeWindowAttributesBuilder winGravity(int winGravity) {
this.winGravity = winGravity;
valueMaskEnable(Cw.WIN_GRAVITY);
return this;
}
public ChangeWindowAttributes.ChangeWindowAttributesBuilder winGravity(Gravity winGravity) {
this.winGravity = (int) winGravity.getValue();
valueMaskEnable(Cw.WIN_GRAVITY);
return this;
}
public ChangeWindowAttributes.ChangeWindowAttributesBuilder backingStore(int backingStore) {
this.backingStore = backingStore;
valueMaskEnable(Cw.BACKING_STORE);
return this;
}
public ChangeWindowAttributes.ChangeWindowAttributesBuilder backingStore(
BackingStore backingStore) {
this.backingStore = (int) backingStore.getValue();
valueMaskEnable(Cw.BACKING_STORE);
return this;
}
public ChangeWindowAttributes.ChangeWindowAttributesBuilder backingPlanes(int backingPlanes) {
this.backingPlanes = backingPlanes;
valueMaskEnable(Cw.BACKING_PLANES);
return this;
}
public ChangeWindowAttributes.ChangeWindowAttributesBuilder backingPixel(int backingPixel) {
this.backingPixel = backingPixel;
valueMaskEnable(Cw.BACKING_PIXEL);
return this;
}
public ChangeWindowAttributes.ChangeWindowAttributesBuilder overrideRedirect(
int overrideRedirect) {
this.overrideRedirect = overrideRedirect;
valueMaskEnable(Cw.OVERRIDE_REDIRECT);
return this;
}
public ChangeWindowAttributes.ChangeWindowAttributesBuilder saveUnder(int saveUnder) {
this.saveUnder = saveUnder;
valueMaskEnable(Cw.SAVE_UNDER);
return this;
}
public ChangeWindowAttributes.ChangeWindowAttributesBuilder eventMask(int eventMask) {
this.eventMask = eventMask;
valueMaskEnable(Cw.EVENT_MASK);
return this;
}
public boolean isEventMaskEnabled(@NonNull EventMask... maskEnums) {
for(EventMask m : maskEnums) {
if(!m.isEnabled(eventMask)) {
return false;
}
}
return true;
}
public ChangeWindowAttributes.ChangeWindowAttributesBuilder eventMaskEnable(
EventMask... maskEnums) {
for(EventMask m : maskEnums) {
eventMask((int) m.enableFor(eventMask));
}
return this;
}
public ChangeWindowAttributes.ChangeWindowAttributesBuilder eventMaskDisable(
EventMask... maskEnums) {
for(EventMask m : maskEnums) {
eventMask((int) m.disableFor(eventMask));
}
return this;
}
public ChangeWindowAttributes.ChangeWindowAttributesBuilder doNotPropogateMask(
int doNotPropogateMask) {
this.doNotPropogateMask = doNotPropogateMask;
valueMaskEnable(Cw.DONT_PROPAGATE);
return this;
}
public boolean isDoNotPropogateMaskEnabled(@NonNull EventMask... maskEnums) {
for(EventMask m : maskEnums) {
if(!m.isEnabled(doNotPropogateMask)) {
return false;
}
}
return true;
}
public ChangeWindowAttributes.ChangeWindowAttributesBuilder doNotPropogateMaskEnable(
EventMask... maskEnums) {
for(EventMask m : maskEnums) {
doNotPropogateMask((int) m.enableFor(doNotPropogateMask));
}
return this;
}
public ChangeWindowAttributes.ChangeWindowAttributesBuilder doNotPropogateMaskDisable(
EventMask... maskEnums) {
for(EventMask m : maskEnums) {
doNotPropogateMask((int) m.disableFor(doNotPropogateMask));
}
return this;
}
public ChangeWindowAttributes.ChangeWindowAttributesBuilder colormap(int colormap) {
this.colormap = colormap;
valueMaskEnable(Cw.COLORMAP);
return this;
}
public ChangeWindowAttributes.ChangeWindowAttributesBuilder cursor(int cursor) {
this.cursor = cursor;
valueMaskEnable(Cw.CURSOR);
return this;
}
public int getSize() {
return 12 + (isValueMaskEnabled(Cw.BACK_PIXMAP) ? 4 : 0) + (isValueMaskEnabled(Cw.BACK_PIXEL) ? 4 : 0) + (isValueMaskEnabled(Cw.BORDER_PIXMAP) ? 4 : 0) + (isValueMaskEnabled(Cw.BORDER_PIXEL) ? 4 : 0) + (isValueMaskEnabled(Cw.BIT_GRAVITY) ? 4 : 0) + (isValueMaskEnabled(Cw.WIN_GRAVITY) ? 4 : 0) + (isValueMaskEnabled(Cw.BACKING_STORE) ? 4 : 0) + (isValueMaskEnabled(Cw.BACKING_PLANES) ? 4 : 0) + (isValueMaskEnabled(Cw.BACKING_PIXEL) ? 4 : 0) + (isValueMaskEnabled(Cw.OVERRIDE_REDIRECT) ? 4 : 0) + (isValueMaskEnabled(Cw.SAVE_UNDER) ? 4 : 0) + (isValueMaskEnabled(Cw.EVENT_MASK) ? 4 : 0) + (isValueMaskEnabled(Cw.DONT_PROPAGATE) ? 4 : 0) + (isValueMaskEnabled(Cw.COLORMAP) ? 4 : 0) + (isValueMaskEnabled(Cw.CURSOR) ? 4 : 0);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy