@domicile-desktop/manganese-window-management 1.3.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/package.json +22 -17
  2. package/src/AppPopup.tsx +22 -10
  3. package/src/AppWindow.tsx +130 -73
  4. package/src/BrowserWindow.tsx +262 -21
  5. package/src/FocusGlow.tsx +5 -1
  6. package/src/GroupWell.tsx +5 -1
  7. package/src/SelectionTint.tsx +5 -1
  8. package/src/Stage.tsx +116 -30
  9. package/src/TabStrip.tsx +5 -1
  10. package/src/TitleBar.tsx +261 -120
  11. package/src/WindowFrame.tsx +95 -34
  12. package/src/WindowTitleBar.tsx +4 -0
  13. package/src/browser/AddressBar.tsx +46 -37
  14. package/src/browser/AppMenuBar.tsx +106 -0
  15. package/src/browser/AppPopupMenu.tsx +45 -0
  16. package/src/browser/ConnectionIndicator.tsx +2 -2
  17. package/src/browser/HistoryButton.tsx +150 -0
  18. package/src/browser/PageMenu.tsx +20 -6
  19. package/src/browser/PageViews.tsx +101 -0
  20. package/src/browser/ProfileMenu.tsx +332 -0
  21. package/src/browser/app-window-shape.ts +33 -0
  22. package/src/browser/page-history.ts +54 -0
  23. package/src/browser/page-menu.ts +85 -9
  24. package/src/browser/profile-ink.ts +17 -0
  25. package/src/browser/useAppMenuBar.ts +51 -0
  26. package/src/browser/useAppMessageBox.ts +47 -0
  27. package/src/browser/useAppPopupMenu.ts +49 -0
  28. package/src/browser/useAppWindowLooks.ts +49 -0
  29. package/src/browser/useAppWindowState.ts +59 -0
  30. package/src/browser/useBrowserProfile.ts +230 -0
  31. package/src/browser/useLongPress.ts +66 -0
  32. package/src/closing.ts +30 -12
  33. package/src/floating/FloatGrab.tsx +10 -0
  34. package/src/floating/FloatShadow.tsx +5 -1
  35. package/src/floating/useFloatDrag.ts +3 -2
  36. package/src/handed-drag.ts +57 -0
  37. package/src/keyboard/command.ts +148 -9
  38. package/src/keyboard/commands.ts +22 -7
  39. package/src/keyboard/query.ts +94 -0
  40. package/src/keyboard/useKeybindings.ts +41 -11
  41. package/src/overview/OverviewPicker.tsx +19 -5
  42. package/src/overview/seen-styles.ts +28 -11
  43. package/src/overview/sight.ts +5 -1
  44. package/src/panda-preset.ts +71 -0
  45. package/src/picture-in-picture/PictureInPictureFloats.tsx +865 -0
  46. package/src/picture-in-picture/page-of.ts +25 -0
  47. package/src/picture-in-picture/pip-box.ts +156 -0
  48. package/src/picture-in-picture/playhead.ts +33 -0
  49. package/src/pointer-confinement.ts +107 -0
  50. package/src/pointer-lock.ts +113 -0
  51. package/src/popup.ts +25 -37
  52. package/src/screens/popup-scene.ts +38 -0
  53. package/src/screens/reading-order.ts +29 -0
  54. package/src/shown.ts +5 -0
  55. package/src/sliding-screen.ts +12 -0
  56. package/src/tab-drop.ts +43 -0
  57. package/src/tiled/TileGrab.tsx +10 -0
  58. package/src/tiled/aim.ts +23 -2
  59. package/src/tiled/useTileDrag.ts +3 -2
  60. package/src/tree/drop.ts +59 -19
  61. package/src/tree/layout.ts +40 -9
  62. package/src/useHandedPress.ts +25 -0
  63. package/src/usePointerConfinement.ts +103 -0
  64. package/src/usePointerLock.ts +12 -0
  65. package/src/useTabDrop.ts +65 -0
  66. package/src/useWindowMotion.ts +44 -7
  67. package/src/useWindows.ts +101 -16
  68. package/src/window-changes.ts +13 -3
  69. package/src/window-log.ts +106 -0
  70. package/src/window-state.ts +258 -60
  71. package/src/window-styles.ts +52 -2
  72. package/src/window.ts +14 -0
  73. package/src/workspace.ts +6 -4
  74. package/styled-system/styles.css +2448 -1950
  75. package/styled-system/tokens/index.mjs +7 -3
  76. package/styled-system/tokens/tokens.d.ts +2 -2
  77. package/styled-system/types/prop-type.d.ts +2 -2
