On Wed, 18 Oct 2023, Stuart Henderson wrote:
> CC'ing maintainer.
> 
> Not tested yet but I think this should do the trick.
> If it works it would make sense to commit to 7.4-stable too.

Hi Stuart, hi all

I'm an Openbox user myself.
The fix for this specific problem is ok, but here's a patch incorporating
all the relevant bugfixes from the Debian package:

Index: x11/openbox/Makefile
===================================================================
RCS file: /cvs/ports/x11/openbox/Makefile,v
retrieving revision 1.91
diff -u -p -u -p -r1.91 Makefile
--- x11/openbox/Makefile        27 Sep 2023 20:37:19 -0000      1.91
+++ x11/openbox/Makefile        18 Oct 2023 08:54:58 -0000
@@ -1,7 +1,7 @@
 COMMENT =      small, fast & usable window manager
 
 V =            3.6.1
-REVISION =     11
+REVISION =     12
 DISTNAME =     openbox-${V}
 SHARED_LIBS += obrender        12.0    # 32.0
 SHARED_LIBS += obt             1.1     # 2.2
@@ -15,7 +15,7 @@ MAINTAINER =  Benoit Lecocq <benoit@openb
 # GPLv2
 PERMIT_PACKAGE =       Yes
 
-WANTLIB += ICE Imlib2 SM X11 X11-xcb Xau Xcursor Xext Xfixes Xft
+WANTLIB += ICE Imlib2 SM X11 X11-xcb Xau Xcursor Xext Xfixes Xft Xi
 WANTLIB += Xinerama Xrandr Xrender c cairo cairo-gobject expat ffi
 WANTLIB += fontconfig freetype fribidi gdk_pixbuf-2.0 gio-2.0 glib-2.0
 WANTLIB += gmodule-2.0 gobject-2.0 graphite2 harfbuzz iconv
