|
@@ -25,6 +25,10 @@
|
|
|
#define WM_CLOSE_INSET 3
|
|
#define WM_CLOSE_INSET 3
|
|
|
#define WM_CLOSE_ICON_PX 16
|
|
#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 uwin {
|
|
|
struct wm_window_info info;
|
|
struct wm_window_info info;
|
|
|
struct wm_map_info map;
|
|
struct wm_map_info map;
|
|
@@ -965,6 +969,83 @@ static unsigned int rect_sub(struct orect *out, const struct orect *r,
|
|
|
return n;
|
|
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;
|
|
|
|
|
+
|
|
|
|
|
+ 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 - WM_SHADOW_SPREAD;
|
|
|
|
|
+ y0 = u->info.y - WM_SHADOW_SPREAD;
|
|
|
|
|
+ x1 = u->info.x + (int)u->info.w + WM_SHADOW_SPREAD;
|
|
|
|
|
+ y1 = u->info.y + (int)u->info.h + WM_SHADOW_SPREAD;
|
|
|
|
|
+ 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,
|
|
|
|
|
+ WM_SHADOW_SPREAD,
|
|
|
|
|
+ cur[j].x, cur[j].y,
|
|
|
|
|
+ cur[j].w, cur[j].h);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
static void wall_build_maps(void)
|
|
static void wall_build_maps(void)
|
|
|
{
|
|
{
|
|
|
unsigned int i;
|
|
unsigned int i;
|
|
@@ -1130,6 +1211,15 @@ 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 < wins[i].info.y + (int)wins[i].info.h &&
|
|
|
y + (int)h > wins[i].info.y)
|
|
y + (int)h > wins[i].info.y)
|
|
|
draw_window_clip(i, x, y, w, h);
|
|
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)
|
|
static void draw_rect(int x, int y, unsigned int w, unsigned int h)
|
|
@@ -1201,8 +1291,11 @@ static void draw_rect(int x, int y, unsigned int w, unsigned int h)
|
|
|
draw_window_clip((unsigned int)order[i], cur[j].x,
|
|
draw_window_clip((unsigned int)order[i], cur[j].x,
|
|
|
cur[j].y, cur[j].w, cur[j].h);
|
|
cur[j].y, cur[j].w, cur[j].h);
|
|
|
}
|
|
}
|
|
|
- if (overflow)
|
|
|
|
|
|
|
+ if (overflow) {
|
|
|
draw_rect_naive(dmg.x, dmg.y, dmg.w, dmg.h);
|
|
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
|
|
/* Invisible resize border: edge bits for a point in the band around the
|
|
@@ -1376,6 +1469,26 @@ 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 - WM_SHADOW_SPREAD;
|
|
|
|
|
+ r->y = y - WM_SHADOW_SPREAD;
|
|
|
|
|
+ r->w = w + 2 * WM_SHADOW_SPREAD;
|
|
|
|
|
+ r->h = h + 2 * WM_SHADOW_SPREAD;
|
|
|
|
|
+ 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. */
|
|
/* Damage rectangle covering one window's close button, for a hover change. */
|
|
|
static void close_add_damage(struct wm_present_info *p, int idx)
|
|
static void close_add_damage(struct wm_present_info *p, int idx)
|
|
|
{
|
|
{
|
|
@@ -1509,16 +1622,18 @@ static int shadow_overlay_covers(int x, int y, int w, int h)
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-/* 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. */
|
|
|
|
|
|
|
+/* 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. */
|
|
|
static void move_window_pixels(struct uwin *u, int ox, int oy, int nx, int ny)
|
|
static void move_window_pixels(struct uwin *u, int ox, int oy, int nx, int ny)
|
|
|
{
|
|
{
|
|
|
struct wm_present_info present;
|
|
struct wm_present_info present;
|
|
|
- struct orect oldr, newr, pieces[4];
|
|
|
|
|
|
|
+ struct orect old_sh, new_sh, new_win, pieces[4];
|
|
|
unsigned int np, k;
|
|
unsigned int np, k;
|
|
|
int w = (int)u->info.w, h = (int)u->info.h;
|
|
int w = (int)u->info.w, h = (int)u->info.h;
|
|
|
int old_on = ox >= 0 && oy >= 0 &&
|
|
int old_on = ox >= 0 && oy >= 0 &&
|
|
@@ -1527,34 +1642,47 @@ static void move_window_pixels(struct uwin *u, int ox, int oy, int nx, int ny)
|
|
|
int new_on = nx >= 0 && ny >= 0 &&
|
|
int new_on = nx >= 0 && ny >= 0 &&
|
|
|
nx + w <= (int)fbw && ny + h <= (int)fbh;
|
|
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)
|
|
if (u_wm_begin() != 0)
|
|
|
return;
|
|
return;
|
|
|
remap_window_contents();
|
|
remap_window_contents();
|
|
|
if (old_on && new_on)
|
|
if (old_on && new_on)
|
|
|
usurf_copy(&screen, nx, ny, ox, oy, u->info.w, u->info.h);
|
|
usurf_copy(&screen, nx, ny, ox, oy, u->info.w, u->info.h);
|
|
|
- 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);
|
|
|
|
|
|
|
+ /* 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);
|
|
|
for (k = 0; k < np; k++)
|
|
for (k = 0; k < np; k++)
|
|
|
draw_rect(pieces[k].x, pieces[k].y, pieces[k].w, pieces[k].h);
|
|
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.count = 0;
|
|
|
present.immediate = 1;
|
|
present.immediate = 1;
|
|
|
- /* 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. */
|
|
|
|
|
|
|
+ /* 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. */
|
|
|
{
|
|
{
|
|
|
- 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;
|
|
|
|
|
|
|
+ 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;
|
|
|
|
|
|
|
|
add_rect(&present, ux0, uy0, (unsigned int)(ux1 - ux0),
|
|
add_rect(&present, ux0, uy0, (unsigned int)(ux1 - ux0),
|
|
|
(unsigned int)(uy1 - uy0));
|
|
(unsigned int)(uy1 - uy0));
|
|
@@ -1568,22 +1696,29 @@ static int iabs(int v)
|
|
|
return v < 0 ? -v : v;
|
|
return v < 0 ? -v : v;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-/* Repaint the old and new rectangles of a geometry change. */
|
|
|
|
|
|
|
+/* 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. */
|
|
|
static void redraw_geom(struct uwin *u, int ox, int oy,
|
|
static void redraw_geom(struct uwin *u, int ox, int oy,
|
|
|
unsigned int ow, unsigned int oh)
|
|
unsigned int ow, unsigned int oh)
|
|
|
{
|
|
{
|
|
|
struct wm_present_info present;
|
|
struct wm_present_info present;
|
|
|
- unsigned int i;
|
|
|
|
|
|
|
+ struct orect oldr, newr, pieces[4];
|
|
|
|
|
+ unsigned int i, np;
|
|
|
|
|
|
|
|
|
|
+ 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.count = 0;
|
|
|
present.immediate = 1;
|
|
present.immediate = 1;
|
|
|
- add_rect(&present, ox, oy, ow, oh);
|
|
|
|
|
- add_rect(&present, u->info.x, u->info.y, u->info.w, u->info.h);
|
|
|
|
|
|
|
+ add_rect(&present, oldr.x, oldr.y, oldr.w, oldr.h);
|
|
|
|
|
+ add_rect(&present, newr.x, newr.y, newr.w, newr.h);
|
|
|
if (u_wm_begin() == 0) {
|
|
if (u_wm_begin() == 0) {
|
|
|
remap_window_contents();
|
|
remap_window_contents();
|
|
|
- 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);
|
|
|
|
|
|
|
+ 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);
|
|
|
wm_overlays(&present);
|
|
wm_overlays(&present);
|
|
|
u_wm_present(&present);
|
|
u_wm_present(&present);
|
|
|
}
|
|
}
|
|
@@ -3241,7 +3376,8 @@ static void handle_mouse(struct wm_status *st)
|
|
|
clamp_geom(u, &nx, &ny);
|
|
clamp_geom(u, &nx, &ny);
|
|
|
if (nx != ox || ny != oy) {
|
|
if (nx != ox || ny != oy) {
|
|
|
struct wm_present_info present;
|
|
struct wm_present_info present;
|
|
|
- unsigned int i;
|
|
|
|
|
|
|
+ struct orect oldr, newr, pieces[4];
|
|
|
|
|
+ unsigned int i, np;
|
|
|
|
|
|
|
|
u_wm_set_geom((unsigned int)drag_id,
|
|
u_wm_set_geom((unsigned int)drag_id,
|
|
|
nx, ny);
|
|
nx, ny);
|
|
@@ -3251,21 +3387,33 @@ static void handle_mouse(struct wm_status *st)
|
|
|
move_window_pixels(u, ox, oy,
|
|
move_window_pixels(u, ox, oy,
|
|
|
nx, ny);
|
|
nx, ny);
|
|
|
} else {
|
|
} 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.count = 0;
|
|
|
present.immediate = 1;
|
|
present.immediate = 1;
|
|
|
- add_rect(&present, ox, oy,
|
|
|
|
|
- u->info.w, u->info.h);
|
|
|
|
|
- add_rect(&present, nx, ny,
|
|
|
|
|
- u->info.w, u->info.h);
|
|
|
|
|
|
|
+ add_rect(&present, oldr.x,
|
|
|
|
|
+ oldr.y, oldr.w,
|
|
|
|
|
+ oldr.h);
|
|
|
|
|
+ add_rect(&present, newr.x,
|
|
|
|
|
+ newr.y, newr.w,
|
|
|
|
|
+ newr.h);
|
|
|
if (u_wm_begin() == 0) {
|
|
if (u_wm_begin() == 0) {
|
|
|
remap_window_contents();
|
|
remap_window_contents();
|
|
|
- for (i = 0;
|
|
|
|
|
- i < present.count; i++)
|
|
|
|
|
|
|
+ np = rect_sub(pieces,
|
|
|
|
|
+ &oldr,
|
|
|
|
|
+ &newr);
|
|
|
|
|
+ for (i = 0; i < np; i++)
|
|
|
draw_rect(
|
|
draw_rect(
|
|
|
- present.rect[i].x,
|
|
|
|
|
- present.rect[i].y,
|
|
|
|
|
- present.rect[i].w,
|
|
|
|
|
- present.rect[i].h);
|
|
|
|
|
|
|
+ pieces[i].x,
|
|
|
|
|
+ pieces[i].y,
|
|
|
|
|
+ pieces[i].w,
|
|
|
|
|
+ pieces[i].h);
|
|
|
|
|
+ draw_rect(newr.x, newr.y,
|
|
|
|
|
+ newr.w, newr.h);
|
|
|
wm_overlays(&present);
|
|
wm_overlays(&present);
|
|
|
u_wm_present(&present);
|
|
u_wm_present(&present);
|
|
|
}
|
|
}
|