From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id sKyeE0muRWJnFAAAgWs5BA (envelope-from ) for ; Thu, 31 Mar 2022 15:36:09 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id OJBTDEmuRWIRIwAAG6o9tA (envelope-from ) for ; Thu, 31 Mar 2022 15:36:09 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 943363EF37 for ; Thu, 31 Mar 2022 15:36:08 +0200 (CEST) Received: from localhost ([::1]:58640 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nZuy7-0003KF-98 for larch@yhetil.org; Thu, 31 Mar 2022 09:36:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47726) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZuv9-0006lJ-1B for bug-guix@gnu.org; Thu, 31 Mar 2022 09:33:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:44396) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nZuv8-0001Sp-O7 for bug-guix@gnu.org; Thu, 31 Mar 2022 09:33:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nZuv8-0006B4-JE for bug-guix@gnu.org; Thu, 31 Mar 2022 09:33:02 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#54654: libx11 libxcursor handling - Problems with big cursors not working in Java and xterm Resent-From: Danny Milosavljevic Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Thu, 31 Mar 2022 13:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 54654 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 54654@debbugs.gnu.org X-Debbugs-Original-To: Received: via spool by submit@debbugs.gnu.org id=B.164873354323679 (code B ref -1); Thu, 31 Mar 2022 13:33:02 +0000 Received: (at submit) by debbugs.gnu.org; 31 Mar 2022 13:32:23 +0000 Received: from localhost ([127.0.0.1]:38293 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nZuuU-00069q-IX for submit@debbugs.gnu.org; Thu, 31 Mar 2022 09:32:23 -0400 Received: from lists.gnu.org ([209.51.188.17]:46936) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nZuuQ-00069e-KI for submit@debbugs.gnu.org; Thu, 31 Mar 2022 09:32:19 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47610) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZuuN-0005BL-Iq for bug-guix@gnu.org; Thu, 31 Mar 2022 09:32:17 -0400 Received: from dd30410.kasserver.com ([85.13.145.193]:36504) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZuuK-0001Ic-Aa for bug-guix@gnu.org; Thu, 31 Mar 2022 09:32:14 -0400 Received: from localhost (84-115-234-55.cable.dynamic.surfer.at [84.115.234.55]) by dd30410.kasserver.com (Postfix) with ESMTPSA id 76C3311201BF for ; Thu, 31 Mar 2022 15:32:03 +0200 (CEST) Date: Thu, 31 Mar 2022 15:31:56 +0200 From: Danny Milosavljevic Message-ID: <20220331153156.0ae2b4ce@scratchpost.org> X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/alElXZ6f6a=i8NvTM6VfbyS"; protocol="application/pgp-signature"; micalg=pgp-sha512 Received-SPF: none client-ip=85.13.145.193; envelope-from=dannym@scratchpost.org; helo=dd30410.kasserver.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1648733768; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:list-id:list-help:list-unsubscribe:list-subscribe: list-post; bh=XhbVl3EVTnBXlr86+Mroo9fTpV6afN127bingdpPTzE=; b=VCqe4ZI75DocTt/K5F8IeX+fRbdKkiZfdRjywgm39mdTGH82fltzH5bzSrbe/rSI30YAde uLYdqmy6Hd5BdMIo4D4g0Lxuny9JjhAYGP69mf/Bd8pyz6Hlvmcvon7haY+ZnADAz+F3qJ HJQnoao8vZWlUgy2jvU6iGwN1sq2nSXRUIKxG5rigwdyjWwg5csmyokj/tHSuyRvuHDTTq /sZBkRBCXVDMG5NrcJ0gUUG2JoADE3IHyjF+OqxEjEak0SWCvydMXonrRMsg+EBpqy3+45 GJmVV8TA+x55mxS4kk2LLIHqmv2AdWyIay0mUSgA5opVtiSB6G69/Gi4VDDpeg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1648733768; a=rsa-sha256; cv=none; b=lfmrwMl9fBjjU6UW1Gbwwll2nmeNUUA42KmsbXwVNd/C8cdW5Rs08HvbyJtLHn9v5D9uCG GYBUj6dHtlcuwUObUQmh5d6W/xpMgwYieaslyHtu1tyrjoFHns4WL87gUtCk9FLaFbKkwf kaHJXhqnPV+oQfZaZeDsFoxjiNm9R6LflUNztYhZ1ea2DzKBDs2aH5rgi9JRPW48joZlGW 5lIPzXeFVKvTsd9i6a1oX/066MSaNKU+n0yMQ6Pi5FPYGkiql9IgLmw4zncBdzLF2LRLzz e9Cj50JLSLaYamxA8kmHsgbFpJb+UDr3jlAv7+MLz4BcEi4by0Zc4odxh7WEAg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -6.17 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 943363EF37 X-Spam-Score: -6.17 X-Migadu-Scanner: scn0.migadu.com X-TUID: JXbjydjTzmcr --Sig_/alElXZ6f6a=i8NvTM6VfbyS Content-Type: multipart/mixed; boundary="MP_/ind9sE8NE8ua2Ui8onSJf5Q" --MP_/ind9sE8NE8ua2Ui8onSJf5Q Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi, After I got HiDPI displays (3840 pixels x 2160 pixels) mostly working in Gu= ix system, I am only left with one remaining problem: libx11's XCreateFontCursor tries to dynamically-load libxcursor with just t= he basename "libXcursor.so.1". Because libxcursor depends on libx11, it's not possible to just add libxcur= sor as a dependency TO libx11. The problematic location is: # libX11-1.7.3.1/src/CrGlCur.c #define LIBXCURSOR "libXcursor.so.1" static char libraryName[] =3D LIBXCURSOR; static XModuleType open_library (void) { [...] module =3D dlopen(library, RTLD_LAZY); [...] } #define GetFunc(type,name,ret) {\ [...] _XcursorModule =3D open_library (); #define CURSORFONT "cursor" /* standard cursor fonts */ It's getting to dlopen of "LibXcursor.so.1" via XCreateFontCursor, which calls XCreateGlyphCursor, which calls _XTryShapeCursor, which calls open_library. static Cursor _XTryShapeCursor (Display *dpy, Font source_font, Font mask_font, unsigned int source_char, unsigned int mask_char, XColor _Xconst *foreground, XColor _Xconst *background) { TryShapeCursorFunc func; GetFunc (TryShapeCursorFunc, "XcursorTryShapeCursor", func); <----- pro= blem if (func) return (*func) (dpy, source_font, mask_font, source_char, mask_char, foreground, background); return None; } Cursor XCreateGlyphCursor( register Display *dpy, Font source_font, Font mask_font, unsigned int source_char, unsigned int mask_char, XColor _Xconst *foreground, XColor _Xconst *background) { Cursor cid; register xCreateGlyphCursorReq *req; #ifdef USE_DYNAMIC_XCURSOR cid =3D _XTryShapeCursor (dpy, source_font, mask_font, source_char, mask_char, foreground, background); if (cid) return cid; #endif LockDisplay(dpy); GetReq(CreateGlyphCursor, req); cid =3D req->cid =3D XAllocID(dpy); req->source =3D source_font; req->mask =3D mask_font; req->sourceChar =3D source_char; req->maskChar =3D mask_char; req->foreRed =3D foreground->red; req->foreGreen =3D foreground->green; req->foreBlue =3D foreground->blue; req->backRed =3D background->red; req->backGreen =3D background->green; req->backBlue =3D background->blue; UnlockDisplay(dpy); SyncHandle(); return (cid); } Cursor XCreateFontCursor( Display *dpy, unsigned int which) { /* * the cursor font contains the shape glyph followed by the mask * glyph; so character position 0 contains a shape, 1 the mask for = 0, * 2 a shape, etc. contains hash define names * for all of these. */ if (dpy->cursor_font =3D=3D None) { dpy->cursor_font =3D XLoadFont (dpy, CURSORFONT); if (dpy->cursor_font =3D=3D None) return None; } return XCreateGlyphCursor (dpy, dpy->cursor_font, dpy->cursor_font, which, which + 1, &foreground, &backgrou= nd); } Cursor XCreateGlyphCursor( register Display *dpy, Font source_font, Font mask_font, unsigned int source_char, unsigned int mask_char, XColor _Xconst *foreground, XColor _Xconst *background) { Cursor cid; register xCreateGlyphCursorReq *req; #ifdef USE_DYNAMIC_XCURSOR cid =3D _XTryShapeCursor (dpy, source_font, mask_font, source_char, mask_char, foreground, background); if (cid) return cid; #endif LockDisplay(dpy); GetReq(CreateGlyphCursor, req); cid =3D req->cid =3D XAllocID(dpy); req->source =3D source_font; req->mask =3D mask_font; req->sourceChar =3D source_char; req->maskChar =3D mask_char; req->foreRed =3D foreground->red; req->foreGreen =3D foreground->green; req->foreBlue =3D foreground->blue; req->backRed =3D background->red; req->backGreen =3D background->green; req->backBlue =3D background->blue; UnlockDisplay(dpy); SyncHandle(); return (cid); } To test, to enable HiDPI: 1. Put big mouse cursors into .icons/default/cursors 2. Invoke: gsettings set org.gnome.desktop.interface cursor-size 64 3. Add to .xinitrc: xsetroot -cursor_name left_ptr # does it again 4. xrdb merge: Xft.dpi: 163 To test whether it's actually because of that (don't do it for too long): 1. Find the /gnu/store location for the libx11 used by openjdk. 2. cp -r /gnu/store/whatever-libx11* /tmp/foo 3. mount -o bind /tmp/foo /gnu/store/whatever-libx11 4. cp `guix build libxcursor`/lib/libXcursor.so* /tmp/foo/lib 5. Call your fancy Java program (for example IntelliJ IDEA) Not sure what the best way forward is. Possible alternative 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). 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? c. Inline the build of libxcursor into the build of libx11. If we did that, we would add libxrender libxfixes to libx11's inputs. ! I think this would actually be nice, especially since libxcursor seems to rarely change anyway (last change was in 2015). But even then, libxcursor depends on libxrender and libxfixes, both of which depends on libx11. Non-solution steps (that's asking too much from the user--shared libraries are an implementation detail): 1. Add an environment variable XCURSOR_RUNPATH that the user has to set 2. Patch our libx11 package to read the environment variable in GetFunc instead of using the global variable. 3. Add search-path or something to libxcursor. I-don't-know-how-to-do-that-probably-bad-solution steps: 1. Add an environment variable XCURSOR_RUNPATH (see attachment) 2. Patch our libx11 package to read the environment variable in GetFunc instead of using the global variable. (add such a variable to search-path or something) 3. Patch our libxcursor package to set search-path 4. Patch our libx11 package to propagate ,(delay libxcursor) All of those have their pros and cons. Unfortunately, any fix causes a massive rebuild of guix, except "a". What to do? P.S. Same problem exists in nix. --MP_/ind9sE8NE8ua2Ui8onSJf5Q Content-Type: text/x-patch Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename=libx11-xcursor-use-env-var.patch 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 =3D libraryName; + char *library =3D getenv("XCURSOR_RUNPATH") ?: libraryName; char *dot; XModuleType module; for (;;) --MP_/ind9sE8NE8ua2Ui8onSJf5Q-- --Sig_/alElXZ6f6a=i8NvTM6VfbyS Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAmJFrUwACgkQ5xo1VCww uqXXsQf+J7NG7FYikFixbyUXN0K9mo1qcx5ofQNrFMfRi15RAfMKTvQwN//MlTGY Dt/ubuTRUcBm7Ey2j7988EhECIKY4SYS2H/1eWogcmqv43wwgRETwSzFH34KvDwy 6jL6J6TAfdtZNC2Ickm54+iKoRcKQHFjXCYGvcMUeNWItLuQzJfRz4GzAsXRCmvZ rWdu/bThvTAW4nadSXjNuUvEDIp8EgR5zSt6JPC4fE0gg3N0ZkdF3fNdwBwN5aT8 WpFHKWWsu4XZ0SfpzRBxiPDphvX/2anseObaw1l47ieRzvVcV/Mw89SIg80pPNTu wpVRM1rauqMNdsPQCF9e5M86XcNF0A== =jIyn -----END PGP SIGNATURE----- --Sig_/alElXZ6f6a=i8NvTM6VfbyS--