Skip to content

Commit a83139d

Browse files
committed
fix(desktop): bound snapshot helper strips to the content edge
1 parent 4a970d3 commit a83139d

2 files changed

Lines changed: 48 additions & 0 deletions

File tree

‎apps/desktop/src/snapShot/ActiveWindow.test.ts‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,18 @@ it.each([
101101
bounds: { x: 0, y: 161, width: 1_800, height: 1_008 },
102102
},
103103
},
104+
{
105+
name: "vertical strips at a negative desktop origin",
106+
helpers: [
107+
{ id: 1, title: "", bounds: { x: -122, y: -100, width: 41, height: 1_000 } },
108+
{ id: 2, title: "", bounds: { x: -81, y: -100, width: 81, height: 1_000 } },
109+
],
110+
content: {
111+
id: 3,
112+
title: "Document",
113+
bounds: { x: 0, y: -100, width: 1_008, height: 1_000 },
114+
},
115+
},
104116
{
105117
name: "a smaller front window's strips with a larger background window",
106118
helpers: [
@@ -130,6 +142,36 @@ it.each([
130142
{ name: "titled palette", title: "Palette", bounds: { x: 0, y: 0, width: 800, height: 50 } },
131143
{ name: "offset untitled strip", title: "", bounds: { x: 100, y: 100, width: 800, height: 50 } },
132144
{ name: "tall untitled window", title: "", bounds: { x: 0, y: 0, width: 800, height: 900 } },
145+
{
146+
name: "horizontal strip below the document",
147+
title: "",
148+
bounds: { x: 0, y: 1_200, width: 800, height: 50 },
149+
},
150+
{
151+
name: "horizontal strip inside the document",
152+
title: "",
153+
bounds: { x: 0, y: 600, width: 800, height: 50 },
154+
},
155+
{
156+
name: "horizontal strip far above the document",
157+
title: "",
158+
bounds: { x: 0, y: -300, width: 800, height: 50 },
159+
},
160+
{
161+
name: "vertical strip right of the document",
162+
title: "",
163+
bounds: { x: 900, y: 0, width: 50, height: 1_000 },
164+
},
165+
{
166+
name: "vertical strip inside the document",
167+
title: "",
168+
bounds: { x: 400, y: 0, width: 50, height: 1_000 },
169+
},
170+
{
171+
name: "vertical strip far left of the document",
172+
title: "",
173+
bounds: { x: -250, y: 0, width: 50, height: 1_000 },
174+
},
133175
])("keeps a frontmost $name ahead of a larger document", async ({ title, bounds }) => {
134176
stubMacLookup(
135177
macLookup([

‎apps/desktop/src/snapShot/ActiveWindow.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,16 @@ async function macActiveWindow(): Promise<ActiveWindow | undefined> {
125125
return (
126126
(bounds.x === reference.bounds.x &&
127127
bounds.width === reference.bounds.width &&
128+
bounds.y <= reference.bounds.y &&
129+
reference.bounds.y - bounds.y <=
130+
reference.bounds.height * MAC_HELPER_STRIP_MAX_THICKNESS_RATIO &&
128131
bounds.height <= bounds.width * MAC_HELPER_STRIP_MAX_THICKNESS_RATIO &&
129132
bounds.height <= reference.bounds.height * MAC_HELPER_STRIP_MAX_THICKNESS_RATIO) ||
130133
(bounds.y === reference.bounds.y &&
131134
bounds.height === reference.bounds.height &&
135+
bounds.x <= reference.bounds.x &&
136+
reference.bounds.x - bounds.x <=
137+
reference.bounds.width * MAC_HELPER_STRIP_MAX_THICKNESS_RATIO &&
132138
bounds.width <= bounds.height * MAC_HELPER_STRIP_MAX_THICKNESS_RATIO &&
133139
bounds.width <= reference.bounds.width * MAC_HELPER_STRIP_MAX_THICKNESS_RATIO)
134140
);

0 commit comments

Comments
 (0)