浏览代码

wm: remove the window drop shadow

Johannes Zellner 2 天之前
父节点
当前提交
e34b15cd5d
共有 9 个文件被更改,包括 62 次插入 和 379 次删除
  1. 3 14
      AGENTS.md
  2. 7 16
      docs/graphics.html
  3. 2 2
      docs/userland.html
  4. 1 2
      include/wm_abi.h
  5. 1 2
      kernel/wm.c
  6. 2 17
      user/apps/settings/ucmd_settings.c
  7. 46 200
      user/apps/wm/ucmd_wm.c
  8. 0 119
      user/lib/uwm/uwm_lib.c
  9. 0 7
      user/lib/uwm/uwm_lib.h

+ 3 - 14
AGENTS.md

@@ -551,18 +551,7 @@ it to `0x7E00`.  The kernel region itself only has one wall (`_end` below
   edge, and the close control is the Adwaita `window-close` icon in the top
   right (3 px from the edge, no red button fill); it is dimmed while idle,
   turns white while the pointer is over it and shows the hand cursor.  A
-  hover change repaints only the two affected button rectangles.  Every
-  normal window casts a soft 10 px (`WM_SHADOW_SPREAD`) drop shadow through
-  `usurf_window_shadow()` (`uwm_lib.c`): the ring darkens with a rounded
-  distance falloff, so its corners fade in a curve.  Shadows are painted
-  after the windows, back to front, so a front
-  window's shadow falls on the windows behind it and is clipped by every
-  window in front; popovers stay flat.  The shadow can be turned off in the
-  Settings app; the WM then uses a zero spread (`shadow_px`), so the damage
-  paths still work without a ring.  Geometry damage expands by the
-  spread, and a focused drag copies the window block but repaints the old
-  and new ring strips with `draw_rect()` because the ring's background is
-  stationary and must not be block-copied.  A resize
+  hover change repaints only the two affected button rectangles.  A resize
   band (`WM_RESIZE_IN` 1 px inside,
   `WM_RESIZE_OUT` 4 px outside every outer edge) is the edge/corner resize
   grab area; corner squares reach `WM_CORNER_IN` (12 px) along both edges.
@@ -714,7 +703,7 @@ it to `0x7E00`.  The kernel region itself only has one wall (`_end` below
   and AC/battery state; Date & Time edits the RTC and runs SNTP; Appearance
   selects a desktop colour and can browse the VFS mounts for a wallpaper
   image (decoded with the image library and written in the same pre-scaled
-  RGB565 format the viewer uses); Windows toggles shadows, edge snapping and
+  RGB565 format the viewer uses); Windows toggles edge snapping and
   drag resistance; About shows version, display, uptime, memory and CPU
   temperature.  The WM is the only process that may focus another window, so
   start menu, dock and popover launchers all go through `SYS_WM_OPEN_SETTINGS`
@@ -1148,7 +1137,7 @@ it to `0x7E00`.  The kernel region itself only has one wall (`_end` below
   `ngui_section` and `ngui_list_row`), three power-mode rows plus brightness
   and AC/battery state, an inline date/time editor (fields, Set, Now, Sync
   NTP), an appearance page with desktop colours and an image file picker, the
-  WM shadow/snapping/resistance toggles, and an About page.
+  WM snapping/resistance toggles, and an About page.
   Hidden SSIDs are omitted, and
   BSSIDs that share an SSID/security collapse to the strongest entry (the
   active BSSID wins while connected).  `wifi.c` (the Intel

+ 7 - 16
docs/graphics.html

@@ -161,22 +161,13 @@
 			inset 8 px from the left; the close control is the Adwaita
 			<code>window-close</code> symbol at the right edge with no red
 			button fill, dimmed while idle and brightened on hover, and it
-			shows the hand cursor. Every normal window also casts a 10 px
-			soft drop shadow: <code>usurf_window_shadow()</code> darkens
-			the ring outside the window edge with a rounded distance
-			falloff, so the corners fade in a curve. The shadow, the edge
-			snapping and the drag resistance can be changed in
-			<code>bin/settings</code> (<em>Windows</em>): the WM keeps a
-			<code>struct wm_prefs</code> in <code>wm_status</code>, applied
-			through <code>SYS_WM_PREFS</code> and persisted in
-			<code>/data/SETTINGS.CFG</code> (or the RAM copy
+			shows the hand cursor. The edge snapping and the drag resistance
+			can be changed in <code>bin/settings</code> (<em>Windows</em>):
+			the WM keeps a <code>struct wm_prefs</code> in
+			<code>wm_status</code>, applied through <code>SYS_WM_PREFS</code>
+			and persisted in <code>/data/SETTINGS.CFG</code> (or the RAM copy
 			<code>/share/settings.cfg</code>).
-			Shadows are painted after the windows, back to front, so a
-			front window's shadow falls on the windows behind it and is
-			clipped by every window in front; popovers stay flat. Geometry
-			damage grows by the shadow spread, while a title-bar drag
-			repaints only the old and new ring strips around the copied
-			window block. The desktop is a configurable flat colour
+			The desktop is a configurable flat colour
 			(<code>wm_prefs.bg_rgb</code>, default <code>#202030</code>);
 			<code>view</code>'s <em>Background</em> button or the
 			Settings app's <em>Appearance</em> page stores a pre-scaled
@@ -568,7 +559,7 @@
 			</div>
 			<div class="card">
 				<h3>settings</h3>
-				<p>The real Settings window: a titled canvas window with a left section sidebar and a scrollable right pane. Network (NIC selection, DHCP, Wi-Fi scan/join/saved networks and details), Power (P-state modes, brightness, AC/battery), Date &amp; Time (RTC editor and SNTP), Appearance (desktop colour and an image picker for the wallpaper), Windows (soft shadows, edge snapping and drag resistance through <code>SYS_WM_PREFS</code>) and About (version, display, uptime, memory, CPU temperature). It is reused by the WM; a pill click focuses it and hands over the requested section.</p>
+				<p>The real Settings window: a titled canvas window with a left section sidebar and a scrollable right pane. Network (NIC selection, DHCP, Wi-Fi scan/join/saved networks and details), Power (P-state modes, brightness, AC/battery), Date &amp; Time (RTC editor and SNTP), Appearance (desktop colour and an image picker for the wallpaper), Windows (edge snapping and drag resistance through <code>SYS_WM_PREFS</code>) and About (version, display, uptime, memory, CPU temperature). It is reused by the WM; a pill click focuses it and hands over the requested section.</p>
 			</div>
 			<div class="card">
 				<h3>netmenu</h3>

+ 2 - 2
docs/userland.html

@@ -331,7 +331,7 @@
 					<tr><td>Storage</td><td>119–120</td><td><code>SYS_BLK_READ(index, lba, buf)</code> reads one raw sector, <code>SYS_MOUNT_CTL(op, ...)</code> sets/gets a mount policy (name, read-only, no automount); used by <code>disks</code></td></tr>
 					<tr><td>Mouse cursor</td><td>117–118, 121</td><td><code>SYS_WIN_SET_CURSOR(shape)</code> sets the caller's content cursor, <code>SYS_WM_SET_CURSOR(shape | -1)</code> is the WM's override for its chrome, and <code>SYS_WM_MOUSE_CAPTURE(on)</code> takes/releases the pointer while the WM drags or resizes a window (shapes in <span class="file">cursor_abi.h</span>)</td></tr>
 					<tr><td>Wallpaper</td><td>123</td><td><code>SYS_WM_WALLPAPER(1)</code> bumps <code>wm_status.wallpaper_seq</code> after a client writes the RGB565 wallpaper file; the WM reloads it and repaints the desktop</td></tr>
-					<tr><td>Settings</td><td>128–129</td><td><code>SYS_WM_PREFS(GET|SET, struct wm_prefs *)</code> exchanges the live WM preferences (shadows, edge snapping, drag resistance and desktop colour); <code>SYS_WM_OPEN_SETTINGS(section)</code> asks the WM to open or focus <code>bin/settings</code> at a section</td></tr>
+					<tr><td>Settings</td><td>128–129</td><td><code>SYS_WM_PREFS(GET|SET, struct wm_prefs *)</code> exchanges the live WM preferences (edge snapping, drag resistance and desktop colour); <code>SYS_WM_OPEN_SETTINGS(section)</code> asks the WM to open or focus <code>bin/settings</code> at a section</td></tr>
 				</tbody>
 			</table>
 		</div>
@@ -466,7 +466,7 @@
 			<li><strong>clock</strong> / <strong>colors</strong> — small window canvas demos.</li>
 			<li><strong>settime</strong> — the standalone Date &amp; Time editor (the Settings app has the same editor on its Date &amp; Time page). It reads and writes the CMOS RTC through <code>SYS_RTC_GET</code>/<code>SYS_RTC_SET</code>; the <em>Sync NTP</em> button asks the kernel's SNTP client (<code>SYS_NTP_SYNC</code>, 106) for UTC and writes the result to the RTC. The two-digit RTC year is expanded over 1970–2069 so dead-battery defaults such as 1980/1990 can be corrected.</li>
 			<li><strong>netmenu</strong> — the top-bar quick-settings popover, opened by clicking anywhere in the right top-bar status area (temperature, date/time, network and AC/battery items). It is a chromeless <code>WIN_F_POPOVER</code> canvas window, anchored flush under the bar at the right screen edge and dismissed by a click outside or <code>Esc</code>. It shows the battery/AC and clock summary, a brightness slider when the panel PWM is present, and six pills: Network, Power, Date &amp; Time, Appearance, Windows and About. A pill is a launcher: it calls <code>SYS_WM_OPEN_SETTINGS(section)</code>, the WM opens or focuses <code>bin/settings</code> at that section, and the popover closes. All editors and lists now live in the Settings window.</li>
-			<li><strong>settings</strong> — the real Settings window (start menu <em>Settings</em>, dock <em>Settings</em>, or <code>settings [section]</code>): a titled canvas window with a left section sidebar and a scrollable right pane. <em>Network</em> lists the present NICs from <code>SYS_NET_DEVLIST</code> (Ethernet, USB Ethernet, RNDIS tethering), selects one with <code>SYS_NET_SELECT</code> and runs DHCP, scans Wi-Fi through <code>SYS_WIFI_SCAN</code>/<code>RESULTS</code>, asks for a WPA2 passphrase (staged in <code>/share/netmenu.wifi</code> because the <code>SYS_SPAWN</code> argument is too short for an SSID plus passphrase), joins saved networks from <code>/data/WIFI.CFG</code>, can forget entries, and shows IP/gateway/DNS/MAC. <em>Power</em> offers the three <code>SYS_CPUFREQ</code> modes, a brightness slider when available and the AC/battery state. <em>Date &amp; Time</em> edits the CMOS RTC through <code>SYS_RTC_GET</code>/<code>SET</code> and syncs UTC with <code>SYS_NTP_SYNC</code>. <em>Appearance</em> selects the desktop colour and a wallpaper image through an in-app file picker that browses the VFS mounts and decodes the chosen image with the image library into the same pre-scaled <code>WALLPAPR.BIN</code>/<code>/share/wallpaper</code> format the viewer uses. <em>Windows</em> toggles soft window shadows, edge snapping and drag resistance; the changes go through <code>SYS_WM_PREFS</code>, apply immediately, and are persisted in <code>/data/SETTINGS.CFG</code> (or <code>/share/settings.cfg</code>). <em>About</em> shows the OS version, display size, uptime, memory and CPU temperature. A second launch is not a second window: the WM focuses the existing one and writes the requested section to <code>/share/settings.req</code>, which the app polls and consumes.</li>
+			<li><strong>settings</strong> — the real Settings window (start menu <em>Settings</em>, dock <em>Settings</em>, or <code>settings [section]</code>): a titled canvas window with a left section sidebar and a scrollable right pane. <em>Network</em> lists the present NICs from <code>SYS_NET_DEVLIST</code> (Ethernet, USB Ethernet, RNDIS tethering), selects one with <code>SYS_NET_SELECT</code> and runs DHCP, scans Wi-Fi through <code>SYS_WIFI_SCAN</code>/<code>RESULTS</code>, asks for a WPA2 passphrase (staged in <code>/share/netmenu.wifi</code> because the <code>SYS_SPAWN</code> argument is too short for an SSID plus passphrase), joins saved networks from <code>/data/WIFI.CFG</code>, can forget entries, and shows IP/gateway/DNS/MAC. <em>Power</em> offers the three <code>SYS_CPUFREQ</code> modes, a brightness slider when available and the AC/battery state. <em>Date &amp; Time</em> edits the CMOS RTC through <code>SYS_RTC_GET</code>/<code>SET</code> and syncs UTC with <code>SYS_NTP_SYNC</code>. <em>Appearance</em> selects the desktop colour and a wallpaper image through an in-app file picker that browses the VFS mounts and decodes the chosen image with the image library into the same pre-scaled <code>WALLPAPR.BIN</code>/<code>/share/wallpaper</code> format the viewer uses. <em>Windows</em> toggles edge snapping and drag resistance; the changes go through <code>SYS_WM_PREFS</code>, apply immediately, and are persisted in <code>/data/SETTINGS.CFG</code> (or <code>/share/settings.cfg</code>). <em>About</em> shows the OS version, display size, uptime, memory and CPU temperature. A second launch is not a second window: the WM focuses the existing one and writes the requested section to <code>/share/settings.req</code>, which the app polls and consumes.</li>
 			<li><strong>wm</strong> / <strong>term</strong> — the ring-3 window manager and terminal launcher used by the desktop.</li>
 		</ul>
 		<p>

+ 1 - 2
include/wm_abi.h

@@ -58,7 +58,6 @@
 #define WM_DEFAULT_BG_RGB 0x202030u
 
 struct wm_prefs {
-	unsigned int shadow;       /* 1 = soft window shadows */
 	unsigned int snap;         /* 1 = snap to screen edges on drop */
 	unsigned int resist;       /* 1 = edge resistance while dragging */
 	unsigned int bg_rgb;       /* desktop colour without a wallpaper */
@@ -66,7 +65,7 @@ struct wm_prefs {
 };
 
 #define WM_PREFS_MAGIC   "NBSET1\0\0"
-#define WM_PREFS_VERSION 1u
+#define WM_PREFS_VERSION 2u
 #define WM_PREFS_DATA    "/data/SETTINGS.CFG"
 #define WM_PREFS_SHARE   "/share/settings.cfg"
 /* The WM writes the requested section here before focusing an already

+ 1 - 2
kernel/wm.c

@@ -56,7 +56,7 @@ static unsigned int wm_wallpaper_seq;
  * WM exchange them through SYS_WM_PREFS.  Defaults match the old hardcoded
  * ring-3 WM behaviour. */
 static struct wm_prefs wm_prefs = {
-	1, 1, 1, WM_DEFAULT_BG_RGB, { 0, 0, 0, 0 }
+	1, 1, WM_DEFAULT_BG_RGB, { 0, 0, 0, 0 }
 };
 static unsigned int wm_prefs_seq;
 static unsigned int wm_settings_req_seq;
@@ -1205,7 +1205,6 @@ static void wm_prefs_sanitize(struct wm_prefs *p)
 {
 	unsigned int i;
 
-	p->shadow = p->shadow ? 1u : 0u;
 	p->snap = p->snap ? 1u : 0u;
 	p->resist = p->resist ? 1u : 0u;
 	p->bg_rgb &= 0x00FFFFFFu;

+ 2 - 17
user/apps/settings/ucmd_settings.c

@@ -8,7 +8,7 @@
  *   Power       P-state mode, panel brightness and AC/battery state
  *   Date & Time CMOS clock editor and SNTP sync
  *   Appearance  desktop colour and a wallpaper image picker
- *   Windows     window shadows, edge snapping and drag resistance
+ *   Windows     edge snapping and drag resistance
  *   About       version, screen, memory and temperature
  *
  * The top-bar control-center popover's pills call SYS_WM_OPEN_SETTINGS, but
@@ -81,7 +81,6 @@
 #define ID_PICK_UP      550
 #define ID_PICK_CANCEL  551
 #define ID_PICK_ROW_BASE 600
-#define ID_WIN_SHADOW   750
 #define ID_WIN_SNAP     751
 #define ID_WIN_RESIST   752
 
@@ -126,7 +125,6 @@ enum {
 	A_PICK_UP,
 	A_PICK_CANCEL,
 	A_PICK_ROW,
-	A_WIN_SHADOW,
 	A_WIN_SNAP,
 	A_WIN_RESIST
 };
@@ -142,7 +140,7 @@ static const struct section_info sections[SEC_COUNT] = {
 	{ "Power",       "Mode and brightness",    "power" },
 	{ "Date & Time", "Clock and time sync",    "time" },
 	{ "Appearance",  "Desktop background",     "appearance" },
-	{ "Windows",     "Shadows and snapping",   "windows" },
+	{ "Windows",     "Snapping and dragging",  "windows" },
 	{ "About",       "System information",     "about" }
 };
 
@@ -340,7 +338,6 @@ static int section_from_name(const char *name)
 static void prefs_defaults(void)
 {
 	memset(&prefs, 0, sizeof(prefs));
-	prefs.shadow = 1;
 	prefs.snap = 1;
 	prefs.resist = 1;
 	prefs.bg_rgb = WM_DEFAULT_BG_RGB;
@@ -373,7 +370,6 @@ static int prefs_file_load(void)
 		    f->version != WM_PREFS_VERSION)
 			continue;
 		prefs = f->prefs;
-		prefs.shadow = prefs.shadow ? 1u : 0u;
 		prefs.snap = prefs.snap ? 1u : 0u;
 		prefs.resist = prefs.resist ? 1u : 0u;
 		prefs.bg_rgb &= 0x00FFFFFFu;
@@ -2354,12 +2350,6 @@ static void draw_windows(struct ngui_rect area, int *yy)
 		       "boot.", ui.theme.text_dim);
 	y += 26;
 
-	r = (struct ngui_rect){ area.x, y, area.w, 44 };
-	if (settings_row(ID_WIN_SHADOW, r, "Window shadows",
-			 "Soft drop shadow around normal windows",
-			 prefs.shadow ? "On" : "Off", prefs.shadow ? 1 : 0, -1))
-		request_action(A_WIN_SHADOW, 0);
-	y += 46;
 	r = (struct ngui_rect){ area.x, y, area.w, 44 };
 	if (settings_row(ID_WIN_SNAP, r, "Snap windows",
 			 "Drag a title bar to a screen edge to snap it",
@@ -2766,11 +2756,6 @@ static void handle_action(void)
 	case A_PICK_ROW:
 		picker_activate(arg);
 		break;
-	case A_WIN_SHADOW:
-		prefs.shadow = prefs.shadow ? 0 : 1;
-		commit_prefs(prefs.shadow ? "Window shadows enabled" :
-					    "Window shadows disabled");
-		break;
 	case A_WIN_SNAP:
 		prefs.snap = prefs.snap ? 0 : 1;
 		commit_prefs(prefs.snap ? "Edge snapping enabled" :

+ 46 - 200
user/apps/wm/ucmd_wm.c

@@ -25,10 +25,6 @@
 #define WM_CLOSE_INSET    3
 #define WM_CLOSE_ICON_PX  16
 
-/* Soft drop shadow around normal windows: this many pixels outside every
- * edge.  Geometry damage expands by it and the shadow pass paints the ring. */
-#define WM_SHADOW_SPREAD  10
-
 struct uwin {
 	struct wm_window_info info;
 	struct wm_map_info map;
@@ -88,10 +84,9 @@ static unsigned int wall_rgb32[65536];
 /* Settings pushed by the Settings app through SYS_WM_PREFS.  The kernel
  * keeps them across a WM restart; the app loads the file at boot and pushes
  * it here. */
-static struct wm_prefs prefs = { 1, 1, 1, WM_DEFAULT_BG_RGB, { 0, 0, 0, 0 } };
+static struct wm_prefs prefs = { 1, 1, WM_DEFAULT_BG_RGB, { 0, 0, 0, 0 } };
 static unsigned int prefs_seq_seen;
 static int prefs_seen_valid;
-static int shadow_px = WM_SHADOW_SPREAD;
 static unsigned int desktop_rgb = WM_DEFAULT_BG_RGB;
 /* Settings app launcher: SYS_WM_OPEN_SETTINGS bumps a request counter in
  * wm_status.  One window is reused, and a section request for a running app
@@ -987,85 +982,6 @@ static unsigned int rect_sub(struct orect *out, const struct orect *r,
 	return n;
 }
 
-/* cur = cur minus cut, using nxt as scratch.  Returns the new rectangle
- * count; 0 also means the region is empty or the scratch list overflowed. */
-static unsigned int region_sub(struct orect *cur, unsigned int ncur,
-			       struct orect *nxt, const struct orect *cut)
-{
-	unsigned int k, n = 0;
-
-	for (k = 0; k < ncur; k++) {
-		if (n + 4 > OCC_MAX)
-			return 0;
-		n += rect_sub(&nxt[n], &cur[k], cut);
-	}
-	for (k = 0; k < n; k++)
-		cur[k] = nxt[k];
-	return n;
-}
-
-/* Soft shadows are painted after the windows, back to front, so a front
- * window's shadow falls on the windows behind it while every window and
- * every window in front of it occludes that shadow.  Only the damage
- * rectangle is touched. */
-static void draw_shadows(const struct orect *dmg)
-{
-	static struct orect cur[OCC_MAX], nxt[OCC_MAX];
-	int order[WM_MAX_WINDOWS];
-	unsigned int n = build_order(order), i, j, ncur;
-
-	if (shadow_px <= 0)
-		return;
-	for (i = n; i-- > 0;) {
-		struct uwin *u = &wins[order[i]];
-		struct orect own, fr;
-		int x0, y0, x1, y1;
-
-		if (!u->info.used || u->info.popover)
-			continue;
-		x0 = u->info.x - shadow_px;
-		y0 = u->info.y - shadow_px;
-		x1 = u->info.x + (int)u->info.w + shadow_px;
-		y1 = u->info.y + (int)u->info.h + shadow_px;
-		if (x0 < dmg->x) x0 = dmg->x;
-		if (y0 < dmg->y) y0 = dmg->y;
-		if (x1 > dmg->x + (int)dmg->w) x1 = dmg->x + (int)dmg->w;
-		if (y1 > dmg->y + (int)dmg->h) y1 = dmg->y + (int)dmg->h;
-		if (y0 < WM_BAR_H) y0 = WM_BAR_H;
-		if (x1 <= x0 || y1 <= y0)
-			continue;
-		cur[0].x = x0;
-		cur[0].y = y0;
-		cur[0].w = (unsigned int)(x1 - x0);
-		cur[0].h = (unsigned int)(y1 - y0);
-		ncur = 1;
-		own.x = u->info.x;
-		own.y = u->info.y;
-		own.w = u->info.w;
-		own.h = u->info.h;
-		ncur = region_sub(cur, ncur, nxt, &own);
-		for (j = 0; j < i && ncur; j++) {
-			struct uwin *f = &wins[order[j]];
-
-			if (!f->info.used)
-				continue;
-			fr.x = f->info.x;
-			fr.y = f->info.y;
-			fr.w = f->info.w;
-			fr.h = f->info.h;
-			ncur = region_sub(cur, ncur, nxt, &fr);
-		}
-		if (!ncur)
-			continue;
-		for (j = 0; j < ncur; j++)
-			usurf_window_shadow(&screen, u->info.x, u->info.y,
-					    (int)u->info.w, (int)u->info.h,
-					    shadow_px,
-					    cur[j].x, cur[j].y,
-					    cur[j].w, cur[j].h);
-	}
-}
-
 static void wall_build_maps(void)
 {
 	unsigned int i;
@@ -1143,7 +1059,6 @@ static void wall_load(void)
 
 static void apply_prefs(void)
 {
-	shadow_px = prefs.shadow ? WM_SHADOW_SPREAD : 0;
 	desktop_rgb = prefs.bg_rgb & 0x00FFFFFFu;
 }
 
@@ -1271,15 +1186,6 @@ static void draw_rect_naive(int x, int y, unsigned int w, unsigned int h)
 		    y < wins[i].info.y + (int)wins[i].info.h &&
 		    y + (int)h > wins[i].info.y)
 			draw_window_clip(i, x, y, w, h);
-	{
-		struct orect dmg;
-
-		dmg.x = x;
-		dmg.y = y;
-		dmg.w = w;
-		dmg.h = h;
-		draw_shadows(&dmg);
-	}
 }
 
 static void draw_rect(int x, int y, unsigned int w, unsigned int h)
@@ -1351,11 +1257,8 @@ static void draw_rect(int x, int y, unsigned int w, unsigned int h)
 			draw_window_clip((unsigned int)order[i], cur[j].x,
 					 cur[j].y, cur[j].w, cur[j].h);
 	}
-	if (overflow) {
+	if (overflow)
 		draw_rect_naive(dmg.x, dmg.y, dmg.w, dmg.h);
-		return;
-	}
-	draw_shadows(&dmg);
 }
 
 /* Invisible resize border: edge bits for a point in the band around the
@@ -1529,26 +1432,6 @@ static void add_rect(struct wm_present_info *p, int x, int y,
 	}
 }
 
-/* The rectangle a window occupies including its drop shadow, clipped below
- * the top bar. */
-static void window_shadow_rect(struct orect *r, int x, int y,
-			       unsigned int w, unsigned int h)
-{
-	r->x = x - shadow_px;
-	r->y = y - shadow_px;
-	r->w = w + 2 * (unsigned int)shadow_px;
-	r->h = h + 2 * (unsigned int)shadow_px;
-	if (r->y < WM_BAR_H) {
-		unsigned int cut = (unsigned int)(WM_BAR_H - r->y);
-
-		if (cut >= r->h)
-			r->h = 0;
-		else
-			r->h -= cut;
-		r->y = WM_BAR_H;
-	}
-}
-
 /* Damage rectangle covering one window's close button, for a hover change. */
 static void close_add_damage(struct wm_present_info *p, int idx)
 {
@@ -1682,18 +1565,16 @@ static int shadow_overlay_covers(int x, int y, int w, int h)
 	return 0;
 }
 
-/* A focused window is topmost, so the screen shadow contains exactly its
- * pixels in the old rectangle, unless the dock or the brightness OSD covers
- * part of it.  Copy that block, repaint the old ring the new window does not
- * cover, and repaint the new shadow ring (its background is stationary and
- * may differ from the old position, so the ring is never block-copied).
- * When either window rectangle is partly off-screen, or an overlay hid part
- * of the source, repaint the whole new shadow rect instead of copying
- * overlay pixels into the window. */
+/* A focused window is topmost, so the shadow contains exactly its pixels in
+ * the old rectangle, unless the dock or the brightness OSD covers part of
+ * it.  Move that block and repaint only the old part the new rectangle does
+ * not cover.  When either rectangle is partly off-screen, or an overlay hid
+ * part of the source, the shadow has no valid pixels there, so repaint the
+ * new rect instead of copying overlay pixels into the window. */
 static void move_window_pixels(struct uwin *u, int ox, int oy, int nx, int ny)
 {
 	struct wm_present_info present;
-	struct orect old_sh, new_sh, new_win, pieces[4];
+	struct orect oldr, newr, pieces[4];
 	unsigned int np, k;
 	int w = (int)u->info.w, h = (int)u->info.h;
 	int old_on = ox >= 0 && oy >= 0 &&
@@ -1702,47 +1583,34 @@ static void move_window_pixels(struct uwin *u, int ox, int oy, int nx, int ny)
 	int new_on = nx >= 0 && ny >= 0 &&
 		     nx + w <= (int)fbw && ny + h <= (int)fbh;
 
-	window_shadow_rect(&old_sh, ox, oy, u->info.w, u->info.h);
-	window_shadow_rect(&new_sh, nx, ny, u->info.w, u->info.h);
-	new_win.x = nx;
-	new_win.y = ny;
-	new_win.w = u->info.w;
-	new_win.h = u->info.h;
 	if (u_wm_begin() != 0)
 		return;
 	remap_window_contents();
 	if (old_on && new_on)
 		usurf_copy(&screen, nx, ny, ox, oy, u->info.w, u->info.h);
-	/* Everything the old shadow rect covered outside the new window and
-	 * its shadow.  The new ring is repainted below, so cutting it out here
-	 * also keeps its falloff from being darkened twice. */
-	np = rect_sub(pieces, &old_sh, &new_sh);
+	else
+		draw_rect(nx, ny, u->info.w, u->info.h);
+	oldr.x = ox;
+	oldr.y = oy;
+	oldr.w = u->info.w;
+	oldr.h = u->info.h;
+	newr.x = nx;
+	newr.y = ny;
+	newr.w = u->info.w;
+	newr.h = u->info.h;
+	np = rect_sub(pieces, &oldr, &newr);
 	for (k = 0; k < np; k++)
 		draw_rect(pieces[k].x, pieces[k].y, pieces[k].w, pieces[k].h);
-	if (old_on && new_on) {
-		/* Only the ring around the new position; its interior is the
-		 * copied window block. */
-		np = rect_sub(pieces, &new_sh, &new_win);
-		for (k = 0; k < np; k++)
-			draw_rect(pieces[k].x, pieces[k].y,
-				  pieces[k].w, pieces[k].h);
-	} else {
-		draw_rect(new_sh.x, new_sh.y, new_sh.w, new_sh.h);
-	}
 	present.count = 0;
 	present.immediate = 1;
-	/* Present the union of the old and new shadow rectangles as one
-	 * rect.  The screen shadow is correct for all of it, and one rect
-	 * cannot be cut off by the kernel's four-entry present list. */
+	/* 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 = old_sh.x < new_sh.x ? old_sh.x : new_sh.x;
-		int uy0 = old_sh.y < new_sh.y ? old_sh.y : new_sh.y;
-		int ox1 = old_sh.x + (int)old_sh.w;
-		int oy1 = old_sh.y + (int)old_sh.h;
-		int nx1 = new_sh.x + (int)new_sh.w;
-		int ny1 = new_sh.y + (int)new_sh.h;
-		int ux1 = ox1 > nx1 ? ox1 : nx1;
-		int uy1 = oy1 > ny1 ? oy1 : ny1;
+		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));
@@ -1756,29 +1624,22 @@ static int iabs(int v)
 	return v < 0 ? -v : v;
 }
 
-/* Repaint the old and new rectangles of a geometry change.  The old rect
- * is cut by the new one and the new rect drawn last, so a pixel in the
- * overlap gets its window and shadow exactly once. */
+/* Repaint the old and new rectangles of a geometry change. */
 static void redraw_geom(struct uwin *u, int ox, int oy,
 			unsigned int ow, unsigned int oh)
 {
 	struct wm_present_info present;
-	struct orect oldr, newr, pieces[4];
-	unsigned int i, np;
+	unsigned int i;
 
-	window_shadow_rect(&oldr, ox, oy, ow, oh);
-	window_shadow_rect(&newr, u->info.x, u->info.y, u->info.w, u->info.h);
 	present.count = 0;
 	present.immediate = 1;
-	add_rect(&present, oldr.x, oldr.y, oldr.w, oldr.h);
-	add_rect(&present, newr.x, newr.y, newr.w, newr.h);
+	add_rect(&present, ox, oy, ow, oh);
+	add_rect(&present, u->info.x, u->info.y, u->info.w, u->info.h);
 	if (u_wm_begin() == 0) {
 		remap_window_contents();
-		np = rect_sub(pieces, &oldr, &newr);
-		for (i = 0; i < np; i++)
-			draw_rect(pieces[i].x, pieces[i].y,
-				  pieces[i].w, pieces[i].h);
-		draw_rect(newr.x, newr.y, newr.w, newr.h);
+		for (i = 0; i < present.count; i++)
+			draw_rect(present.rect[i].x, present.rect[i].y,
+				  present.rect[i].w, present.rect[i].h);
 		wm_overlays(&present);
 		u_wm_present(&present);
 	}
@@ -3514,8 +3375,7 @@ static void handle_mouse(struct wm_status *st)
 				clamp_geom(u, &nx, &ny);
 				if (nx != ox || ny != oy) {
 					struct wm_present_info present;
-					struct orect oldr, newr, pieces[4];
-					unsigned int i, np;
+					unsigned int i;
 
 					u_wm_set_geom((unsigned int)drag_id,
 						      nx, ny);
@@ -3525,33 +3385,21 @@ static void handle_mouse(struct wm_status *st)
 						move_window_pixels(u, ox, oy,
 								   nx, ny);
 					} else {
-						window_shadow_rect(&oldr, ox, oy,
-								   u->info.w,
-								   u->info.h);
-						window_shadow_rect(&newr, nx, ny,
-								   u->info.w,
-								   u->info.h);
 						present.count = 0;
 						present.immediate = 1;
-						add_rect(&present, oldr.x,
-							 oldr.y, oldr.w,
-							 oldr.h);
-						add_rect(&present, newr.x,
-							 newr.y, newr.w,
-							 newr.h);
+						add_rect(&present, ox, oy,
+							 u->info.w, u->info.h);
+						add_rect(&present, nx, ny,
+							 u->info.w, u->info.h);
 						if (u_wm_begin() == 0) {
 							remap_window_contents();
-							np = rect_sub(pieces,
-								      &oldr,
-								      &newr);
-							for (i = 0; i < np; i++)
+							for (i = 0;
+							     i < present.count; i++)
 								draw_rect(
-								  pieces[i].x,
-								  pieces[i].y,
-								  pieces[i].w,
-								  pieces[i].h);
-							draw_rect(newr.x, newr.y,
-								  newr.w, newr.h);
+								  present.rect[i].x,
+								  present.rect[i].y,
+								  present.rect[i].w,
+								  present.rect[i].h);
 							wm_overlays(&present);
 							u_wm_present(&present);
 						}
@@ -3667,15 +3515,13 @@ void _start(const char *arg)
 		if (u_wm_poll(&st) != 0)
 			u_exit(1);
 		if (!prefs_seen_valid || st.prefs_seq != prefs_seq_seen) {
-			unsigned int old_shadow = (unsigned int)shadow_px;
 			unsigned int old_bg = desktop_rgb;
 
 			prefs = st.prefs;
 			prefs_seq_seen = st.prefs_seq;
 			prefs_seen_valid = 1;
 			apply_prefs();
-			if (old_shadow != (unsigned int)shadow_px ||
-			    old_bg != desktop_rgb)
+			if (old_bg != desktop_rgb)
 				full_redraw = 1;
 		}
 		if (!settings_req_seen_valid) {

+ 0 - 119
user/lib/uwm/uwm_lib.c

@@ -155,125 +155,6 @@ int usurf_icon(struct usurf *s, int x, int y, enum uwm_icon icon,
 	return usurf_icon_clip(s, x, y, icon, rgb, 0, 0, s->w, s->h);
 }
 
-/* ---- Window drop shadow ------------------------------------------------ */
-#define SHADOW_FALLOFF_N 11
-static const unsigned char shadow_falloff[SHADOW_FALLOFF_N] = {
-	0, 120, 110, 100, 90, 80, 69, 58, 46, 33, 20
-};
-
-/* Darken one band outside (wx,wy)-(wx1,wy1).  The alpha comes from the
- * rounded distance to the window edge (max + 0.4 * min), so the four bands
- * together form a soft ring whose corners fade in a curve instead of a
- * square corner, without touching the window interior. */
-static void shadow_band(struct usurf *s, int x0, int y0, int x1, int y1,
-			int wx, int wy, int wx1, int wy1, int spread,
-			int bytes)
-{
-	int x, y;
-
-	for (y = y0; y < y1; y++) {
-		unsigned char *row = s->px + (unsigned long)y * s->pitch;
-		int dy = 0;
-
-		if (y < wy)
-			dy = wy - y;
-		else if (y >= wy1)
-			dy = y - wy1 + 1;
-		for (x = x0; x < x1; x++) {
-			int dx = 0, d, lo, hi;
-			unsigned int a, ia;
-			unsigned char *p;
-
-			if (x < wx)
-				dx = wx - x;
-			else if (x >= wx1)
-				dx = x - wx1 + 1;
-			lo = dx < dy ? dx : dy;
-			hi = dx < dy ? dy : dx;
-			d = hi + ((lo * 13) >> 5);
-			if (d <= 0 || d > spread)
-				continue;
-			if (d >= SHADOW_FALLOFF_N)
-				d = SHADOW_FALLOFF_N - 1;
-			a = shadow_falloff[d];
-			if (!a)
-				continue;
-			ia = 256 - a;
-			usurf_pixels++;
-			if (s->bpp == 16) {
-				unsigned short *q = (unsigned short *)row + x;
-				unsigned int v = *q;
-				unsigned int r = ((((v >> 11) & 0x1F) * ia)
-						  + 128) >> 8;
-				unsigned int g = ((((v >> 5) & 0x3F) * ia)
-						  + 128) >> 8;
-				unsigned int b = (((v & 0x1F) * ia)
-						  + 128) >> 8;
-
-				*q = (unsigned short)((r << 11) | (g << 5) | b);
-			} else {
-				p = row + x * bytes;
-				p[0] = (unsigned char)((p[0] * ia + 128) >> 8);
-				p[1] = (unsigned char)((p[1] * ia + 128) >> 8);
-				p[2] = (unsigned char)((p[2] * ia + 128) >> 8);
-				if (s->bpp == 32)
-					p[3] = 0xFF;
-			}
-		}
-	}
-}
-
-/* A soft drop shadow around a window rectangle: `spread` pixels outward,
- * strongest next to the window.  The window interior is never touched and
- * the whole ring is clipped to (cx,cy,cw,ch); callers pass the current
- * damage rectangle so a partial repaint only darkens pixels it owns. */
-void usurf_window_shadow(struct usurf *s, int wx, int wy, int ww, int wh,
-			 int spread, int cx, int cy,
-			 unsigned int cw, unsigned int ch)
-{
-	int wx1 = wx + ww, wy1 = wy + wh;
-	int x0, y0, x1, y1, ix0, iy0, ix1, iy1;
-	int bytes;
-
-	if (!s || !s->px || ww <= 0 || wh <= 0 || spread <= 0)
-		return;
-	if (s->bpp != 16 && s->bpp != 24 && s->bpp != 32)
-		return;
-	bytes = (int)(s->bpp / 8);
-	x0 = wx - spread;
-	y0 = wy - spread;
-	x1 = wx1 + spread;
-	y1 = wy1 + spread;
-	ix0 = cx;
-	iy0 = cy;
-	ix1 = cx + (int)cw;
-	iy1 = cy + (int)ch;
-	if (ix0 < 0) ix0 = 0;
-	if (iy0 < 0) iy0 = 0;
-	if (ix1 > (int)s->w) ix1 = (int)s->w;
-	if (iy1 > (int)s->h) iy1 = (int)s->h;
-	if (x0 < ix0) x0 = ix0;
-	if (y0 < iy0) y0 = iy0;
-	if (x1 > ix1) x1 = ix1;
-	if (y1 > iy1) y1 = iy1;
-	if (x1 <= x0 || y1 <= y0)
-		return;
-	/* Corners belong to the top and bottom bands. */
-	shadow_band(s, x0, y0, x1, wy < y1 ? wy : y1,
-		    wx, wy, wx1, wy1, spread, bytes);
-	shadow_band(s, x0, wy1 > y0 ? wy1 : y0, x1, y1,
-		    wx, wy, wx1, wy1, spread, bytes);
-	{
-		int by0 = wy > y0 ? wy : y0;
-		int by1 = wy1 < y1 ? wy1 : y1;
-
-		shadow_band(s, x0, by0, wx < x1 ? wx : x1, by1,
-			    wx, wy, wx1, wy1, spread, bytes);
-		shadow_band(s, wx1 > x0 ? wx1 : x0, by0, x1, by1,
-			    wx, wy, wx1, wy1, spread, bytes);
-	}
-}
-
 /* ---- Full-colour app icons -------------------------------------------- */
 #define UWM_APP_BYTES (APP_ICON_PX * APP_ICON_PX * 3u)
 

+ 0 - 7
user/lib/uwm/uwm_lib.h

@@ -66,13 +66,6 @@ int usurf_icon_clip(struct usurf *s, int x, int y, enum uwm_icon icon,
 		    unsigned int rgb, int cx, int cy,
 		    unsigned int cw, unsigned int ch);
 
-/* Soft drop shadow around a window rectangle: `spread` pixels outward,
- * darkest next to the edge, clipped to (cx,cy,cw,ch).  The window interior
- * is not modified. */
-void usurf_window_shadow(struct usurf *s, int wx, int wy, int ww, int wh,
-			 int spread, int cx, int cy,
-			 unsigned int cw, unsigned int ch);
-
 /* Draw one full-colour app icon from /ramfs/icons/apps96.icn, scaled to
  * size x size and centred at (x, y).  Returns 0 when the bundle (or that
  * id) is not available, so the caller can fall back to a letter tile. */