Index: x11/openbox/patches/patch-configure
===================================================================
RCS file: x11/openbox/patches/patch-configure
diff -N x11/openbox/patches/patch-configure
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ x11/openbox/patches/patch-configure 18 Oct 2023 08:54:58 -0000
@@ -0,0 +1,50 @@
+Fix for Openbox not showing startup notifications.
+Debian bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=719620
+
+Index: configure
+--- configure.orig
++++ configure
+@@ -14647,12 +14647,12 @@ if test -n "$LIBSN_CFLAGS"; then
+     pkg_cv_LIBSN_CFLAGS="$LIBSN_CFLAGS"
+  elif test -n "$PKG_CONFIG"; then
+     if test -n "$PKG_CONFIG" && \
+-    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists 
--print-errors \"libstartup-notification-1.0 >= 0.8\""; } >&5
+-  ($PKG_CONFIG --exists --print-errors "libstartup-notification-1.0 >= 0.8") 
2>&5
++    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists 
--print-errors \"libstartup-notification-1.0 >= 0.8 xi\""; } >&5
++  ($PKG_CONFIG --exists --print-errors "libstartup-notification-1.0 >= 0.8 
xi") 2>&5
+   ac_status=$?
+   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+   test $ac_status = 0; }; then
+-  pkg_cv_LIBSN_CFLAGS=`$PKG_CONFIG --cflags "libstartup-notification-1.0 >= 
0.8" 2>/dev/null`
++  pkg_cv_LIBSN_CFLAGS=`$PKG_CONFIG --cflags "libstartup-notification-1.0 >= 
0.8 xi" 2>/dev/null`
+                     test "x$?" != "x0" && pkg_failed=yes
+ else
+   pkg_failed=yes
+@@ -14664,12 +14664,12 @@ if test -n "$LIBSN_LIBS"; then
+     pkg_cv_LIBSN_LIBS="$LIBSN_LIBS"
+  elif test -n "$PKG_CONFIG"; then
+     if test -n "$PKG_CONFIG" && \
+-    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists 
--print-errors \"libstartup-notification-1.0 >= 0.8\""; } >&5
+-  ($PKG_CONFIG --exists --print-errors "libstartup-notification-1.0 >= 0.8") 
2>&5
++    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists 
--print-errors \"libstartup-notification-1.0 >= 0.8 xi\""; } >&5
++  ($PKG_CONFIG --exists --print-errors "libstartup-notification-1.0 >= 0.8 
xi") 2>&5
+   ac_status=$?
+   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+   test $ac_status = 0; }; then
+-  pkg_cv_LIBSN_LIBS=`$PKG_CONFIG --libs "libstartup-notification-1.0 >= 0.8" 
2>/dev/null`
++  pkg_cv_LIBSN_LIBS=`$PKG_CONFIG --libs "libstartup-notification-1.0 >= 0.8 
xi" 2>/dev/null`
+                     test "x$?" != "x0" && pkg_failed=yes
+ else
+   pkg_failed=yes
+@@ -14690,9 +14690,9 @@ else
+         _pkg_short_errors_supported=no
+ fi
+         if test $_pkg_short_errors_supported = yes; then
+-              LIBSN_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors 
--cflags --libs "libstartup-notification-1.0 >= 0.8" 2>&1`
++              LIBSN_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors 
--cflags --libs "libstartup-notification-1.0 >= 0.8 xi" 2>&1`
+         else
+-              LIBSN_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs 
"libstartup-notification-1.0 >= 0.8" 2>&1`
++              LIBSN_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs 
"libstartup-notification-1.0 >= 0.8 xi" 2>&1`
+         fi
+       # Put the nasty error message in config.log where it belongs
+       echo "$LIBSN_PKG_ERRORS" >&5
Index: x11/openbox/patches/patch-obrender_theme_c
===================================================================
RCS file: x11/openbox/patches/patch-obrender_theme_c
diff -N x11/openbox/patches/patch-obrender_theme_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ x11/openbox/patches/patch-obrender_theme_c  18 Oct 2023 08:54:58 -0000
@@ -0,0 +1,33 @@
+Fix for toggled hover and pressed images masks not loaded.
+Toggled hover and pressed images masks in Openbox themes are not loaded
+which broke many existing themes.
+Debian bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=887908
+
+Index: obrender/theme.c
+--- obrender/theme.c.orig
++++ obrender/theme.c
+@@ -1494,8 +1494,10 @@ static void read_button_styles(XrmDatabase db, const R
+     READ_BUTTON_MASK_COPY(disabled, btn->unpressed_mask);
+     READ_BUTTON_MASK_COPY(hover, btn->unpressed_mask);
+     if (toggled_mask) {
+-        READ_BUTTON_MASK_COPY(pressed_toggled, btn->unpressed_toggled_mask);
+-        READ_BUTTON_MASK_COPY(hover_toggled, btn->unpressed_toggled_mask);
++        g_snprintf(name, 128, "%s_toggled_pressed.xbm", btnname);
++        READ_MASK_COPY(name, btn->pressed_toggled_mask, 
btn->unpressed_toggled_mask);
++        g_snprintf(name, 128, "%s_toggled_hover.xbm", btnname);
++        READ_MASK_COPY(name, btn->hover_toggled_mask, 
btn->unpressed_toggled_mask);
+     }
+ 
+ #define READ_BUTTON_APPEARANCE(typedots, type, fallback) \
+@@ -1532,8 +1534,8 @@ static void read_button_styles(XrmDatabase db, const R
+     READ_BUTTON_APPEARANCE("disabled", disabled, 0);
+     READ_BUTTON_APPEARANCE("hover", hover, 0);
+     if (toggled_mask) {
+-        READ_BUTTON_APPEARANCE("unpressed.toggled", unpressed_toggled, 1);
+-        READ_BUTTON_APPEARANCE("pressed.toggled", pressed_toggled, 0);
+-        READ_BUTTON_APPEARANCE("hover.toggled", hover_toggled, 0);
++        READ_BUTTON_APPEARANCE("toggled.unpressed", unpressed_toggled, 1);
++        READ_BUTTON_APPEARANCE("toggled.pressed", pressed_toggled, 0);
++        READ_BUTTON_APPEARANCE("toggled.hover", hover_toggled, 0);
+     }
+ }
Index: x11/openbox/patches/patch-openbox_client_c
===================================================================
RCS file: /cvs/ports/x11/openbox/patches/patch-openbox_client_c,v
retrieving revision 1.4
diff -u -p -u -p -r1.4 patch-openbox_client_c
--- x11/openbox/patches/patch-openbox_client_c  11 Mar 2022 20:16:51 -0000      
1.4
+++ x11/openbox/patches/patch-openbox_client_c  18 Oct 2023 08:54:58 -0000
@@ -3,6 +3,14 @@ Java GUI applications.
 From https://bugzilla.icculus.org/show_bug.cgi?id=5277 via Arch
 Linux.
 
+Fix list traversal issue in client_calc_layer.
+The calls to client_calc_layer_internal can modify stacking_list, which
+can cause us to follow dangling ->next pointers (either by the pointer
+itself already being freed, or it pointing to a freed area).
+Avoid this by copying the list first, the goal is to visit every client
+in the list once so this should be fine.
+From upstream via Debian: 
http://git.openbox.org/?p=mikachu/openbox.git;a=commit;h=d41128e5a1002af41c976c8860f8299cfcd3cd72
+
 Index: openbox/client.c
 --- openbox/client.c.orig
 +++ openbox/client.c
@@ -15,3 +23,35 @@ Index: openbox/client.c
                   !g_pattern_match(app->title,
                                    strlen(self->title), self->title, NULL))
              match = FALSE;
