libx11 libxcursor handling - Problems with big cursors not working in Java and xterm

  • Open
  • quality assurance status badge
Details
2 participants
  • Danny Milosavljevic
  • Liliana Marie Prikler
Owner
unassigned
Submitted by
Danny Milosavljevic
Severity
normal
D
D
Danny Milosavljevic wrote on 31 Mar 2022 15:31
(address . bug-guix@gnu.org)
20220331153156.0ae2b4ce@scratchpost.org
Attachment: file
diff -ru orig/libX11-1.7.3.1/src/CrGlCur.c libX11-1.7.3.1/src/CrGlCur.c
--- orig/libX11-1.7.3.1/src/CrGlCur.c 2022-03-31 14:29:15.743894864 +0200
+++ libX11-1.7.3.1/src/CrGlCur.c 2022-03-31 14:30:26.485732511 +0200
@@ -63,7 +63,7 @@
static XModuleType
open_library (void)
{
- char *library = libraryName;
+ char *library = getenv("XCURSOR_RUNPATH") ?: libraryName;
char *dot;
XModuleType module;
for (;;)
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCgAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAmJFrUwACgkQ5xo1VCww
uqXXsQf+J7NG7FYikFixbyUXN0K9mo1qcx5ofQNrFMfRi15RAfMKTvQwN//MlTGY
Dt/ubuTRUcBm7Ey2j7988EhECIKY4SYS2H/1eWogcmqv43wwgRETwSzFH34KvDwy
6jL6J6TAfdtZNC2Ickm54+iKoRcKQHFjXCYGvcMUeNWItLuQzJfRz4GzAsXRCmvZ
rWdu/bThvTAW4nadSXjNuUvEDIp8EgR5zSt6JPC4fE0gg3N0ZkdF3fNdwBwN5aT8
WpFHKWWsu4XZ0SfpzRBxiPDphvX/2anseObaw1l47ieRzvVcV/Mw89SIg80pPNTu
wpVRM1rauqMNdsPQCF9e5M86XcNF0A==
=jIyn
-----END PGP SIGNATURE-----


D
D
dannym wrote on 31 Mar 2022 19:13
[PATCH] gnu: openjdk15: Make big cursors work.
(address . 54654@debbugs.gnu.org)(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
20220331171311.20805-1-dannym@scratchpost.org
From: Danny Milosavljevic <dannym@scratchpost.org>

* gnu/packages/patches/openjdk-15-xcursor-no-dynamic.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/java.scm (openjdk15)[source]: Add it.
---
.../openjdk-15-xcursor-no-dynamic.patch | 66 +++++++++++++++++++
1 file changed, 66 insertions(+)
create mode 100644 gnu/packages/patches/openjdk-15-xcursor-no-dynamic.patch

Toggle diff (74 lines)
diff --git a/gnu/packages/patches/openjdk-15-xcursor-no-dynamic.patch b/gnu/packages/patches/openjdk-15-xcursor-no-dynamic.patch
new file mode 100644
index 0000000000..975730518b
--- /dev/null
+++ b/gnu/packages/patches/openjdk-15-xcursor-no-dynamic.patch
@@ -0,0 +1,66 @@
+From: Danny Milosavljevic <dannym@scratchpost.org>
+Date: Thu, 31 Mar 2022 17:02:00 +0200
+Subject: Make openjdk use libxcursor directly
+
+Fixes <https://issues.guix.gnu.org/54654>.
+
+This patch makes openjdk use libxcursor directly.
+Without it, libx11 would try to dlopen("libXcursor.so.1") and fail.
+
+diff -ru orig/22kjr9lzrml0h5m55viq7zlfkqr9p7ny-openjdk-15.0.3-checkout/make/modules/java.desktop/lib/Awt2dLibraries.gmk 22kjr9lzrml0h5m55viq7zlfkqr9p7ny-openjdk-15.0.3-checkout/make/modules/java.desktop/lib/Awt2dLibraries.gmk
+--- orig/22kjr9lzrml0h5m55viq7zlfkqr9p7ny-openjdk-15.0.3-checkout/make/modules/java.desktop/lib/Awt2dLibraries.gmk 2022-03-31 15:34:08.773419480 +0200
++++ 22kjr9lzrml0h5m55viq7zlfkqr9p7ny-openjdk-15.0.3-checkout/make/modules/java.desktop/lib/Awt2dLibraries.gmk 2022-03-31 17:47:26.259535832 +0200
+@@ -217,7 +217,7 @@
+ endif
+ endif
+
+- LIBAWT_XAWT_LIBS := $(LIBM) -lawt -lXext -lX11 -lXrender $(LIBDL) -lXtst -lXi -ljava -ljvm
++ LIBAWT_XAWT_LIBS := $(LIBM) -lawt -lXext -lX11 -lXcursor -lXrender $(LIBDL) -lXtst -lXi -ljava -ljvm
+
+ ifeq ($(call isTargetOs, linux), true)
+ LIBAWT_XAWT_LIBS += -lpthread
+diff -ru orig/22kjr9lzrml0h5m55viq7zlfkqr9p7ny-openjdk-15.0.3-checkout/test/jdk/java/awt/JAWT/Makefile.unix 22kjr9lzrml0h5m55viq7zlfkqr9p7ny-openjdk-15.0.3-checkout/test/jdk/java/awt/JAWT/Makefile.unix
+--- orig/22kjr9lzrml0h5m55viq7zlfkqr9p7ny-openjdk-15.0.3-checkout/test/jdk/java/awt/JAWT/Makefile.unix 2022-03-31 15:34:10.553466316 +0200
++++ 22kjr9lzrml0h5m55viq7zlfkqr9p7ny-openjdk-15.0.3-checkout/test/jdk/java/awt/JAWT/Makefile.unix 2022-03-31 17:47:08.027052750 +0200
+@@ -31,7 +31,7 @@
+
+ J_INC = $(TESTJAVA)/include
+ INCLUDES = -I$(J_INC) -I$(J_INC)/$(SYST) -I.
+-LIBS = -L$(TESTJAVA)/lib -ljawt -lX11
++LIBS = -L$(TESTJAVA)/lib -ljawt -lX11 -lXcursor
+
+ all: $(CLASSES) libmylib.so
+
+diff -ru orig/22kjr9lzrml0h5m55viq7zlfkqr9p7ny-openjdk-15.0.3-checkout/src/java.desktop/unix/native/libawt_xawt/xawt/XlibWrapper.c 22kjr9lzrml0h5m55viq7zlfkqr9p7ny-openjdk-15.0.3-checkout/src/java.desktop/unix/native/libawt_xawt/xawt/XlibWrapper.c
+--- orig/22kjr9lzrml0h5m55viq7zlfkqr9p7ny-openjdk-15.0.3-checkout/src/java.desktop/unix/native/libawt_xawt/xawt/XlibWrapper.c 2022-03-31 15:34:11.917502206 +0200
++++ 22kjr9lzrml0h5m55viq7zlfkqr9p7ny-openjdk-15.0.3-checkout/src/java.desktop/unix/native/libawt_xawt/xawt/XlibWrapper.c 2022-03-31 17:07:25.664488391 +0200
+@@ -44,6 +44,7 @@
+ #include <X11/XKBlib.h>
+ #include <X11/Xos.h>
+ #include <X11/Xutil.h>
++#include <X11/Xcursor/Xcursor.h>
+
+ #if defined(AIX)
+ #undef X_HAVE_UTF8_STRING
+@@ -972,10 +973,20 @@
+
+ }
+
++static XColor _Xconst foreground = { 0, 0, 0, 0 }; /* black */
++static XColor _Xconst background = { 0, 65535, 65535, 65535 }; /* white */
++
+ JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XCreateFontCursor
+ (JNIEnv *env, jclass clazz, jlong display, jint shape) {
+ AWT_CHECK_HAVE_LOCK_RETURN(0);
+- return XCreateFontCursor((Display *) jlong_to_ptr(display), (int) shape);
++ Display * dpy = (Display *) jlong_to_ptr(display);
++ Font font = XLoadFont(dpy, "cursor"); /* note: leak */
++ if (font == None)
++ return 0;
++ Cursor result = XcursorTryShapeCursor(dpy, font, font, (int) shape, (int) shape + 1, &foreground, &background);
++ if (!result)
++ result = XCreateFontCursor(dpy, (int) shape);
++ return result;
+ }
+
+ /*
--
2.34.0
D
D
dannym wrote on 31 Mar 2022 22:03
[PATCH v2] gnu: openjdk15: Make big cursors work.
(address . 54654@debbugs.gnu.org)(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
20220331200323.10098-1-dannym@scratchpost.org
From: Danny Milosavljevic <dannym@scratchpost.org>

* gnu/packages/patches/openjdk-15-xcursor-no-dynamic.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/java.scm (openjdk15)[source]: Add it.
---
gnu/local.mk | 1 +
gnu/packages/java.scm | 7 +-
.../openjdk-15-xcursor-no-dynamic.patch | 72 +++++++++++++++++++
3 files changed, 79 insertions(+), 1 deletion(-)
create mode 100644 gnu/packages/patches/openjdk-15-xcursor-no-dynamic.patch

Toggle diff (110 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index a704161abc..ac8992885e 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1564,6 +1564,7 @@ dist_patch_DATA = \
%D%/packages/patches/opencascade-oce-glibc-2.26.patch \
%D%/packages/patches/openfoam-4.1-cleanup.patch \
%D%/packages/patches/openjdk-10-idlj-reproducibility.patch \
+ %D%/packages/patches/openjdk-15-xcursor-no-dynamic.patch \
%D%/packages/patches/openmpi-mtl-priorities.patch \
%D%/packages/patches/openssh-hurd.patch \
%D%/packages/patches/openresolv-restartcmd-guix.patch \
diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index b27892841e..b0908cc15a 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -2185,7 +2185,12 @@ (define-public openjdk15
(file-name (git-file-name name version))
(sha256
(base32
- "168cr08nywp0q3vyj8njkhsmmnyd8rz9r58hk4xhzdzc6bdfkl1i"))))
+ "168cr08nywp0q3vyj8njkhsmmnyd8rz9r58hk4xhzdzc6bdfkl1i"))
+ (patches
+ (search-patches "openjdk-15-xcursor-no-dynamic.patch"))))
+ (inputs
+ (cons `("libxcursor" ,libxcursor) ; for our patch to work
+ (package-inputs openjdk14)))
(native-inputs
`(("autoconf" ,autoconf)
("openjdk14:jdk" ,openjdk14 "jdk")
diff --git a/gnu/packages/patches/openjdk-15-xcursor-no-dynamic.patch b/gnu/packages/patches/openjdk-15-xcursor-no-dynamic.patch
new file mode 100644
index 0000000000..9325dd3da6
--- /dev/null
+++ b/gnu/packages/patches/openjdk-15-xcursor-no-dynamic.patch
@@ -0,0 +1,72 @@
+From: Danny Milosavljevic <dannym@scratchpost.org>
+Date: Thu, 31 Mar 2022 17:02:00 +0200
+Subject: Make openjdk use libxcursor directly
+
+Fixes <https://issues.guix.gnu.org/54654>.
+
+This patch makes openjdk use libxcursor directly.
+Without it, libx11 would try to dlopen("libXcursor.so.1") and fail.
+
+diff -ru orig/22kjr9lzrml0h5m55viq7zlfkqr9p7ny-openjdk-15.0.3-checkout/make/modules/java.desktop/lib/Awt2dLibraries.gmk 22kjr9lzrml0h5m55viq7zlfkqr9p7ny-openjdk-15.0.3-checkout/make/modules/java.desktop/lib/Awt2dLibraries.gmk
+--- orig/22kjr9lzrml0h5m55viq7zlfkqr9p7ny-openjdk-15.0.3-checkout/make/modules/java.desktop/lib/Awt2dLibraries.gmk 2022-03-31 15:34:08.773419480 +0200
++++ 22kjr9lzrml0h5m55viq7zlfkqr9p7ny-openjdk-15.0.3-checkout/make/modules/java.desktop/lib/Awt2dLibraries.gmk 2022-03-31 21:36:27.854273411 +0200
+@@ -217,7 +217,7 @@
+ endif
+ endif
+
+- LIBAWT_XAWT_LIBS := $(LIBM) -lawt -lXext -lX11 -lXrender $(LIBDL) -lXtst -lXi -ljava -ljvm
++ LIBAWT_XAWT_LIBS := $(LIBM) -lawt -lXext -lX11 -lXcursor -lXrender $(LIBDL) -lXtst -lXi -ljava -ljvm
+
+ ifeq ($(call isTargetOs, linux), true)
+ LIBAWT_XAWT_LIBS += -lpthread
+diff -ru orig/22kjr9lzrml0h5m55viq7zlfkqr9p7ny-openjdk-15.0.3-checkout/src/java.desktop/unix/native/libawt_xawt/xawt/XlibWrapper.c 22kjr9lzrml0h5m55viq7zlfkqr9p7ny-openjdk-15.0.3-checkout/src/java.desktop/unix/native/libawt_xawt/xawt/XlibWrapper.c
+--- orig/22kjr9lzrml0h5m55viq7zlfkqr9p7ny-openjdk-15.0.3-checkout/src/java.desktop/unix/native/libawt_xawt/xawt/XlibWrapper.c 2022-03-31 15:34:11.917502206 +0200
++++ 22kjr9lzrml0h5m55viq7zlfkqr9p7ny-openjdk-15.0.3-checkout/src/java.desktop/unix/native/libawt_xawt/xawt/XlibWrapper.c 2022-03-31 21:38:16.417253535 +0200
+@@ -40,10 +40,12 @@
+ #include <X11/keysym.h>
+ #include <X11/Sunkeysym.h>
+ #include <X11/Xlib.h>
++#include <X11/Xlibint.h>
+ #include <X11/Xatom.h>
+ #include <X11/XKBlib.h>
+ #include <X11/Xos.h>
+ #include <X11/Xutil.h>
++#include <X11/Xcursor/Xcursor.h>
+
+ #if defined(AIX)
+ #undef X_HAVE_UTF8_STRING
+@@ -972,10 +974,21 @@
+
+ }
+
++static XColor _Xconst foreground = { 0, 0, 0, 0 }; /* black */
++static XColor _Xconst background = { 0, 65535, 65535, 65535 }; /* white */
++
+ JNIEXPORT jint JNICALL Java_sun_awt_X11_XlibWrapper_XCreateFontCursor
+ (JNIEnv *env, jclass clazz, jlong display, jint shape) {
+ AWT_CHECK_HAVE_LOCK_RETURN(0);
+- return XCreateFontCursor((Display *) jlong_to_ptr(display), (int) shape);
++ Display * dpy = (Display *) jlong_to_ptr(display);
++ if (dpy->cursor_font == None) {
++ dpy->cursor_font = XLoadFont(dpy, "cursor");
++ if (dpy->cursor_font == None) return None;
++ }
++ Cursor result = XcursorTryShapeCursor(dpy, dpy->cursor_font, dpy->cursor_font, (int) shape, (int) shape + 1, &foreground, &background);
++ if (!result)
++ result = XCreateFontCursor(dpy, (int) shape);
++ return result;
+ }
+
+ /*
+diff -ru orig/22kjr9lzrml0h5m55viq7zlfkqr9p7ny-openjdk-15.0.3-checkout/test/jdk/java/awt/JAWT/Makefile.unix 22kjr9lzrml0h5m55viq7zlfkqr9p7ny-openjdk-15.0.3-checkout/test/jdk/java/awt/JAWT/Makefile.unix
+--- orig/22kjr9lzrml0h5m55viq7zlfkqr9p7ny-openjdk-15.0.3-checkout/test/jdk/java/awt/JAWT/Makefile.unix 2022-03-31 15:34:10.553466316 +0200
++++ 22kjr9lzrml0h5m55viq7zlfkqr9p7ny-openjdk-15.0.3-checkout/test/jdk/java/awt/JAWT/Makefile.unix 2022-03-31 21:36:27.854273411 +0200
+@@ -31,7 +31,7 @@
+
+ J_INC = $(TESTJAVA)/include
+ INCLUDES = -I$(J_INC) -I$(J_INC)/$(SYST) -I.
+-LIBS = -L$(TESTJAVA)/lib -ljawt -lX11
++LIBS = -L$(TESTJAVA)/lib -ljawt -lX11 -lXcursor
+
+ all: $(CLASSES) libmylib.so
+
--
2.34.0
L
L
Liliana Marie Prikler wrote on 1 Apr 2022 08:16
Re: libx11 libxcursor handling - Problems with big cursors not working in Java and xterm
4e22551e52e7187ea770bcbdce713940c322dc14.camel@ist.tugraz.at
Am Donnerstag, dem 31.03.2022 um 15:31 +0200 schrieb Danny
Milosavljevic:
Toggle quote (13 lines)
> [...]
> Possible fixes:
>
> a. Patch openjdk and xterm (and who knows what) such that it also
> does the
>    XcursorTryShapeCursor before it calls XCreateFontCursor.
>    That's a lot of work.
>    Note: There are no libxcursor or XLoadFont bindings in openjdk
> yet,
>    and one is not supposed to access Display->cursor_font from
> outside.
>    Note: xterm use libxcursor--but for something else. So it still
>    doesn't work (because it doesn't call XcursorTryShapeCursor).
This solution works short-term and should probably be done in the
meantime while...

Toggle quote (7 lines)
> b. Patch guix such that the libx11 package used by libxcursor is one
> without
>    reference to libxcursor, but a new user-visible libx11 package
> actually
>    would just link libxcursor in. Not sure whether that's such a good
>    idea--it could increase the size of everything and have two libx11
>    libraries loaded in the same user process, no?
this is the proper solution, which we would need to deploy on core-
updates first due to the enormous amount of dependents. As for the two
libx11s being loaded into the same user process, I think there ought to
be a way of making that just one, which would be the big one containing
all the right paths. I don't think libxcursor should reload libx11 if
there's already a libx11 dynamically loaded.

Cheers
D
D
Danny Milosavljevic wrote on 4 Apr 2022 12:14
Re: bug#54654: libx11 libxcursor handling - Problems with big cursors not working in Java and xterm
(address . 54654@debbugs.gnu.org)
20220404121430.3b71d39f@scratchpost.org
For future reference:

* See also bug# 54680 for a patch to xterm.
* See also bug# 54701 for a patch to openjdk.
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCgAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAmJKxQYACgkQ5xo1VCww
uqWU+wgAoW91HO8F6p5XUvs78O98ueLIEoUAoXfL2mR8RTjO+0HgvutZGk1zHolr
LgtDQoWnrgfj5S9+Wng5VHEtxu250ohDNK6IND8QjZt/sJ5WZMEBORzDFd/NABNr
IjjwjHVr3GecwdXEh5scujVGuhUJPlUpFaxUWqLG1RgzOd2ucC80lMTEnPXy2Fl4
tjQRugVYOdYuUrHkK96J/cU4wfyJFl207RWqd7Ruw/VauHZzMYY4ILS1fpiz7MuB
y7zFoatv3TPzZKW1CIlGJ0t9baJ5pZgNp7bgroYcngMevfQePqassPj4ijShQGt9
3rHFc8prKBY8/K9Ixt140Bwv7J8Mkw==
=0Wsw
-----END PGP SIGNATURE-----


D
D
Danny Milosavljevic wrote on 7 Apr 2022 20:04
(address . 54654@debbugs.gnu.org)
20220407200403.4d9c8ade@scratchpost.org
On Thu, 31 Mar 2022 15:31:56 +0200
Danny Milosavljevic <dannym@scratchpost.org> wrote:

Toggle quote (2 lines)
> Possible alternative fixes:

d. Move the definitions of XCreateFontCursor and XCreatePixmapCursor to
libxcursor (i.e. delete their definitions from libx11 and create them
in libxcursor). Fix up now-failing packages such that they always add
-lxcursor to their linker flags.
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCgAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAmJPJ5MACgkQ5xo1VCww
uqWyYgf9Gn0MgI4YBsmTTr2lDG15usH+hlghDvffMDHHZAQQGgkTD2D+kIgOi+8n
Z9x7UchTXheSmBji+0FON+IA9V5gdtKSAnm83XbbDffIg91vNBoHi523ODt3iAsw
XfdZ0BnXsuuT2ss2QVXpsdd/ywsg+AP0r+cvTh2oK6UatUs38mux5xGtADw1GxNj
QQfLIa7EPS2JGoujEjPRmkbfFrvqzQL9BY4MjzmItpr0gGjJ+LoK79xIuBszQ++I
wxuUOggKOz+P0CxkV9CiOsqCNH9U/6qWvVdaqieyK/B474PlMhiA6GHRksl+hyR2
m5NK0DrSY24wC1hqploBk0ROulVL5A==
=wOiZ
-----END PGP SIGNATURE-----


D
D
Danny Milosavljevic wrote on 7 Apr 2022 22:21
(address . 54654@debbugs.gnu.org)
20220407222146.3ea42405@scratchpost.org
Attachment: file
Attachment: XCURSOR
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCgAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAmJPR9oACgkQ5xo1VCww
uqWGSwf/SNl4NQVybGpIX6LaZMbaiLSEcDtDsKuxVYg+gcIc9Q/pf7bt1WZ1dgB2
213OiquGUzrccoMwUNzOtHHu2yC1dBOCkkVH5Oa/52BDGinJLWeSGmDKzxNfmzFT
/mmqmJ2xGPAdwzBonH71DMl3bA0UkKf08ycNOz9M3QeEUsWAea4Nay/zarvP0CrN
CVy1POgH49TQd4OyNeZwyAQAg2kIKjLvK4+4vpRjCyTWKA19Sdhx1KZP9XXklQYB
sG/f56blZWkRr4sSO2rC1pmKhBgtVNd3065nXCFw9LUXCE+gwAOEfLZYC/R6bqcb
YhdF9ztzWz0g5Lvv0qXf4tVwwbwCEA==
=bHsc
-----END PGP SIGNATURE-----


?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 54654@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 54654
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch