From: Alex Goins <agoins@nvidia.com>
Date: Thu, 18 Feb 2021 21:25:22 -0600
Subject: [PATCH] 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.

Bug-Debian: https://bugs.debian.org/983882
Bug-Ubuntu: https://bugs.launchpad.net/bugs/1917516
Origin: https://github.com/AlexGoinsNV/openbox-multiXscreen-bugfix/commit/2635c87d160aa5f6f9e91e290678e99111788d57
Last-Updated: 2021-03-02

Index: openbox-debian/openbox/screen.c
===================================================================
--- openbox-debian.orig/openbox/screen.c
+++ openbox-debian/openbox/screen.c
@@ -1908,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;
     }
