├── src └── main │ └── java │ └── com │ └── sun │ └── glass │ └── ui │ ├── wayland │ ├── WaylandClipboardDelegate.java │ ├── WaylandCursor.java │ ├── WaylandMenuBarDelegate.java │ ├── WaylandTimer.java │ ├── WaylandDnDClipboard.java │ ├── WaylandSystemClipboard.java │ ├── WaylandPlatformFactory.java │ ├── WaylandMenuDelegate.java │ ├── WaylandMenuItemDelegate.java │ ├── WaylandRobot.java │ ├── WaylandPixels.java │ ├── WaylandView.java │ ├── WaylandApplication.java │ └── WaylandWindow.java │ └── monocle │ ├── WaylandShm.java │ ├── Libc.java │ ├── WaylandBufferPool.java │ ├── WaylandAcceleratedScreen.java │ ├── WaylandBuffer.java │ ├── WaylandPlatformFactory.java │ ├── WaylandBufferPoolFactory.java │ ├── WaylandCursor.java │ ├── Libpixman1.java │ ├── WaylandShmBuffer.java │ ├── WaylandSeat.java │ ├── WaylandOutput.java │ ├── WaylandInputDeviceTouch.java │ ├── WaylandPlatform.java │ ├── WaylandInputDevicePointer.java │ ├── WaylandInputDeviceKeyboard.java │ └── WaylandScreen.java ├── .gitignore ├── README.md ├── pom.xml └── LICENSE /src/main/java/com/sun/glass/ui/wayland/WaylandClipboardDelegate.java: -------------------------------------------------------------------------------- 1 | package com.sun.glass.ui.wayland; 2 | 3 | import com.sun.glass.ui.Clipboard; 4 | import com.sun.glass.ui.delegate.ClipboardDelegate; 5 | 6 | 7 | public class WaylandClipboardDelegate implements ClipboardDelegate { 8 | @Override 9 | public Clipboard createClipboard(final String clipboardName) { 10 | if (Clipboard.SYSTEM.equals(clipboardName)) { 11 | return new WaylandSystemClipboard(); 12 | } 13 | if (Clipboard.DND.equals(clipboardName)) { 14 | return new WaylandDnDClipboard(); 15 | } 16 | return null; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/sun/glass/ui/wayland/WaylandCursor.java: -------------------------------------------------------------------------------- 1 | package com.sun.glass.ui.wayland; 2 | 3 | import com.sun.glass.ui.Cursor; 4 | import com.sun.glass.ui.Pixels; 5 | 6 | 7 | public class WaylandCursor extends Cursor { 8 | protected WaylandCursor(final int type) { 9 | super(type); 10 | } 11 | 12 | protected WaylandCursor(final int x, 13 | final int y, 14 | final Pixels pixels) { 15 | super(x, 16 | y, 17 | pixels); 18 | } 19 | 20 | @Override 21 | protected long _createCursor(final int x, 22 | final int y, 23 | final Pixels pixels) { 24 | return 0; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/sun/glass/ui/wayland/WaylandMenuBarDelegate.java: -------------------------------------------------------------------------------- 1 | package com.sun.glass.ui.wayland; 2 | 3 | import com.sun.glass.ui.delegate.MenuBarDelegate; 4 | import com.sun.glass.ui.delegate.MenuDelegate; 5 | 6 | 7 | public class WaylandMenuBarDelegate implements MenuBarDelegate { 8 | @Override 9 | public boolean createMenuBar() { 10 | return true; 11 | } 12 | 13 | @Override 14 | public boolean insert(final MenuDelegate menu, 15 | final int pos) { 16 | return true; 17 | } 18 | 19 | @Override 20 | public boolean remove(final MenuDelegate menu, 21 | final int pos) { 22 | return true; 23 | } 24 | 25 | @Override 26 | public long getNativeMenu() { 27 | return 0; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/sun/glass/ui/wayland/WaylandTimer.java: -------------------------------------------------------------------------------- 1 | package com.sun.glass.ui.wayland; 2 | 3 | import com.sun.glass.ui.Timer; 4 | 5 | 6 | public class WaylandTimer extends Timer { 7 | /** 8 | * Constructs a new timer. 9 | *

10 | * If the application overrides the Timer.run(), it should call super.run() 11 | * in order to run the runnable passed to the constructor. 12 | * 13 | * @param runnable 14 | */ 15 | protected WaylandTimer(final Runnable runnable) { 16 | super(runnable); 17 | } 18 | 19 | @Override 20 | protected long _start(final Runnable runnable) { 21 | return 0; 22 | } 23 | 24 | @Override 25 | protected long _start(final Runnable runnable, 26 | final int period) { 27 | return 0; 28 | } 29 | 30 | @Override 31 | protected void _stop(final long timer) { 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/sun/glass/ui/monocle/WaylandShm.java: -------------------------------------------------------------------------------- 1 | package com.sun.glass.ui.monocle; 2 | 3 | import org.freedesktop.wayland.client.WlRegistryProxy; 4 | import org.freedesktop.wayland.client.WlShmEvents; 5 | import org.freedesktop.wayland.client.WlShmProxy; 6 | 7 | import javax.annotation.Nonnull; 8 | 9 | public class WaylandShm implements WlShmEvents { 10 | 11 | private final WlShmProxy wlShmProxy; 12 | 13 | WaylandShm(@Nonnull final WlRegistryProxy registryProxy, 14 | final int name, 15 | @Nonnull final String interfaceName, 16 | final int version) { 17 | this.wlShmProxy = registryProxy.bind(name, 18 | WlShmProxy.class, 19 | WlShmEvents.VERSION, 20 | this); 21 | } 22 | 23 | @Override 24 | public void format(final WlShmProxy emitter, 25 | final int format) { 26 | 27 | } 28 | 29 | public WlShmProxy getWlShmProxy() { 30 | return this.wlShmProxy; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/sun/glass/ui/wayland/WaylandDnDClipboard.java: -------------------------------------------------------------------------------- 1 | package com.sun.glass.ui.wayland; 2 | 3 | import com.sun.glass.ui.Clipboard; 4 | import com.sun.glass.ui.SystemClipboard; 5 | 6 | import java.util.HashMap; 7 | 8 | 9 | public class WaylandDnDClipboard extends SystemClipboard { 10 | protected WaylandDnDClipboard() { 11 | super(Clipboard.DND); 12 | } 13 | 14 | @Override 15 | protected boolean isOwner() { 16 | return false; 17 | } 18 | 19 | @Override 20 | protected void pushToSystem(final HashMap cacheData, 21 | final int supportedActions) { 22 | 23 | } 24 | 25 | @Override 26 | protected void pushTargetActionToSystem(final int actionDone) { 27 | 28 | } 29 | 30 | @Override 31 | protected Object popFromSystem(final String mimeType) { 32 | return null; 33 | } 34 | 35 | @Override 36 | protected int supportedSourceActionsFromSystem() { 37 | return 0; 38 | } 39 | 40 | @Override 41 | protected String[] mimesFromSystem() { 42 | return new String[0]; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/sun/glass/ui/wayland/WaylandSystemClipboard.java: -------------------------------------------------------------------------------- 1 | package com.sun.glass.ui.wayland; 2 | 3 | 4 | import com.sun.glass.ui.Clipboard; 5 | import com.sun.glass.ui.SystemClipboard; 6 | 7 | import java.util.HashMap; 8 | 9 | public class WaylandSystemClipboard extends SystemClipboard { 10 | protected WaylandSystemClipboard() { 11 | super(Clipboard.SYSTEM); 12 | } 13 | 14 | @Override 15 | protected boolean isOwner() { 16 | return false; 17 | } 18 | 19 | @Override 20 | protected void pushToSystem(final HashMap cacheData, 21 | final int supportedActions) { 22 | 23 | } 24 | 25 | @Override 26 | protected void pushTargetActionToSystem(final int actionDone) { 27 | 28 | } 29 | 30 | @Override 31 | protected Object popFromSystem(final String mimeType) { 32 | return null; 33 | } 34 | 35 | @Override 36 | protected int supportedSourceActionsFromSystem() { 37 | return 0; 38 | } 39 | 40 | @Override 41 | protected String[] mimesFromSystem() { 42 | return new String[0]; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/sun/glass/ui/monocle/Libc.java: -------------------------------------------------------------------------------- 1 | package com.sun.glass.ui.monocle; 2 | 3 | import org.freedesktop.jaccall.Lib; 4 | import org.freedesktop.jaccall.Ptr; 5 | 6 | @Lib(value = "c", 7 | version = 6) 8 | public class Libc { 9 | 10 | static { 11 | new Libc_Symbols().link(); 12 | } 13 | 14 | public static native int mkstemp(@Ptr(String.class) long template); 15 | 16 | public static native int fcntl(int fd, 17 | int cmd, 18 | int arg); 19 | 20 | @Ptr(Void.class) 21 | public static native long mmap(@Ptr(Void.class) long addr, 22 | int len, 23 | int prot, 24 | int flags, 25 | int fildes, 26 | int off); 27 | 28 | public static native int munmap(@Ptr(Void.class) long addr, 29 | int len); 30 | 31 | public static native int close(int fildes); 32 | 33 | public static native int ftruncate(int fildes, 34 | int length); 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/sun/glass/ui/wayland/WaylandPlatformFactory.java: -------------------------------------------------------------------------------- 1 | package com.sun.glass.ui.wayland; 2 | 3 | import com.sun.glass.ui.Application; 4 | import com.sun.glass.ui.Menu; 5 | import com.sun.glass.ui.MenuBar; 6 | import com.sun.glass.ui.MenuItem; 7 | import com.sun.glass.ui.PlatformFactory; 8 | import com.sun.glass.ui.delegate.ClipboardDelegate; 9 | import com.sun.glass.ui.delegate.MenuBarDelegate; 10 | import com.sun.glass.ui.delegate.MenuDelegate; 11 | import com.sun.glass.ui.delegate.MenuItemDelegate; 12 | 13 | 14 | public class WaylandPlatformFactory extends PlatformFactory { 15 | @Override 16 | public Application createApplication() { 17 | return new WaylandApplication(); 18 | } 19 | 20 | @Override 21 | public MenuBarDelegate createMenuBarDelegate(final MenuBar menubar) { 22 | return new WaylandMenuBarDelegate(); 23 | } 24 | 25 | @Override 26 | public MenuDelegate createMenuDelegate(final Menu menu) { 27 | return new WaylandMenuDelegate(); 28 | } 29 | 30 | @Override 31 | public MenuItemDelegate createMenuItemDelegate(final MenuItem menuItem) { 32 | return new WaylandMenuItemDelegate(); 33 | } 34 | 35 | @Override 36 | public ClipboardDelegate createClipboardDelegate() { 37 | return new WaylandClipboardDelegate(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/sun/glass/ui/monocle/WaylandBufferPool.java: -------------------------------------------------------------------------------- 1 | package com.sun.glass.ui.monocle; 2 | 3 | 4 | import org.freedesktop.wayland.client.WlBufferProxy; 5 | import org.freedesktop.wayland.client.WlShmPoolEvents; 6 | 7 | import java.util.concurrent.ArrayBlockingQueue; 8 | 9 | public class WaylandBufferPool implements WlShmPoolEvents { 10 | 11 | private ArrayBlockingQueue bufferQueue = new ArrayBlockingQueue<>(2); 12 | private boolean destroyed; 13 | 14 | public void queueBuffer(final WlBufferProxy buffer) { 15 | if (this.destroyed) { 16 | throw new IllegalStateException("Pool destroyed"); 17 | } 18 | 19 | this.bufferQueue.add(buffer); 20 | } 21 | 22 | public WlBufferProxy popBuffer() { 23 | if (this.destroyed) { 24 | throw new IllegalStateException("Pool destroyed"); 25 | } 26 | 27 | return this.bufferQueue.poll(); 28 | } 29 | 30 | public void destroy() { 31 | if (this.destroyed) { 32 | throw new IllegalStateException("Pool destroyed"); 33 | } 34 | 35 | this.bufferQueue.forEach(WlBufferProxy::destroy); 36 | this.bufferQueue.clear(); 37 | this.destroyed = true; 38 | } 39 | 40 | public boolean isDestroyed() { 41 | return this.destroyed; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/sun/glass/ui/monocle/WaylandAcceleratedScreen.java: -------------------------------------------------------------------------------- 1 | package com.sun.glass.ui.monocle; 2 | 3 | 4 | public class WaylandAcceleratedScreen extends AcceleratedScreen { 5 | 6 | /* 7 | * An AcceleratedScreen provides a way to get an OpenGL ES context on the screen. This typically uses the native 8 | * EGL API to create a drawing surface. While the EGL API used to create the surface is standard 9 | * (eglCreateWindowSurface), it requires a NativeWindowType parameter whose meaning varies from platform to 10 | * platform. It is the call to the native function eglCreateWindowSurface that typically needs to be customized for 11 | * a new port. This function on some platforms takes 0 as an argument to indicate that the screen's framebuffer is 12 | * to be used for output. On other platforms a pointer to some data structure is required. 13 | */ 14 | 15 | /** 16 | * Perform basic egl intialization - open the display, create the drawing 17 | * surface, and create a GL context to that drawing surface. 18 | * 19 | * @param attributes - attributes to be used for filtering the EGL 20 | * configurations to choose from 21 | * 22 | * @throws GLException 23 | * @throws UnsatisfiedLinkError 24 | */ 25 | WaylandAcceleratedScreen(final int[] attributes) throws GLException, UnsatisfiedLinkError { 26 | super(attributes); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/sun/glass/ui/wayland/WaylandMenuDelegate.java: -------------------------------------------------------------------------------- 1 | package com.sun.glass.ui.wayland; 2 | 3 | import com.sun.glass.ui.Pixels; 4 | import com.sun.glass.ui.delegate.MenuDelegate; 5 | import com.sun.glass.ui.delegate.MenuItemDelegate; 6 | 7 | /** 8 | * Created by zubzub on 9/3/16. 9 | */ 10 | public class WaylandMenuDelegate implements MenuDelegate { 11 | 12 | @Override 13 | public boolean createMenu(final String title, 14 | final boolean enabled) { 15 | return true; 16 | } 17 | 18 | @Override 19 | public boolean setTitle(final String title) { 20 | return true; 21 | } 22 | 23 | @Override 24 | public boolean setEnabled(final boolean enabled) { 25 | return true; 26 | } 27 | 28 | @Override 29 | public boolean setPixels(final Pixels pixels) { 30 | return true; 31 | } 32 | 33 | @Override 34 | public boolean insert(final MenuDelegate menu, 35 | final int pos) { 36 | return true; 37 | } 38 | 39 | @Override 40 | public boolean insert(final MenuItemDelegate item, 41 | final int pos) { 42 | return true; 43 | } 44 | 45 | @Override 46 | public boolean remove(final MenuDelegate menu, 47 | final int pos) { 48 | return true; 49 | } 50 | 51 | @Override 52 | public boolean remove(final MenuItemDelegate item, 53 | final int pos) { 54 | return true; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/sun/glass/ui/wayland/WaylandMenuItemDelegate.java: -------------------------------------------------------------------------------- 1 | package com.sun.glass.ui.wayland; 2 | 3 | 4 | import com.sun.glass.ui.MenuItem; 5 | import com.sun.glass.ui.Pixels; 6 | import com.sun.glass.ui.delegate.MenuItemDelegate; 7 | 8 | public class WaylandMenuItemDelegate implements MenuItemDelegate { 9 | @Override 10 | public boolean createMenuItem(final String title, 11 | final MenuItem.Callback callback, 12 | final int shortcutKey, 13 | final int shortcutModifiers, 14 | final Pixels pixels, 15 | final boolean enabled, 16 | final boolean checked) { 17 | return true; 18 | } 19 | 20 | @Override 21 | public boolean setTitle(final String title) { 22 | return true; 23 | } 24 | 25 | @Override 26 | public boolean setCallback(final MenuItem.Callback callback) { 27 | return true; 28 | } 29 | 30 | @Override 31 | public boolean setShortcut(final int shortcutKey, 32 | final int shortcutModifiers) { 33 | return true; 34 | } 35 | 36 | @Override 37 | public boolean setPixels(final Pixels pixels) { 38 | return true; 39 | } 40 | 41 | @Override 42 | public boolean setEnabled(final boolean enabled) { 43 | return true; 44 | } 45 | 46 | @Override 47 | public boolean setChecked(final boolean checked) { 48 | return true; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/sun/glass/ui/wayland/WaylandRobot.java: -------------------------------------------------------------------------------- 1 | package com.sun.glass.ui.wayland; 2 | 3 | import com.sun.glass.ui.Pixels; 4 | import com.sun.glass.ui.Robot; 5 | 6 | public class WaylandRobot extends Robot { 7 | @Override 8 | protected void _create() { 9 | 10 | } 11 | 12 | @Override 13 | protected void _destroy() { 14 | 15 | } 16 | 17 | @Override 18 | protected void _keyPress(final int code) { 19 | 20 | } 21 | 22 | @Override 23 | protected void _keyRelease(final int code) { 24 | 25 | } 26 | 27 | @Override 28 | protected void _mouseMove(final int x, 29 | final int y) { 30 | 31 | } 32 | 33 | @Override 34 | protected void _mousePress(final int buttons) { 35 | 36 | } 37 | 38 | @Override 39 | protected void _mouseRelease(final int buttons) { 40 | 41 | } 42 | 43 | @Override 44 | protected void _mouseWheel(final int wheelAmt) { 45 | 46 | } 47 | 48 | @Override 49 | protected int _getMouseX() { 50 | return 0; 51 | } 52 | 53 | @Override 54 | protected int _getMouseY() { 55 | return 0; 56 | } 57 | 58 | @Override 59 | protected int _getPixelColor(final int x, 60 | final int y) { 61 | return 0; 62 | } 63 | 64 | @Override 65 | protected Pixels _getScreenCapture(final int x, 66 | final int y, 67 | final int width, 68 | final int height, 69 | final boolean isHiDPI) { 70 | return null; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/com/sun/glass/ui/monocle/WaylandBuffer.java: -------------------------------------------------------------------------------- 1 | package com.sun.glass.ui.monocle; 2 | 3 | import org.freedesktop.wayland.client.WlBufferEvents; 4 | import org.freedesktop.wayland.client.WlBufferProxy; 5 | 6 | 7 | public class WaylandBuffer implements WlBufferEvents { 8 | 9 | private final WaylandBufferPool waylandBufferPool; 10 | private final WaylandShmBuffer waylandShmBuffer; 11 | private final long pixmanImage; 12 | 13 | public WaylandBuffer(final WaylandBufferPool waylandBufferPool, 14 | final WaylandShmBuffer waylandShmBuffer) { 15 | this.waylandBufferPool = waylandBufferPool; 16 | this.waylandShmBuffer = waylandShmBuffer; 17 | 18 | this.pixmanImage = Libpixman1.pixman_image_create_bits(Libpixman1.PIXMAN_a8r8g8b8, 19 | waylandShmBuffer.getWidth(), 20 | waylandShmBuffer.getHeight(), 21 | waylandShmBuffer.getBuffer(), 22 | waylandShmBuffer.getWidth() * 4); 23 | } 24 | 25 | @Override 26 | public void release(final WlBufferProxy emitter) { 27 | if (this.waylandBufferPool.isDestroyed()) { 28 | emitter.destroy(); 29 | this.waylandShmBuffer.close(); 30 | } 31 | else { 32 | this.waylandBufferPool.queueBuffer(emitter); 33 | } 34 | } 35 | 36 | public WaylandShmBuffer getWaylandShmBuffer() { 37 | return this.waylandShmBuffer; 38 | } 39 | 40 | public long getPixmanImage() { 41 | return this.pixmanImage; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | 3 | # Mobile Tools for Java (J2ME) 4 | .mtj.tmp/ 5 | 6 | # Package Files # 7 | *.jar 8 | *.war 9 | *.ear 10 | 11 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 12 | hs_err_pid* 13 | ### JetBrains template 14 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 15 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 16 | 17 | # User-specific stuff: 18 | .idea/workspace.xml 19 | .idea/tasks.xml 20 | .idea/dictionaries 21 | .idea/vcs.xml 22 | .idea/jsLibraryMappings.xml 23 | 24 | # Sensitive or high-churn files: 25 | .idea/dataSources.ids 26 | .idea/dataSources.xml 27 | .idea/dataSources.local.xml 28 | .idea/sqlDataSources.xml 29 | .idea/dynamic.xml 30 | .idea/uiDesigner.xml 31 | 32 | # Gradle: 33 | .idea/gradle.xml 34 | .idea/libraries 35 | 36 | # Mongo Explorer plugin: 37 | .idea/mongoSettings.xml 38 | 39 | ## File-based project format: 40 | *.iws 41 | 42 | ## Plugin-specific files: 43 | 44 | # IntelliJ 45 | /out/ 46 | .idea/ 47 | 48 | # mpeltonen/sbt-idea plugin 49 | .idea_modules/ 50 | 51 | # JIRA plugin 52 | atlassian-ide-plugin.xml 53 | 54 | # Crashlytics plugin (for Android Studio and IntelliJ) 55 | com_crashlytics_export_strings.xml 56 | crashlytics.properties 57 | crashlytics-build.properties 58 | fabric.properties 59 | ### Java template 60 | 61 | # Mobile Tools for Java (J2ME) 62 | 63 | # Package Files # 64 | 65 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 66 | ### Maven template 67 | target/ 68 | pom.xml.tag 69 | pom.xml.releaseBackup 70 | pom.xml.versionsBackup 71 | pom.xml.next 72 | release.properties 73 | dependency-reduced-pom.xml 74 | buildNumber.properties 75 | .mvn/timing.properties 76 | /wayland-javafx.iml 77 | -------------------------------------------------------------------------------- /src/main/java/com/sun/glass/ui/wayland/WaylandPixels.java: -------------------------------------------------------------------------------- 1 | package com.sun.glass.ui.wayland; 2 | 3 | 4 | import com.sun.glass.ui.Pixels; 5 | 6 | import java.nio.ByteBuffer; 7 | import java.nio.IntBuffer; 8 | 9 | public class WaylandPixels extends Pixels { 10 | protected WaylandPixels(final int width, 11 | final int height, 12 | final ByteBuffer pixels) { 13 | super(width, 14 | height, 15 | pixels); 16 | } 17 | 18 | protected WaylandPixels(final int width, 19 | final int height, 20 | final IntBuffer pixels) { 21 | super(width, 22 | height, 23 | pixels); 24 | } 25 | 26 | protected WaylandPixels(final int width, 27 | final int height, 28 | final IntBuffer pixels, 29 | final float scale) { 30 | super(width, 31 | height, 32 | pixels, 33 | scale); 34 | } 35 | 36 | @Override 37 | protected void _fillDirectByteBuffer(final ByteBuffer bb) { 38 | 39 | } 40 | 41 | @Override 42 | protected void _attachInt(final long ptr, 43 | final int w, 44 | final int h, 45 | final IntBuffer ints, 46 | final int[] array, 47 | final int offset) { 48 | 49 | } 50 | 51 | @Override 52 | protected void _attachByte(final long ptr, 53 | final int w, 54 | final int h, 55 | final ByteBuffer bytes, 56 | final byte[] array, 57 | final int offset) { 58 | 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/sun/glass/ui/monocle/WaylandPlatformFactory.java: -------------------------------------------------------------------------------- 1 | package com.sun.glass.ui.monocle; 2 | 3 | import org.freedesktop.wayland.client.WlDisplayProxy; 4 | 5 | import java.util.concurrent.ExecutionException; 6 | import java.util.concurrent.ExecutorService; 7 | import java.util.concurrent.Executors; 8 | import java.util.concurrent.Future; 9 | 10 | public class WaylandPlatformFactory extends NativePlatformFactory { 11 | 12 | public static final ExecutorService WL_LOOP = Executors.newSingleThreadExecutor(r -> new Thread(r, 13 | "wayland-event-loop")); 14 | 15 | private static final int MAJOR = 1; 16 | private static final int MINOR = 0; 17 | 18 | protected boolean matches() { 19 | //TODO check if we're capable of running wayland (check if xdg_runtime dir is set & check if compositor socket exists) 20 | return true; 21 | } 22 | 23 | protected WaylandPlatform createNativePlatform() { 24 | //this ensures that all init happens on the wayland thread 25 | final Future waylandPlatformFuture = WL_LOOP.submit(() -> { 26 | final WlDisplayProxy wlDisplayProxy = WlDisplayProxy.connect("wayland-0"); 27 | final WaylandPlatform waylandPlatform = new WaylandPlatform(wlDisplayProxy); 28 | wlDisplayProxy.getRegistry(waylandPlatform); 29 | 30 | //start looping 31 | loop(wlDisplayProxy); 32 | 33 | return waylandPlatform; 34 | }); 35 | 36 | 37 | try { 38 | return waylandPlatformFuture.get(); 39 | } 40 | catch (InterruptedException | ExecutionException e) { 41 | throw new Error(e); 42 | } 43 | } 44 | 45 | private void loop(final WlDisplayProxy wlDisplayProxy) { 46 | wlDisplayProxy.roundtrip(); 47 | WL_LOOP.submit(() -> loop(wlDisplayProxy)); 48 | } 49 | 50 | protected int getMajorVersion() { 51 | return MAJOR; 52 | } 53 | 54 | protected int getMinorVersion() { 55 | return MINOR; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/sun/glass/ui/wayland/WaylandView.java: -------------------------------------------------------------------------------- 1 | package com.sun.glass.ui.wayland; 2 | 3 | import com.sun.glass.ui.Pixels; 4 | import com.sun.glass.ui.View; 5 | 6 | import java.util.Map; 7 | 8 | 9 | public class WaylandView extends View { 10 | @Override 11 | protected void _enableInputMethodEvents(final long ptr, 12 | final boolean enable) { 13 | 14 | } 15 | 16 | @Override 17 | protected long _create(final Map capabilities) { 18 | return 0; 19 | } 20 | 21 | @Override 22 | protected long _getNativeView(final long ptr) { 23 | return 0; 24 | } 25 | 26 | @Override 27 | protected int _getX(final long ptr) { 28 | return 0; 29 | } 30 | 31 | @Override 32 | protected int _getY(final long ptr) { 33 | return 0; 34 | } 35 | 36 | @Override 37 | protected void _setParent(final long ptr, 38 | final long parentPtr) { 39 | 40 | } 41 | 42 | @Override 43 | protected boolean _close(final long ptr) { 44 | return false; 45 | } 46 | 47 | @Override 48 | protected void _scheduleRepaint(final long ptr) { 49 | 50 | } 51 | 52 | @Override 53 | protected void _begin(final long ptr) { 54 | 55 | } 56 | 57 | @Override 58 | protected void _end(final long ptr) { 59 | 60 | } 61 | 62 | @Override 63 | protected int _getNativeFrameBuffer(final long ptr) { 64 | return 0; 65 | } 66 | 67 | @Override 68 | protected void _uploadPixels(final long ptr, 69 | final Pixels pixels) { 70 | 71 | } 72 | 73 | @Override 74 | protected boolean _enterFullscreen(final long ptr, 75 | final boolean animate, 76 | final boolean keepRatio, 77 | final boolean hideCursor) { 78 | return false; 79 | } 80 | 81 | @Override 82 | protected void _exitFullscreen(final long ptr, 83 | final boolean animate) { 84 | 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/com/sun/glass/ui/monocle/WaylandBufferPoolFactory.java: -------------------------------------------------------------------------------- 1 | package com.sun.glass.ui.monocle; 2 | 3 | import org.freedesktop.wayland.client.WlBufferProxy; 4 | import org.freedesktop.wayland.client.WlShmPoolProxy; 5 | import org.freedesktop.wayland.client.WlShmProxy; 6 | import org.freedesktop.wayland.shared.WlShmFormat; 7 | 8 | public class WaylandBufferPoolFactory { 9 | 10 | WaylandBufferPoolFactory() { 11 | } 12 | 13 | public WaylandBufferPool create(final WlShmProxy wlShmProxy, 14 | final int width, 15 | final int height, 16 | final int size, 17 | final WlShmFormat shmFormat) { 18 | 19 | final WaylandBufferPool waylandBufferPool = new WaylandBufferPool(); 20 | for (int i = 0; i < size; i++) { 21 | final int bufferSize = width * height * 4; 22 | final WaylandShmBuffer shmPool = new WaylandShmBuffer(bufferSize, 23 | width, 24 | height); 25 | 26 | final WlShmPoolProxy wlShmPoolProxy = wlShmProxy.createPool(waylandBufferPool, 27 | shmPool.getFileDescriptor(), 28 | bufferSize); 29 | final WlBufferProxy buffer = wlShmPoolProxy.createBuffer(new WaylandBuffer(waylandBufferPool, 30 | shmPool), 31 | 0, 32 | width, 33 | height, 34 | width * 4, 35 | shmFormat.value); 36 | waylandBufferPool.queueBuffer(buffer); 37 | wlShmPoolProxy.destroy(); 38 | } 39 | return waylandBufferPool; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/sun/glass/ui/monocle/WaylandCursor.java: -------------------------------------------------------------------------------- 1 | package com.sun.glass.ui.monocle; 2 | 3 | 4 | import com.sun.glass.ui.Size; 5 | import org.freedesktop.wayland.client.WlCompositorProxy; 6 | import org.freedesktop.wayland.client.WlOutputProxy; 7 | import org.freedesktop.wayland.client.WlShmProxy; 8 | import org.freedesktop.wayland.client.WlSurfaceEventsV4; 9 | import org.freedesktop.wayland.client.WlSurfaceProxy; 10 | import org.freedesktop.wayland.shared.WlShmFormat; 11 | 12 | import javax.annotation.Nonnull; 13 | 14 | public class WaylandCursor extends NativeCursor implements WlSurfaceEventsV4 { 15 | 16 | private final WlShmProxy wlShmProxy; 17 | private final Size size; 18 | private final WaylandBufferPool waylandBufferPool; 19 | private final WlSurfaceProxy wlSurfaceProxy; 20 | 21 | WaylandCursor(final WlShmProxy wlShmProxy, 22 | final WlCompositorProxy wlCompositorProxy, 23 | final WaylandSeat waylandSeat) { 24 | this.wlShmProxy = wlShmProxy; 25 | this.wlSurfaceProxy = wlCompositorProxy.createSurface(this); 26 | //TODO from config? 27 | this.size = new Size(32, 28 | 32); 29 | this.waylandBufferPool = new WaylandBufferPoolFactory().create(wlShmProxy, 30 | this.size.width, 31 | this.size.height, 32 | 2, 33 | WlShmFormat.ARGB8888); 34 | } 35 | 36 | Size getBestSize() { 37 | return this.size; 38 | } 39 | 40 | void setVisibility(final boolean visibility) { 41 | 42 | } 43 | 44 | void setImage(final byte[] cursorImage) { 45 | 46 | } 47 | 48 | void setLocation(final int x, 49 | final int y) { 50 | 51 | } 52 | 53 | void setHotSpot(final int hotspotX, 54 | final int hotspotY) { 55 | 56 | } 57 | 58 | void shutdown() { 59 | 60 | } 61 | 62 | @Override 63 | public void enter(final WlSurfaceProxy emitter, 64 | @Nonnull final WlOutputProxy output) { 65 | //NOOP monocle doesnt really support multi screen setup 66 | } 67 | 68 | @Override 69 | public void leave(final WlSurfaceProxy emitter, 70 | @Nonnull final WlOutputProxy output) { 71 | //NOOP monocle doesnt really support multi screen setup 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # wayland-javafx 2 | A Wayland backend for JavaFX. 3 | 4 | This is a work in progress. Currently software rendering, mouse & keyboard works (touch too but untested). 5 | 6 | TODO: 7 | - output using hw rendering (via wayland drm buffers). 8 | - Rewrite & cleanup code to production quality standards. 9 | - Remove all 3rd party jdk libraries. 10 | - Include in openjfx as monocle back-end? 11 | - Create a non monocle, desktop enabled wayland back-end. 12 | 13 | DONE: 14 | - output using sw rendering (via wayland shared memory buffers) 15 | - input handling through wayland's input protocols (keyboard+pointer+touch) 16 | 17 | This library *will* make use of libraries not present in a standard jdk/jfx install as to get things up and running as quickly as possible. 18 | - [wayland-java-bindings](https://github.com/udevbe/wayland-java-bindings) 19 | - [jaccall](https://github.com/udevbe/jaccall) 20 | 21 | The primary goal is to be able to use JavaFX as a pure client side widget toolkit capable to run on any Wayland compositor. 22 | 23 | Initial effort will focus on creating a Wayland implementation for the JavaFX Monocle back-end. This back-end is meant for the embedded, fullscreen, single application use case. 24 | 25 | Secondary effort is to create JavaFX Wayland back-end for general desktop usage. 26 | 27 | #Running 28 | 29 | In case you've decided you're crazy enough to take this ugly poc for a spin. Here's how: 30 | 31 | - Make sure you have a javafx version with monocle support available. This will most likely mean you'll have to build it from source (eglx86 profile for non embedded usage). See https://wiki.openjdk.java.net/display/OpenJFX/Building+OpenJFX#BuildingOpenJFX-CrossBuilds 32 | 33 | - Edit the pom.xml of the project and make sure ```/home/zubzub/hg/openjfx8-devrt/build/sdk/rt/lib/ext/jfxrt.jar```matches the jfxrt.jar of your monacle enabled and installed jfx library. 34 | 35 | - Build the project. You will also need to build the latest SNAPSHOT versions of [jaccall](https://github.com/udevbe/jaccall) & [wayland-java-bindings](https://github.com/udevbe/wayland-java-bindings). 36 | 37 | - Copy the ```./target/wayland-javafx-1.0.0-SNAPSHOT.jar``` to your local jdk installation's ext folder; eg. ```/usr/lib/jvm/oracle-jdk-bin-1.8/jre/lib/ext/``` 38 | 39 | - Run your javafx application; eg. ```unset DISPLAY && java -Dglass.platform=Monocle -Dmonocle.platform=Wayland -jar Ensemble8.jar``` 40 | 41 | - Make sure you delete ```wayland-javafx-1.0.0-SNAPSHOT.jar``` from your jdk installation once you're done as it might introduce some unwanted behavior in other programs. 42 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | org.freedesktop 4 | wayland-javafx 5 | 1.0.0-SNAPSHOT 6 | 7 | 8 | 1.5.0-SNAPSHOT 9 | 1.0.4-SNAPSHOT 10 | 1.0-beta3 11 | 3.5.1 12 | 13 | 14 | 1.9 15 | 1.9 16 | 1.9 17 | javac 18 | 19 | 20 | /home/zubzub/hg/openjfx8-devrt/build/sdk/rt/lib/ext/jfxrt.jar 21 | 22 | 23 | 24 | 25 | com.oracle 26 | openjfx 27 | 8 28 | system 29 | ${jfxrt.path} 30 | 31 | 32 | org.freedesktop 33 | wayland-client 34 | ${wayland.client.version} 35 | 36 | 37 | org.freedesktop 38 | jaccall.runtime 39 | ${jaccall.version} 40 | 41 | 42 | 43 | 44 | 45 | 46 | org.apache.maven.plugins 47 | maven-compiler-plugin 48 | ${maven.compiler.plugin.version} 49 | 50 | 1.8 51 | 1.8 52 | -Xlint:all 53 | true 54 | true 55 | false 56 | 57 | 58 | org.freedesktop 59 | jaccall.generator 60 | ${jaccall.version} 61 | 62 | 63 | 64 | 65 | 66 | org.apache.maven.plugins 67 | maven-shade-plugin 68 | 2.3 69 | 70 | 71 | package 72 | 73 | shade 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /src/main/java/com/sun/glass/ui/monocle/Libpixman1.java: -------------------------------------------------------------------------------- 1 | package com.sun.glass.ui.monocle; 2 | 3 | import org.freedesktop.jaccall.Lib; 4 | import org.freedesktop.jaccall.Ptr; 5 | import org.freedesktop.jaccall.Unsigned; 6 | 7 | @Lib(value = "pixman-1", 8 | version = 0) 9 | public class Libpixman1 { 10 | 11 | public static final int PIXMAN_TYPE_ARGB = 2; 12 | public static final int PIXMAN_TYPE_BGRA = 8; 13 | 14 | public static final int PIXMAN_b8g8r8a8 = PIXMAN_FORMAT(32, 15 | PIXMAN_TYPE_BGRA, 16 | 8, 17 | 8, 18 | 8, 19 | 8); 20 | public static final int PIXMAN_a8r8g8b8 = PIXMAN_FORMAT(32, 21 | PIXMAN_TYPE_ARGB, 22 | 8, 23 | 8, 24 | 8, 25 | 8); 26 | 27 | public static final int PIXMAN_OP_SRC = 0x01; 28 | public static final int PIXMAN_OP_OVER = 0x03; 29 | 30 | 31 | static { 32 | new Libpixman1_Symbols().link(); 33 | } 34 | 35 | public static int PIXMAN_FORMAT(final int bpp, 36 | final int type, 37 | final int a, 38 | final int r, 39 | final int g, 40 | final int b) { 41 | return (((bpp) << 24) | 42 | ((type) << 16) | 43 | ((a) << 12) | 44 | ((r) << 8) | 45 | ((g) << 4) | 46 | ((b))); 47 | } 48 | 49 | @Ptr 50 | public static native long pixman_image_create_bits(int format, 51 | int width, 52 | int height, 53 | @Ptr(int.class) long bits, 54 | int rowstride_bytes); 55 | 56 | @Ptr 57 | public static native long pixman_image_create_bits_no_clear(int format, 58 | int width, 59 | int height, 60 | @Ptr(int.class) long bits, 61 | int rowstride_bytes); 62 | 63 | public static native void pixman_image_composite(int op, 64 | @Ptr long src, 65 | @Ptr long mask, 66 | @Ptr long dest, 67 | short src_x, 68 | short src_y, 69 | short mask_x, 70 | short mask_y, 71 | short dest_x, 72 | short dest_y, 73 | @Unsigned short width, 74 | @Unsigned short height); 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/com/sun/glass/ui/monocle/WaylandShmBuffer.java: -------------------------------------------------------------------------------- 1 | //Copyright 2015 Erik De Rijcke 2 | // 3 | //Licensed under the Apache License,Version2.0(the"License"); 4 | //you may not use this file except in compliance with the License. 5 | //You may obtain a copy of the License at 6 | // 7 | //http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | //Unless required by applicable law or agreed to in writing,software 10 | //distributed under the License is distributed on an"AS IS"BASIS, 11 | //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,either express or implied. 12 | //See the License for the specific language governing permissions and 13 | //limitations under the License. 14 | package com.sun.glass.ui.monocle; 15 | 16 | import org.freedesktop.jaccall.Pointer; 17 | 18 | import java.io.Closeable; 19 | 20 | public final class WaylandShmBuffer implements Closeable { 21 | private final int width; 22 | private final int height; 23 | private int fd; 24 | private int size; 25 | private long buffer; 26 | 27 | public WaylandShmBuffer(final int size, 28 | final int width, 29 | final int height) { 30 | this.width = width; 31 | this.height = height; 32 | this.fd = createTmpFileNative(); 33 | this.size = size; 34 | truncateNative(getFd(), 35 | getSize()); 36 | this.buffer = map(getFd(), 37 | getSize()); 38 | } 39 | 40 | private static int createTmpFileNative() { 41 | final String template = "/wayland-jfx-shm-XXXXXX"; 42 | final String path = System.getenv("XDG_RUNTIME_DIR"); 43 | if (path == null) { 44 | throw new IllegalStateException("Cannot create temporary file: XDG_RUNTIME_DIR not set"); 45 | } 46 | 47 | final Pointer name = Pointer.nref(path + template); 48 | final int fd = Libc.mkstemp(name.address); 49 | 50 | final int F_GETFD = 1; 51 | int flags = Libc.fcntl(fd, 52 | F_GETFD, 53 | 0); 54 | if (-1 == flags) { 55 | Libc.close(fd); 56 | throw new RuntimeException("error"); 57 | } 58 | 59 | final int FD_CLOEXEC = 1; 60 | flags |= FD_CLOEXEC; 61 | final int F_SETFD = 2; 62 | final int ret = Libc.fcntl(fd, 63 | F_SETFD, 64 | flags); 65 | if (-1 == ret) { 66 | Libc.close(fd); 67 | throw new RuntimeException("error"); 68 | } 69 | 70 | return fd; 71 | } 72 | 73 | private static void truncateNative(final int fd, 74 | final int size) { 75 | Libc.ftruncate(fd, 76 | size); 77 | } 78 | 79 | public int getFd() { 80 | return this.fd; 81 | } 82 | 83 | public int getSize() { 84 | return this.size; 85 | } 86 | 87 | private static long map(final int fd, 88 | final int size) { 89 | final int PROT_READ = 0x01; 90 | final int PROT_WRITE = 0x02; 91 | 92 | final int prot = PROT_READ | PROT_WRITE; 93 | final int MAP_SHARED = 0x001; 94 | return Libc.mmap(0L, 95 | size, 96 | prot, 97 | MAP_SHARED, 98 | fd, 99 | 0); 100 | } 101 | 102 | public int getFileDescriptor() { 103 | return this.fd; 104 | } 105 | 106 | public long size() { 107 | return this.size; 108 | } 109 | 110 | @Override 111 | public void finalize() throws Throwable { 112 | close(); 113 | super.finalize(); 114 | } 115 | 116 | @Override 117 | public void close() { 118 | if (this.buffer != 0L) { 119 | unmapNative(); 120 | closeNative(getFd()); 121 | this.fd = -1; 122 | this.size = 0; 123 | this.buffer = 0L; 124 | } 125 | } 126 | 127 | private void unmapNative() { 128 | Libc.munmap(this.buffer, 129 | this.size); 130 | } 131 | 132 | private static void closeNative(final int fd) { 133 | Libc.close(fd); 134 | } 135 | 136 | public int getWidth() { 137 | return this.width; 138 | } 139 | 140 | public int getHeight() { 141 | return this.height; 142 | } 143 | 144 | public long getBuffer() { 145 | return this.buffer; 146 | } 147 | } 148 | 149 | -------------------------------------------------------------------------------- /src/main/java/com/sun/glass/ui/monocle/WaylandSeat.java: -------------------------------------------------------------------------------- 1 | package com.sun.glass.ui.monocle; 2 | 3 | import org.freedesktop.wayland.client.WlRegistryProxy; 4 | import org.freedesktop.wayland.client.WlSeatEventsV3; 5 | import org.freedesktop.wayland.client.WlSeatProxy; 6 | import org.freedesktop.wayland.shared.WlSeatCapability; 7 | 8 | import javax.annotation.Nonnull; 9 | import javax.annotation.Nullable; 10 | 11 | public class WaylandSeat implements WlSeatEventsV3 { 12 | 13 | @Nonnull 14 | private final WlSeatProxy wlSeatProxy; 15 | @Nonnull 16 | private final InputDeviceRegistry inputDeviceRegistry; 17 | 18 | @Nullable 19 | private WaylandInputDeviceKeyboard waylandInputDeviceKeyboard; 20 | @Nullable 21 | private WaylandInputDeviceTouch waylandInputDeviceTouch; 22 | @Nullable 23 | private WaylandInputDevicePointer waylandInputDevicePointer; 24 | 25 | WaylandSeat(@Nonnull final WlRegistryProxy registryProxy, 26 | final int name, 27 | @Nonnull final String interfaceName, 28 | final int version, 29 | @Nonnull final InputDeviceRegistry inputDeviceRegistry) { 30 | this.inputDeviceRegistry = inputDeviceRegistry; 31 | this.wlSeatProxy = registryProxy.bind(name, 32 | WlSeatProxy.class, 33 | WlSeatEventsV3.VERSION, 34 | this); 35 | } 36 | 37 | @Override 38 | public void capabilities(final WlSeatProxy emitter, 39 | final int capabilities) { 40 | //TODO delete/add wayland input device 41 | 42 | if ((WlSeatCapability.KEYBOARD.value & capabilities) != 0 && this.waylandInputDeviceKeyboard == null) { 43 | //keyboard was added 44 | this.waylandInputDeviceKeyboard = new WaylandInputDeviceKeyboard(this.wlSeatProxy); 45 | this.inputDeviceRegistry.getInputDevices() 46 | .add(this.waylandInputDeviceKeyboard); 47 | } 48 | else if ((WlSeatCapability.KEYBOARD.value & capabilities) == 0 && this.waylandInputDeviceKeyboard != null) { 49 | //keyboard was removed 50 | this.inputDeviceRegistry.getInputDevices() 51 | .remove(this.waylandInputDeviceKeyboard); 52 | this.waylandInputDeviceKeyboard.getWlKeyboardProxy() 53 | .release(); 54 | this.waylandInputDeviceKeyboard = null; 55 | } 56 | 57 | if ((WlSeatCapability.POINTER.value & capabilities) != 0 && this.waylandInputDevicePointer == null) { 58 | //pointer was added 59 | this.waylandInputDevicePointer = new WaylandInputDevicePointer(this.wlSeatProxy); 60 | this.inputDeviceRegistry.getInputDevices() 61 | .add(this.waylandInputDevicePointer); 62 | } 63 | else if ((WlSeatCapability.POINTER.value & capabilities) == 0 && this.waylandInputDevicePointer != null) { 64 | //pointer was removed 65 | this.inputDeviceRegistry.getInputDevices() 66 | .remove(this.waylandInputDevicePointer); 67 | this.waylandInputDevicePointer.getWlPointerProxy() 68 | .release(); 69 | this.waylandInputDevicePointer = null; 70 | } 71 | 72 | if ((WlSeatCapability.TOUCH.value & capabilities) != 0 && this.waylandInputDeviceTouch == null) { 73 | //touch was added 74 | this.waylandInputDeviceTouch = new WaylandInputDeviceTouch(this.wlSeatProxy); 75 | ; 76 | this.inputDeviceRegistry.getInputDevices() 77 | .add(this.waylandInputDeviceTouch); 78 | } 79 | else if ((WlSeatCapability.TOUCH.value & capabilities) == 0 && this.waylandInputDeviceTouch != null) { 80 | //touch was removed 81 | this.inputDeviceRegistry.getInputDevices() 82 | .remove(this.waylandInputDeviceTouch); 83 | this.waylandInputDeviceTouch.getWlTouchProxy() 84 | .release(); 85 | this.waylandInputDeviceTouch = null; 86 | } 87 | 88 | //TODO release seat if no devices are announced anymore 89 | } 90 | 91 | @Override 92 | public void name(final WlSeatProxy emitter, 93 | @Nonnull final String name) { 94 | 95 | } 96 | 97 | @Nullable 98 | public WaylandInputDevicePointer getWaylandInputDevicePointer() { 99 | return waylandInputDevicePointer; 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /src/main/java/com/sun/glass/ui/monocle/WaylandOutput.java: -------------------------------------------------------------------------------- 1 | package com.sun.glass.ui.monocle; 2 | 3 | import org.freedesktop.wayland.client.WlDisplayProxy; 4 | import org.freedesktop.wayland.client.WlOutputEventsV2; 5 | import org.freedesktop.wayland.client.WlOutputProxy; 6 | import org.freedesktop.wayland.client.WlRegistryProxy; 7 | 8 | import javax.annotation.Nonnull; 9 | 10 | class WaylandOutput implements WlOutputEventsV2 { 11 | 12 | private final WlOutputProxy wlOutputProxy; 13 | private int x; 14 | private int y; 15 | private int physicalWidth; 16 | private int physicalHeight; 17 | private int subpixel; 18 | private String make; 19 | private String model; 20 | private int transform; 21 | private int flags; 22 | private int width; 23 | private int height; 24 | private int refresh; 25 | private int scaleFactor; 26 | private boolean done; 27 | 28 | private boolean geo; 29 | private boolean mode; 30 | 31 | WaylandOutput(final WlDisplayProxy wlDisplayProxy, 32 | final int name, 33 | @Nonnull final WlRegistryProxy registryProxy) { 34 | //binding to the output global will notify the compositor which in turn will send out the output information events 35 | this.wlOutputProxy = registryProxy.bind(name, 36 | WlOutputProxy.class, 37 | VERSION, 38 | this); 39 | 40 | //keep firing roundrips until we received all output information 41 | if (this.wlOutputProxy.getVersion() < VERSION) { 42 | while (!this.geo && !this.mode) { 43 | //TODO safeguard in case we never receive desired output info 44 | wlDisplayProxy.roundtrip(); 45 | } 46 | } 47 | else { 48 | while (!this.done) { 49 | //TODO safeguard in case we never receive desired output info 50 | wlDisplayProxy.roundtrip(); 51 | } 52 | } 53 | } 54 | 55 | @Override 56 | public void geometry(final WlOutputProxy emitter, 57 | final int x, 58 | final int y, 59 | final int physicalWidth, 60 | final int physicalHeight, 61 | final int subpixel, 62 | @Nonnull final String make, 63 | @Nonnull final String model, 64 | final int transform) { 65 | 66 | this.x = x; 67 | this.y = y; 68 | this.physicalWidth = physicalWidth; 69 | this.physicalHeight = physicalHeight; 70 | this.subpixel = subpixel; 71 | this.make = make; 72 | this.model = model; 73 | this.transform = transform; 74 | 75 | this.geo = true; 76 | } 77 | 78 | @Override 79 | public void mode(final WlOutputProxy emitter, 80 | final int flags, 81 | final int width, 82 | final int height, 83 | final int refresh) { 84 | 85 | this.flags = flags; 86 | this.width = width; 87 | this.height = height; 88 | this.refresh = refresh; 89 | 90 | this.mode = true; 91 | } 92 | 93 | @Override 94 | public void done(final WlOutputProxy emitter) { 95 | this.done = true; 96 | } 97 | 98 | @Override 99 | public void scale(final WlOutputProxy emitter, 100 | final int factor) { 101 | this.scaleFactor = factor; 102 | } 103 | 104 | public int getX() { 105 | return this.x; 106 | } 107 | 108 | public int getY() { 109 | return this.y; 110 | } 111 | 112 | public int getPhysicalWidth() { 113 | return this.physicalWidth; 114 | } 115 | 116 | public int getPhysicalHeight() { 117 | return this.physicalHeight; 118 | } 119 | 120 | public int getSubpixel() { 121 | return this.subpixel; 122 | } 123 | 124 | public String getMake() { 125 | return this.make; 126 | } 127 | 128 | public String getModel() { 129 | return this.model; 130 | } 131 | 132 | public int getTransform() { 133 | return this.transform; 134 | } 135 | 136 | public int getFlags() { 137 | return this.flags; 138 | } 139 | 140 | public int getWidth() { 141 | return this.width; 142 | } 143 | 144 | public int getHeight() { 145 | return this.height; 146 | } 147 | 148 | public int getRefresh() { 149 | return this.refresh; 150 | } 151 | 152 | public int getScaleFactor() { 153 | return this.scaleFactor; 154 | } 155 | 156 | public WlOutputProxy getWlOutputProxy() { 157 | return this.wlOutputProxy; 158 | } 159 | } 160 | -------------------------------------------------------------------------------- /src/main/java/com/sun/glass/ui/monocle/WaylandInputDeviceTouch.java: -------------------------------------------------------------------------------- 1 | package com.sun.glass.ui.monocle; 2 | 3 | import org.freedesktop.wayland.client.WlSeatProxy; 4 | import org.freedesktop.wayland.client.WlSurfaceProxy; 5 | import org.freedesktop.wayland.client.WlTouchEventsV5; 6 | import org.freedesktop.wayland.client.WlTouchProxy; 7 | import org.freedesktop.wayland.util.Fixed; 8 | 9 | import javax.annotation.Nonnull; 10 | 11 | public class WaylandInputDeviceTouch implements InputDevice, WlTouchEventsV5 { 12 | 13 | //should be accessed by jfx thread only! -> 14 | @Nonnull 15 | private final TouchInput touchInput = TouchInput.getInstance(); 16 | @Nonnull 17 | private final TouchState touchState = new TouchState(); 18 | //<- 19 | 20 | @Nonnull 21 | private final WlTouchProxy wlTouchProxy; 22 | 23 | WaylandInputDeviceTouch(@Nonnull final WlSeatProxy wlSeatProxy) { 24 | this.wlTouchProxy = wlSeatProxy.getTouch(this); 25 | } 26 | 27 | @Override 28 | public boolean isTouch() { 29 | return true; 30 | } 31 | 32 | @Override 33 | public boolean isMultiTouch() { 34 | return true; 35 | } 36 | 37 | @Override 38 | public boolean isRelative() { 39 | return true; 40 | } 41 | 42 | @Override 43 | public boolean is5Way() { 44 | return false; 45 | } 46 | 47 | @Override 48 | public boolean isFullKeyboard() { 49 | return false; 50 | } 51 | 52 | @Override 53 | public void down(final WlTouchProxy emitter, 54 | final int serial, 55 | final int time, 56 | @Nonnull final WlSurfaceProxy surface, 57 | final int id, 58 | @Nonnull final Fixed x, 59 | @Nonnull final Fixed y) { 60 | RunnableProcessor.runLater(() -> handleDown(serial, 61 | time, 62 | surface, 63 | id, 64 | x, 65 | y)); 66 | } 67 | 68 | private void handleDown(final int serial, 69 | final int time, 70 | @Nonnull final WlSurfaceProxy surface, 71 | final int id, 72 | @Nonnull final Fixed x, 73 | @Nonnull final Fixed y) { 74 | this.touchInput.getState(this.touchState); 75 | final TouchState.Point point = new TouchState.Point(); 76 | point.id = id; 77 | point.x = x.asInt(); 78 | point.y = y.asInt(); 79 | this.touchState.addPoint(point); 80 | } 81 | 82 | @Override 83 | public void up(final WlTouchProxy emitter, 84 | final int serial, 85 | final int time, 86 | final int id) { 87 | RunnableProcessor.runLater(() -> handleUp(serial, 88 | time, 89 | id)); 90 | } 91 | 92 | private void handleUp(final int serial, 93 | final int time, 94 | final int id) { 95 | this.touchInput.getState(this.touchState); 96 | this.touchState.removePointForID(id); 97 | } 98 | 99 | @Override 100 | public void motion(final WlTouchProxy emitter, 101 | final int time, 102 | final int id, 103 | @Nonnull final Fixed x, 104 | @Nonnull final Fixed y) { 105 | RunnableProcessor.runLater(() -> handleMotion(time, 106 | id, 107 | x, 108 | y)); 109 | } 110 | 111 | private void handleMotion(final int time, 112 | final int id, 113 | @Nonnull final Fixed x, 114 | @Nonnull final Fixed y) { 115 | this.touchInput.getState(this.touchState); 116 | final TouchState.Point pointForID = this.touchState.getPointForID(id); 117 | pointForID.x = x.asInt(); 118 | pointForID.y = y.asInt(); 119 | } 120 | 121 | @Override 122 | public void frame(final WlTouchProxy emitter) { 123 | RunnableProcessor.runLater(this::handleFrame); 124 | } 125 | 126 | private void handleFrame() { 127 | this.touchInput.setState(this.touchState); 128 | } 129 | 130 | @Override 131 | public void cancel(final WlTouchProxy emitter) { 132 | RunnableProcessor.runLater(this::handleCancel); 133 | } 134 | 135 | private void handleCancel() { 136 | this.touchState.clear(); 137 | this.touchInput.setState(this.touchState); 138 | } 139 | 140 | @Nonnull 141 | public WlTouchProxy getWlTouchProxy() { 142 | return this.wlTouchProxy; 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /src/main/java/com/sun/glass/ui/wayland/WaylandApplication.java: -------------------------------------------------------------------------------- 1 | package com.sun.glass.ui.wayland; 2 | 3 | import com.sun.glass.ui.Application; 4 | import com.sun.glass.ui.CommonDialogs; 5 | import com.sun.glass.ui.Cursor; 6 | import com.sun.glass.ui.Pixels; 7 | import com.sun.glass.ui.Robot; 8 | import com.sun.glass.ui.Screen; 9 | import com.sun.glass.ui.Size; 10 | import com.sun.glass.ui.Timer; 11 | import com.sun.glass.ui.View; 12 | import com.sun.glass.ui.Window; 13 | 14 | import java.io.File; 15 | import java.nio.ByteBuffer; 16 | import java.nio.IntBuffer; 17 | 18 | 19 | public class WaylandApplication extends Application { 20 | @Override 21 | protected void runLoop(final Runnable launchable) { 22 | 23 | } 24 | 25 | @Override 26 | protected void _invokeAndWait(final Runnable runnable) { 27 | 28 | } 29 | 30 | @Override 31 | protected void _invokeLater(final Runnable runnable) { 32 | 33 | } 34 | 35 | @Override 36 | protected Object _enterNestedEventLoop() { 37 | return null; 38 | } 39 | 40 | @Override 41 | protected void _leaveNestedEventLoop(final Object retValue) { 42 | 43 | } 44 | 45 | @Override 46 | public Window createWindow(final Window owner, 47 | final Screen screen, 48 | final int styleMask) { 49 | return null; 50 | } 51 | 52 | @Override 53 | public Window createWindow(final long parent) { 54 | return null; 55 | } 56 | 57 | @Override 58 | public View createView() { 59 | return null; 60 | } 61 | 62 | @Override 63 | public Cursor createCursor(final int type) { 64 | return null; 65 | } 66 | 67 | @Override 68 | public Cursor createCursor(final int x, 69 | final int y, 70 | final Pixels pixels) { 71 | return null; 72 | } 73 | 74 | @Override 75 | protected void staticCursor_setVisible(final boolean visible) { 76 | 77 | } 78 | 79 | @Override 80 | protected Size staticCursor_getBestSize(final int width, 81 | final int height) { 82 | return null; 83 | } 84 | 85 | @Override 86 | public Pixels createPixels(final int width, 87 | final int height, 88 | final ByteBuffer data) { 89 | return null; 90 | } 91 | 92 | @Override 93 | public Pixels createPixels(final int width, 94 | final int height, 95 | final IntBuffer data) { 96 | return null; 97 | } 98 | 99 | @Override 100 | public Pixels createPixels(final int width, 101 | final int height, 102 | final IntBuffer data, 103 | final float scale) { 104 | return null; 105 | } 106 | 107 | @Override 108 | protected int staticPixels_getNativeFormat() { 109 | return 0; 110 | } 111 | 112 | @Override 113 | public Robot createRobot() { 114 | return null; 115 | } 116 | 117 | @Override 118 | protected double staticScreen_getVideoRefreshPeriod() { 119 | return 0; 120 | } 121 | 122 | @Override 123 | protected Screen[] staticScreen_getScreens() { 124 | return new Screen[0]; 125 | } 126 | 127 | @Override 128 | public Timer createTimer(final Runnable runnable) { 129 | return null; 130 | } 131 | 132 | @Override 133 | protected int staticTimer_getMinPeriod() { 134 | return 0; 135 | } 136 | 137 | @Override 138 | protected int staticTimer_getMaxPeriod() { 139 | return 0; 140 | } 141 | 142 | @Override 143 | protected CommonDialogs.FileChooserResult staticCommonDialogs_showFileChooser(final Window owner, 144 | final String folder, 145 | final String filename, 146 | final String title, 147 | final int type, 148 | final boolean multipleMode, 149 | final CommonDialogs.ExtensionFilter[] extensionFilters, 150 | final int defaultFilterIndex) { 151 | return null; 152 | } 153 | 154 | @Override 155 | protected File staticCommonDialogs_showFolderChooser(final Window owner, 156 | final String folder, 157 | final String title) { 158 | return null; 159 | } 160 | 161 | @Override 162 | protected long staticView_getMultiClickTime() { 163 | return 0; 164 | } 165 | 166 | @Override 167 | protected int staticView_getMultiClickMaxX() { 168 | return 0; 169 | } 170 | 171 | @Override 172 | protected int staticView_getMultiClickMaxY() { 173 | return 0; 174 | } 175 | 176 | @Override 177 | protected boolean _supportsTransparentWindows() { 178 | return false; 179 | } 180 | 181 | @Override 182 | protected boolean _supportsUnifiedWindows() { 183 | return false; 184 | } 185 | 186 | @Override 187 | protected int _getKeyCodeForChar(final char c) { 188 | return 0; 189 | } 190 | } 191 | -------------------------------------------------------------------------------- /src/main/java/com/sun/glass/ui/monocle/WaylandPlatform.java: -------------------------------------------------------------------------------- 1 | package com.sun.glass.ui.monocle; 2 | 3 | import org.freedesktop.wayland.client.WlCompositorEventsV3; 4 | import org.freedesktop.wayland.client.WlCompositorProxy; 5 | import org.freedesktop.wayland.client.WlDisplayProxy; 6 | import org.freedesktop.wayland.client.WlOutputProxy; 7 | import org.freedesktop.wayland.client.WlRegistryEvents; 8 | import org.freedesktop.wayland.client.WlRegistryProxy; 9 | import org.freedesktop.wayland.client.WlSeatProxy; 10 | import org.freedesktop.wayland.client.WlShellEvents; 11 | import org.freedesktop.wayland.client.WlShellProxy; 12 | import org.freedesktop.wayland.client.WlShmProxy; 13 | 14 | import javax.annotation.Nonnull; 15 | import javax.annotation.Nullable; 16 | 17 | public class WaylandPlatform extends NativePlatform implements WlRegistryEvents { 18 | 19 | /* 20 | * A NativePlatform bundles together a NativeScreen, NativeCursor and InputDeviceRegistry. 21 | * NativePlatform is a singleton, as are the classes it contains. 22 | */ 23 | 24 | @Nonnull 25 | private final WlDisplayProxy wlDisplayProxy; 26 | 27 | @Nullable 28 | private WlCompositorProxy compositorProxy; 29 | @Nullable 30 | private WlShellProxy shellProxy; 31 | @Nullable 32 | private WaylandShm waylandShm; 33 | private WaylandOutput waylandOutput; 34 | private WaylandSeat waylandSeat; 35 | 36 | WaylandPlatform(@Nonnull final WlDisplayProxy wlDisplayProxy) { 37 | this.wlDisplayProxy = wlDisplayProxy; 38 | } 39 | 40 | protected InputDeviceRegistry createInputDeviceRegistry() { 41 | return new InputDeviceRegistry(); 42 | } 43 | 44 | protected WaylandCursor createCursor() { 45 | if (this.waylandShm == null || 46 | this.compositorProxy == null) { 47 | ensureGlobals(); 48 | } 49 | 50 | if (this.waylandSeat == null) { 51 | return null; 52 | } 53 | else { 54 | return new WaylandCursor(this.waylandShm.getWlShmProxy(), 55 | this.compositorProxy, 56 | this.waylandSeat); 57 | } 58 | } 59 | 60 | private void ensureGlobals() { 61 | //make sure we receive all globals 62 | while (this.waylandOutput == null || 63 | this.compositorProxy == null || 64 | this.shellProxy == null || 65 | this.waylandShm == null) { 66 | //We keep on tripping (pun intended) until we have received all globals. 67 | //FIXME safe guard so we can bail if required globals are never received 68 | this.wlDisplayProxy.roundtrip(); 69 | } 70 | } 71 | 72 | protected WaylandScreen createScreen() { 73 | if (this.waylandOutput == null || 74 | this.compositorProxy == null || 75 | this.shellProxy == null || 76 | this.waylandShm == null) { 77 | ensureGlobals(); 78 | } 79 | return new WaylandScreen(new WaylandBufferPoolFactory(), 80 | this.wlDisplayProxy, 81 | this.waylandOutput, 82 | this.compositorProxy, 83 | this.shellProxy, 84 | this.waylandShm); 85 | } 86 | 87 | @Override 88 | public void global(final WlRegistryProxy emitter, 89 | final int name, 90 | @Nonnull final String interface_, 91 | final int version) { 92 | if (WlCompositorProxy.INTERFACE_NAME.equals(interface_)) { 93 | this.compositorProxy = emitter.bind(name, 94 | WlCompositorProxy.class, 95 | WlCompositorEventsV3.VERSION, 96 | new WlCompositorEventsV3() { 97 | }); 98 | } 99 | else if (WlShmProxy.INTERFACE_NAME.equals(interface_)) { 100 | this.waylandShm = new WaylandShm(emitter, 101 | name, 102 | interface_, 103 | version); 104 | } 105 | else if (WlShellProxy.INTERFACE_NAME.equals(interface_)) { 106 | this.shellProxy = emitter.bind(name, 107 | WlShellProxy.class, 108 | WlShellEvents.VERSION, 109 | new WlShellEvents() { 110 | }); 111 | } 112 | else if (WlOutputProxy.INTERFACE_NAME.equals(interface_)) { 113 | //monocle doesnt support multiple outputs 114 | if (this.waylandOutput == null) { 115 | this.waylandOutput = new WaylandOutput(this.wlDisplayProxy, 116 | name, 117 | emitter); 118 | } 119 | } 120 | else if (WlSeatProxy.INTERFACE_NAME.equals(interface_)) { 121 | //TODO support multi seat (does monocle support this?) 122 | if (this.waylandSeat == null) { 123 | this.waylandSeat = new WaylandSeat(emitter, 124 | name, 125 | interface_, 126 | version, 127 | getInputDeviceRegistry()); 128 | } 129 | } 130 | } 131 | 132 | @Override 133 | public void globalRemove(final WlRegistryProxy emitter, 134 | final int name) { 135 | //TODO listen for eg seat removals 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /src/main/java/com/sun/glass/ui/wayland/WaylandWindow.java: -------------------------------------------------------------------------------- 1 | package com.sun.glass.ui.wayland; 2 | 3 | import com.sun.glass.ui.Cursor; 4 | import com.sun.glass.ui.Pixels; 5 | import com.sun.glass.ui.Screen; 6 | import com.sun.glass.ui.View; 7 | import com.sun.glass.ui.Window; 8 | 9 | 10 | public class WaylandWindow extends Window { 11 | 12 | protected WaylandWindow(final Window owner, 13 | final Screen screen, 14 | final int styleMask) { 15 | super(owner, 16 | screen, 17 | styleMask); 18 | } 19 | 20 | protected WaylandWindow(final long parent) { 21 | super(parent); 22 | } 23 | 24 | @Override 25 | protected long _createWindow(final long ownerPtr, 26 | final long screenPtr, 27 | final int mask) { 28 | return 0; 29 | } 30 | 31 | @Override 32 | protected long _createChildWindow(final long parent) { 33 | return 0; 34 | } 35 | 36 | @Override 37 | protected boolean _close(final long ptr) { 38 | return false; 39 | } 40 | 41 | @Override 42 | protected boolean _setView(final long ptr, 43 | final View view) { 44 | return false; 45 | } 46 | 47 | @Override 48 | protected boolean _setMenubar(final long ptr, 49 | final long menubarPtr) { 50 | return false; 51 | } 52 | 53 | @Override 54 | protected boolean _minimize(final long ptr, 55 | final boolean minimize) { 56 | return false; 57 | } 58 | 59 | @Override 60 | protected boolean _maximize(final long ptr, 61 | final boolean maximize, 62 | final boolean wasMaximized) { 63 | return false; 64 | } 65 | 66 | @Override 67 | protected int _getEmbeddedX(final long ptr) { 68 | return 0; 69 | } 70 | 71 | @Override 72 | protected int _getEmbeddedY(final long ptr) { 73 | return 0; 74 | } 75 | 76 | @Override 77 | protected void _setBounds(final long ptr, 78 | final int x, 79 | final int y, 80 | final boolean xSet, 81 | final boolean ySet, 82 | final int w, 83 | final int h, 84 | final int cw, 85 | final int ch, 86 | final float xGravity, 87 | final float yGravity) { 88 | 89 | } 90 | 91 | @Override 92 | protected boolean _setVisible(final long ptr, 93 | final boolean visible) { 94 | return false; 95 | } 96 | 97 | @Override 98 | protected boolean _setResizable(final long ptr, 99 | final boolean resizable) { 100 | return false; 101 | } 102 | 103 | @Override 104 | protected boolean _requestFocus(final long ptr, 105 | final int event) { 106 | return false; 107 | } 108 | 109 | @Override 110 | protected void _setFocusable(final long ptr, 111 | final boolean isFocusable) { 112 | 113 | } 114 | 115 | @Override 116 | protected boolean _grabFocus(final long ptr) { 117 | return false; 118 | } 119 | 120 | @Override 121 | protected void _ungrabFocus(final long ptr) { 122 | 123 | } 124 | 125 | @Override 126 | protected boolean _setTitle(final long ptr, 127 | final String title) { 128 | return false; 129 | } 130 | 131 | @Override 132 | protected void _setLevel(final long ptr, 133 | final int level) { 134 | 135 | } 136 | 137 | @Override 138 | protected void _setAlpha(final long ptr, 139 | final float alpha) { 140 | 141 | } 142 | 143 | @Override 144 | protected boolean _setBackground(final long ptr, 145 | final float r, 146 | final float g, 147 | final float b) { 148 | return false; 149 | } 150 | 151 | @Override 152 | protected void _setEnabled(final long ptr, 153 | final boolean enabled) { 154 | 155 | } 156 | 157 | @Override 158 | protected boolean _setMinimumSize(final long ptr, 159 | final int width, 160 | final int height) { 161 | return false; 162 | } 163 | 164 | @Override 165 | protected boolean _setMaximumSize(final long ptr, 166 | final int width, 167 | final int height) { 168 | return false; 169 | } 170 | 171 | @Override 172 | protected void _setIcon(final long ptr, 173 | final Pixels pixels) { 174 | 175 | } 176 | 177 | @Override 178 | protected void _setCursor(final long ptr, 179 | final Cursor cursor) { 180 | 181 | } 182 | 183 | @Override 184 | protected void _toFront(final long ptr) { 185 | 186 | } 187 | 188 | @Override 189 | protected void _toBack(final long ptr) { 190 | 191 | } 192 | 193 | @Override 194 | protected void _enterModal(final long ptr) { 195 | 196 | } 197 | 198 | @Override 199 | protected void _enterModalWithWindow(final long dialog, 200 | final long window) { 201 | 202 | } 203 | 204 | @Override 205 | protected void _exitModal(final long ptr) { 206 | 207 | } 208 | 209 | @Override 210 | protected void _requestInput(final long ptr, 211 | final String text, 212 | final int type, 213 | final double width, 214 | final double height, 215 | final double Mxx, 216 | final double Mxy, 217 | final double Mxz, 218 | final double Mxt, 219 | final double Myx, 220 | final double Myy, 221 | final double Myz, 222 | final double Myt, 223 | final double Mzx, 224 | final double Mzy, 225 | final double Mzz, 226 | final double Mzt) { 227 | 228 | } 229 | 230 | @Override 231 | protected void _releaseInput(final long ptr) { 232 | 233 | } 234 | } 235 | -------------------------------------------------------------------------------- /src/main/java/com/sun/glass/ui/monocle/WaylandInputDevicePointer.java: -------------------------------------------------------------------------------- 1 | package com.sun.glass.ui.monocle; 2 | 3 | import com.sun.glass.events.MouseEvent; 4 | import org.freedesktop.wayland.client.WlPointerEventsV5; 5 | import org.freedesktop.wayland.client.WlPointerProxy; 6 | import org.freedesktop.wayland.client.WlSeatProxy; 7 | import org.freedesktop.wayland.client.WlSurfaceProxy; 8 | import org.freedesktop.wayland.shared.WlPointerAxis; 9 | import org.freedesktop.wayland.shared.WlPointerButtonState; 10 | import org.freedesktop.wayland.util.Fixed; 11 | 12 | import javax.annotation.Nonnull; 13 | 14 | public class WaylandInputDevicePointer implements InputDevice, WlPointerEventsV5 { 15 | 16 | //should be accessed by jfx thread only! -> 17 | @Nonnull 18 | private final MouseInput mouseInput = MouseInput.getInstance(); 19 | @Nonnull 20 | private final MouseState mouseState = new MouseState(); 21 | //<- 22 | 23 | @Nonnull 24 | private final WlPointerProxy wlPointerProxy; 25 | 26 | //the protocol version supported by the compositor for this object 27 | private final int version; 28 | 29 | WaylandInputDevicePointer(@Nonnull final WlSeatProxy wlSeatProxy) { 30 | this.wlPointerProxy = wlSeatProxy.getPointer(this); 31 | this.version = this.wlPointerProxy.getVersion(); 32 | } 33 | 34 | @Override 35 | public boolean isTouch() { 36 | return false; 37 | } 38 | 39 | @Override 40 | public boolean isMultiTouch() { 41 | return false; 42 | } 43 | 44 | @Override 45 | public boolean isRelative() { 46 | return true; 47 | } 48 | 49 | @Override 50 | public boolean is5Way() { 51 | return false; 52 | } 53 | 54 | @Override 55 | public boolean isFullKeyboard() { 56 | return false; 57 | } 58 | 59 | @Override 60 | public void enter(final WlPointerProxy emitter, 61 | final int serial, 62 | @Nonnull final WlSurfaceProxy surface, 63 | @Nonnull final Fixed surfaceX, 64 | @Nonnull final Fixed surfaceY) { 65 | //NOOP. we only create one surface (window), so it always has the focus by default. 66 | } 67 | 68 | @Override 69 | public void leave(final WlPointerProxy emitter, 70 | final int serial, 71 | @Nonnull final WlSurfaceProxy surface) { 72 | //NOOP. we only create one surface (window), so it always has the focus by default. 73 | } 74 | 75 | @Override 76 | public void motion(final WlPointerProxy emitter, 77 | final int time, 78 | @Nonnull final Fixed surfaceX, 79 | @Nonnull final Fixed surfaceY) { 80 | RunnableProcessor.runLater(() -> handleMotion(time, 81 | surfaceX, 82 | surfaceY)); 83 | } 84 | 85 | private void handleMotion(final int time, 86 | @Nonnull final Fixed surfaceX, 87 | @Nonnull final Fixed surfaceY) { 88 | final int x = surfaceX.asInt(); 89 | final int y = surfaceY.asInt(); 90 | 91 | this.mouseInput.getState(this.mouseState); 92 | this.mouseState.setX(x); 93 | this.mouseState.setY(y); 94 | 95 | //versions prior to V5 do not support the frame event, which signals the end of a stream of events. 96 | if (this.version < WlPointerEventsV5.VERSION) { 97 | this.mouseInput.setState(this.mouseState, 98 | false); 99 | } 100 | } 101 | 102 | @Override 103 | public void button(final WlPointerProxy emitter, 104 | final int serial, 105 | final int time, 106 | final int button, 107 | final int state) { 108 | RunnableProcessor.runLater(() -> handleButton(serial, 109 | time, 110 | button, 111 | state)); 112 | } 113 | 114 | private void handleButton(final int serial, 115 | final int time, 116 | final int button, 117 | final int state) { 118 | this.mouseInput.getState(this.mouseState); 119 | if (state == WlPointerButtonState.PRESSED.value) { 120 | this.mouseState.pressButton(mouseButtonForKeyCode(button)); 121 | } 122 | else { 123 | this.mouseState.releaseButton(mouseButtonForKeyCode(button)); 124 | } 125 | //versions prior to V5 do not support the frame event, which signals the end of a stream of events. 126 | if (this.version < WlPointerEventsV5.VERSION) { 127 | this.mouseInput.setState(this.mouseState, 128 | false); 129 | } 130 | } 131 | 132 | //copy-pasta from LinuxMouseProcessor 133 | private static int mouseButtonForKeyCode(final int keyCode) { 134 | switch (keyCode) { 135 | case LinuxInput.BTN_MOUSE: 136 | return MouseEvent.BUTTON_LEFT; 137 | case LinuxInput.BTN_MIDDLE: 138 | return MouseEvent.BUTTON_OTHER; 139 | case LinuxInput.BTN_RIGHT: 140 | return MouseEvent.BUTTON_RIGHT; 141 | default: 142 | return -1; 143 | } 144 | } 145 | 146 | @Override 147 | public void axis(final WlPointerProxy emitter, 148 | final int time, 149 | final int axis, 150 | @Nonnull final Fixed value) { 151 | RunnableProcessor.runLater(() -> handleAxis(time, 152 | axis, 153 | value)); 154 | } 155 | 156 | private void handleAxis(final int time, 157 | final int axis, 158 | @Nonnull final Fixed value) { 159 | this.mouseInput.getState(this.mouseState); 160 | if (axis == WlPointerAxis.VERTICAL_SCROLL.value) { 161 | //monocle does not support a specific scroll value, just down/up/none which corresponds to a value of 1 or 0. :( 162 | if (value.asInt() < 0) { 163 | this.mouseState.setWheel(MouseState.WHEEL_DOWN); 164 | } 165 | else if (value.asInt() > 0) { 166 | this.mouseState.setWheel(MouseState.WHEEL_UP); 167 | } 168 | else { 169 | this.mouseState.setWheel(MouseState.WHEEL_NONE); 170 | } 171 | } 172 | //else { 173 | //monocle does not support horizontal scrolling 174 | //} 175 | 176 | 177 | //versions prior to V5 do not support the frame event, which signals the end of a stream of events. 178 | if (this.version < WlPointerEventsV5.VERSION) { 179 | this.mouseInput.setState(this.mouseState, 180 | false); 181 | } 182 | } 183 | 184 | @Override 185 | public void frame(final WlPointerProxy emitter) { 186 | this.mouseInput.setState(this.mouseState, 187 | false); 188 | } 189 | 190 | @Override 191 | public void axisSource(final WlPointerProxy emitter, 192 | final int axisSource) { 193 | //NOOP monocle doesn't care what the event source is 194 | } 195 | 196 | @Override 197 | public void axisStop(final WlPointerProxy emitter, 198 | final int time, 199 | final int axis) { 200 | //NOOP monocle does it's own kind of kinetic scrolling 201 | } 202 | 203 | @Override 204 | public void axisDiscrete(final WlPointerProxy emitter, 205 | final int axis, 206 | final int discrete) { 207 | //NOOP monocle does not support a discrete scroll values, just down/up/none which corresponds to a value 208 | //of 1 or 0. :( This is already handled in the axis() event. 209 | } 210 | 211 | @Nonnull 212 | public WlPointerProxy getWlPointerProxy() { 213 | return this.wlPointerProxy; 214 | } 215 | } 216 | -------------------------------------------------------------------------------- /src/main/java/com/sun/glass/ui/monocle/WaylandInputDeviceKeyboard.java: -------------------------------------------------------------------------------- 1 | package com.sun.glass.ui.monocle; 2 | 3 | import com.sun.glass.events.KeyEvent; 4 | import org.freedesktop.wayland.client.WlKeyboardEventsV5; 5 | import org.freedesktop.wayland.client.WlKeyboardProxy; 6 | import org.freedesktop.wayland.client.WlSeatProxy; 7 | import org.freedesktop.wayland.client.WlSurfaceProxy; 8 | import org.freedesktop.wayland.shared.WlKeyboardKeyState; 9 | 10 | import javax.annotation.Nonnull; 11 | import java.nio.ByteBuffer; 12 | 13 | public class WaylandInputDeviceKeyboard implements InputDevice, WlKeyboardEventsV5 { 14 | 15 | //should be accessed by jfx thread only! -> 16 | @Nonnull 17 | private final KeyInput keyInput = KeyInput.getInstance(); 18 | @Nonnull 19 | private final KeyState keyState = new KeyState(); 20 | //<- 21 | 22 | @Nonnull 23 | private final WlKeyboardProxy wlKeyboardProxy; 24 | 25 | WaylandInputDeviceKeyboard(@Nonnull final WlSeatProxy wlSeatProxy) { 26 | this.wlKeyboardProxy = wlSeatProxy.getKeyboard(this); 27 | } 28 | 29 | @Override 30 | public boolean isTouch() { 31 | return false; 32 | } 33 | 34 | @Override 35 | public boolean isMultiTouch() { 36 | return false; 37 | } 38 | 39 | @Override 40 | public boolean isRelative() { 41 | return true; 42 | } 43 | 44 | @Override 45 | public boolean is5Way() { 46 | return true; 47 | } 48 | 49 | @Override 50 | public boolean isFullKeyboard() { 51 | return true; 52 | } 53 | 54 | @Override 55 | public void keymap(final WlKeyboardProxy emitter, 56 | final int format, 57 | final int fd, 58 | final int size) { 59 | //NOOP monocle does it own kind of crude keymap thingy it seems. 60 | } 61 | 62 | @Override 63 | public void enter(final WlKeyboardProxy emitter, 64 | final int serial, 65 | @Nonnull final WlSurfaceProxy surface, 66 | @Nonnull final ByteBuffer keys) { 67 | //NOOP. we only create one surface (window), so it always has the focus by default. 68 | } 69 | 70 | @Override 71 | public void leave(final WlKeyboardProxy emitter, 72 | final int serial, 73 | @Nonnull final WlSurfaceProxy surface) { 74 | //NOOP. we only create one surface (window), so it always has the focus by default. 75 | 76 | } 77 | 78 | @Override 79 | public void key(final WlKeyboardProxy emitter, 80 | final int serial, 81 | final int time, 82 | final int key, 83 | final int state) { 84 | RunnableProcessor.runLater(() -> keyEvent(serial, 85 | time, 86 | key, 87 | state)); 88 | } 89 | 90 | private void keyEvent(final int serial, 91 | final int time, 92 | final int key, 93 | final int state) { 94 | this.keyInput.getState(this.keyState); 95 | final int virtualKeyCode = getVirtualKeyCode(key); 96 | if (state == WlKeyboardKeyState.PRESSED.value) { 97 | this.keyState.pressKey(virtualKeyCode); 98 | } 99 | else { 100 | this.keyState.releaseKey(virtualKeyCode); 101 | } 102 | this.keyInput.setState(this.keyState); 103 | } 104 | 105 | //copy-pasta from LinuxKeyProcessor 106 | private int getVirtualKeyCode(final int linuxKeyCode) { 107 | if (linuxKeyCode >= LinuxInput.KEY_1 && linuxKeyCode <= LinuxInput.KEY_9) { 108 | return linuxKeyCode - LinuxInput.KEY_1 + KeyEvent.VK_1; 109 | } 110 | else if (linuxKeyCode >= LinuxInput.KEY_NUMERIC_0 && linuxKeyCode <= LinuxInput.KEY_NUMERIC_9) { 111 | return linuxKeyCode - LinuxInput.KEY_NUMERIC_0 + KeyEvent.VK_0; 112 | } 113 | else if (linuxKeyCode >= LinuxInput.KEY_F1 && linuxKeyCode <= LinuxInput.KEY_F10) { 114 | return linuxKeyCode - LinuxInput.KEY_F1 + KeyEvent.VK_F1; 115 | } 116 | else if (linuxKeyCode >= LinuxInput.KEY_F11 && linuxKeyCode <= LinuxInput.KEY_F12) { 117 | return linuxKeyCode - LinuxInput.KEY_F11 + KeyEvent.VK_F11; 118 | } 119 | else if (linuxKeyCode >= LinuxInput.KEY_F13 && linuxKeyCode <= LinuxInput.KEY_F24) { 120 | return linuxKeyCode - LinuxInput.KEY_F13 + KeyEvent.VK_F13; 121 | } 122 | else { 123 | switch (linuxKeyCode) { 124 | case LinuxInput.KEY_0: 125 | return KeyEvent.VK_0; 126 | case LinuxInput.KEY_A: 127 | return KeyEvent.VK_A; 128 | case LinuxInput.KEY_B: 129 | return KeyEvent.VK_B; 130 | case LinuxInput.KEY_C: 131 | return KeyEvent.VK_C; 132 | case LinuxInput.KEY_D: 133 | return KeyEvent.VK_D; 134 | case LinuxInput.KEY_E: 135 | return KeyEvent.VK_E; 136 | case LinuxInput.KEY_F: 137 | return KeyEvent.VK_F; 138 | case LinuxInput.KEY_G: 139 | return KeyEvent.VK_G; 140 | case LinuxInput.KEY_H: 141 | return KeyEvent.VK_H; 142 | case LinuxInput.KEY_I: 143 | return KeyEvent.VK_I; 144 | case LinuxInput.KEY_J: 145 | return KeyEvent.VK_J; 146 | case LinuxInput.KEY_K: 147 | return KeyEvent.VK_K; 148 | case LinuxInput.KEY_L: 149 | return KeyEvent.VK_L; 150 | case LinuxInput.KEY_M: 151 | return KeyEvent.VK_M; 152 | case LinuxInput.KEY_N: 153 | return KeyEvent.VK_N; 154 | case LinuxInput.KEY_O: 155 | return KeyEvent.VK_O; 156 | case LinuxInput.KEY_P: 157 | return KeyEvent.VK_P; 158 | case LinuxInput.KEY_Q: 159 | return KeyEvent.VK_Q; 160 | case LinuxInput.KEY_R: 161 | return KeyEvent.VK_R; 162 | case LinuxInput.KEY_S: 163 | return KeyEvent.VK_S; 164 | case LinuxInput.KEY_T: 165 | return KeyEvent.VK_T; 166 | case LinuxInput.KEY_U: 167 | return KeyEvent.VK_U; 168 | case LinuxInput.KEY_V: 169 | return KeyEvent.VK_V; 170 | case LinuxInput.KEY_W: 171 | return KeyEvent.VK_W; 172 | case LinuxInput.KEY_X: 173 | return KeyEvent.VK_X; 174 | case LinuxInput.KEY_Y: 175 | return KeyEvent.VK_Y; 176 | case LinuxInput.KEY_Z: 177 | return KeyEvent.VK_Z; 178 | case LinuxInput.KEY_LEFTCTRL: 179 | case LinuxInput.KEY_RIGHTCTRL: 180 | return KeyEvent.VK_CONTROL; 181 | case LinuxInput.KEY_LEFTSHIFT: 182 | case LinuxInput.KEY_RIGHTSHIFT: 183 | return KeyEvent.VK_SHIFT; 184 | case LinuxInput.KEY_CAPSLOCK: 185 | return KeyEvent.VK_CAPS_LOCK; 186 | case LinuxInput.KEY_TAB: 187 | return KeyEvent.VK_TAB; 188 | case LinuxInput.KEY_GRAVE: 189 | return KeyEvent.VK_BACK_QUOTE; 190 | case LinuxInput.KEY_MINUS: 191 | return KeyEvent.VK_MINUS; 192 | case LinuxInput.KEY_EQUAL: 193 | return KeyEvent.VK_EQUALS; 194 | case LinuxInput.KEY_BACKSPACE: 195 | return KeyEvent.VK_BACKSPACE; 196 | case LinuxInput.KEY_LEFTBRACE: 197 | return KeyEvent.VK_BRACELEFT; 198 | case LinuxInput.KEY_RIGHTBRACE: 199 | return KeyEvent.VK_BRACERIGHT; 200 | case LinuxInput.KEY_BACKSLASH: 201 | return KeyEvent.VK_BACK_SLASH; 202 | case LinuxInput.KEY_SEMICOLON: 203 | return KeyEvent.VK_SEMICOLON; 204 | case LinuxInput.KEY_APOSTROPHE: 205 | return KeyEvent.VK_QUOTE; 206 | case LinuxInput.KEY_COMMA: 207 | return KeyEvent.VK_COMMA; 208 | case LinuxInput.KEY_DOT: 209 | return KeyEvent.VK_PERIOD; 210 | case LinuxInput.KEY_SLASH: 211 | return KeyEvent.VK_SLASH; 212 | case LinuxInput.KEY_LEFTALT: 213 | case LinuxInput.KEY_RIGHTALT: 214 | return KeyEvent.VK_ALT; 215 | case LinuxInput.KEY_LEFTMETA: 216 | case LinuxInput.KEY_RIGHTMETA: 217 | return KeyEvent.VK_COMMAND; 218 | case LinuxInput.KEY_SPACE: 219 | return KeyEvent.VK_SPACE; 220 | case LinuxInput.KEY_MENU: 221 | return KeyEvent.VK_CONTEXT_MENU; 222 | case LinuxInput.KEY_ENTER: 223 | return KeyEvent.VK_ENTER; 224 | case LinuxInput.KEY_LEFT: 225 | return KeyEvent.VK_LEFT; 226 | case LinuxInput.KEY_RIGHT: 227 | return KeyEvent.VK_RIGHT; 228 | case LinuxInput.KEY_UP: 229 | return KeyEvent.VK_UP; 230 | case LinuxInput.KEY_DOWN: 231 | return KeyEvent.VK_DOWN; 232 | case LinuxInput.KEY_HOME: 233 | return KeyEvent.VK_HOME; 234 | case LinuxInput.KEY_DELETE: 235 | return KeyEvent.VK_DELETE; 236 | case LinuxInput.KEY_INSERT: 237 | return KeyEvent.VK_INSERT; 238 | case LinuxInput.KEY_END: 239 | return KeyEvent.VK_END; 240 | case LinuxInput.KEY_PAGEDOWN: 241 | return KeyEvent.VK_PAGE_DOWN; 242 | case LinuxInput.KEY_PAGEUP: 243 | return KeyEvent.VK_PAGE_UP; 244 | case LinuxInput.KEY_NUMLOCK: 245 | return KeyEvent.VK_NUM_LOCK; 246 | case LinuxInput.KEY_ESC: 247 | return KeyEvent.VK_ESCAPE; 248 | case LinuxInput.KEY_NUMERIC_STAR: 249 | return KeyEvent.VK_MULTIPLY; 250 | default: 251 | return KeyEvent.VK_UNDEFINED; 252 | } 253 | } 254 | } 255 | 256 | @Override 257 | public void modifiers(final WlKeyboardProxy emitter, 258 | final int serial, 259 | final int modsDepressed, 260 | final int modsLatched, 261 | final int modsLocked, 262 | final int group) { 263 | //NOOP. monocle has a fixed hard coded list of what is considered a modifier and what isn't. 264 | } 265 | 266 | @Override 267 | public void repeatInfo(final WlKeyboardProxy emitter, 268 | final int rate, 269 | final int delay) { 270 | //NOOP. 271 | } 272 | 273 | @Nonnull 274 | public WlKeyboardProxy getWlKeyboardProxy() { 275 | return this.wlKeyboardProxy; 276 | } 277 | } 278 | -------------------------------------------------------------------------------- /src/main/java/com/sun/glass/ui/monocle/WaylandScreen.java: -------------------------------------------------------------------------------- 1 | package com.sun.glass.ui.monocle; 2 | 3 | import com.sun.glass.ui.Pixels; 4 | import org.freedesktop.jaccall.JNI; 5 | import org.freedesktop.jaccall.Pointer; 6 | import org.freedesktop.wayland.client.WlBufferProxy; 7 | import org.freedesktop.wayland.client.WlCallbackProxy; 8 | import org.freedesktop.wayland.client.WlCompositorProxy; 9 | import org.freedesktop.wayland.client.WlDisplayProxy; 10 | import org.freedesktop.wayland.client.WlOutputProxy; 11 | import org.freedesktop.wayland.client.WlShellProxy; 12 | import org.freedesktop.wayland.client.WlShellSurfaceEvents; 13 | import org.freedesktop.wayland.client.WlShellSurfaceProxy; 14 | import org.freedesktop.wayland.client.WlSurfaceEventsV4; 15 | import org.freedesktop.wayland.client.WlSurfaceProxy; 16 | import org.freedesktop.wayland.shared.WlShellSurfaceFullscreenMethod; 17 | import org.freedesktop.wayland.shared.WlShmFormat; 18 | 19 | import javax.annotation.Nonnull; 20 | import java.nio.Buffer; 21 | import java.nio.ByteBuffer; 22 | import java.nio.IntBuffer; 23 | import java.util.concurrent.CountDownLatch; 24 | 25 | import static com.sun.glass.ui.monocle.Libpixman1.PIXMAN_OP_OVER; 26 | import static com.sun.glass.ui.monocle.Libpixman1.PIXMAN_OP_SRC; 27 | import static com.sun.glass.ui.monocle.Libpixman1.PIXMAN_a8r8g8b8; 28 | 29 | class WaylandScreen implements NativeScreen, 30 | WlSurfaceEventsV4, 31 | WlShellSurfaceEvents { 32 | 33 | private final WlSurfaceProxy wlSurfaceProxy; 34 | private final WlDisplayProxy display; 35 | private final WaylandOutput waylandOutput; 36 | private final WaylandBufferPool waylandBufferPool; 37 | private int dpi; 38 | private WlBufferProxy wlBufferProxy; 39 | private WlCallbackProxy wlCallbackProxy; 40 | 41 | /* 42 | * A NativeScreen provides a way for JavaFX to get information about the screen it is using and to put pixels on 43 | * the screen using software rendering. Most implementations in Monocle of NativeScreen are based on Linux frame 44 | * buffers, but other implementations are possible. For example, the X11Screen class creates a single window using 45 | * the X API and renders all content into that. 46 | * 47 | * Note that there is no class "NativeWindow" in Monocle. This is because Monocle does not make use of any native 48 | * window system on the devices it uses, and does not require such a window system. In general, Monocle assumes 49 | * that it owns the entire screen and makes no attempt to cooperate with any window system that may be present. 50 | * 51 | * Windows and Stages in JavaFX on embedded Linux devices are concepts internal to JavaFX that do not correspond 52 | * directly to any native window system. In practice window content is stored in JavaFX and the window stack is 53 | * composed onto the screen surface whenever JavaFX enders a frame. When using the software rendering pipeline, 54 | * window content is stored in a Pixels object that wraps a ByteBuffer. When using the accelerated OpenGL ES 2.0 55 | * pipeline, window content is stored internally in an OpenGL Texture. 56 | */ 57 | 58 | WaylandScreen(final WaylandBufferPoolFactory waylandBufferPoolFactory, 59 | final WlDisplayProxy wlDisplayProxy, 60 | final WaylandOutput waylandOutput, 61 | final WlCompositorProxy wlCompositorProxy, 62 | final WlShellProxy wlShellProxy, 63 | final WaylandShm waylandShm) { 64 | this.display = wlDisplayProxy; 65 | this.waylandOutput = waylandOutput; 66 | 67 | this.wlSurfaceProxy = wlCompositorProxy.createSurface(this); 68 | final WlShellSurfaceProxy shellSurface = wlShellProxy.getShellSurface(this, 69 | this.wlSurfaceProxy); 70 | //notify the compositor we want to run fullscreen 71 | shellSurface.setFullscreen(WlShellSurfaceFullscreenMethod.DRIVER.value, 72 | 0, 73 | waylandOutput.getWlOutputProxy()); 74 | 75 | this.waylandBufferPool = waylandBufferPoolFactory.create(waylandShm.getWlShmProxy(), 76 | getWidth(), 77 | getHeight(), 78 | 2, 79 | WlShmFormat.ARGB8888); 80 | this.wlBufferProxy = this.waylandBufferPool.popBuffer(); 81 | this.wlSurfaceProxy.attach(this.wlBufferProxy, 82 | 0, 83 | 0); 84 | } 85 | 86 | public int getWidth() { 87 | return this.waylandOutput.getWidth(); 88 | } 89 | 90 | public int getHeight() { 91 | return this.waylandOutput.getHeight(); 92 | } 93 | 94 | public int getDepth() { 95 | return 32; 96 | } 97 | 98 | public int getNativeFormat() { 99 | return Pixels.Format.BYTE_BGRA_PRE; 100 | } 101 | 102 | public int getDPI() { 103 | if (0 == this.dpi) { 104 | updateDpi(); 105 | } 106 | return this.dpi; 107 | } 108 | 109 | private void updateDpi() { 110 | if (0 >= this.waylandOutput.getPhysicalWidth() || 111 | 0 >= this.waylandOutput.getPhysicalHeight() || 112 | 0 >= this.waylandOutput.getWidth() || 113 | 0 >= this.waylandOutput.getHeight()) { 114 | //not all values have a sensible value, return something standard. 115 | this.dpi = 96; 116 | } 117 | else { 118 | final double diagonalScreenMM = Math.sqrt((this.waylandOutput.getPhysicalWidth() * this.waylandOutput.getPhysicalWidth()) + 119 | (this.waylandOutput.getPhysicalHeight() * this.waylandOutput.getPhysicalHeight())); 120 | final double diagonalPixels = Math.sqrt((this.waylandOutput.getWidth() * this.waylandOutput.getWidth()) + 121 | (this.waylandOutput.getHeight() * this.waylandOutput.getHeight())); 122 | final double dpMM = diagonalPixels / diagonalScreenMM; 123 | this.dpi = (int) (dpMM * 25.4); 124 | } 125 | } 126 | 127 | @Override 128 | public long getNativeHandle() { 129 | return this.wlSurfaceProxy.getPointer(); 130 | } 131 | 132 | @Override 133 | public void shutdown() { 134 | 135 | } 136 | 137 | @Override 138 | public void uploadPixels(final Buffer b, 139 | final int x, 140 | final int y, 141 | final int width, 142 | final int height, 143 | final float alpha) { 144 | 145 | WaylandPlatformFactory.WL_LOOP.submit(() -> { 146 | //TODO this call should block if no more buffers are available & it should unblock as soon as the compositor release one. 147 | //-> we don't have to wait here, but instead can initiate a wait as soon as we actually need a buffer (eg uploadPixels). 148 | 149 | if (this.wlBufferProxy == null) { 150 | this.wlBufferProxy = this.waylandBufferPool.popBuffer(); 151 | this.wlSurfaceProxy.attach(this.wlBufferProxy, 152 | 0, 153 | 0); 154 | this.wlSurfaceProxy.damage(x, 155 | y, 156 | width, 157 | height); 158 | } 159 | 160 | 161 | final WaylandBuffer waylandBuffer = (WaylandBuffer) this.wlBufferProxy.getImplementation(); 162 | 163 | final long pixels; 164 | if (b.isDirect()) { 165 | pixels = JNI.unwrap(b); 166 | } 167 | else { 168 | if (b instanceof ByteBuffer) { 169 | final ByteBuffer bb = (ByteBuffer) b; 170 | final byte[] array; 171 | if (bb.hasArray()) { 172 | array = bb.array(); 173 | } 174 | else { 175 | array = new byte[bb.capacity()]; 176 | bb.rewind(); 177 | bb.get(array); 178 | } 179 | pixels = Pointer.nref(array).address; 180 | } 181 | else { 182 | final IntBuffer ib = ((IntBuffer) b); 183 | final int[] array; 184 | if (ib.hasArray()) { 185 | array = ib.array(); 186 | } 187 | else { 188 | array = new int[ib.capacity()]; 189 | ib.rewind(); 190 | ib.get(array); 191 | } 192 | pixels = Pointer.nref(array).address; 193 | } 194 | } 195 | 196 | final long src = Libpixman1.pixman_image_create_bits_no_clear(PIXMAN_a8r8g8b8, 197 | width, 198 | height, 199 | pixels, 200 | width * 4); 201 | final long dst = waylandBuffer.getPixmanImage(); 202 | 203 | Libpixman1.pixman_image_composite(alpha == 1.0f ? PIXMAN_OP_SRC : PIXMAN_OP_OVER, 204 | src, 205 | 0L, 206 | dst, 207 | (short) 0, 208 | (short) 0, 209 | (short) 0, 210 | (short) 0, 211 | (short) x, 212 | (short) y, 213 | (short) width, 214 | (short) height); 215 | }); 216 | } 217 | 218 | @Override 219 | public void swapBuffers() { 220 | final CountDownLatch countDownLatch = new CountDownLatch(1); 221 | WaylandPlatformFactory.WL_LOOP.submit(() -> { 222 | if (this.wlCallbackProxy != null) { 223 | this.wlCallbackProxy.destroy(); 224 | } 225 | this.wlCallbackProxy = this.wlSurfaceProxy.frame((emitter, callbackData) -> { 226 | countDownLatch.countDown(); 227 | }); 228 | this.wlSurfaceProxy.commit(); 229 | this.wlBufferProxy = null; 230 | }); 231 | 232 | //this blocks until we receive feedback from the compositor that a next redraw should happen 233 | try { 234 | countDownLatch.await(); 235 | } 236 | catch (final InterruptedException e) { 237 | e.printStackTrace(); 238 | } 239 | } 240 | 241 | public ByteBuffer getScreenCapture() { 242 | return null; 243 | } 244 | 245 | public float getScale() { 246 | return this.waylandOutput.getScaleFactor(); 247 | } 248 | 249 | @Override 250 | public void enter(final WlSurfaceProxy emitter, 251 | @Nonnull final WlOutputProxy output) { 252 | //NOOP monocle only supports a single output 253 | } 254 | 255 | @Override 256 | public void leave(final WlSurfaceProxy emitter, 257 | @Nonnull final WlOutputProxy output) { 258 | //NOOP monocle only supports a single output 259 | } 260 | 261 | @Override 262 | public void ping(final WlShellSurfaceProxy emitter, 263 | final int serial) { 264 | emitter.pong(serial); 265 | } 266 | 267 | @Override 268 | public void configure(final WlShellSurfaceProxy emitter, 269 | final int edges, 270 | final int width, 271 | final int height) { 272 | //NOOP monocle doesn't do pointer based resizes 273 | } 274 | 275 | @Override 276 | public void popupDone(final WlShellSurfaceProxy emitter) { 277 | //NOOP monocle assumes we're the only (wayland) client on the system 278 | } 279 | } 280 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | --------------------------------------------------------------------------------