GithubHelp home page GithubHelp logo

x11's Introduction

Hi there πŸ‘‹

x11's People

Contributors

moaxcp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

tf-185 wenfer

x11's Issues

RECORD plugin can't work

my code

package x11;

import com.github.moaxcp.x11client.X11Client;
import com.github.moaxcp.x11client.protocol.record.*;

import java.io.IOException;
import java.util.List;

public class X11Test {


    public static void main(String[] args) {
        try (X11Client client = X11Client.connect()) {
            int rc = client.nextResourceId();
            Range8 empty = Range8.builder().build();
            ExtRange emptyExtRange = ExtRange.builder()
                    .major(empty)
                    .minor(Range16.builder().build())
                    .build();
            Range range = Range.builder()
                    .deviceEvents(Range8.builder().first((byte) 2).last((byte) 6).build())
                    .coreRequests(empty)
                    .coreReplies(empty)
                    .extRequests(emptyExtRange)
                    .extReplies(emptyExtRange)
                    .deliveredEvents(empty)
                    .clientStarted(false)
                    .errors(empty)
                    .clientDied(false)
                    .build();

            CreateContext createContext = CreateContext.builder()
                    .context(rc)
                    .clientSpecs(List.of(Cs.ALL_CLIENTS.getValue()))
                    .elementHeader((byte) 0)
                    .ranges(List.of(range))
                    .build();
            client.send(createContext);

            EnableContext enableContext = EnableContext
                    .builder()
                    .context(rc)
                    .build();
            EnableContextReply enableContextReply = client.send(enableContext);
            if (enableContextReply.getCategory() == 0) {
                for (Byte datum : enableContextReply.getData()) {
                    System.out.println(datum);
                }
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

}

the code can't work, got this exception

Exception in thread "main" com.github.moaxcp.x11client.X11ErrorException: WindowError(firstErrorOffset=0, sequenceNumber=2, badValue=230686721, minorOpcode=0, majorOpcode=2)
	at com.github.moaxcp.x11client.XProtocolService.readReply(XProtocolService.java:87)
	at com.github.moaxcp.x11client.XProtocolService.send(XProtocolService.java:66)
	at com.github.moaxcp.x11client.X11Client.send(X11Client.java:238)
	at x11.X11Test.main(X11Test.java:51)

is somewhere wrong?

Add support for extra attributes

Optional values are defined in a switch element with bit cases in the protocol. These are added to each pojo and used in the read and write methods. It is possible for x11 extensions to add fields to one of these switch elements dynamically. To support this in java a new list of Integers can be added for each of these fields.

Each field in a bitcase is 32 bits
The field is only sent if the bit for the field is set in the value mask.

Protocol classes

All XObjects support reading and writing. The objects could be used in a client and a server. The ProtocolService can also be changed to read and write all objects. The protocol service should be moved the the protocol package.

To make exceptions more generic X11ClientException should only be used at the client level. A new X11ProtocolException should be used for all classes under the protocol package.

Add altmask support

When a primatives field has an mask methods are added to mask the value with an enum parameter. The same should be done with an altmask.

Add builder methods to primatives fields that support altenum.

Make XObjects immutable

Generated XObjects should be immutable and have a builder. This requires that Lists are used instead of arrays for lists in the protocol.

Use lists for x11 lists

instead of using arrays in XObjects List should be used. This will require changes in the generator.

java modularity

Switch to java 11 and implement modularity

  1. move protocol into its own subproject
  2. move x11-client into a subproject
  3. each plugin and set of protocol classes will need to be a separate project
  4. define module-info with service for XProtocolPlugin implementation
  5. x11-client will need to depend on each plugin project

java.net.SocketException: Cannot find method "setCreated" or field "created" in java.net.Socket. Unsupported JVM?

code:

import java.io.IOException;

import com.github.moaxcp.x11client.X11Client;
import com.github.moaxcp.x11client.protocol.DisplayName;
import com.github.moaxcp.x11client.protocol.xproto.CreateWindow;
import com.github.moaxcp.x11client.protocol.xproto.EventMask;

public class WMTest {
	public static void main(final String[] args) throws InterruptedException, IOException {
		try (var x11Client = X11Client.connect(DisplayName.displayName(":1"))) {
			final var EXPOSURE = EventMask.EXPOSURE;
			final var KEY_PRESS = EventMask.KEY_PRESS;

			final var window = CreateWindow.builder().depth(x11Client.getDepth(0)).wid(x11Client.nextResourceId())
					.parent(x11Client.getRoot(0)).x((short) 10).y((short) 10).width((short) 600).height((short) 480)
					.borderWidth((short) 5)
					// .clazz(COPY_FROM_PARENT)

					.visual(x11Client.getVisualId(0)).backgroundPixel(x11Client.getWhitePixel(0))
					.borderPixel(x11Client.getBlackPixel(0)).eventMaskEnable(EXPOSURE, KEY_PRESS).build();
			Thread.sleep(100000);
		}
	}
}

exception:

Exception in thread "main" com.github.moaxcp.x11client.X11ClientException: Could not connect with :1.0
	at com.github.moaxcp.x11client.X11Client.connect(X11Client.java:80)
	at WMTest.main(WMTest.java:12)
Caused by: java.net.SocketException: Cannot find method "setCreated" or field "created" in java.net.Socket. Unsupported JVM?
	at org.newsclub.net.unix.NativeUnixSocket.setCreated(Native Method)
	at org.newsclub.net.unix.AFUNIXSocket.setIsCreated(AFUNIXSocket.java:56)
	at org.newsclub.net.unix.AFUNIXSocket.<init>(AFUNIXSocket.java:50)
	at org.newsclub.net.unix.AFUNIXSocket.newInstance(AFUNIXSocket.java:79)
	at org.newsclub.net.unix.AFUNIXSocket.newInstance(AFUNIXSocket.java:74)
	at org.newsclub.net.unix.AFUNIXSocket.connectTo(AFUNIXSocket.java:108)
	at com.github.moaxcp.x11client.X11Connection.connect(X11Connection.java:116)
	at com.github.moaxcp.x11client.X11Connection.connect(X11Connection.java:141)
	at com.github.moaxcp.x11client.X11Client.connect(X11Client.java:78)
	... 1 more

versions:

java:

/usr/lib/jvm/java-21-openjdk/bin/java -version
openjdk version "21" 2023-09-19
OpenJDK Runtime Environment (build 21+35)
OpenJDK 64-Bit Server VM (build 21+35, mixed mode, sharing)

maven deps:

[INFO]    com.kohlschutter.junixsocket:junixsocket-core:jar:2.3.2:runtime
[INFO]    com.kohlschutter.junixsocket:junixsocket-common:jar:2.3.2:runtime
[INFO]    com.kohlschutter.junixsocket:junixsocket-native-common:jar:2.3.2:runtime
[INFO]    net.java.dev.jna:jna:jar:5.13.0:compile
[INFO]    org.projectlombok:lombok:jar:1.18.30:provided
[INFO]    com.github.moaxcp.x11:x11-client:jar:0.11.0:compile

add support for switch fields

Value lists are an optional part of x11 objects. When they are set a bit in a value mask is set. There are default values but they are not in the protocol xmls.

Add switch fields
Add custom setter which als sets the bit in the value mask
Add support in read and write methods

XGrabKeyboard support

At a glance I couldn't find any evidence that XGrabKeyboard is supported. Did I miss something? What would it take to add it?

Generate Request objects

Request objects are used to send requests to the x11 server. These objects are generated from the xcb xmls.

Make sure to check requests against the xproto.pdf.

Implement error messages

The raw XErrror only contains a few codes to get the correct error message.

WindowError(sequenceNumber=36, badValue=0, minorOpcode=0, majorOpcode=1)

It is up to the client to use those codes to generate an error message. This story is to discuss and implement error messages.

X11lib uses ErrDec to generate the messages. It uses some methods which read an errordb file.

Add generation code for plugins

Every extension should add a class implementing XProtocolPlugin. This enables the client to support the extension.

Also generate the service loader properties file.

Generate reply classes

reply objects are optional parts of request objects in the x11 protocol.

Generate objects and compare with xproto.pdf

Enums should be suggested values

The protocol sends enums as a primative type (byte, short). The java classes currently have members for the java enum rather than this protocol type. This makes it impossible to set values that are not defined in the enum. This is a good general practice in java but not in this case.

One proble is supporting altenums for the field. The other issie is when an X11 extension adds new possible values for an enum field.

Remove the use of enum member fields and replace them with their primative type.

Add builder methods for setting the member based on an enum or alt enum.

Fix class names

Class names like SetupStruct should only be used in cases where there is a duplicate name. For instance

WindowEvent
WindowError

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.