Skip to content

Commit

Permalink
patched to jdk21/javafx 21 per recipe in repo
Browse files Browse the repository at this point in the history
  • Loading branch information
homberghp committed Dec 19, 2023
1 parent c66c32b commit 48cdb77
Show file tree
Hide file tree
Showing 73 changed files with 3,564 additions and 205 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ build/

# Executables downloaded via sync script
.sync/
target/
50 changes: 50 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.testfx</groupId>
<artifactId>openjfx-monocle</artifactId>
<version>jdk-21.0.1</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<exec.mainClass>TestfxMonocle</exec.mainClass>
</properties>
<dependencies>
<!-- <dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
</dependency>-->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>21.0.1</version>
<type>jar</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.6.3</version>
</plugin>
<!-- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>verify</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>-->
</plugins>
</build>
</project>
18 changes: 13 additions & 5 deletions src/main/java/com/sun/glass/ui/monocle/AcceleratedScreen.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -33,10 +33,10 @@ public class AcceleratedScreen {
private static long glesLibraryHandle;
private static long eglLibraryHandle;
private static boolean initialized = false;
private long eglSurface;
private long eglContext;
private long eglDisplay;
private long nativeWindow;
long eglSurface;
long eglContext;
long eglDisplay;
long nativeWindow;
protected static final LinuxSystem ls = LinuxSystem.getLinuxSystem();
private EGL egl;
long eglConfigs[] = {0};
Expand All @@ -55,6 +55,14 @@ protected long platformGetNativeWindow() {
return 0L;
}

/**
* Create and initialize an AcceleratedScreen. Subclasses should override
* this constructor in case the {@link #AcceleratedScreen(int[]) AcceleratedScreen(int[])}
* constructor is not sufficient.
*/
AcceleratedScreen() {
}

/**
* Perform basic egl intialization - open the display, create the drawing
* surface, and create a GL context to that drawing surface.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -25,9 +25,6 @@

package com.sun.glass.ui.monocle;

import java.security.AccessController;
import java.security.PrivilegedAction;

/**
* Provide Android implementation of AcceleratedScreen
*
Expand All @@ -39,6 +36,7 @@ class AndroidAcceleratedScreen extends AcceleratedScreen {
super(attributes);
}

@Override
boolean initPlatformLibraries() {
return super.initPlatformLibraries();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -25,8 +25,6 @@

package com.sun.glass.ui.monocle;

import java.io.IOException;

/**
*
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -59,7 +59,7 @@ public static void gotTouchEventFromNative(int count, int[] actions, int[] ids,
touchState.addPoint(p);
}
}
instance.gotTouchEvent(touchState);
Platform.runLater(() -> instance.gotTouchEvent(touchState));
}

private void gotTouchEvent(TouchState touchState) {
Expand All @@ -77,6 +77,14 @@ private void gotTouchEvent(TouchState touchState) {
}


public static void dispatchKeyEventFromNative(int type, int key, char[] chars, int modifiers) {
instance.processor.dispatchKeyEvent(type, key, chars, modifiers);
}

public static void dispatchMenuEventFromNative(int x, int y, int xAbs, int yAbs, boolean isKeyboardTrigger) {
instance.processor.dispatchMenuEvent(x, y, xAbs, yAbs, isKeyboardTrigger);
}

public static void gotKeyEventFromNative(int action, int linuxKey) {
instance.gotKeyEvent (action, linuxKey);
}
Expand Down Expand Up @@ -124,6 +132,7 @@ private AndroidInputDevice addDeviceInternal(AndroidInputDevice device, String n
}

void removeDevice(AndroidInputDevice device) {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkPermission(new AllPermission());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -24,6 +24,8 @@
*/
package com.sun.glass.ui.monocle;

import javafx.application.Platform;

class AndroidInputProcessor {

private final AndroidInputDevice device;
Expand Down Expand Up @@ -54,4 +56,32 @@ synchronized void pushKeyEvent(KeyState keyState) {
keyInput.setState(keyState);
}

synchronized void dispatchKeyEvent(int type, int key, char[] chars, int modifiers) {
Platform.runLater( () -> {
MonocleWindow window = MonocleWindowManager.getInstance().getFocusedWindow();
if (window == null) {
return;
}
MonocleView view = (MonocleView) window.getView();
if (view == null) {
return;
}
RunnableProcessor.runLater( () -> view.notifyKey(type, key, chars, modifiers));
});
}

synchronized void dispatchMenuEvent(int x, int y, int xAbs, int yAbs, boolean isKeyboardTrigger) {
Platform.runLater(() -> {
MonocleWindow window = MonocleWindowManager.getInstance().getFocusedWindow();
if (window == null) {
return;
}
MonocleView view = (MonocleView) window.getView();
if (view == null) {
return;
}
RunnableProcessor.runLater(() -> view.notifyMenu(x, y, xAbs, yAbs, isKeyboardTrigger));
});
}

}
4 changes: 2 additions & 2 deletions src/main/java/com/sun/glass/ui/monocle/AndroidPlatform.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -39,7 +39,7 @@ protected InputDeviceRegistry createInputDeviceRegistry() {

@Override
protected NativeCursor createCursor() {
return new NullCursor();
return logSelectedCursor(new NullCursor());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -33,6 +33,7 @@ class AndroidPlatformFactory extends NativePlatformFactory {

@Override
protected boolean matches() {
@SuppressWarnings("removal")
String platform = AccessController.doPrivileged(
(PrivilegedAction<String>) () -> System.getProperty("javafx.platform"));
return platform != null && platform.equals("android");
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/com/sun/glass/ui/monocle/AndroidScreen.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -33,6 +33,7 @@
public class AndroidScreen implements NativeScreen {

private float density = -1;
@Override
public int getDepth() {
return 24;
}
Expand All @@ -41,13 +42,15 @@ public int getDepth() {
* Returns the native format of the screen, as a constant from the Pixels
* class.
*/
@Override
public int getNativeFormat() {
return Pixels.Format.BYTE_ARGB;
}

/**
* Returns the pixel width of the screen.
*/
@Override
public int getWidth() {
int answer = (int)(_getWidth()/getScale());
return answer;
Expand All @@ -56,13 +59,15 @@ public int getWidth() {
/**
* Returns the pixel height of the screen.
*/
@Override
public int getHeight() {
return (int)(_getHeight()/getScale());
}

/**
* Returns the number of pixels per inch in the screen.
*/
@Override
public int getDPI() {
return 100;
}
Expand All @@ -78,6 +83,7 @@ public float getScale () {
/**
* Returns a native handle for the screen. The handle is platform-specific.
*/
@Override
public long getNativeHandle() {
long answer = _getNativeHandle();
return answer;
Expand All @@ -86,6 +92,7 @@ public long getNativeHandle() {
/**
* Called during JavaFX shutdown to release the screen. Called only once.
*/
@Override
public void shutdown() {
_shutdown();
}
Expand All @@ -101,6 +108,7 @@ public void shutdown() {
* @param alpha The alpha level to use to compose the data over existing
* pixels
*/
@Override
public void uploadPixels(Buffer b,
int x, int y, int width, int height, float alpha) {
_uploadPixels (b, x, y, width, height, alpha);
Expand All @@ -110,6 +118,7 @@ public void uploadPixels(Buffer b,
* Called on the JavaFX application thread when pixel data for all windows
* has been uploaded.
*/
@Override
public void swapBuffers() {
_swapBuffers();
}
Expand All @@ -118,6 +127,7 @@ public void swapBuffers() {
* Returns a read-only ByteBuffer in the native pixel format containing the screen contents.
* @return ByteBuffer a read-only ByteBuffer containing the screen contents
*/
@Override
public ByteBuffer getScreenCapture() {
return _getScreenCapture();
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/sun/glass/ui/monocle/C.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -51,6 +51,7 @@ static C getC() {
}

private static void checkPermissions() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkPermission(permission);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -38,9 +38,11 @@ class DispmanAcceleratedScreen extends AcceleratedScreen {

@Override
protected long platformGetNativeWindow() {
@SuppressWarnings("removal")
int displayID = AccessController.doPrivileged(
(PrivilegedAction<Integer>)
() -> Integer.getInteger("dispman.display", 0 /* LCD */));
@SuppressWarnings("removal")
int layerID = AccessController.doPrivileged(
(PrivilegedAction<Integer>)
() -> Integer.getInteger("dispman.layer", 1));
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/sun/glass/ui/monocle/DispmanPlatform.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -29,7 +29,8 @@ class DispmanPlatform extends LinuxPlatform {

@Override
protected NativeCursor createCursor() {
return new DispmanCursor();
final NativeCursor c = useCursor ? new DispmanCursor() : new NullCursor();
return logSelectedCursor(c);
}

@Override
Expand Down
Loading

0 comments on commit 48cdb77

Please sign in to comment.