diff mbox series

[bug#61630] gnu: fluxbox: Make big cursors work.

Message ID 20230219154420.6781-1-dannym@scratchpost.org
State New
Headers show
Series [bug#61630] gnu: fluxbox: Make big cursors work. | expand

Commit Message

Danny Milosavljevic Feb. 19, 2023, 3:44 p.m. UTC
From: Danny Milosavljevic <dannym@scratchpost.org>

* gnu/packages/patches/fluxbox-1.3.7-no-dynamic-cursor.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it.
* gnu/packages/wm.scm (fluxbox)[source]: Add patch.
[arguments]<#:phases>[force-bootstrap]: New phase.
[native-inputs]: Add autoconf, automake, gnu-gettext.
[inputs]: Add libxcursor.
---
 gnu/local.mk                                  |   1 +
 .../fluxbox-1.3.7-no-dynamic-cursor.patch     | 163 ++++++++++++++++++
 gnu/packages/wm.scm                           |  11 +-
 3 files changed, 173 insertions(+), 2 deletions(-)
 create mode 100644 gnu/packages/patches/fluxbox-1.3.7-no-dynamic-cursor.patch

Comments

Ludovic Courtès March 4, 2023, 5:43 p.m. UTC | #1
Hi Danny,

dannym@scratchpost.org skribis:

> From: Danny Milosavljevic <dannym@scratchpost.org>
>
> * gnu/packages/patches/fluxbox-1.3.7-no-dynamic-cursor.patch: New file.
> * gnu/local.mk (dist_patch_DATA): Register it.
> * gnu/packages/wm.scm (fluxbox)[source]: Add patch.
> [arguments]<#:phases>[force-bootstrap]: New phase.
> [native-inputs]: Add autoconf, automake, gnu-gettext.
> [inputs]: Add libxcursor.

LGTM! :-)

Ludo’.
diff mbox series

Patch

diff --git a/gnu/local.mk b/gnu/local.mk
index f3d8dfcac6..e585a8be5e 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1122,6 +1122,7 @@  dist_patch_DATA =						\
   %D%/packages/patches/flashrom-fix-building-on-aarch64.patch	\
   %D%/packages/patches/flatpak-fix-path.patch			\
   %D%/packages/patches/flatpak-unset-gdk-pixbuf-for-sandbox.patch	\
+  %D%/packages/patches/fluxbox-1.3.7-no-dynamic-cursor.patch	\
   %D%/packages/patches/fontconfig-cache-ignore-mtime.patch	\
   %D%/packages/patches/foobillard++-pkg-config.patch		\
   %D%/packages/patches/foomatic-filters-CVE-2015-8327.patch	\
diff --git a/gnu/packages/patches/fluxbox-1.3.7-no-dynamic-cursor.patch b/gnu/packages/patches/fluxbox-1.3.7-no-dynamic-cursor.patch
new file mode 100644
index 0000000000..8ac455833c
--- /dev/null
+++ b/gnu/packages/patches/fluxbox-1.3.7-no-dynamic-cursor.patch
@@ -0,0 +1,163 @@ 
+From: Danny Milosavljevic <dannym@scratchpost.org>
+Date: Sun, 19 Feb 2023 15:48:23 +0100
+Subject: Make fluxbox use libxcursor directly
+
+This patch makes fluxbox use libxcursor directly. This way, big cursors work.
+Without it, libx11 would try to dlopen("libXcursor.so.1") and fail.
+
+--- orig/fluxbox-1.3.7/configure.ac	2015-02-08 11:44:45.333187008 +0100
++++ fluxbox-1.3.7/configure.ac	2023-02-19 15:42:50.595886984 +0100
+@@ -214,6 +214,18 @@
+ CXXFLAGS="$X11_CFLAGS $CXXFLAGS"
+ LIBS="$X11_LIBS $LIBS"
+ 
++dnl Check for Xcursor
++PKG_CHECK_MODULES([XCURSOR], [ xcursor ],
++        [AC_DEFINE([HAVE_XCURSOR], [1], [Define if xcursor is available]) have_cursor=yes],
++        [have_xcursor=no])
++AM_CONDITIONAL([XCURSOR], [test "$have_xcursor" = "yes"], AC_MSG_ERROR([Could not find XOpenDisplay in -lXcursor.]))
++AS_IF([test x$have_xcursor = "xno"], [
++        AC_MSG_ERROR([Fluxbox requires the Xcursor libraries and headers.])
++])
++
++CXXFLAGS="$XCURSOR_CFLAGS $CXXFLAGS"
++LIBS="$XCURSOR_LIBS $LIBS"
++
+ dnl Check for xpg4
+ AC_CHECK_LIB([xpg4], [setlocale], [LIBS="-lxpg4 $LIBS"])
+ AC_CHECK_PROGS([gencat_cmd], [gencat])
+diff -ru orig/fluxbox-1.3.7/src/FbWinFrameTheme.cc fluxbox-1.3.7/src/FbWinFrameTheme.cc
+--- orig/fluxbox-1.3.7/src/FbWinFrameTheme.cc	2015-02-08 11:44:45.365187009 +0100
++++ fluxbox-1.3.7/src/FbWinFrameTheme.cc	2023-02-19 15:28:56.183284901 +0100
+@@ -20,6 +20,7 @@
+ // DEALINGS IN THE SOFTWARE.
+ 
+ #include "FbWinFrameTheme.hh"
++#include "Xutil.hh"
+ #include "IconbarTheme.hh"
+ 
+ #include "FbTk/App.hh"
+@@ -53,15 +54,15 @@
+ 
+     // create cursors
+     Display *disp = FbTk::App::instance()->display();
+-    m_cursor_move = XCreateFontCursor(disp, XC_fleur);
+-    m_cursor_lower_left_angle = XCreateFontCursor(disp, XC_bottom_left_corner);
+-    m_cursor_lower_right_angle = XCreateFontCursor(disp, XC_bottom_right_corner);
+-    m_cursor_upper_right_angle = XCreateFontCursor(disp, XC_top_right_corner);
+-    m_cursor_upper_left_angle = XCreateFontCursor(disp, XC_top_left_corner);
+-    m_cursor_left_side = XCreateFontCursor(disp, XC_left_side);
+-    m_cursor_top_side = XCreateFontCursor(disp, XC_top_side);
+-    m_cursor_right_side = XCreateFontCursor(disp, XC_right_side);
+-    m_cursor_bottom_side = XCreateFontCursor(disp, XC_bottom_side);
++    m_cursor_move = Xutil::hidpiCreateFontCursor(disp, XC_fleur);
++    m_cursor_lower_left_angle = Xutil::hidpiCreateFontCursor(disp, XC_bottom_left_corner);
++    m_cursor_lower_right_angle = Xutil::hidpiCreateFontCursor(disp, XC_bottom_right_corner);
++    m_cursor_upper_right_angle = Xutil::hidpiCreateFontCursor(disp, XC_top_right_corner);
++    m_cursor_upper_left_angle = Xutil::hidpiCreateFontCursor(disp, XC_top_left_corner);
++    m_cursor_left_side = Xutil::hidpiCreateFontCursor(disp, XC_left_side);
++    m_cursor_top_side = Xutil::hidpiCreateFontCursor(disp, XC_top_side);
++    m_cursor_right_side = Xutil::hidpiCreateFontCursor(disp, XC_right_side);
++    m_cursor_bottom_side = Xutil::hidpiCreateFontCursor(disp, XC_bottom_side);
+ 
+     FbTk::ThemeManager::instance().loadTheme(*this);
+     reconfigTheme();
+diff -ru orig/fluxbox-1.3.7/src/Screen.cc fluxbox-1.3.7/src/Screen.cc
+--- orig/fluxbox-1.3.7/src/Screen.cc	2015-02-08 11:44:45.369187009 +0100
++++ fluxbox-1.3.7/src/Screen.cc	2023-02-19 15:28:23.783092203 +0100
+@@ -53,6 +53,7 @@
+ #include "SystemTray.hh"
+ #endif
+ #include "Debug.hh"
++#include "Xutil.hh"
+ 
+ #include "FbTk/I18n.hh"
+ #include "FbTk/FbWindow.hh"
+@@ -306,7 +307,7 @@
+     if (keys)
+         keys->registerWindow(rootWindow().window(), *this,
+                              Keys::GLOBAL|Keys::ON_DESKTOP);
+-    rootWindow().setCursor(XCreateFontCursor(disp, XC_left_ptr));
++    rootWindow().setCursor(Xutil::hidpiCreateFontCursor(disp, XC_left_ptr));
+ 
+     // load this screens resources
+     fluxbox->load_rc(*this);
+diff -ru orig/fluxbox-1.3.7/src/Xutil.cc fluxbox-1.3.7/src/Xutil.cc
+--- orig/fluxbox-1.3.7/src/Xutil.cc	2015-02-08 11:44:45.377187009 +0100
++++ fluxbox-1.3.7/src/Xutil.cc	2023-02-19 15:47:29.009541689 +0100
+@@ -28,6 +28,10 @@
+ 
+ #include <X11/Xutil.h>
+ #include <X11/Xatom.h>
++#include <X11/Xlibint.h>
++#undef min
++#undef max
++#include <X11/Xcursor/Xcursor.h>
+ #include <iostream>
+ 
+ #ifdef HAVE_CSTRING
+@@ -133,5 +137,19 @@
+     return class_name;
+ }
+ 
++static XColor _Xconst foreground = { 0,    0,     0,     0  };  /* black */
++static XColor _Xconst background = { 0, 65535, 65535, 65535 };  /* white */
++Cursor hidpiCreateFontCursor(Display* dpy, unsigned int shape) {
++	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;
++}
++
+ } // end namespace Xutil
+ 
+diff -ru orig/fluxbox-1.3.7/src/Xutil.hh fluxbox-1.3.7/src/Xutil.hh
+--- orig/fluxbox-1.3.7/src/Xutil.hh	2015-02-08 11:44:45.377187009 +0100
++++ fluxbox-1.3.7/src/Xutil.hh	2023-02-19 15:26:37.495619659 +0100
+@@ -32,7 +32,7 @@
+ 
+ FbTk::FbString getWMClassName(Window win);
+ FbTk::FbString getWMClassClass(Window win);
+-
++Cursor hidpiCreateFontCursor(Display* dpy, unsigned int shape);
+ 
+ } // end namespace Xutil
+ 
+diff -ru orig/fluxbox-1.3.7/util/fbrun/FbRun.cc fluxbox-1.3.7/util/fbrun/FbRun.cc
+--- orig/fluxbox-1.3.7/util/fbrun/FbRun.cc	2015-02-08 11:44:45.377187009 +0100
++++ fluxbox-1.3.7/util/fbrun/FbRun.cc	2023-02-19 15:28:18.532468099 +0100
+@@ -26,6 +26,7 @@
+ #include "FbTk/Color.hh"
+ #include "FbTk/KeyUtil.hh"
+ #include "FbTk/FileUtil.hh"
++#include "Xutil.hh"
+ 
+ #ifdef HAVE_XPM
+ #include <X11/xpm.h>
+@@ -67,7 +68,7 @@
+     m_current_history_item(0),
+     m_last_completion_prefix(""),
+     m_current_apps_item(0),
+-    m_cursor(XCreateFontCursor(FbTk::App::instance()->display(), XC_xterm)) {
++    m_cursor(Xutil::hidpiCreateFontCursor(FbTk::App::instance()->display(), XC_xterm)) {
+ 
+     setGC(m_gc.gc());
+     setCursor(m_cursor);
+diff -ru orig/fluxbox-1.3.7/util/fbrun/Makemodule.am fluxbox-1.3.7/util/fbrun/Makemodule.am
+--- orig/fluxbox-1.3.7/util/fbrun/Makemodule.am	2015-02-08 11:44:45.377187009 +0100
++++ fluxbox-1.3.7/util/fbrun/Makemodule.am	2023-02-19 15:50:33.029069099 +0100
+@@ -8,7 +8,8 @@
+ 	util/fbrun/FbRun.hh \
+ 	util/fbrun/FbRun.cc \
+ 	util/fbrun/main.cc \
+-	util/fbrun/fbrun.xpm
++	util/fbrun/fbrun.xpm \
++	src/Xutil.cc
+ 
+ fbrun_LDADD = libFbTk.a \
+ 	$(FRIBIDI_LIBS) \
diff --git a/gnu/packages/wm.scm b/gnu/packages/wm.scm
index 5c391f5e1b..889ce08f1a 100644
--- a/gnu/packages/wm.scm
+++ b/gnu/packages/wm.scm
@@ -109,6 +109,7 @@  (define-module (gnu packages wm)
   #:use-module (gnu packages freedesktop)
   #:use-module (gnu packages fribidi)
   #:use-module (gnu packages gawk)
+  #:use-module (gnu packages gettext)
   #:use-module (gnu packages gl)
   #:use-module (gnu packages glib)
   #:use-module (gnu packages gperf)
@@ -1045,12 +1046,17 @@  (define-public fluxbox
                                   version "/fluxbox-" version ".tar.xz"))
               (sha256
                (base32
-                "1h1f70y40qd225dqx937vzb4k2cz219agm1zvnjxakn5jkz7b37w"))))
+                "1h1f70y40qd225dqx937vzb4k2cz219agm1zvnjxakn5jkz7b37w"))
+              (patches
+               (search-patches "fluxbox-1.3.7-no-dynamic-cursor.patch"))))
     (build-system gnu-build-system)
     (arguments
      `(#:make-flags '("CPPFLAGS=-U__TIME__") ;ugly, but for reproducibility
        #:phases
        (modify-phases %standard-phases
+         (add-before 'bootstrap 'force-bootstrap
+           (lambda _
+             (delete-file "configure")))
          (add-after 'install 'install-vim-files
            (lambda* (#:key outputs #:allow-other-keys)
              (let* ((out (assoc-ref outputs "out"))
@@ -1073,12 +1079,13 @@  (define-public fluxbox
                      Type=Application~%" ,name ,synopsis out)))
                #t))))))
     (native-inputs
-     (list pkg-config))
+     (list autoconf automake gnu-gettext pkg-config))
     (inputs
      (list freetype
            fribidi
            imlib2
            libx11
+           libxcursor
            libxext
            libxft
            libxinerama