@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
@@ -2,8 +2,10 @@
2
2
 
3
3
  import { FilePicker } from "@domicile-desktop/component-library/FilePicker";
4
4
  import { desktopFolders } from "@domicile-desktop/component-library/folders";
5
+ import { AppMessageBox } from "@domicile-desktop/manganese-page-requests/AppMessageBox";
5
6
  import { DeviceAsk } from "@domicile-desktop/manganese-page-requests/DeviceAsk";
6
7
  import { ExternalAppAsk } from "@domicile-desktop/manganese-page-requests/ExternalAppAsk";
8
+ import { IdentityAsk } from "@domicile-desktop/manganese-page-requests/IdentityAsk";
7
9
  import { PageDialog } from "@domicile-desktop/manganese-page-requests/PageDialog";
8
10
  import { PickerAsk } from "@domicile-desktop/manganese-page-requests/PickerAsk";
9
11
  import { PromptAsk } from "@domicile-desktop/manganese-page-requests/PromptAsk";
@@ -11,26 +13,41 @@ import { SignInAsk } from "@domicile-desktop/manganese-page-requests/SignInAsk";
11
13
  import { useDeviceRequest } from "@domicile-desktop/manganese-page-requests/useDeviceRequest";
12
14
  import { useDialogRequest } from "@domicile-desktop/manganese-page-requests/useDialogRequest";
13
15
  import { useExternalAppRequest } from "@domicile-desktop/manganese-page-requests/useExternalAppRequest";
16
+ import { useIdentityRequest } from "@domicile-desktop/manganese-page-requests/useIdentityRequest";
14
17
  import { useLinkOpener } from "@domicile-desktop/manganese-page-requests/useLinkOpener";
15
18
  import { usePermissionRequest } from "@domicile-desktop/manganese-page-requests/usePermissionRequest";
16
19
  import { usePickerRequest } from "@domicile-desktop/manganese-page-requests/usePickerRequest";
17
20
  import { usePromptRequest } from "@domicile-desktop/manganese-page-requests/usePromptRequest";
18
21
  import { useSignInRequest } from "@domicile-desktop/manganese-page-requests/useSignInRequest";
22
+ import {
23
+ acceleratedBy,
24
+ openedByMnemonic,
25
+ } from "@domicile-desktop/sdk/app-menu";
19
26
  import type { Domicile } from "@domicile-desktop/sdk/desktop/desktop";
20
27
  import {
21
28
  WEBVIEW_DIALOG_EVENT,
22
29
  WEBVIEW_FOCUS_REQUEST_EVENT,
23
30
  WEBVIEW_GUEST_FOCUS_EVENT,
24
31
  WEBVIEW_GUEST_KEYDOWN_EVENT,
32
+ WEBVIEW_GUEST_KEYUP_EVENT,
25
33
  WEBVIEW_ZOOM_IN_REQUEST_EVENT,
26
34
  WEBVIEW_ZOOM_OUT_REQUEST_EVENT,
27
35
  } from "@domicile-desktop/sdk/webview-element";
28
36
  import type { FocusEvent } from "react";
29
- import { useCallback, useEffect, useMemo, useRef, useState } from "react";
37
+ import {
38
+ useCallback,
39
+ useContext,
40
+ useEffect,
41
+ useMemo,
42
+ useRef,
43
+ useState,
44
+ } from "react";
30
45
  import { css, cx } from "../styled-system/css";
31
46
  import { flex } from "../styled-system/patterns";
32
47
  import { AddressBar } from "./browser/AddressBar";
33
48
  import { AppAddress } from "./browser/AppAddress";
49
+ import { AppMenuBar } from "./browser/AppMenuBar";
50
+ import { AppPopupMenu } from "./browser/AppPopupMenu";
34
51
  import { leftOrigin } from "./browser/app-origin";
35
52
  import { BrowserCommand, browserCommandFor } from "./browser/browser-command";
36
53
  import { FindBar } from "./browser/FindBar";