package/package.json CHANGED
@@ -1,29 +1,29 @@
1
1
  {
2
2
  "dependencies": {
3
3
  "@cprussin/option-result": "^2.0.1",
4
- "@domicile-desktop/component-library": "2.1.0",
5
- "@domicile-desktop/manganese-address": "1.0.3",
6
- "@domicile-desktop/manganese-bar": "1.1.2",
7
- "@domicile-desktop/manganese-host": "2.0.2",
8
- "@domicile-desktop/manganese-page-requests": "1.2.0",
9
- "@domicile-desktop/sdk": "2.2.0",
10
- "@domicile-desktop/system-apps": "1.2.0",
11
- "@pandacss/dev": "^1.12.1",
4
+ "@domicile-desktop/component-library": "2.2.0",
5
+ "@domicile-desktop/manganese-address": "1.1.0",
6
+ "@domicile-desktop/manganese-bar": "1.1.3",
7
+ "@domicile-desktop/manganese-host": "2.0.3",
8
+ "@domicile-desktop/manganese-page-requests": "1.3.0",
9
+ "@domicile-desktop/sdk": "3.0.0",
10
+ "@domicile-desktop/system-apps": "1.3.0",
11
+ "@pandacss/dev": "^1.12.2",
12
12
  "@phosphor-icons/react": "^2.1.10",
13
- "react": "^19.2.8",
14
- "zod": "^4.5.4"
13
+ "react": "^19.3.1",
14
+ "zod": "^4.6.7"
15
15
  },
16
16
  "description": "Manganese's window management: sway's layout tree, tiling, floating, workspaces, keybindings and the windows' chrome.",
17
17
  "devDependencies": {
18
18
  "@cprussin/tsconfig": "^5.0.0",
19
19
  "@domicile-desktop/test-support": "0.0.2",
20
- "@pandacss/preset-panda": "^1.12.1",
20
+ "@pandacss/preset-panda": "^1.12.2",
21
21
  "@testing-library/react": "^16.3.3",
22
- "@testing-library/user-event": "^14.6.7",
23
- "@types/bun": "^1.4.2",
24
- "@types/react": "^19.2.18",
25
- "@types/react-dom": "^19.2.7",
26
- "postcss": "^8.5.28",
22
+ "@testing-library/user-event": "^14.6.10",
23
+ "@types/bun": "^1.4.4",
24
+ "@types/react": "^19.3.0",
25
+ "@types/react-dom": "^19.3.0",
26
+ "postcss": "^8.5.32",
27
27
  "typescript": "^7.0.2"
28
28
  },
29
29
  "engines": {
@@ -36,6 +36,7 @@
36
36
  "./grab-cursor-styles": "./src/grab-cursor-styles.ts",
37
37
  "./keyboard/commands": "./src/keyboard/commands.ts",
38
38
  "./keyboard/media-key": "./src/keyboard/media-key.ts",
39
+ "./keyboard/query": "./src/keyboard/query.ts",
39
40
  "./keyboard/useKeybindings": "./src/keyboard/useKeybindings.ts",
40
41
  "./keyboard/useModifiers": "./src/keyboard/useModifiers.ts",
41
42
  "./overview/OverviewBackdrop": "./src/overview/OverviewBackdrop.tsx",
@@ -45,12 +46,15 @@
45
46
  "./overview/steering": "./src/overview/steering.ts",
46
47
  "./overview/useOverviewPhase": "./src/overview/useOverviewPhase.ts",
47
48
  "./panda-preset": "./src/panda-preset.ts",
49
+ "./picture-in-picture/PictureInPictureFloats": "./src/picture-in-picture/PictureInPictureFloats.tsx",
50
+ "./picture-in-picture/page-of": "./src/picture-in-picture/page-of.ts",
48
51
  "./placement": "./src/placement.ts",
49
52
  "./pointer-warp": "./src/pointer-warp.ts",
50
53
  "./rect": "./src/rect.ts",
51
54
  "./Stage": "./src/Stage.tsx",
52
55
  "./screens/fixture": "./src/screens/fixture.tsx",
53
56
  "./screens/host-displays": "./src/screens/host-displays.ts",
57
+ "./screens/popup-scene": "./src/screens/popup-scene.ts",
54
58
  "./screens/shown-windows": "./src/screens/shown-windows.ts",
55
59
  "./screens/stage-screens": "./src/screens/stage-screens.ts",
56
60
  "./screens/useScreenFollowsPointer": "./src/screens/useScreenFollowsPointer.ts",
@@ -60,6 +64,7 @@
60
64
  "./tree/path": "./src/tree/path.ts",
61
65
  "./useClientIcons": "./src/useClientIcons.ts",
62
66
  "./useGrabCursor": "./src/useGrabCursor.ts",
67
+ "./usePointerLock": "./src/usePointerLock.ts",
63
68
  "./usePointerWarp": "./src/usePointerWarp.ts",
64
69
  "./useWindows": "./src/useWindows.ts",
65
70
  "./window": "./src/window.ts",
@@ -90,5 +95,5 @@
90
95
  "test:unit": "bun test"
91
96
  },
92
97
  "type": "module",
93
- "version": "1.3.0"
98
+ "version": "2.0.0"
94
99
  }