+@@ -2702,9 +2702,12 @@ static void client_calc_layer_internal(ObClient *self)
+ void client_calc_layer(ObClient *self)
+ {
+     GList *it;
++    /* the client_calc_layer_internal calls below modify stacking_list,
++       so we have to make a copy to iterate over */
++    GList *list = g_list_copy(stacking_list);
+ 
+     /* skip over stuff above fullscreen layer */
+-    for (it = stacking_list; it; it = g_list_next(it))
++    for (it = list; it; it = g_list_next(it))
+         if (window_layer(it->data) <= OB_STACKING_LAYER_FULLSCREEN) break;
+ 
+     /* find the windows in the fullscreen layer, and mark them not-visited */
+@@ -2717,7 +2720,7 @@ void client_calc_layer(ObClient *self)
+     client_calc_layer_internal(self);
+ 
+     /* skip over stuff above fullscreen layer */
+-    for (it = stacking_list; it; it = g_list_next(it))
++    for (it = list; it; it = g_list_next(it))
+         if (window_layer(it->data) <= OB_STACKING_LAYER_FULLSCREEN) break;
+ 
+     /* now recalc any windows in the fullscreen layer which have not
+@@ -2728,6 +2731,8 @@ void client_calc_layer(ObClient *self)
+                  !WINDOW_AS_CLIENT(it->data)->visited)
+             client_calc_layer_internal(it->data);
+     }
++
++    g_list_free(it);
+ }
+ 
+ gboolean client_should_show(ObClient *self)
Index: x11/openbox/patches/patch-openbox_screen_c
===================================================================
RCS file: x11/openbox/patches/patch-openbox_screen_c
diff -N x11/openbox/patches/patch-openbox_screen_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ x11/openbox/patches/patch-openbox_screen_c  18 Oct 2023 08:54:58 -0000
@@ -0,0 +1,61 @@
+Fix for Openbox not showing startup notifications.
+Debian bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=719620
+
+Fix collision between iterator and throw-away argument to XQueryPointer().
+Without this, Openbox is unstable on any setup with more than 2 X screens,
+as the collision can make the loop infinitely call XQueryPointer()
+on X screen 1.
+Debian bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=983882
+
+Index: openbox/screen.c
+--- openbox/screen.c.orig
++++ openbox/screen.c
+@@ -40,6 +40,7 @@
+ #include "obt/prop.h"
+ 
+ #include <X11/Xlib.h>
++#include <X11/extensions/XInput2.h>
+ #ifdef HAVE_UNISTD_H
+ #  include <sys/types.h>
+ #  include <unistd.h>
+@@ -1878,12 +1879,15 @@ const Rect* screen_physical_area_primary(gboolean fixe
+ 
+ void screen_set_root_cursor(void)
+ {
++    int pointer_id;
++    if (!XIGetClientPointer(obt_display, None, &pointer_id))
++        return;
+     if (sn_app_starting())
+-        XDefineCursor(obt_display, obt_root(ob_screen),
+-                      ob_cursor(OB_CURSOR_BUSYPOINTER));
++        XIDefineCursor(obt_display, pointer_id, obt_root(ob_screen),
++                       ob_cursor(OB_CURSOR_BUSYPOINTER));
+     else
+-        XDefineCursor(obt_display, obt_root(ob_screen),
+-                      ob_cursor(OB_CURSOR_POINTER));
++        XIDefineCursor(obt_display, pointer_id, obt_root(ob_screen),
++                       ob_cursor(OB_CURSOR_POINTER));
+ }
+ 
+ guint screen_find_monitor_point(guint x, guint y)
+@@ -1904,16 +1908,16 @@ guint screen_monitor_pointer()
+ gboolean screen_pointer_pos(gint *x, gint *y)
+ {
+     Window w;
+-    gint i;
++    gint i, scrnindex;
+     guint u;
+     gboolean ret;
+ 
+     ret = !!XQueryPointer(obt_display, obt_root(ob_screen),
+                           &w, &w, x, y, &i, &i, &u);
+     if (!ret) {
+-        for (i = 0; i < ScreenCount(obt_display); ++i)
+-            if (i != ob_screen)
+-                if (XQueryPointer(obt_display, obt_root(i),
++        for (scrnindex = 0; scrnindex < ScreenCount(obt_display); ++scrnindex)
++            if (scrnindex != ob_screen)
++                if (XQueryPointer(obt_display, obt_root(scrnindex),
+                                   &w, &w, x, y, &i, &i, &u))
+                     break;
+     }

Reply via email to