diff options
author | Sven Gothel <[email protected]> | 2019-12-05 06:56:36 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2019-12-05 06:56:36 +0100 |
commit | 78292f1098ef3a83c0426bd0e30b4e725805fa1a (patch) | |
tree | 1155931dd1d08c40e3e626fd6c6c494cec7eebb6 /src/newt | |
parent | 59fe721a926ff66e98b716a25a08bdfa584ca6fa (diff) |
Bug 1156: NEWT DRM/GBM PointerIcon: Use hotX/hotY drmModeSetCursor2(..), hence pass PointerIconImpl through
Diffstat (limited to 'src/newt')
4 files changed, 35 insertions, 30 deletions
diff --git a/src/newt/classes/jogamp/newt/driver/egl/gbm/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/egl/gbm/DisplayDriver.java index bc177a8b3..a7fa29170 100644 --- a/src/newt/classes/jogamp/newt/driver/egl/gbm/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/egl/gbm/DisplayDriver.java @@ -152,10 +152,11 @@ public class DisplayDriver extends DisplayImpl { //---------------------------------------------------------------------- // Internals only // - /* pp */ boolean setPointerIcon(final int crtc_id, final long piHandle, final boolean enable, final int x, final int y) { + + /* pp */ boolean setPointerIcon(final int crtc_id, final long piHandle, final boolean enable, final int hotX, final int hotY, final int x, final int y) { this.aDevice.lock(); try { - return SetPointerIcon0(DRMUtil.getDrmFd(), crtc_id, piHandle, enable, x, y); + return SetPointerIcon0(DRMUtil.getDrmFd(), crtc_id, piHandle, enable, hotX, hotY, x, y); } finally { this.aDevice.unlock(); } @@ -188,7 +189,8 @@ public class DisplayDriver extends DisplayImpl { private static native long CreatePointerIcon0(long gbmDevice, Object pixels, int pixels_byte_offset, boolean pixels_is_direct, int width, int height, int hotX, int hotY); private static native void DestroyPointerIcon0(long piHandle); - private static native boolean SetPointerIcon0(int drmFd, int crtc_id, long piHandle, boolean enable, int x, int y); + + private static native boolean SetPointerIcon0(int drmFd, int crtc_id, long piHandle, boolean enable, int hotX, int hotY, int x, int y); private static native boolean MovePointerIcon0(int drmFd, int crtc_id, int x, int y); /* pp */ static final boolean DEBUG_POINTER_ICON = Display.DEBUG_POINTER_ICON; diff --git a/src/newt/classes/jogamp/newt/driver/egl/gbm/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/egl/gbm/ScreenDriver.java index 2faa8e54e..2e1b88c47 100644 --- a/src/newt/classes/jogamp/newt/driver/egl/gbm/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/egl/gbm/ScreenDriver.java @@ -28,6 +28,7 @@ package jogamp.newt.driver.egl.gbm; import com.jogamp.nativewindow.DefaultGraphicsScreen; +import com.jogamp.nativewindow.util.PointImmutable; import com.jogamp.nativewindow.util.Rectangle; import com.jogamp.newt.Display; import com.jogamp.newt.MonitorDevice; @@ -121,9 +122,9 @@ public class ScreenDriver extends ScreenImpl { if( null != defaultPointerIcon ) { final LinuxMouseTracker lmt = LinuxMouseTracker.getSingleton(); if( null != lmt ) { - setPointerIconActive(defaultPointerIcon.getHandle(), lmt.getLastX(), lmt.getLastY()); + setPointerIconActive(defaultPointerIcon, lmt.getLastX(), lmt.getLastY()); } else { - setPointerIconActive(defaultPointerIcon.getHandle(), 0, 0); + setPointerIconActive(defaultPointerIcon, 0, 0); } } } @@ -148,43 +149,43 @@ public class ScreenDriver extends ScreenImpl { viewportInWindowUnits.set(viewport); } - /* pp */ void setPointerIconActive(long piHandle, final int x, final int y) { + /* pp */ void setPointerIconActive(PointerIconImpl pi, final int x, final int y) { synchronized(pointerIconSync) { if( DisplayDriver.DEBUG_POINTER_ICON ) { System.err.println("Screen.PointerIcon.set.0: "+Thread.currentThread().getName()); - System.err.println("Screen.PointerIcon.set.0: crtc id "+Display.toHexString(crtc_ids[0])+", active ["+Display.toHexString(activePointerIcon)+", visible "+activePointerIconVisible+"] -> "+Display.toHexString(piHandle)); + System.err.println("Screen.PointerIcon.set.0: crtc id "+Display.toHexString(crtc_ids[0])+", active ["+activePointerIcon+", visible "+activePointerIconVisible+"] -> "+pi); } - if( 0 != activePointerIcon && activePointerIconVisible ) { + if( null != activePointerIcon && activePointerIconVisible ) { // disable active pointerIcon first - System.err.println("Screen.PointerIcon.set.1"); - ((DisplayDriver)display).setPointerIcon(crtc_ids[0], activePointerIcon, false, x, y); + ((DisplayDriver)display).setPointerIcon(crtc_ids[0], activePointerIcon.validatedHandle(), false, 0, 0, x, y); } - if( 0 == piHandle && null != defaultPointerIcon ) { - System.err.println("Screen.PointerIcon.set.2"); - piHandle = ((DisplayDriver)display).defaultPointerIcon.getHandle(); + if( null == pi && null != defaultPointerIcon ) { + // fallback to default + pi = ((DisplayDriver)display).defaultPointerIcon; } - if( 0 != piHandle ) { - System.err.println("Screen.PointerIcon.set.3"); - ((DisplayDriver)display).setPointerIcon(crtc_ids[0], piHandle, true, x, y); + if( null != pi ) { + final PointImmutable hot = pi.getHotspot(); + ((DisplayDriver)display).setPointerIcon(crtc_ids[0], pi.validatedHandle(), true, hot.getX(), hot.getY(), x, y); activePointerIconVisible = true; } else { - System.err.println("Screen.PointerIcon.set.4"); activePointerIconVisible = false; } - activePointerIcon = piHandle; + activePointerIcon = pi; if( DisplayDriver.DEBUG_POINTER_ICON ) { - System.err.println("Screen.PointerIcon.set.X: active ["+Display.toHexString(activePointerIcon)+", visible "+activePointerIconVisible+"]"); + System.err.println("Screen.PointerIcon.set.X: active ["+activePointerIcon+", visible "+activePointerIconVisible+"]"); } } + } /* pp */ void setActivePointerIconVisible(final boolean visible, final int x, final int y) { synchronized(pointerIconSync) { if( DisplayDriver.DEBUG_POINTER_ICON ) { - System.err.println("Screen.PointerIcon.visible: crtc id "+Display.toHexString(crtc_ids[0])+", active ["+Display.toHexString(activePointerIcon)+", visible "+activePointerIconVisible+"] -> visible "+visible); + System.err.println("Screen.PointerIcon.visible: crtc id "+Display.toHexString(crtc_ids[0])+", active ["+activePointerIcon+", visible "+activePointerIconVisible+"] -> visible "+visible); } if( activePointerIconVisible != visible ) { - if( 0 != activePointerIcon ) { - ((DisplayDriver)display).setPointerIcon(crtc_ids[0], activePointerIcon, visible, x, y); + if( null != activePointerIcon ) { + final PointImmutable hot = activePointerIcon.getHotspot(); + ((DisplayDriver)display).setPointerIcon(crtc_ids[0], activePointerIcon.validatedHandle(), visible, hot.getX(), hot.getY(), x, y); } activePointerIconVisible = visible; } @@ -193,9 +194,9 @@ public class ScreenDriver extends ScreenImpl { /* pp */ void moveActivePointerIcon(final int x, final int y) { synchronized(pointerIconSync) { if( DisplayDriver.DEBUG_POINTER_ICON ) { - System.err.println("Screen.PointerIcon.move: crtc id "+Display.toHexString(crtc_ids[0])+", active ["+Display.toHexString(activePointerIcon)+", visible "+activePointerIconVisible+"], "+x+"/"+y); + System.err.println("Screen.PointerIcon.move: crtc id "+Display.toHexString(crtc_ids[0])+", active ["+activePointerIcon+", visible "+activePointerIconVisible+"], "+x+"/"+y); } - if( 0 != activePointerIcon && activePointerIconVisible ) { + if( null != activePointerIcon && activePointerIconVisible ) { ((DisplayDriver)display).movePointerIcon(crtc_ids[0], x, y); } } @@ -208,7 +209,7 @@ public class ScreenDriver extends ScreenImpl { protected native void initNative(long drmHandle); protected int[] crtc_ids; - private long activePointerIcon; + private PointerIconImpl activePointerIcon; private boolean activePointerIconVisible; private final Object pointerIconSync = new Object(); private PointerIconImpl defaultPointerIcon = null; diff --git a/src/newt/classes/jogamp/newt/driver/egl/gbm/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/egl/gbm/WindowDriver.java index e618e1b8c..ce1ffc1da 100644 --- a/src/newt/classes/jogamp/newt/driver/egl/gbm/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/egl/gbm/WindowDriver.java @@ -353,9 +353,9 @@ public class WindowDriver extends WindowImpl { protected void setPointerIconImpl(final PointerIconImpl pi) { final ScreenDriver screen = (ScreenDriver) getScreen(); if( null != mouseTracker ) { - screen.setPointerIconActive(null != pi ? pi.validatedHandle() : 0, mouseTracker.getLastX(), mouseTracker.getLastY()); + screen.setPointerIconActive(pi, mouseTracker.getLastX(), mouseTracker.getLastY()); } else { - screen.setPointerIconActive(null != pi ? pi.validatedHandle() : 0, 0, 0); + screen.setPointerIconActive(pi, 0, 0); } } diff --git a/src/newt/native/drm_gbm.c b/src/newt/native/drm_gbm.c index 0ba8d7e3f..637693bff 100644 --- a/src/newt/native/drm_gbm.c +++ b/src/newt/native/drm_gbm.c @@ -112,17 +112,18 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_egl_gbm_DisplayDriver_DestroyPoin } JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_egl_gbm_DisplayDriver_SetPointerIcon0 - (JNIEnv *env, jobject obj, jint drmFd, jint jcrtc_id, jlong jcursor, jboolean enable, jint x, jint y) + (JNIEnv *env, jobject obj, jint drmFd, jint jcrtc_id, jlong jcursor, jboolean enable, jint hotX, jint hotY, jint x, jint y) { uint32_t crtc_id = (uint32_t)jcrtc_id; struct gbm_bo *bo = (struct gbm_bo *) (intptr_t) jcursor; uint32_t bo_handle = gbm_bo_get_handle(bo).u32; int ret; + DBG_PRINT( "EGL_GBM.Screen SetPointerIcon0.0: bo %p, enable %d, hot %d/%d, pos %d/%d\n", bo, enable, hotX, hotY, x, y); // int drmModeSetCursor(int fd, uint32_t crtcId, uint32_t bo_handle, uint32_t width, uint32_t height); // int drmModeSetCursor2(int fd, uint32_t crtcId, uint32_t bo_handle, uint32_t width, uint32_t height, int32_t hot_x, int32_t hot_y); if( enable ) { - ret = drmModeSetCursor(drmFd, crtc_id, bo_handle, 64, 64); + ret = drmModeSetCursor2(drmFd, crtc_id, bo_handle, 64, 64, hotX, hotY); if( ret ) { ERR_PRINT("SetCursor enable failed: %d %s\n", ret, strerror(errno)); } else { @@ -132,11 +133,12 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_egl_gbm_DisplayDriver_SetPoin } } } else { - ret = drmModeSetCursor(drmFd, crtc_id, 0, 0, 0); + ret = drmModeSetCursor2(drmFd, crtc_id, 0, 0, 0, 0, 0); if( ret ) { ERR_PRINT("SetCursor disable failed: %d %s\n", ret, strerror(errno)); } } + DBG_PRINT( "EGL_GBM.Screen SetPointerIcon0.X: bo %p, enable %d, hot %d/%d, pos %d/%d\n", bo, enable, hotX, hotY, x, y); return ret ? JNI_FALSE : JNI_TRUE; } |