@@ -40,7 +57,19 @@ import { PageMenu } from "./browser/PageMenu";
40
57
  import { PagePopup } from "./browser/PagePopup";
41
58
  import { PageProblem } from "./browser/PageProblem";
42
59
  import { PageTooltip } from "./browser/PageTooltip";
60
+ import { PageViews } from "./browser/PageViews";
61
+ import { pageHistoryFor } from "./browser/page-history";
43
62
  import { choosePageCommand, pageMenuFor } from "./browser/page-menu";
63
+ import { useAppMenuBar } from "./browser/useAppMenuBar";
64
+ import { useAppMessageBox } from "./browser/useAppMessageBox";
65
+ import { useAppPopupMenu } from "./browser/useAppPopupMenu";
66
+ import { useAppWindowLooks } from "./browser/useAppWindowLooks";
67
+ import { useAppWindowState } from "./browser/useAppWindowState";
68
+ import {
69
+ useBrowserProfile,
70
+ usePinnedSite,
71
+ useProfileExtensions,
72
+ } from "./browser/useBrowserProfile";
44
73
  import { useFileRequest } from "./browser/useFileRequest";
45
74
  import { usePageMenu } from "./browser/usePageMenu";
46
75
  import { useSitePermissions } from "./browser/useSitePermissions";
@@ -51,6 +80,7 @@ import { endsOwnAnimation } from "./own-animation";
51
80
  import { CROSSING } from "./placement";
52
81
  import type { Rect } from "./rect";
53
82
  import type { Restack } from "./restacking";
83
+ import { SlidingScreen } from "./sliding-screen";
54
84
  import { useHistoryAvailability } from "./useHistoryAvailability";
55
85
  import { useLoading } from "./useLoading";
56
86
  import { useLoadProgress } from "./useLoadProgress";
