Skip to content

Commit

Permalink
Upgrading to jdk 21 with module-info.java
Browse files Browse the repository at this point in the history
  • Loading branch information
moaxcp committed Apr 25, 2024
1 parent b183ddc commit c9c7581
Show file tree
Hide file tree
Showing 115 changed files with 751 additions and 282 deletions.
28 changes: 14 additions & 14 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ jobs:
uses: actions/setup-java@v2
with:
distribution: temurin
java-version: 17
- name: Cache SonarCloud packages
uses: actions/cache@v1
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Gradle packages
uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
java-version: 21
# - name: Cache SonarCloud packages
# uses: actions/cache@v1
# with:
# path: ~/.sonar/cache
# key: ${{ runner.os }}-sonar
# restore-keys: ${{ runner.os }}-sonar
# - name: Cache Gradle packages
# uses: actions/cache@v1
# with:
# path: ~/.gradle/caches
# key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
# restore-keys: ${{ runner.os }}-gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
Expand All @@ -45,4 +45,4 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew sonar --info
run: ./gradlew sonar
4 changes: 3 additions & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules/x11-keysym/x11.x11-keysym.main.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 21 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ as X11lib by queuing one-way requests before sending them to the server. The
x11-protocol project enables reading and writing the entire protocol and can
be used to help write a x11 server.

