Explorar el Código

wm: fix wallpaper blits in partial damage rects

Johannes Zellner hace 2 días
padre
commit
29b7a1c185
Se han modificado 2 ficheros con 26 adiciones y 9 borrados
  1. 7 3
      AGENTS.md
  2. 19 6
      user/apps/wm/ucmd_wm.c

+ 7 - 3
AGENTS.md

@@ -527,9 +527,13 @@ it to `0x7E00`.  The kernel region itself only has one wall (`_end` below
   nearest-neighbour maps and repaints.  The WM has no image decoder: it
   stretches the stored buffer into every desktop damage rectangle under the
   bar and windows, with a static 2.4 MB buffer plus a 256 KB RGB565-to-BGRA
-  table for 32 bpp (and direct stores for 16/24 bpp).  A missing or invalid
-  file falls back to `COL_BG`.  The file survives a reboot on an installed
-  board because it lives on the `NEBOSDATA` volume.
+  table for 32 bpp (and direct stores for 16/24 bpp).  A row pointer starts
+  at the row and is indexed with absolute screen x, so a partial damage rect
+  paints exactly the same pixels as a full redraw; adding x0 to both shifted
+  the wallpaper inside the rect and left the previous window pixels behind
+  while dragging.  A missing or invalid file falls back to `COL_BG`.  The
+  file survives a reboot on an installed board because it lives on the
+  `NEBOSDATA` volume.
   The NebOS banner in the top-left corner is the start button.  Clicking it
   opens the WM's Windows-like start menu, a flat overlay panel drawn by the
   WM (not a window, so it does not consume a `WM_MAX_WINDOWS` slot).  It is

+ 19 - 6
user/apps/wm/ucmd_wm.c

@@ -971,15 +971,20 @@ static void wall_draw(int x, int y, unsigned int w, unsigned int h)
 		const unsigned short *srow = src + (unsigned int)wall_ymap[yy] *
 						 wall_w;
 
+		/* d points at the start of the row; the loops index it with
+		 * absolute screen x.  Pointing d at x0 and still indexing with
+		 * x shifted every damage rect's wallpaper right by x0, which
+		 * left old window pixels in the uncovered strip and made
+		 * dragging windows leave a trail. */
 		if (screen.bpp == 16) {
 			unsigned short *d = (unsigned short *)(screen.px +
-				(unsigned long)yy * screen.pitch) + x0;
+				(unsigned long)yy * screen.pitch);
 
 			for (xx = (unsigned int)x0; xx < (unsigned int)x1; xx++)
 				d[xx] = srow[wall_xmap[xx]];
 		} else if (screen.bpp == 32) {
 			unsigned int *d = (unsigned int *)(screen.px +
-				(unsigned long)yy * screen.pitch) + x0;
+				(unsigned long)yy * screen.pitch);
 
 			for (xx = (unsigned int)x0; xx < (unsigned int)x1; xx++)
 				d[xx] = wall_rgb32[srow[wall_xmap[xx]]];
@@ -1379,10 +1384,18 @@ static void move_window_pixels(struct uwin *u, int ox, int oy, int nx, int ny)
 		draw_rect(pieces[k].x, pieces[k].y, pieces[k].w, pieces[k].h);
 	present.count = 0;
 	present.immediate = 1;
-	add_rect(&present, nx, ny, u->info.w, u->info.h);
-	for (k = 0; k < np; k++)
-		add_rect(&present, pieces[k].x, pieces[k].y,
-			 pieces[k].w, pieces[k].h);
+	/* Present the union of the old and new rectangles as one rect.
+	 * The shadow is correct for all of it, and one rect cannot be cut
+	 * off by the kernel's four-entry present list. */
+	{
+		int ux0 = ox < nx ? ox : nx;
+		int uy0 = oy < ny ? oy : ny;
+		int ux1 = (ox > nx ? ox : nx) + (int)u->info.w;
+		int uy1 = (oy > ny ? oy : ny) + (int)u->info.h;
+
+		add_rect(&present, ux0, uy0, (unsigned int)(ux1 - ux0),
+			 (unsigned int)(uy1 - uy0));
+	}
 	wm_overlays(&present);
 	u_wm_present(&present);
 }