@@ -69,6 +99,7 @@ import { isLeaving, isMoving, isSlidingIn } from "./window-motion";
69
99
  import {
70
100
  bottomCornerStyles,
71
101
  clickThroughStyles,
102
+ clippedAlong,
72
103
  contentsScaledAbout,
73
104
  edgeStyles,
74
105
  heldStyles,
@@ -261,10 +292,13 @@ export const BrowserWindow = ({
261
292
  const unclickable = covered || behindPanel;
262
293
  // `null` because React passes `null` to a callback ref on unmount.
263
294
  const [view, setView] = useState<HTMLWebViewElement | null>(null);
295
+ /** The page and the app's views over it, whose keys bubble up to it. */
296
+ const [page, setPage] = useState<HTMLDivElement | null>(null);
264
297
  // The whole window, used to check whether focus is inside it and to ease it
265
298
  // into a new box. A ref because only effects read it.
266
299
  const element = useRef<HTMLElement>(null);
267
300
  const lowered = useLowered(depth);
301
+ const sliding = useContext(SlidingScreen);
268
302
  // The box the window eases from, while it settles.
269
303
  const [settlingFrom, setSettlingFrom] = useState<Rect | undefined>(undefined);
270
304
  useSettling({
@@ -289,6 +323,12 @@ export const BrowserWindow = ({
289
323
  // the shell did not start (links, redirects, form posts).
290
324
  const shown = useShownPage(view);
291
325
  const address = addressOf(shown.url, sent);
326
+ const pageProfile = useBrowserProfile(domicile, window);
327
+ const pinned = usePinnedSite(domicile, address);
328
+ const profileExtensions = useProfileExtensions(
329
+ domicile,
330
+ pageProfile?.profile,
331
+ );
292
332
  usePageIcon(view, window, onIcon);
293
333
  usePageDescription(view, window, onDescription);
294
334
  const { canGoBack, canGoForward } = useHistoryAvailability(view);
@@ -305,6 +345,9 @@ export const BrowserWindow = ({
305
345
  const zoom = useZoom(view);
306
346
  // A fullscreen page, such as a video, fills the window without its bar.
307
347
  const pageFullscreen = usePageFullscreen(view, fullscreen, onPageFullscreen);
348
+ // An Electron app's win.setFullScreen does as a fullscreen page does, and
349
+ // the app hears what the window is.
350
+ useAppWindowState(domicile, window, fullscreen, onPageFullscreen);
308
351
  // True while `focusOwn` is calling `focus()`. Focus events fire
309
352
  // synchronously inside that call, so this marks them as not user reaches.
310
353
  const focusing = useRef(false);
@@ -312,9 +355,11 @@ export const BrowserWindow = ({
312
355
  () => foldersOf(domicile.files),
313
356
  [domicile, foldersOf],
314
357
  );
315
- // A pending file request from the page. The engine draws no dialog; see
316
- // `useFileRequest`.
317
- const asking = useFileRequest(view, folders);
358
+ // A pending file request from the page, or from one of an Electron app's
359
+ // views over it, as an upload or a download in either asks for a path. The
360
+ // request bubbles, so the element around them all hears it. The engine
361
+ // draws no dialog; see `useFileRequest`.
362
+ const asking = useFileRequest(page, folders);
318
363
  // The file picker's input. While open it takes the window's keyboard.
319
364
  const [pickerBox, setPickerBox] = useState<HTMLInputElement | null>(null);
320
365
  // Whether the find bar is open, and its input.
@@ -339,6 +384,12 @@ export const BrowserWindow = ({
339
384
  // paused on, and the element in it to focus. The engine draws no dialog.
340
385
  const dialogRequest = useDialogRequest(view);
341
386
  const [dialogBox, setDialogBox] = useState<HTMLElement | null>(null);
387
+ // The message box an Electron app asks over this window, and the button
388
+ // in it to focus. The engine draws no dialog.
389
+ const appBox = useAppMessageBox(domicile, window);
390
+ // A popup menu the app opened (`Menu.popup`), such as its menu button's.
391
+ const appPopup = useAppPopupMenu(domicile, window);
392
+ const [appBoxButton, setAppBoxButton] = useState<HTMLElement | null>(null);
342
393
  // The link for an application the page opened, the application that opens
343
394
  // it, and the button to focus. The engine draws no dialog.
344
395
  const externalApp = useExternalAppRequest(view);
@@ -352,6 +403,10 @@ export const BrowserWindow = ({
352
403
  // permissions, and the element to focus. The engine draws no dialog.
353
404
  const prompt = usePromptRequest(view);
354
405
  const [promptBox, setPromptBox] = useState<HTMLElement | null>(null);
406
+ // The "Sign in with" step the site's sign-in is on, and the answer to
407
+ // focus when it asks over the page. The engine draws no account chooser.
408
+ const identity = useIdentityRequest(view);
409
+ const [identityBox, setIdentityBox] = useState<HTMLElement | null>(null);
355
410
  // The color, date or list picker a form control in the page opened, and
356
411
  // the element in it to focus. The engine draws no picker.
357
412
  const pagePicker = usePickerRequest(view);
@@ -363,9 +418,11 @@ export const BrowserWindow = ({
363
418
  // What the page waits on, which takes the keyboard while it is open.
364
419
  const waiting =
365
420
  pickerBox ??
421
+ appBoxButton ??
366
422
  dialogBox ??
367
423
  signInBox ??
368
424
  promptBox ??
425
+ identityBox ??
369
426
  appAskBox ??
370
427
  pagePickerBox ??
371
428
  problemBox;
@@ -497,6 +554,36 @@ export const BrowserWindow = ({
497
554
  [findBox, focusOwn, showPopup, view],
498
555
  );
499
556
 
557
+ // An Electron app's menu bar, the menu open on it, and whether Alt showed a
558
+ // bar that hides until Alt (`autoHideMenuBar`).
559
+ const menuBar = useAppMenuBar(domicile, window);
560
+ // What an Electron app asks of its window's looks and input.
561
+ const looks = useAppWindowLooks(domicile, window);
562
+ const [openMenu, setOpenMenu] = useState<number | undefined>(undefined);
563
+ const [menuBarShown, setMenuBarShown] = useState(false);
564
+ // Whether Alt is down with nothing pressed with it, so letting it go is a
565
+ // tap that shows or hides an auto-hidden bar.
566
+ const altAlone = useRef(false);
567
+ const shownMenuBar =
568
+ menuBar?.visible === true &&
569
+ !pageFullscreen &&
570
+ (!menuBar.autoHide || menuBarShown || openMenu !== undefined)
571
+ ? menuBar
572
+ : undefined;
573
+ const openedMenu = useCallback((opened: number | undefined) => {
574
+ setOpenMenu(opened);
575
+ // A choice or Escape puts an auto-hidden bar away, as on Electron.
576
+ if (opened === undefined) {
577
+ setMenuBarShown(false);
578
+ }
579
+ }, []);
580
+ const chooseMenuEntry = useCallback(
581
+ (id: number) => {
582
+ domicile.browser.clickMenu(window, id);
583
+ },
584
+ [domicile, window],
585
+ );
586
+
500
587
  // Focuses the find bar when it opens.
501
588
  useEffect(() => {
502
589
  if (findBox !== null) {
@@ -507,32 +594,62 @@ export const BrowserWindow = ({
507
594
  // Keys pressed in the guest never reach this document. The engine forwards
508
595
  // chords the page did not handle, and Ctrl+wheel as zoom requests, so sites
509
596
  // keep their own bindings as in Chrome. See `WEBVIEW_GUEST_KEYDOWN_EVENT`.
597
+ // An Electron app's views are part of its window, so the app's keys are
598
+ // heard from them too; the browser's keys act on the window's own page, so
599
+ // only that page's run them.
510
600
  useEffect(() => {
511
- if (view === null) {
601
+ if (view === null || page === null) {
512
602
  return undefined;
513
603
  } else {
514
604
  const pressed = (event: KeyboardEvent) => {
515
- const command = browserCommandFor(event);
516
- if (command !== undefined) {
605
+ altAlone.current =
606
+ event.key === "Alt" && (altAlone.current || !event.repeat);
607
+ // An app's accelerators come before the browser's keys, as its menu
608
+ // runs them in Electron, and Alt with a mnemonic opens a menu.
609
+ const accelerated =
610
+ menuBar === undefined
611
+ ? undefined
612
+ : acceleratedBy(menuBar.entries, event);
613
+ const mnemonic =
614
+ menuBar === undefined || !menuBar.visible
615
+ ? undefined
616
+ : openedByMnemonic(menuBar.entries, event);
617
+ const command =
618
+ event.target === view ? browserCommandFor(event) : undefined;
619
+ if (accelerated !== undefined) {
620
+ chooseMenuEntry(accelerated.id);
621
+ } else if (mnemonic !== undefined) {
622
+ setOpenMenu(mnemonic.id);
623
+ } else if (command !== undefined) {
517
624
  run(command);
518
625
  }
519
626
  };
627
+ const released = (event: KeyboardEvent) => {
628
+ if (event.key === "Alt" && altAlone.current) {
629
+ altAlone.current = false;
630
+ if (menuBar?.visible === true && menuBar.autoHide) {
631
+ setMenuBarShown((shown) => !shown);
632
+ }
633
+ }
634
+ };
520
635
  const zoomIn = () => {
521
636
  run(BrowserCommand.ZoomIn);
522
637
  };
523
638
  const zoomOut = () => {
524
639
  run(BrowserCommand.ZoomOut);
525
640
  };
526
- view.addEventListener(WEBVIEW_GUEST_KEYDOWN_EVENT, pressed);
641
+ page.addEventListener(WEBVIEW_GUEST_KEYDOWN_EVENT, pressed);
642
+ page.addEventListener(WEBVIEW_GUEST_KEYUP_EVENT, released);
527
643
  view.addEventListener(WEBVIEW_ZOOM_IN_REQUEST_EVENT, zoomIn);
528
644
  view.addEventListener(WEBVIEW_ZOOM_OUT_REQUEST_EVENT, zoomOut);
529
645
  return () => {
530
- view.removeEventListener(WEBVIEW_GUEST_KEYDOWN_EVENT, pressed);
646
+ page.removeEventListener(WEBVIEW_GUEST_KEYDOWN_EVENT, pressed);
647
+ page.removeEventListener(WEBVIEW_GUEST_KEYUP_EVENT, released);
531
648
  view.removeEventListener(WEBVIEW_ZOOM_IN_REQUEST_EVENT, zoomIn);
532
649
  view.removeEventListener(WEBVIEW_ZOOM_OUT_REQUEST_EVENT, zoomOut);
533
650
  };
534
651
  }
535
- }, [run, view]);
652
+ }, [chooseMenuEntry, menuBar, page, run, view]);
536
653
 
537
654
  // Gives the keyboard to the focused window's page.
538
655
  //
@@ -600,6 +717,19 @@ export const BrowserWindow = ({
600
717
  }
601
718
  };
602
719
 
720
+ // Opens a link from the page in another browser window: in this one's
721
+ // profile when it is private, so the link stays private, and otherwise in
722
+ // its site's.
723
+ const openWindow = (url: string): void => {
724
+ if (isPrivate && pageProfile !== undefined) {
725
+ domicile.browser.open(url, { profile: pageProfile.profile.id });
726
+ } else if (isPrivate) {
727
+ domicile.browser.openPrivate(url);
728
+ } else {
729
+ domicile.browser.open(url);
730
+ }
731
+ };
732
+
603
733
  const drive = (command: (view: HTMLWebViewElement) => void) => () => {
604
734
  withView(command);
605
735
  };
@@ -647,7 +777,10 @@ export const BrowserWindow = ({
647
777
  !fullscreen && bottomCornerStyles,
648
778
  noTopEdgeStyles,
649
779
  movingStyles({ contents: true, motion }),
650
- (clickThrough || leaving) && clickThroughStyles,
780
+ // An Electron app's window that ignores the mouse lets it through to
781
+ // what is under it (`setIgnoreMouseEvents`).
782
+ (clickThrough || leaving || looks.ignoresPointer) && clickThroughStyles,
783
+ urgentStyles,
651
784
  // The page's box takes its new size at once; `useSettling` eases it.
652
785
  // Colors still ease; see `settlingStyles`.
653
786
  settlingStyles({ lowered }),
@@ -655,6 +788,8 @@ export const BrowserWindow = ({
655
788
  )}
656
789
  // Exposes the motion on the element for tests and debugging.
657
790
  data-motion={motion}
791
+ // An Electron app asks for the user's attention (`flashFrame`).
792
+ data-urgent={looks.urgent ? "" : undefined}
658
793
  hidden={rect === undefined}
659
794
  // A leaving window is unreachable by keyboard.
660
795
  inert={leaving}
@@ -684,6 +819,7 @@ export const BrowserWindow = ({
684
819
  ? undefined
685
820
  : {
686
821
  ...placedAt(rect, depth),
822
+ ...clippedAlong(sliding, rect),
687
823
  ...contentsScaledAbout(motion, frame, tab, rect),
688
824
  ...shuffledBy(restack),
689
825
  }
@@ -704,6 +840,8 @@ export const BrowserWindow = ({
704
840
  address={address}
705
841
  canGoBack={canGoBack}
706
842
  canGoForward={canGoForward}
843
+ // Cheap, so read each render rather than memoized with the view.
844
+ history={view === null ? undefined : pageHistoryFor(view)}
707
845
  holdZoom={zoomShown}
708
846
  isPrivate={isPrivate}
709
847
  loading={loading}
@@ -730,6 +868,9 @@ export const BrowserWindow = ({
730
868
  loaded.setSitePermission(permission, setting);
731
869
  });
732
870
  }}
871
+ onShowAllHistory={() => {
872
+ domicile.processes.launch(["domicile-history"]);
873
+ }}
733
874
  onStop={drive((loaded) => {
734
875
  loaded.stop();
735
876
  })}
@@ -743,12 +884,60 @@ export const BrowserWindow = ({
743
884
  run(BrowserCommand.ZoomReset);
744
885
  }}
745
886
  permissionRequest={permissionRequest}
887
+ profile={
888
+ pageProfile === undefined
889
+ ? undefined
890
+ : {
891
+ ...pageProfile,
892
+ extensions: profileExtensions,
893
+ onMove: (id) => {
894
+ domicile.browser.reopen(window, id);
895
+ },
896
+ onOpenInNew: (id) => {
897
+ domicile.browser.open(address, { profile: id });
898
+ },
899
+ onPin: (id) => {
900
+ if (pinned !== undefined) {
901
+ domicile.browser
902
+ .pin(pinned.site, id)
903
+ .catch((error: unknown) => {
904
+ // biome-ignore lint/suspicious/noConsole: the menu offers no pin the engine refuses, so one is a list a change behind
905
+ console.error(
906
+ `Couldn't pin ${pinned.site} to profile ${id}`,
907
+ error,
908
+ );
909
+ });
910
+ }
911
+ },
912
+ onSwitchExtension: (id, on) => {
913
+ const { profile } = pageProfile;
914
+ domicile.browser
915
+ .setExtensionEnabled(profile.id, id, on)
916
+ .catch((error: unknown) => {
917
+ // biome-ignore lint/suspicious/noConsole: the menu offers no switch the engine refuses, so one is a list a change behind
918
+ console.error(
919
+ `Couldn't switch ${id} ${on ? "on" : "off"} in profile ${profile.id}`,
920
+ error,
921
+ );
922
+ });
923
+ },
924
+ pinned,
925
+ }
926
+ }
746
927
  security={shown.security}
747
928
  sitePermissions={sitePermissions}
748
929
  visited={shown.visited}
749
930
  zoom={zoom}
750
931
  />
751
932
  )}
933
+ {shownMenuBar !== undefined && (
934
+ <AppMenuBar
935
+ entries={shownMenuBar.entries}
936
+ onChoose={chooseMenuEntry}
937
+ onOpen={openedMenu}
938
+ open={openMenu}
939
+ />
940
+ )}
752
941
  {isApp && !pageFullscreen && leftOrigin(start, address) && (
753
942
  <AppAddress address={address} security={shown.security} />
754
943
  )}
@@ -756,7 +945,18 @@ export const BrowserWindow = ({
756
945
  Wraps the page so the find bar and file picker cover the page but not
757
946
  the address bar.
758
947
  */}
759
- <div className={pageStyles}>
948
+ <div
949
+ className={pageStyles}
950
+ ref={setPage}
951
+ // Inline because an Electron app's shape (`setShape`) is a runtime
952
+ // value Panda cannot extract. The page draws and takes input only
953
+ // within it.
954
+ style={
955
+ looks.clipPath === undefined
956
+ ? undefined
957
+ : { clipPath: looks.clipPath }
958
+ }
959
+ >
760
960
  <webview
761
961
  className={viewStyles}
762
962
  ref={setView}
@@ -773,6 +973,12 @@ export const BrowserWindow = ({
773
973
  // See `window`.
774
974
  window={window}
775
975
  />
976
+ <PageViews
977
+ domicile={domicile}
978
+ onReach={onReach}
979
+ unclickable={unclickable}
980
+ window={window}
981
+ />
776
982
  {problem !== undefined && (
777
983
  <PageProblem
778
984
  canGoBack={canGoBack}
@@ -846,21 +1052,23 @@ export const BrowserWindow = ({
846
1052
  canGoForward,
847
1053
  zoom,
848
1054
  })}
849
- onChoose={(command) => {
850
- choosePageCommand(command, menu.context, {
1055
+ onChoose={(item) => {
1056
+ choosePageCommand(item, menu.context, {
851
1057
  browse: run,
852
- openWindow: (url) => {
853
- if (isPrivate) {
854
- domicile.browser.openPrivate(url);
855
- } else {
856
- domicile.browser.open(url);
857
- }
858
- },
1058
+ openWindow,
859
1059
  });
860
1060
  }}
861
1061
  onClose={dismissMenu}
862
1062
  />
863
1063
  )}
1064
+ {appPopup !== undefined && view !== null && (
1065
+ <AppPopupMenu
1066
+ at={pagePoint(view, appPopup.popup.at)}
1067
+ entries={appPopup.popup.entries}
1068
+ key={appPopup.key}
1069
+ onAnswer={appPopup.answer}
1070
+ />
1071
+ )}
864
1072
  {deviceRequest !== undefined && (
865
1073
  <div className={deviceAskStyles}>
866
1074
  <DeviceAsk request={deviceRequest} />
@@ -884,6 +1092,18 @@ export const BrowserWindow = ({
884
1092
  request={prompt}
885
1093
  />
886
1094
  )}
1095
+ {dialogRequest === undefined &&
1096
+ signIn === undefined &&
1097
+ prompt === undefined &&
1098
+ identity !== undefined && (
1099
+ <IdentityAsk
1100
+ // A new card per step, so each starts unanswered.
1101
+ key={identity.step}
1102
+ onOpenLink={openWindow}
1103
+ ref={setIdentityBox}
1104
+ request={identity}
1105
+ />
1106
+ )}
887
1107
  {dialogRequest === undefined &&
888
1108
  signIn === undefined &&
889
1109
  prompt === undefined &&
@@ -895,6 +1115,16 @@ export const BrowserWindow = ({
895
1115
  request={externalApp}
896
1116
  />
897
1117
  )}
1118
+ {appBox !== undefined && (
1119
+ <AppMessageBox
1120
+ box={appBox.box}
1121
+ // A new box per box the app asks, so each starts with its
1122
+ // own checkbox.
1123
+ key={appBox.key}
1124
+ onAnswer={appBox.answer}
1125
+ ref={setAppBoxButton}
1126
+ />
1127
+ )}
898
1128
  {asking !== undefined && (
899
1129
  <FilePicker
900
1130
  // A new picker per request, so each starts empty.
@@ -991,6 +1221,11 @@ const viewStyles = css({
991
1221
  minInlineSize: 0,
992
1222
  });
993
1223
 
1224
+ // An Electron app's window asking for the user's attention, as sway draws an
1225
+ // urgent window's border. An attribute selector, so it outranks the edge's
1226
+ // own color.
1227
+ const urgentStyles = css({ "&[data-urgent]": { borderColor: "warning" } });
1228
+
994
1229
  // The title bar draws the top edge.
995
1230
  const noTopEdgeStyles = css({ borderBlockStartWidth: 0 });
996
1231
 
@@ -1003,3 +1238,9 @@ const noTopEdgeStyles = css({ borderBlockStartWidth: 0 });
1003
1238
  */
1004
1239
  const addressOf = (shown: string, sent: string): string =>
1005
1240
  shown === "" ? sent : shown;
1241
+
1242
+ /** A point in `view`'s page, in the viewport's CSS pixels. */
1243
+ const pagePoint = (view: HTMLElement, at: { x: number; y: number }) => {
1244
+ const box = view.getBoundingClientRect();
1245
+ return { x: box.left + at.x, y: box.top + at.y };
1246
+ };
package/src/FocusGlow.tsx CHANGED
@@ -1,14 +1,16 @@
1
- import { useRef } from "react";
1
+ import { useContext, useRef } from "react";
2
2
 
3
3
  import { css, cva, cx } from "../styled-system/css";
4
4
  import type { Rect } from "./rect";
5
5
  import type { Restack } from "./restacking";
6
+ import { SlidingScreen } from "./sliding-screen";
6
7
  import { useLowered } from "./useLowered";
7
8
  import type { Settler } from "./useSettling";
8
9
  import { useSettling } from "./useSettling";
9
10
  import type { WindowMotion } from "./window-motion";
10
11
  import { isMoving } from "./window-motion";
11
12
  import {
13
+ clippedAlong,
12
14
  heldStyles,
13
15
  movingStyles,
14
16
  originOf,
@@ -67,6 +69,7 @@ export const FocusGlow = ({
67
69
  }: Props) => {
68
70
  const element = useRef<HTMLDivElement>(null);
69
71
  const lowered = useLowered(depth);
72
+ const sliding = useContext(SlidingScreen);
70
73
  useSettling({
71
74
  element,
72
75
  origin: originOf(rect, rect),
@@ -93,6 +96,7 @@ export const FocusGlow = ({
93
96
  ref={element}
94
97
  style={{
95
98
  ...placedAt(rect, depth),
99
+ ...clippedAlong(sliding, rect),
96
100
  ...scaledAbout(rect, rect),
97
101
  ...shuffledBy(restack),
98
102
  }}
package/src/GroupWell.tsx CHANGED
@@ -1,13 +1,15 @@
1
- import { useRef } from "react";
1
+ import { useContext, useRef } from "react";
2
2
 
3
3
  import { cva, cx } from "../styled-system/css";
4
4
  import type { Rect } from "./rect";
5
5
  import type { Restack } from "./restacking";
6
+ import { SlidingScreen } from "./sliding-screen";
6
7
  import { useLowered } from "./useLowered";
7
8
  import { useSettling } from "./useSettling";
8
9
  import type { WindowMotion } from "./window-motion";
9
10
  import { isMoving } from "./window-motion";
10
11
  import {
12
+ clippedAlong,
11
13
  heldStyles,
12
14
  movingStyles,
13
15
  originOf,
@@ -58,6 +60,7 @@ export const GroupWell = ({
58
60
  }: Props) => {
59
61
  const element = useRef<HTMLDivElement>(null);
60
62
  const lowered = useLowered(depth);
63
+ const sliding = useContext(SlidingScreen);
61
64
  useSettling({
62
65
  element,
63
66
  origin: originOf(rect, rect),
@@ -76,6 +79,7 @@ export const GroupWell = ({
76
79
  ref={element}
77
80
  style={{
78
81
  ...placedAt(rect, depth),
82
+ ...clippedAlong(sliding, rect),
79
83
  ...scaledAbout(rect, rect),
80
84
  ...shuffledBy(restack),
81
85
  }}
@@ -1,14 +1,16 @@
1
- import { useRef } from "react";
1
+ import { useContext, useRef } from "react";
2
2
 
3
3
  import { css, cx } from "../styled-system/css";
4
4
  import type { Rect } from "./rect";
5
5
  import type { Restack } from "./restacking";
6
+ import { SlidingScreen } from "./sliding-screen";
6
7
  import { useLowered } from "./useLowered";
7
8
  import type { Settler } from "./useSettling";
8
9
  import { useSettling } from "./useSettling";
9
10
  import type { WindowMotion } from "./window-motion";
10
11
  import { isMoving } from "./window-motion";
11
12
  import {
13
+ clippedAlong,
12
14
  heldStyles,
13
15
  movingStyles,
14
16
  originOf,
@@ -52,6 +54,7 @@ export const SelectionTint = ({
52
54
  }: Props) => {
53
55
  const element = useRef<HTMLDivElement>(null);
54
56
  const lowered = useLowered(depth);
57
+ const sliding = useContext(SlidingScreen);
55
58
  useSettling({
56
59
  element,
57
60
  origin: originOf(rect, rect),
@@ -71,6 +74,7 @@ export const SelectionTint = ({
71
74
  ref={element}
72
75
  style={{
73
76
  ...placedAt(rect, depth),
77
+ ...clippedAlong(sliding, rect),
74
78
  ...scaledAbout(rect, rect),
75
79
  ...shuffledBy(restack),
76
80
  }}