[![Java CI with Gradle](https://github.com/moaxcp/x11/workflows/Java%20CI%20with%20Gradle/badge.svg?branch=master)](https://github.com/moaxcp/x11/actions?query=workflow%3A%22Java+CI+with+Gradle%22)
[![Java CI with Gradle](https://github.com/moaxcp/x11/actions/workflows/gradle.yml/badge.svg)](https://github.com/moaxcp/x11/actions/workflows/gradle.yml)
[![maven central](https://img.shields.io/maven-central/v/com.github.moaxcp.x11/x11-client)](https://search.maven.org/artifact/com.github.moaxcp.x11/x11-client)
[![javadoc](https://javadoc.io/badge2/com.github.moaxcp.x11/x11-client/javadoc.svg)](https://javadoc.io/doc/com.github.moaxcp.x11/x11-client)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=moaxcp_x11-client&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=moaxcp_x11-client)
Expand All @@ -23,21 +23,15 @@ The x11-client library can be added to your project using maven or gradle.
<dependency>
<groupId>com.github.moaxcp.x11</groupId>
<artifactId>x11-client</artifactId>
<version>0.16.0</version>
<version>0.18.0</version>
<type>module</type>
</dependency>
```

## Gradle

```
implementation 'com.github.moaxcp.x11:x11-client:0.16.0'
```

The library has one dependency for using unix sockets.

```
implementation 'com.kohlschutter.junixsocket:junixsocket-core:x.x.x'
implementation 'com.github.moaxcp.x11:x11-client:0.18.0'
```

# Usage
Expand Down Expand Up @@ -99,13 +93,12 @@ server.
client.flush();
```

This project converts the x11 protocol to classes which implement certain
interfaces. The client can read and write these objects using the read and
write methods defined in each object’s class. Here is a diagram of the class
hierarchy for the protocol:
This project converts the x11 protocol to classes which implement core
interfaces (XError, XEvent, XRequest, XReply, etc). The client can read and write these objects using the read and
write methods defined in each object’s class.

X11ClientExceptions may be thrown when calling methods on a client. These
exceptions represent IOExceptions with the socket. X11ErrorExceptions represent
X11ProtocolExceptions may be thrown when there are IOExceptions with the socket. X11ClientExceptions are thrown with
client issues such as connection issues or api issues. X11ErrorExceptions represent
Errors from the X11 Server. Errors can be handled using the standard try/catch
method rather than using an error handler callback as is done with X11lib.

Expand Down Expand Up @@ -372,6 +365,9 @@ be shared without synchronization.

# Contributors

Support is most needed for example code. Other x11 libraries have tons of examples that prove the library works.
So far this project only has a few basic examples.

I am not an x11 programmer but I find the protocol to be an interesting
challenge and learning experience. The only other x11 client implementation for
java that I have found is escher. Escher is very hand written and has many
Expand All @@ -398,22 +394,6 @@ enables the client to figure out which class to use when reading errors and
events from the server. These plugins are generated durring the build process.
Plugins are discovered and loaded using the ServiceLoader pattern.

Support is needed for a few things in the protocol before all extensions can
be supported. Contributions are welcome!

fd – file descriptors. I believe these should work like an int field. If this
is true this should be easy to implement.

sumOf expressions – creates a sum value which is used to determine list sizes.
The list is the size of a sumOf function called on another list.

Polymorphism – some objects use a case switch which seems to describe a
polymorphic object. There is usually a type field which describes the type and
each switch case provides additional fields for that type. The generation code
needs to support generating multiple objects when it runs into an object with
these switch constructs. Reading and writing will be tricky since the type
field can be deep within the protocol. These switches may also be nested.

# Frameworks

There is a need for higher levels of abstraction such as Window, Pixmap, and
Expand Down Expand Up @@ -455,6 +435,16 @@ https://www.x.org/releases/X11R7.6/doc/libXtst/recordlib.html

# versions

## 0.18.0

* Switched to a multimodule project
* Switched to jdk 21
* Added java module system support
* Removed delombok due to [issues](https://github.com/freefair/gradle-plugins/issues/824) with modules. This results in javadoc no longer being generated.
* Removed dependency on junixsocket and switched to the jdk UnixDomainSocket.
* Removed jbang
* Moved all integration tests to the examples project with a main method.

## 0.17.0

* Adding generated protocol sources to git
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
plugins {
id 'org.sonarqube' version '4.4.1.3373'
id 'io.freefair.lombok' version '8.4' apply false
id 'org.sonarqube' version '5.0.0.4638'
id 'io.freefair.lombok' version '8.6' apply false
id 'org.unbroken-dome.test-sets' version '4.1.0' apply false
}

allprojects {
version = '0.17.0'
version = '0.18.0'
group = 'com.github.moaxcp.x11'
repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.github.moaxcp.x11.examples;

import com.github.moaxcp.x11.keysym.KeySym;
import com.github.moaxcp.x11.x11client.X11Client;
import lombok.extern.java.Log;

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

@Log
public class KeySymMain {

public static void main(String... args) throws IOException {
try(X11Client client = X11Client.connect()) {
List<Byte> keyCodes = client.keySymToKeyCodes(KeySym.XK_Escape);
for(byte keyCode : keyCodes) {
KeySym keySym = client.keyCodeToKeySym(keyCode, (short) 0);
log.info(keySym.toString());
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.moaxcp.x11.x11client;
package com.github.moaxcp.x11.examples;

import com.github.moaxcp.x11.protocol.record.QueryVersionReply;
import com.github.moaxcp.x11.x11client.X11Client;
import lombok.extern.java.Log;

import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.github.moaxcp.x11.x11client;
package com.github.moaxcp.x11.examples;

import com.github.moaxcp.x11.protocol.KeySym;
import com.github.moaxcp.x11.keysym.KeySym;
import com.github.moaxcp.x11.protocol.XEvent;
import com.github.moaxcp.x11.protocol.record.*;
import com.github.moaxcp.x11.protocol.xproto.KeyPressEvent;
import com.github.moaxcp.x11.protocol.xproto.MotionNotifyEvent;
import com.github.moaxcp.x11.x11client.X11Client;
import lombok.extern.java.Log;

import java.io.IOException;
Expand Down Expand Up @@ -67,7 +68,7 @@ public static void main(String... args) throws IOException {

if (replyData instanceof KeyPressEvent) {
KeyPressEvent e = (KeyPressEvent) replyData;
com.github.moaxcp.x11.protocol.KeySym keysym = data.keyCodeToKeySym(e);
KeySym keysym = data.keyCodeToKeySym(e);
if(keysym == KeySym.XK_Escape) {
break;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.github.moaxcp.x11.x11client;
package com.github.moaxcp.x11.examples;

import com.github.moaxcp.x11.protocol.KeySym;
import com.github.moaxcp.x11.keysym.KeySym;
import com.github.moaxcp.x11.protocol.record.*;
import com.github.moaxcp.x11.protocol.xproto.GeGenericEvent;
import com.github.moaxcp.x11.protocol.xproto.KeyPressEvent;
import com.github.moaxcp.x11.x11client.X11Client;
import com.github.moaxcp.x11.x11client.api.record.RecordData;
import com.github.moaxcp.x11.x11client.api.record.RecordReply;
import lombok.extern.java.Log;
Expand Down Expand Up @@ -67,7 +68,7 @@ public static void main(String... args) throws IOException {
while(true) {
RecordReply recordReply = data.record().readNextRecord();
log.info(String.format("%s", recordReply));
Optional<com.github.moaxcp.x11.protocol.KeySym> first = recordReply.getData().stream()
Optional<KeySym> first = recordReply.getData().stream()
.map(RecordData::getXObject)
.filter(obj -> obj instanceof KeyPressEvent)
.map(KeyPressEvent.class::cast)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.github.moaxcp.x11.x11client;
package com.github.moaxcp.x11.examples;

import com.github.moaxcp.x11.protocol.KeySym;
import com.github.moaxcp.x11.keysym.KeySym;
import com.github.moaxcp.x11.protocol.record.*;
import com.github.moaxcp.x11.protocol.xproto.CreateWindow;
import com.github.moaxcp.x11.protocol.xproto.GeGenericEvent;
import com.github.moaxcp.x11.protocol.xproto.KeyPressEvent;
import com.github.moaxcp.x11.protocol.xproto.NoOperation;
import com.github.moaxcp.x11.x11client.X11Client;
import com.github.moaxcp.x11.x11client.api.record.RecordData;
import com.github.moaxcp.x11.x11client.api.record.RecordReply;
import lombok.extern.java.Log;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.github.moaxcp.x11.x11client;
package com.github.moaxcp.x11.examples;

import com.github.moaxcp.x11.protocol.Utilities;
import com.github.moaxcp.x11.protocol.XEvent;
import com.github.moaxcp.x11.protocol.xproto.*;
import com.github.moaxcp.x11.x11client.X11Client;

import java.io.IOException;
import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.github.moaxcp.x11.x11client;
package com.github.moaxcp.x11.examples;


import com.github.moaxcp.x11.protocol.XEvent;
import com.github.moaxcp.x11.protocol.xproto.*;
import com.github.moaxcp.x11.x11client.X11Client;

import java.io.IOException;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.github.moaxcp.x11.x11client;
package com.github.moaxcp.x11.examples;

import com.github.moaxcp.x11.protocol.KeySym;
import com.github.moaxcp.x11.keysym.KeySym;
import com.github.moaxcp.x11.protocol.Utilities;
import com.github.moaxcp.x11.protocol.XEvent;
import com.github.moaxcp.x11.protocol.xproto.*;
import com.github.moaxcp.x11.x11client.X11Client;

import java.io.IOException;
import java.nio.ByteBuffer;
Expand Down Expand Up @@ -99,7 +100,7 @@ public static void main(String... args) throws IOException {
.build());
} else if(event instanceof KeyPressEvent) {
KeyPressEvent keyPress = (KeyPressEvent) event;
com.github.moaxcp.x11.protocol.KeySym keysym = client.keyCodeToKeySym(keyPress.getDetail(), keyPress.getState());
KeySym keysym = client.keyCodeToKeySym(keyPress.getDetail(), keyPress.getState());
if(keysym == KeySym.XK_Escape) {
break;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.github.moaxcp.x11.x11client.X11Events;
package com.github.moaxcp.x11.examples.X11Events;

import com.github.moaxcp.x11.keysym.KeySym;
import com.github.moaxcp.x11.protocol.DisplayName;
import com.github.moaxcp.x11.protocol.KeySym;
import com.github.moaxcp.x11.protocol.Utilities;
import com.github.moaxcp.x11.protocol.XEvent;
import com.github.moaxcp.x11.protocol.xproto.*;
import com.github.moaxcp.x11.x11client.X11Client;

import java.io.IOException;

public class X11EventsWindow {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.moaxcp.x11.x11client.X11Events;
package com.github.moaxcp.x11.examples.X11Events;

import com.github.moaxcp.x11.xephyr.XephyrRunner;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.moaxcp.x11.x11client.basicwm;
package com.github.moaxcp.x11.examples.basicwm;

import com.github.moaxcp.x11.xephyr.XephyrRunner;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package com.github.moaxcp.x11.x11client.basicwm;
package com.github.moaxcp.x11.examples.basicwm;

import com.github.moaxcp.x11.protocol.*;
import com.github.moaxcp.x11.keysym.KeySym;
import com.github.moaxcp.x11.protocol.AtomValue;
import com.github.moaxcp.x11.protocol.DisplayName;
import com.github.moaxcp.x11.protocol.Utilities;
import com.github.moaxcp.x11.protocol.XEvent;
import com.github.moaxcp.x11.protocol.xproto.*;
import com.github.moaxcp.x11.x11client.X11Client;

import java.io.IOException;
import java.util.Iterator;
import java.util.LinkedHashMap;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.moaxcp.x11.x11client.experimental;
package com.github.moaxcp.x11.examples.experimental;

import com.github.moaxcp.x11.protocol.DisplayName;
import com.github.moaxcp.x11.protocol.xproto.Rectangle;
Expand Down
Loading

0 comments on commit c9c7581

Please sign in to comment.