package/src/AppPopup.tsx CHANGED
@@ -1,20 +1,32 @@
1
1
  /// <reference types="@domicile-desktop/manganese-host/domicile-elements" />
2
2
 
3
- import type { PlacedPopup } from "./popup";
4
- import { placedAt } from "./window-styles";
3
+ import type { WindowPopup } from "./popup";
5
4
 
6
5
  type Props = {
7
- popup: PlacedPopup;
6
+ popup: WindowPopup;
8
7
  };
9
8
 
10
9
  /**
11
- * A client's popup (menu, tooltip) drawn over its window as a bare `<app>`
12
- * with no frame.
10
+ * A client's popup (menu, tooltip, or a subsurface such as the one Firefox
11
+ * draws its whole window into) as a bare `<app>` with no frame, placed on its
12
+ * window's contents. `AppWindow` draws it, so it plays the window's motion.
13
13
  *
14
- * A press on it focuses the parent window. It is a sibling of the window
15
- * because `<app>` has no children, so it does not follow the window's motion.
16
- * That is fine because a menu is open only while its window is at rest.
14
+ * A press on it focuses the parent window. It shows the cursor its client
15
+ * asks for over it.
17
16
  */
18
- export const AppPopup = ({ popup: { appId, depth, frame, rect } }: Props) => (
19
- <app app-id={appId} frame={String(frame)} style={placedAt(rect, depth)} />
17
+ export const AppPopup = ({ popup: { appId, cursor, frame, rect } }: Props) => (
18
+ <app
19
+ app-id={appId}
20
+ frame={String(frame)}
21
+ // Inline because the box and cursor are runtime values that Panda cannot
22
+ // extract at build time.
23
+ style={{
24
+ blockSize: `${rect.height.toString()}px`,
25
+ cursor,
26
+ inlineSize: `${rect.width.toString()}px`,
27
+ insetBlockStart: `${rect.y.toString()}px`,
28
+ insetInlineStart: `${rect.x.toString()}px`,
29
+ position: "absolute",
30
+ }}
31
+ />
20
32
  );
package/src/AppWindow.tsx CHANGED
@@ -5,18 +5,21 @@ import {
5
5
  APP_FOCUS_RELEASE_REQUESTED_EVENT,
6
6
  APP_FOCUS_REQUESTED_EVENT,
7
7
  } from "@domicile-desktop/sdk/app-element";
8
- import type { CursorShape } from "@domicile-desktop/sdk/cursor-shape";
9
8
  import type { Domicile } from "@domicile-desktop/sdk/desktop/desktop";
10
9
  import { SystemErrorKind } from "@domicile-desktop/sdk/system";
11
10
  import { WindowState } from "@domicile-desktop/sdk/window-state";
12
- import { useEffect, useRef, useState } from "react";
11
+ import { useContext, useEffect, useRef, useState } from "react";
13
12
 
14
13
  import { css, cx } from "../styled-system/css";
14
+ import { AppPopup } from "./AppPopup";
15
15
  import { endsOwnAnimation } from "./own-animation";
16
- import { CROSSING } from "./placement";
16
+ import { CROSSING, raised } from "./placement";
17
+ import type { WindowPopup } from "./popup";
17
18
  import type { Rect } from "./rect";
18
19
  import type { Restack } from "./restacking";
20
+ import { SlidingScreen } from "./sliding-screen";
19
21
  import { useLowered } from "./useLowered";
22
+ import { usePointerConfinement } from "./usePointerConfinement";
20
23
  import type { Settler } from "./useSettling";
21
24
  import { UPRIGHT, useSettling } from "./useSettling";
22
25
  import { appWindowId } from "./window";
@@ -25,6 +28,7 @@ import { isLeaving, isMoving, isSlidingIn } from "./window-motion";
25
28
  import {
26
29
  bottomCornerStyles,
27
30
  clickThroughStyles,
31
+ clippedAlong,
28
32
  contentsScaledAbout,
29
33
  edgeStyles,
30
34
  heldStyles,
@@ -74,9 +78,10 @@ type Props = {
74
78
  /** The host's id for this window's client. */
75
79
  appId: string;
76
80
  /**
77
- * The cursor the client requested. `undefined` uses the page's cursor.
81
+ * The CSS cursor the client requested: a shape's keyword, or an image it
82
+ * drew. `undefined` uses the page's cursor.
78
83
  */
79
- cursor: CursorShape | undefined;
84
+ cursor: string | undefined;
80
85
  /**
81
86
  * Whether it just moved to another tab group, so it eases there over the
82
87
  * strips it passes. See `crossing.ts`.
@@ -119,6 +124,8 @@ type Props = {
119
124
  * removed. Uses the animation event so the duration lives only in CSS.
120
125
  */
121
126
  onMotionEnded: () => void;
127
+ /** Its client's popups, drawn over it. See `AppPopup`. */
128
+ popups: readonly WindowPopup[];
122
129
  /**
123
130
  * The contents' box, or `undefined` when off screen (another workspace, or
124
131
  * behind a tab).
@@ -168,6 +175,7 @@ export const AppWindow = ({
168
175
  hasKeyboard,
169
176
  motion,
170
177
  onMotionEnded,
178
+ popups,
171
179
  rect,
172
180
  resizing,
173
181
  restack,
@@ -183,11 +191,12 @@ export const AppWindow = ({
183
191
  // its layout effect reads it.
184
192
  const box = useRef<HTMLDivElement>(null);
185
193
  const lowered = useLowered(depth);
194
+ const sliding = useContext(SlidingScreen);
186
195
  // The box the window eases from, while it settles.
187
196
  const [settlingFrom, setSettlingFrom] = useState<Rect | undefined>(undefined);
188
- useSettling({
189
- element: box,
190
- onSettling: setSettlingFrom,
197
+ // Its popups, which ease along with it.
198
+ const layer = useRef<HTMLDivElement>(null);
199
+ const settling = {
191
200
  origin:
192
201
  rect === undefined || frame === undefined
193
202
  ? undefined
@@ -196,7 +205,9 @@ export const AppWindow = ({
196
205
  rect,
197
206
  settler,
198
207
  still: dragging || isMoving(motion),
199
- });
208
+ };
209
+ useSettling({ ...settling, element: box, onSettling: setSettlingFrom });
210
+ useSettling({ ...settling, element: layer });
200
211
 
201
212
  // Keeps the compositor's keyboard focus in line with the shell's.
202
213
  //
@@ -230,6 +241,15 @@ export const AppWindow = ({
230
241
  domicile.windows.setBounds(appId, { height, width, x, y });
231
242
  }, [appId, domicile, height, width, x, y]);
232
243
 
244
+ // Holds the pointer in the window for a game or VM viewer that asked, while
245
+ // it has the keyboard.
246
+ usePointerConfinement(
247
+ domicile,
248
+ appId,
249
+ rect,
250
+ hasKeyboard && !behindPanel && !leaving,
251
+ );
252
+
233
253
  // Tells the client how it is laid out, so a tiled window draws no shadow,
234
254
  // rounded corners or resize border of its own. Floats get none, as in sway.
235
255
  const { windows } = domicile;
@@ -299,72 +319,109 @@ export const AppWindow = ({
299
319
  }
300
320
  }, [appId, element]);
301
321
 
322
+ // The box's motion and shuffle, which its popups play too.
323
+ const moved =
324
+ rect === undefined || frame === undefined
325
+ ? undefined
326
+ : {
327
+ ...contentsScaledAbout(motion, frame, tab, rect),
328
+ ...shuffledBy(restack),
329
+ };
302
330
  return (
303
- // The box places the window, plays its motions and eases it into a new
304
- // box, clipping the `<app>` to where it is drawn. The `<app>` keeps its
305
- // own size, so a client drawn at its new size is cropped rather than
306
- // stretched while the box gets there.
307
- <div
308
- className={cx(
309
- windowStyles,
310
- boxStyles,
311
- // Neither a line nor rounded corners around the screen's own edge.
312
- !fullscreen && edgeStyles,
313
- !fullscreen && bottomCornerStyles,
314
- movingStyles({ contents: true, motion }),
315
- (clickThrough || leaving) && clickThroughStyles,
316
- // The client's box takes its new size at once; `useSettling` eases
317
- // it. Colors still ease; see `settlingStyles`.
318
- settlingStyles({ lowered }),
319
- dragging && heldStyles,
320
- )}
321
- // Exposes the motion on the element for tests and debugging.
322
- data-motion={motion}
323
- hidden={rect === undefined}
324
- // A leaving window is unreachable by keyboard.
325
- inert={leaving}
326
- // Ignores animations bubbling up from descendants, and the end of a
327
- // motion this one replaced.
328
- onAnimationEnd={(event) => {
329
- if (endsOwnAnimation(event)) {
330
- onMotionEnded();
331
- }
332
- }}
333
- ref={box}
334
- // Inline because the box is a runtime value that Panda cannot extract
335
- // at build time.
336
- style={
337
- rect === undefined || frame === undefined
338
- ? undefined
339
- : {
340
- ...placedAt(rect, depth),
341
- ...contentsScaledAbout(motion, frame, tab, rect),
342
- ...shuffledBy(restack),
343
- }
344
- }
345
- >
346
- <app
347
- app-id={appId}
348
- className={appStyles}
349
- frame={String(syncedFrame)}
350
- ref={setElement}
351
- // Also while the box settles, so the engine neither holds the page
352
- // for the client nor stretches its old frame, and while it slides in,
353
- // so the slide does not wait for the client to draw again.
354
- resizing={
355
- resizing || settlingFrom !== undefined || isSlidingIn(motion)
356
- ? ""
357
- : undefined
358
- }
359
- // Inline because the cursor and size are runtime values that Panda
360
- // cannot extract at build time.
361
- style={{
362
- cursor,
363
- ...(rect === undefined ? {} : keptAt(settlingFrom, rect)),
331
+ <>
332
+ {/*
333
+ The box places the window, plays its motions and eases it into a new
334
+ box, clipping the `<app>` to where it is drawn. The `<app>` keeps its
335
+ own size, so a client drawn at its new size is cropped rather than
336
+ stretched while the box gets there.
337
+ */}
338
+ <div
339
+ className={cx(
340
+ windowStyles,
341
+ boxStyles,
342
+ // Neither a line nor rounded corners around the screen's own edge.
343
+ !fullscreen && edgeStyles,
344
+ !fullscreen && bottomCornerStyles,
345
+ movingStyles({ contents: true, motion }),
346
+ (clickThrough || leaving) && clickThroughStyles,
347
+ // The client's box takes its new size at once; `useSettling` eases
348
+ // it. Colors still ease; see `settlingStyles`.
349
+ settlingStyles({ lowered }),
350
+ dragging && heldStyles,
351
+ )}
352
+ // Exposes the motion on the element for tests and debugging.
353
+ data-motion={motion}
354
+ hidden={rect === undefined}
355
+ // A leaving window is unreachable by keyboard.
356
+ inert={leaving}
357
+ // Ignores animations bubbling up from descendants, and the end of a
358
+ // motion this one replaced.
359
+ onAnimationEnd={(event) => {
360
+ if (endsOwnAnimation(event)) {
361
+ onMotionEnded();
362
+ }
364
363
  }}
365
- {...{ [UPRIGHT]: "" }}
366
- />
367
- </div>
364
+ ref={box}
365
+ // Inline because the box is a runtime value that Panda cannot extract
366
+ // at build time.
367
+ style={
368
+ rect === undefined || frame === undefined
369
+ ? undefined
370
+ : {
371
+ ...placedAt(rect, depth),
372
+ ...clippedAlong(sliding, rect),
373
+ ...moved,
374
+ }
375
+ }
376
+ >
377
+ <app
378
+ app-id={appId}
379
+ className={appStyles}
380
+ frame={String(syncedFrame)}
381
+ ref={setElement}
382
+ // Also while the box settles, so the engine neither holds the page
383
+ // for the client nor stretches its old frame, and while it slides in,
384
+ // so the slide does not wait for the client to draw again.
385
+ resizing={
386
+ resizing || settlingFrom !== undefined || isSlidingIn(motion)
387
+ ? ""
388
+ : undefined
389
+ }
390
+ // Inline because the cursor and size are runtime values that Panda
391
+ // cannot extract at build time.
392
+ style={{
393
+ cursor,
394
+ ...(rect === undefined ? {} : keptAt(settlingFrom, rect)),
395
+ }}
396
+ {...{ [UPRIGHT]: "" }}
397
+ />
398
+ </div>
399
+ {/*
400
+ Its popups, placed, moved and eased as the box is, just over it. Not in
401
+ the box, which would clip a menu reaching past the window.
402
+ */}
403
+ {rect !== undefined && popups.length > 0 && (
404
+ <div
405
+ className={cx(
406
+ movingStyles({ contents: true, motion }),
407
+ (clickThrough || leaving) && clickThroughStyles,
408
+ dragging && heldStyles,
409
+ )}
410
+ data-motion={motion}
411
+ inert={leaving}
412
+ ref={layer}
413
+ style={{
414
+ ...placedAt(rect, raised(depth)),
415
+ ...clippedAlong(sliding, rect),
416
+ ...moved,
417
+ }}
418
+ >
419
+ {popups.map((popup) => (
420
+ <AppPopup key={popup.appId} popup={popup} />
421
+ ))}
422
+ </div>
423
+ )}
424
+ </>
368
425
  );
369
426
  };
370
427