Преглед изворни кода

Fix activation of overlapping inactive windows

Johannes Zellner пре 2 недеља
родитељ
комит
2357e8924a
2 измењених фајлова са 9 додато и 3 уклоњено
  1. 3 1
      ucmd_wm.c
  2. 6 2
      wm.c

+ 3 - 1
ucmd_wm.c

@@ -221,7 +221,9 @@ static int window_at(unsigned int mx, unsigned int my)
 		    mx < (unsigned int)(wins[i].info.x + (int)wins[i].info.w) &&
 		    my < (unsigned int)(wins[i].info.y + (int)wins[i].info.h))
 			return (int)i;
-	for (i = 0; i < WM_MAX_WINDOWS; i++)
+	/* Inactive windows are painted in slot order, so the highest slot is
+	 * the topmost one under the cursor. */
+	for (i = WM_MAX_WINDOWS; i-- > 0; )
 		if (wins[i].info.used && !wins[i].info.focused &&
 		    mx >= (unsigned int)wins[i].info.x &&
 		    my >= (unsigned int)wins[i].info.y &&

+ 6 - 2
wm.c

@@ -1170,7 +1170,9 @@ static void wm_focus_index(unsigned int idx)
 static void wm_focus_top(void)
 {
 	unsigned int i;
-	for (i = 0; i < MAX_WINDOWS; i++)
+	/* With no explicit z-order the highest used slot is painted last, so
+	 * it is the topmost window left after a close. */
+	for (i = MAX_WINDOWS; i-- > 0; )
 		if (windows[i].used) {
 			wm_focus_index(i);
 			return;
@@ -1224,7 +1226,9 @@ static int wm_window_at(unsigned int px, unsigned int py)
 		    wm_point_in_rect(px, py, windows[i].x, windows[i].y,
 		    	windows[i].pw, windows[i].ph))
 			return (int)i;
-	for (i = 0; i < MAX_WINDOWS; i++)
+	/* Inactive windows are painted in slot order, so the highest slot is
+	 * the topmost one under the cursor. */
+	for (i = MAX_WINDOWS; i-- > 0; )
 		if (windows[i].used && !windows[i].focused &&
 		    wm_point_in_rect(px, py, windows[i].x, windows[i].y,
 		    	windows[i].pw, windows[i].ph))