@gtkx/testing 1.6.0 → 2.0.0-beta.2
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.
- package/README.md +5 -5
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -3
- package/dist/config.js.map +1 -1
- package/dist/fire-event.js +1 -1
- package/dist/fire-event.js.map +1 -1
- package/dist/matchers.d.ts.map +1 -1
- package/dist/matchers.js +1 -14
- package/dist/matchers.js.map +1 -1
- package/dist/queries.d.ts +30 -126
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +30 -126
- package/dist/queries.js.map +1 -1
- package/dist/query-helpers.d.ts.map +1 -1
- package/dist/query-helpers.js +8 -2
- package/dist/query-helpers.js.map +1 -1
- package/dist/screenshot.d.ts.map +1 -1
- package/dist/screenshot.js +1 -3
- package/dist/screenshot.js.map +1 -1
- package/dist/user-event/adjustment.d.ts +2 -14
- package/dist/user-event/adjustment.d.ts.map +1 -1
- package/dist/user-event/adjustment.js +2 -14
- package/dist/user-event/adjustment.js.map +1 -1
- package/dist/user-event/click.d.ts +3 -41
- package/dist/user-event/click.d.ts.map +1 -1
- package/dist/user-event/click.js +5 -43
- package/dist/user-event/click.js.map +1 -1
- package/dist/user-event/gesture.d.ts +9 -43
- package/dist/user-event/gesture.d.ts.map +1 -1
- package/dist/user-event/gesture.js +9 -43
- package/dist/user-event/gesture.js.map +1 -1
- package/dist/user-event/index.d.ts +16 -85
- package/dist/user-event/index.d.ts.map +1 -1
- package/dist/user-event/index.js +1 -5
- package/dist/user-event/index.js.map +1 -1
- package/dist/user-event/keyboard.d.ts +1 -1
- package/dist/user-event/keyboard.d.ts.map +1 -1
- package/dist/user-event/keyboard.js +1 -1
- package/dist/user-event/keyboard.js.map +1 -1
- package/dist/user-event/list-row-click.d.ts +1 -1
- package/dist/user-event/list-row-click.d.ts.map +1 -1
- package/dist/user-event/list-row-click.js +2 -1
- package/dist/user-event/list-row-click.js.map +1 -1
- package/dist/user-event/selection.d.ts +2 -18
- package/dist/user-event/selection.d.ts.map +1 -1
- package/dist/user-event/selection.js +3 -21
- package/dist/user-event/selection.js.map +1 -1
- package/dist/user-event/text.d.ts +5 -34
- package/dist/user-event/text.d.ts.map +1 -1
- package/dist/user-event/text.js +5 -34
- package/dist/user-event/text.js.map +1 -1
- package/dist/widget-accessible-properties.d.ts.map +1 -1
- package/dist/widget-accessible-properties.js +14 -34
- package/dist/widget-accessible-properties.js.map +1 -1
- package/package.json +12 -8
- package/src/config.ts +1 -3
- package/src/fire-event.ts +1 -1
- package/src/matchers.ts +1 -22
- package/src/queries.ts +30 -126
- package/src/query-helpers.ts +8 -2
- package/src/screenshot.ts +1 -3
- package/src/user-event/adjustment.ts +2 -14
- package/src/user-event/click.ts +5 -43
- package/src/user-event/gesture.ts +9 -43
- package/src/user-event/index.ts +16 -85
- package/src/user-event/keyboard.ts +1 -1
- package/src/user-event/list-row-click.ts +2 -2
- package/src/user-event/selection.ts +3 -21
- package/src/user-event/text.ts +5 -34
- package/src/widget-accessible-properties.ts +22 -44
package/dist/screenshot.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screenshot.d.ts","sourceRoot":"","sources":["../src/screenshot.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAGpC,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"screenshot.d.ts","sourceRoot":"","sources":["../src/screenshot.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAGpC,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AA2RtE;;;;;;;;;;;;;GAaG;AACH,QAAA,MAAM,UAAU,GAAU,QAAQ,GAAG,CAAC,MAAM,EAAE,UAAU,iBAAiB,KAAG,OAAO,CAAC,gBAAgB,CAkBnG,CAAC;AAYF,QAAA,MAAM,aAAa,GAAU,UAAU,iBAAiB,KAAG,OAAO,CAAC,gBAAgB,CAC5C,CAAC;AAExC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC"}
|
package/dist/screenshot.js
CHANGED
|
@@ -17,9 +17,7 @@ const NOT_PRESENTING_MESSAGE = "Screenshot failed: the display is not presenting
|
|
|
17
17
|
const EMPTY_WIDGET_HINT = "The display is presenting frames to this window, so the widget itself is empty: it painted nothing.";
|
|
18
18
|
const OTHER_FAILURE_HINT = "The display is presenting frames to this window, so the capture failed for another reason.";
|
|
19
19
|
const NOTHING_ON_SCREEN_MESSAGE = "Nothing is on screen to capture: no toplevel window is mapped";
|
|
20
|
-
const bytesToBase64 = (bytes) =>
|
|
21
|
-
return Buffer.from(bytes).toString("base64");
|
|
22
|
-
};
|
|
20
|
+
const bytesToBase64 = (bytes) => Buffer.from(bytes).toString("base64");
|
|
23
21
|
const describeWidgetState = (widget) => `realized=${String(widget.getRealized())} mapped=${String(widget.getMapped())} ` +
|
|
24
22
|
`visible=${String(widget.getVisible())}`;
|
|
25
23
|
const getMappedPopovers = (widget) => {
|
package/dist/screenshot.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screenshot.js","sourceRoot":"","sources":["../src/screenshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAC;AAC9C,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,EAA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,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IAC7D,CAAC;IAED,IAAI,OAAO,EAAE,IAAI,EAAE,CAAC;QAChB,eAAe,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC;IAED,OAAO,OAAO,CAAC,MAAM,CAAC;AAC1B,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,GAAe,EAAE;IAClC,MAAM,MAAM,GAAG,cAAc,EAAE,IAAI,eAAe,EAAE,CAAC,CAAC,CAAC,CAAC;IAExD,IAAI,CAAC,MAAM,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,KAAK,EAAE,OAA2B,EAA6B,EAAE,CACnF,UAAU,CAAC,YAAY,EAAE,EAAE,OAAO,CAAC,CAAC;AAExC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC","sourcesContent":["import * as Gdk from \"@gtkx/gi/gdk\";\nimport * as Graphene from \"@gtkx/gi/graphene\";\nimport * as Gsk from \"@gtkx/gi/gsk\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname } from \"node:path\";\nimport type { ScreenshotOptions, ScreenshotResult } from \"./types.js\";\nimport { getConfig } from \"./config.js\";\nimport { now } from \"./timers.js\";\nimport { descendants } from \"./traversal.js\";\nimport { waitFor } from \"./wait-for.js\";\nimport { activeToplevel, mappedToplevels } from \"./window-state.js\";\n\ntype FrameProbe = {\n counter: bigint | null;\n startedAt: number;\n};\n\ntype CaptureFailure = \"no-size\" | \"no-content\";\n\ntype CaptureState = {\n probe: FrameProbe;\n failure: CaptureFailure | null;\n};\n\ntype CaptureResult =\n { status: \"captured\"; result: ScreenshotResult } |\n { status: \"failed\"; failure: CaptureFailure };\n\ntype CaptureOutcome =\n { status: \"captured\"; result: ScreenshotResult } |\n { status: \"stalled\"; failure: CaptureFailure };\n\nconst DEFAULT_SCREENSHOT_INTERVAL = 10;\nconst PRESENTATION_PROBE_MS = 250;\n\nconst NOT_PRESENTING_MESSAGE =\n \"Screenshot failed: the display is not presenting frames to this window, so GTK has no rendered \" +\n \"content to capture. The window is hidden, minimized, or its compositor is not presenting it; this \" +\n \"is a display problem, not a widget problem.\";\n\nconst EMPTY_WIDGET_HINT =\n \"The display is presenting frames to this window, so the widget itself is empty: it painted nothing.\";\n\nconst OTHER_FAILURE_HINT =\n \"The display is presenting frames to this window, so the capture failed for another reason.\";\n\nconst NOTHING_ON_SCREEN_MESSAGE = \"Nothing is on screen to capture: no toplevel window is mapped\";\n\nconst bytesToBase64 = (bytes: Uint8Array | number[]): string => {\n return Buffer.from(bytes).toString(\"base64\");\n};\n\nconst describeWidgetState = (widget: Gtk.Widget): string =>\n `realized=${String(widget.getRealized())} mapped=${String(widget.getMapped())} ` +\n `visible=${String(widget.getVisible())}`;\n\nconst getMappedPopovers = (widget: Gtk.Widget): Gtk.Popover[] => {\n const popovers: Gtk.Popover[] = [];\n\n for (const descendant of descendants(widget)) {\n if (descendant instanceof Gtk.Popover && descendant.getMapped()) {\n popovers.push(descendant);\n }\n }\n\n return popovers;\n};\n\nconst appendPopover = (snapshot: Gtk.Snapshot, target: Gtk.Widget, popover: Gtk.Popover): void => {\n const [hasBounds, bounds] = popover.computeBounds(target);\n const paintable = new Gtk.WidgetPaintable({ widget: popover });\n const width = paintable.getIntrinsicWidth();\n const height = paintable.getIntrinsicHeight();\n\n if (!hasBounds || width <= 0 || height <= 0) {\n return;\n }\n\n snapshot.save();\n snapshot.translate(new Graphene.Point({ x: bounds.origin.x, y: bounds.origin.y }));\n paintable.snapshot(snapshot, width, height);\n snapshot.restore();\n};\n\nconst appendPopovers = (snapshot: Gtk.Snapshot, target: Gtk.Widget): void => {\n for (const popover of getMappedPopovers(target)) {\n appendPopover(snapshot, target, popover);\n }\n};\n\nconst getSurface = (widget: Gtk.Widget): Gdk.Surface | null => widget.getNative()?.getSurface() ?? null;\nconst isSurfaceOnScreen = (widget: Gtk.Widget): boolean => getSurface(widget)?.getMapped() ?? false;\n\nconst getFrameClock = (widget: Gtk.Widget): Gdk.FrameClock | null =>\n widget.getRoot()?.getFrameClock() ?? widget.getFrameClock();\n\nconst getFrameCounter = (widget: Gtk.Widget): bigint | null => getFrameClock(widget)?.getFrameCounter() ?? null;\n\nconst describePresentation = (widget: Gtk.Widget): string =>\n `${describeWidgetState(widget)} surfaceMapped=${String(isSurfaceOnScreen(widget))} ` +\n `frameCounter=${String(getFrameCounter(widget))}`;\n\nconst requestFrame = (widget: Gtk.Widget): void => {\n getFrameClock(widget)?.requestPhase(Gdk.FrameClockPhase.UPDATE);\n};\n\nconst startFrameProbe = (widget: Gtk.Widget): FrameProbe => {\n requestFrame(widget);\n\n return { counter: getFrameCounter(widget), startedAt: now() };\n};\n\nconst updateFrameProbe = (widget: Gtk.Widget, probe: FrameProbe): void => {\n requestFrame(widget);\n\n if (probe.counter !== null) {\n return;\n }\n\n const counter = getFrameCounter(widget);\n\n if (counter !== null) {\n probe.counter = counter;\n probe.startedAt = now();\n }\n};\n\nconst hasFrameAdvanced = (widget: Gtk.Widget, probe: FrameProbe): boolean => {\n const counter = getFrameCounter(widget);\n\n return counter !== null && probe.counter !== null && counter > probe.counter;\n};\n\nconst isPresenting = (widget: Gtk.Widget, probe: FrameProbe): boolean =>\n isSurfaceOnScreen(widget) && hasFrameAdvanced(widget, probe);\n\nconst isPresentationStalled = (widget: Gtk.Widget, probe: FrameProbe): boolean =>\n now() - probe.startedAt >= PRESENTATION_PROBE_MS && !isPresenting(widget, probe);\n\nconst allocateRoot = (widget: Gtk.Widget): void => {\n const root = widget.getRoot();\n\n if (!root) {\n return;\n }\n\n const width = root.getWidth();\n const height = root.getHeight();\n\n if (width > 0 && height > 0) {\n root.allocate(width, height, -1, null);\n }\n};\n\nconst isDirectlyPaintable = (child: Gtk.Widget): boolean =>\n child.getMapped() && child.getWidth() > 0 && !(child instanceof Gtk.Popover);\n\nconst getPaintableNode = (widget: Gtk.Widget, scale: number, width: number, height: number): Gsk.RenderNode | null => {\n const paintable = new Gtk.WidgetPaintable({ widget });\n const snapshot = new Gtk.Snapshot();\n snapshot.scale(scale, scale);\n paintable.snapshot(snapshot, width, height);\n appendPopovers(snapshot, widget);\n\n return snapshot.toNode();\n};\n\nconst getChildrenNode = (widget: Gtk.Widget, scale: number): Gsk.RenderNode | null => {\n const snapshot = new Gtk.Snapshot();\n snapshot.scale(scale, scale);\n\n for (let child = widget.getFirstChild(); child !== null; child = child.getNextSibling()) {\n if (isDirectlyPaintable(child)) {\n widget.snapshotChild(child, snapshot);\n }\n }\n\n appendPopovers(snapshot, widget);\n\n return snapshot.toNode();\n};\n\nconst getRenderNode = (widget: Gtk.Widget, scale: number, width: number, height: number): Gsk.RenderNode | null => {\n const presented = getPaintableNode(widget, scale, width, height);\n\n if (presented) {\n return presented;\n }\n\n allocateRoot(widget);\n\n return getPaintableNode(widget, scale, width, height) ?? getChildrenNode(widget, scale);\n};\n\nconst renderToPng = (widget: Gtk.Widget, node: Gsk.RenderNode, width: number, height: number): ScreenshotResult => {\n const renderer = new Gsk.CairoRenderer();\n renderer.realizeForDisplay(widget.getDisplay());\n\n try {\n const viewport = Graphene.Rect.alloc().init(0, 0, width, height);\n const texture = renderer.renderTexture(node, viewport);\n const data = texture.saveToPngBytes().getData();\n\n if (!data) {\n throw new Error(\"Failed to serialize screenshot to PNG\");\n }\n\n return { data: bytesToBase64(data), mimeType: \"image/png\", width, height };\n } finally {\n renderer.unrealize();\n }\n};\n\nconst captureSnapshot = (widget: Gtk.Widget, scale: number): CaptureResult => {\n const paintable = new Gtk.WidgetPaintable({ widget });\n const width = paintable.getIntrinsicWidth();\n const height = paintable.getIntrinsicHeight();\n\n if (width <= 0 || height <= 0) {\n return { status: \"failed\", failure: \"no-size\" };\n }\n\n const renderNode = getRenderNode(widget, scale, width, height);\n\n if (!renderNode) {\n return { status: \"failed\", failure: \"no-content\" };\n }\n\n const scaledWidth = Math.round(width * scale);\n const scaledHeight = Math.round(height * scale);\n\n return { status: \"captured\", result: renderToPng(widget, renderNode, scaledWidth, scaledHeight) };\n};\n\nconst failureMessage = (widget: Gtk.Widget, failure: CaptureFailure): string =>\n failure === \"no-size\"\n ? `Widget has no size: ensure it is realized and visible (${describeWidgetState(widget)})`\n : `Widget produced no render content (${describeWidgetState(widget)})`;\n\nconst notPresentingMessage = (widget: Gtk.Widget): string =>\n `${NOT_PRESENTING_MESSAGE} (${describePresentation(widget)})`;\n\nconst stalledMessage = (widget: Gtk.Widget, failure: CaptureFailure): string =>\n `${notPresentingMessage(widget)}\\n\\n${failureMessage(widget, failure)}`;\n\nconst presentingHint = (failure: CaptureFailure | null): string =>\n failure === \"no-content\" ? EMPTY_WIDGET_HINT : OTHER_FAILURE_HINT;\n\nconst timeoutHint = (widget: Gtk.Widget, state: CaptureState): string =>\n isPresenting(widget, state.probe) ? presentingHint(state.failure) : notPresentingMessage(widget);\n\nconst explainTimeout = (error: Error, widget: Gtk.Widget, state: CaptureState): Error =>\n getConfig().getElementError(`${error.message}\\n\\n${timeoutHint(widget, state)}`);\n\nconst attemptCapture = (widget: Gtk.Widget, scale: number, state: CaptureState): CaptureOutcome => {\n const attempt = captureSnapshot(widget, scale);\n\n if (attempt.status === \"captured\") {\n return attempt;\n }\n\n state.failure = attempt.failure;\n updateFrameProbe(widget, state.probe);\n\n if (isPresentationStalled(widget, state.probe)) {\n return { status: \"stalled\", failure: attempt.failure };\n }\n\n throw new Error(failureMessage(widget, attempt.failure));\n};\n\nconst writeScreenshot = (result: ScreenshotResult, path: string): void => {\n mkdirSync(dirname(path), { recursive: true });\n writeFileSync(path, Buffer.from(result.data, \"base64\"));\n};\n\nconst captureUntilPaintable = (\n widget: Gtk.Widget,\n scale: number,\n options: ScreenshotOptions | undefined,\n): Promise<CaptureOutcome> => {\n const state: CaptureState = { probe: startFrameProbe(widget), failure: null };\n\n return waitFor(() => attemptCapture(widget, scale, state), {\n timeout: options?.timeout,\n interval: options?.interval ?? DEFAULT_SCREENSHOT_INTERVAL,\n onTimeout: (error) => explainTimeout(error, widget, state),\n });\n};\n\n/**\n * Captures a PNG snapshot of a widget, retrying until it has a paintable size,\n * and writes the image to `options.path` when one is given, creating any\n * missing parent directories. Popovers open inside the widget render on their\n * own surfaces, so they are composited into the image at their on-screen\n * positions. A display that never presents a frame leaves GTK without a cached\n * render node, so the widget's contents are then snapshotted directly; when\n * even that yields nothing, the failure names the display instead of blaming\n * the widget.\n *\n * @param widget The widget to render to an image.\n * @param options Optional scale, timeout, retry interval, and output path.\n * @returns The base64-encoded PNG data along with its mime type and dimensions.\n */\nconst screenshot = async (widget: Gtk.Widget, options?: ScreenshotOptions): Promise<ScreenshotResult> => {\n const scale = options?.scale ?? 1;\n\n if (!Number.isFinite(scale) || scale <= 0) {\n throw new Error(`Screenshot scale must be a positive number, got ${String(scale)}`);\n }\n\n const outcome = await captureUntilPaintable(widget, scale, options);\n\n if (outcome.status === \"stalled\") {\n throw new Error(stalledMessage(widget, outcome.failure));\n }\n\n if (options?.path) {\n writeScreenshot(outcome.result, options.path);\n }\n\n return outcome.result;\n};\n\nconst screenTarget = (): Gtk.Window => {\n const target = activeToplevel() ?? mappedToplevels()[0];\n\n if (!target) {\n throw new Error(NOTHING_ON_SCREEN_MESSAGE);\n }\n\n return target;\n};\n\nconst captureScreen = async (options?: ScreenshotOptions): Promise<ScreenshotResult> =>\n screenshot(screenTarget(), options);\n\nexport { captureScreen, screenshot };\n"]}
|
|
1
|
+
{"version":3,"file":"screenshot.js","sourceRoot":"","sources":["../src/screenshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAC;AAC9C,OAAO,KAAK,GAAG,MAAM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,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,mDAAmD,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACxF,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,qBAAqB,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAEpE,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IAC7D,CAAC;IAED,IAAI,OAAO,EAAE,IAAI,EAAE,CAAC;QAChB,eAAe,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC;IAED,OAAO,OAAO,CAAC,MAAM,CAAC;AAC1B,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,GAAe,EAAE;IAClC,MAAM,MAAM,GAAG,cAAc,EAAE,IAAI,eAAe,EAAE,CAAC,CAAC,CAAC,CAAC;IAExD,IAAI,CAAC,MAAM,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,KAAK,EAAE,OAA2B,EAA6B,EAAE,CACnF,UAAU,CAAC,YAAY,EAAE,EAAE,OAAO,CAAC,CAAC;AAExC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,CAAC","sourcesContent":["import * as Gdk from \"@gtkx/gi/gdk\";\nimport * as Graphene from \"@gtkx/gi/graphene\";\nimport * as Gsk from \"@gtkx/gi/gsk\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname } from \"node:path\";\nimport type { ScreenshotOptions, ScreenshotResult } from \"./types.js\";\nimport { getConfig } from \"./config.js\";\nimport { now } from \"./timers.js\";\nimport { descendants } from \"./traversal.js\";\nimport { waitFor } from \"./wait-for.js\";\nimport { activeToplevel, mappedToplevels } from \"./window-state.js\";\n\ntype FrameProbe = {\n counter: bigint | null;\n startedAt: number;\n};\n\ntype CaptureFailure = \"no-size\" | \"no-content\";\n\ntype CaptureState = {\n probe: FrameProbe;\n failure: CaptureFailure | null;\n};\n\ntype CaptureResult =\n { status: \"captured\"; result: ScreenshotResult } |\n { status: \"failed\"; failure: CaptureFailure };\n\ntype CaptureOutcome =\n { status: \"captured\"; result: ScreenshotResult } |\n { status: \"stalled\"; failure: CaptureFailure };\n\nconst DEFAULT_SCREENSHOT_INTERVAL = 10;\nconst PRESENTATION_PROBE_MS = 250;\n\nconst NOT_PRESENTING_MESSAGE =\n \"Screenshot failed: the display is not presenting frames to this window, so GTK has no rendered \" +\n \"content to capture. The window is hidden, minimized, or its compositor is not presenting it; this \" +\n \"is a display problem, not a widget problem.\";\n\nconst EMPTY_WIDGET_HINT =\n \"The display is presenting frames to this window, so the widget itself is empty: it painted nothing.\";\n\nconst OTHER_FAILURE_HINT =\n \"The display is presenting frames to this window, so the capture failed for another reason.\";\n\nconst NOTHING_ON_SCREEN_MESSAGE = \"Nothing is on screen to capture: no toplevel window is mapped\";\n\nconst bytesToBase64 = (bytes: Uint8Array | number[]): string => Buffer.from(bytes).toString(\"base64\");\n\nconst describeWidgetState = (widget: Gtk.Widget): string =>\n `realized=${String(widget.getRealized())} mapped=${String(widget.getMapped())} ` +\n `visible=${String(widget.getVisible())}`;\n\nconst getMappedPopovers = (widget: Gtk.Widget): Gtk.Popover[] => {\n const popovers: Gtk.Popover[] = [];\n\n for (const descendant of descendants(widget)) {\n if (descendant instanceof Gtk.Popover && descendant.getMapped()) {\n popovers.push(descendant);\n }\n }\n\n return popovers;\n};\n\nconst appendPopover = (snapshot: Gtk.Snapshot, target: Gtk.Widget, popover: Gtk.Popover): void => {\n const [hasBounds, bounds] = popover.computeBounds(target);\n const paintable = new Gtk.WidgetPaintable({ widget: popover });\n const width = paintable.getIntrinsicWidth();\n const height = paintable.getIntrinsicHeight();\n\n if (!hasBounds || width <= 0 || height <= 0) {\n return;\n }\n\n snapshot.save();\n snapshot.translate(new Graphene.Point({ x: bounds.origin.x, y: bounds.origin.y }));\n paintable.snapshot(snapshot, width, height);\n snapshot.restore();\n};\n\nconst appendPopovers = (snapshot: Gtk.Snapshot, target: Gtk.Widget): void => {\n for (const popover of getMappedPopovers(target)) {\n appendPopover(snapshot, target, popover);\n }\n};\n\nconst getSurface = (widget: Gtk.Widget): Gdk.Surface | null => widget.getNative()?.getSurface() ?? null;\nconst isSurfaceOnScreen = (widget: Gtk.Widget): boolean => getSurface(widget)?.getMapped() ?? false;\n\nconst getFrameClock = (widget: Gtk.Widget): Gdk.FrameClock | null =>\n widget.getRoot()?.getFrameClock() ?? widget.getFrameClock();\n\nconst getFrameCounter = (widget: Gtk.Widget): bigint | null => getFrameClock(widget)?.getFrameCounter() ?? null;\n\nconst describePresentation = (widget: Gtk.Widget): string =>\n `${describeWidgetState(widget)} surfaceMapped=${String(isSurfaceOnScreen(widget))} ` +\n `frameCounter=${String(getFrameCounter(widget))}`;\n\nconst requestFrame = (widget: Gtk.Widget): void => {\n getFrameClock(widget)?.requestPhase(Gdk.FrameClockPhase.UPDATE);\n};\n\nconst startFrameProbe = (widget: Gtk.Widget): FrameProbe => {\n requestFrame(widget);\n\n return { counter: getFrameCounter(widget), startedAt: now() };\n};\n\nconst updateFrameProbe = (widget: Gtk.Widget, probe: FrameProbe): void => {\n requestFrame(widget);\n\n if (probe.counter !== null) {\n return;\n }\n\n const counter = getFrameCounter(widget);\n\n if (counter !== null) {\n probe.counter = counter;\n probe.startedAt = now();\n }\n};\n\nconst hasFrameAdvanced = (widget: Gtk.Widget, probe: FrameProbe): boolean => {\n const counter = getFrameCounter(widget);\n\n return counter !== null && probe.counter !== null && counter > probe.counter;\n};\n\nconst isPresenting = (widget: Gtk.Widget, probe: FrameProbe): boolean =>\n isSurfaceOnScreen(widget) && hasFrameAdvanced(widget, probe);\n\nconst isPresentationStalled = (widget: Gtk.Widget, probe: FrameProbe): boolean =>\n now() - probe.startedAt >= PRESENTATION_PROBE_MS && !isPresenting(widget, probe);\n\nconst allocateRoot = (widget: Gtk.Widget): void => {\n const root = widget.getRoot();\n\n if (!root) {\n return;\n }\n\n const width = root.getWidth();\n const height = root.getHeight();\n\n if (width > 0 && height > 0) {\n root.allocate(width, height, -1, null);\n }\n};\n\nconst isDirectlyPaintable = (child: Gtk.Widget): boolean =>\n child.getMapped() && child.getWidth() > 0 && !(child instanceof Gtk.Popover);\n\nconst getPaintableNode = (widget: Gtk.Widget, scale: number, width: number, height: number): Gsk.RenderNode | null => {\n const paintable = new Gtk.WidgetPaintable({ widget });\n const snapshot = new Gtk.Snapshot();\n snapshot.scale(scale, scale);\n paintable.snapshot(snapshot, width, height);\n appendPopovers(snapshot, widget);\n\n return snapshot.toNode();\n};\n\nconst getChildrenNode = (widget: Gtk.Widget, scale: number): Gsk.RenderNode | null => {\n const snapshot = new Gtk.Snapshot();\n snapshot.scale(scale, scale);\n\n for (let child = widget.getFirstChild(); child !== null; child = child.getNextSibling()) {\n if (isDirectlyPaintable(child)) {\n widget.snapshotChild(child, snapshot);\n }\n }\n\n appendPopovers(snapshot, widget);\n\n return snapshot.toNode();\n};\n\nconst getRenderNode = (widget: Gtk.Widget, scale: number, width: number, height: number): Gsk.RenderNode | null => {\n const presented = getPaintableNode(widget, scale, width, height);\n\n if (presented) {\n return presented;\n }\n\n allocateRoot(widget);\n\n return getPaintableNode(widget, scale, width, height) ?? getChildrenNode(widget, scale);\n};\n\nconst renderToPng = (widget: Gtk.Widget, node: Gsk.RenderNode, width: number, height: number): ScreenshotResult => {\n const renderer = new Gsk.CairoRenderer();\n renderer.realizeForDisplay(widget.getDisplay());\n\n try {\n const viewport = Graphene.Rect.alloc().init(0, 0, width, height);\n const texture = renderer.renderTexture(node, viewport);\n const data = texture.saveToPngBytes().getData();\n\n if (!data) {\n throw new Error(\"Failed to serialize screenshot to PNG\");\n }\n\n return { data: bytesToBase64(data), mimeType: \"image/png\", width, height };\n } finally {\n renderer.unrealize();\n }\n};\n\nconst captureSnapshot = (widget: Gtk.Widget, scale: number): CaptureResult => {\n const paintable = new Gtk.WidgetPaintable({ widget });\n const width = paintable.getIntrinsicWidth();\n const height = paintable.getIntrinsicHeight();\n\n if (width <= 0 || height <= 0) {\n return { status: \"failed\", failure: \"no-size\" };\n }\n\n const renderNode = getRenderNode(widget, scale, width, height);\n\n if (!renderNode) {\n return { status: \"failed\", failure: \"no-content\" };\n }\n\n const scaledWidth = Math.round(width * scale);\n const scaledHeight = Math.round(height * scale);\n\n return { status: \"captured\", result: renderToPng(widget, renderNode, scaledWidth, scaledHeight) };\n};\n\nconst failureMessage = (widget: Gtk.Widget, failure: CaptureFailure): string =>\n failure === \"no-size\"\n ? `Widget has no size: ensure it is realized and visible (${describeWidgetState(widget)})`\n : `Widget produced no render content (${describeWidgetState(widget)})`;\n\nconst notPresentingMessage = (widget: Gtk.Widget): string =>\n `${NOT_PRESENTING_MESSAGE} (${describePresentation(widget)})`;\n\nconst stalledMessage = (widget: Gtk.Widget, failure: CaptureFailure): string =>\n `${notPresentingMessage(widget)}\\n\\n${failureMessage(widget, failure)}`;\n\nconst presentingHint = (failure: CaptureFailure | null): string =>\n failure === \"no-content\" ? EMPTY_WIDGET_HINT : OTHER_FAILURE_HINT;\n\nconst timeoutHint = (widget: Gtk.Widget, state: CaptureState): string =>\n isPresenting(widget, state.probe) ? presentingHint(state.failure) : notPresentingMessage(widget);\n\nconst explainTimeout = (error: Error, widget: Gtk.Widget, state: CaptureState): Error =>\n getConfig().getElementError(`${error.message}\\n\\n${timeoutHint(widget, state)}`);\n\nconst attemptCapture = (widget: Gtk.Widget, scale: number, state: CaptureState): CaptureOutcome => {\n const attempt = captureSnapshot(widget, scale);\n\n if (attempt.status === \"captured\") {\n return attempt;\n }\n\n state.failure = attempt.failure;\n updateFrameProbe(widget, state.probe);\n\n if (isPresentationStalled(widget, state.probe)) {\n return { status: \"stalled\", failure: attempt.failure };\n }\n\n throw new Error(failureMessage(widget, attempt.failure));\n};\n\nconst writeScreenshot = (result: ScreenshotResult, path: string): void => {\n mkdirSync(dirname(path), { recursive: true });\n writeFileSync(path, Buffer.from(result.data, \"base64\"));\n};\n\nconst captureUntilPaintable = (\n widget: Gtk.Widget,\n scale: number,\n options: ScreenshotOptions | undefined,\n): Promise<CaptureOutcome> => {\n const state: CaptureState = { probe: startFrameProbe(widget), failure: null };\n\n return waitFor(() => attemptCapture(widget, scale, state), {\n timeout: options?.timeout,\n interval: options?.interval ?? DEFAULT_SCREENSHOT_INTERVAL,\n onTimeout: (error) => explainTimeout(error, widget, state),\n });\n};\n\n/**\n * Captures a PNG snapshot of a widget, retrying until it has a paintable size,\n * and writes the image to `options.path` when one is given, creating any\n * missing parent directories. Popovers open inside the widget render on their\n * own surfaces, so they are composited into the image at their on-screen\n * positions. A display that never presents a frame leaves GTK without a cached\n * render node, so the widget's contents are then snapshotted directly; when\n * even that yields nothing, the failure names the display instead of blaming\n * the widget.\n *\n * @param widget The widget to render to an image.\n * @param options Optional scale, timeout, retry interval, and output path.\n * @returns The base64-encoded PNG data along with its mime type and dimensions.\n */\nconst screenshot = async (widget: Gtk.Widget, options?: ScreenshotOptions): Promise<ScreenshotResult> => {\n const scale = options?.scale ?? 1;\n\n if (!Number.isFinite(scale) || scale <= 0) {\n throw new Error(`Screenshot scale must be a positive number, got ${String(scale)}`);\n }\n\n const outcome = await captureUntilPaintable(widget, scale, options);\n\n if (outcome.status === \"stalled\") {\n throw new Error(stalledMessage(widget, outcome.failure));\n }\n\n if (options?.path) {\n writeScreenshot(outcome.result, options.path);\n }\n\n return outcome.result;\n};\n\nconst screenTarget = (): Gtk.Window => {\n const target = activeToplevel() ?? mappedToplevels()[0];\n\n if (!target) {\n throw new Error(NOTHING_ON_SCREEN_MESSAGE);\n }\n\n return target;\n};\n\nconst captureScreen = async (options?: ScreenshotOptions): Promise<ScreenshotResult> =>\n screenshot(screenTarget(), options);\n\nexport { captureScreen, screenshot };\n"]}
|
|
@@ -6,21 +6,9 @@ type ScrollDelta = {
|
|
|
6
6
|
/** Distance added to the vertical adjustment. */
|
|
7
7
|
y?: number;
|
|
8
8
|
};
|
|
9
|
-
/**
|
|
10
|
-
* Emits a jump `change-value` so a Gtk.Range moves to the given value.
|
|
11
|
-
*
|
|
12
|
-
* @throws When the widget is not a Gtk.Range.
|
|
13
|
-
*/
|
|
9
|
+
/** Moves a range to a value. */
|
|
14
10
|
declare const slide: (widget: Gtk.Widget, value: number) => Promise<void>;
|
|
15
|
-
/**
|
|
16
|
-
* Adds the delta to the adjustments of the widget itself, or of its nearest Gtk.ScrolledWindow or
|
|
17
|
-
* Gtk.Scrollable ancestor.
|
|
18
|
-
*
|
|
19
|
-
* Each adjustment advances in viewport-sized steps rather than one jump, so virtualized views such
|
|
20
|
-
* as Gtk.ListView, Gtk.GridView and Gtk.ColumnView re-anchor onto the rows the new offset shows.
|
|
21
|
-
*
|
|
22
|
-
* @throws When neither the widget nor any of its ancestors is scrollable.
|
|
23
|
-
*/
|
|
11
|
+
/** Scrolls the widget or its nearest scrollable ancestor. */
|
|
24
12
|
declare const scroll: (widget: Gtk.Widget, delta: ScrollDelta) => Promise<void>;
|
|
25
13
|
export { slide, scroll, type ScrollDelta };
|
|
26
14
|
//# sourceMappingURL=adjustment.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adjustment.d.ts","sourceRoot":"","sources":["../../src/user-event/adjustment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAKpC,mDAAmD;AACnD,KAAK,WAAW,GAAG;IACf,mDAAmD;IACnD,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,iDAAiD;IACjD,CAAC,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAOF
|
|
1
|
+
{"version":3,"file":"adjustment.d.ts","sourceRoot":"","sources":["../../src/user-event/adjustment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAKpC,mDAAmD;AACnD,KAAK,WAAW,GAAG;IACf,mDAAmD;IACnD,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,iDAAiD;IACjD,CAAC,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAOF,gCAAgC;AAChC,QAAA,MAAM,KAAK,GAAI,QAAQ,GAAG,CAAC,MAAM,EAAE,OAAO,MAAM,KAAG,OAAO,CAAC,IAAI,CASzD,CAAC;AA8CP,6DAA6D;AAC7D,QAAA,MAAM,MAAM,GAAI,QAAQ,GAAG,CAAC,MAAM,EAAE,OAAO,WAAW,KAAG,OAAO,CAAC,IAAI,CAa/D,CAAC;AAEP,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,WAAW,EAAE,CAAC"}
|
|
@@ -2,11 +2,7 @@ import * as Gtk from "@gtkx/gi/gtk";
|
|
|
2
2
|
import { scheduleNextFrame } from "../frame-sync.js";
|
|
3
3
|
import { getTypeTag } from "../widget-getters.js";
|
|
4
4
|
import { wrapEvent } from "./event-wrapper.js";
|
|
5
|
-
/**
|
|
6
|
-
* Emits a jump `change-value` so a Gtk.Range moves to the given value.
|
|
7
|
-
*
|
|
8
|
-
* @throws When the widget is not a Gtk.Range.
|
|
9
|
-
*/
|
|
5
|
+
/** Moves a range to a value. */
|
|
10
6
|
const slide = (widget, value) => wrapEvent(widget, () => {
|
|
11
7
|
if (!(widget instanceof Gtk.Range)) {
|
|
12
8
|
throw new TypeError(`userEvent.slide requires a Gtk.Range (e.g. Gtk.Scale), got ${getTypeTag(widget)}`);
|
|
@@ -46,15 +42,7 @@ const applyScrollDelta = (adjustment, delta) => {
|
|
|
46
42
|
const pageSize = adjustment.getPageSize();
|
|
47
43
|
rampTo(adjustment, adjustment.getValue() + delta, pageSize > 0 ? pageSize : Math.abs(delta));
|
|
48
44
|
};
|
|
49
|
-
/**
|
|
50
|
-
* Adds the delta to the adjustments of the widget itself, or of its nearest Gtk.ScrolledWindow or
|
|
51
|
-
* Gtk.Scrollable ancestor.
|
|
52
|
-
*
|
|
53
|
-
* Each adjustment advances in viewport-sized steps rather than one jump, so virtualized views such
|
|
54
|
-
* as Gtk.ListView, Gtk.GridView and Gtk.ColumnView re-anchor onto the rows the new offset shows.
|
|
55
|
-
*
|
|
56
|
-
* @throws When neither the widget nor any of its ancestors is scrollable.
|
|
57
|
-
*/
|
|
45
|
+
/** Scrolls the widget or its nearest scrollable ancestor. */
|
|
58
46
|
const scroll = (widget, delta) => wrapEvent(widget, async () => {
|
|
59
47
|
const adjustments = resolveScrollAdjustments(widget);
|
|
60
48
|
if (!adjustments) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adjustment.js","sourceRoot":"","sources":["../../src/user-event/adjustment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAe/C
|
|
1
|
+
{"version":3,"file":"adjustment.js","sourceRoot":"","sources":["../../src/user-event/adjustment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAe/C,gCAAgC;AAChC,MAAM,KAAK,GAAG,CAAC,MAAkB,EAAE,KAAa,EAAiB,EAAE,CAC/D,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE;IACnB,IAAI,CAAC,CAAC,MAAM,YAAY,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,SAAS,CAC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AO,EAAE,KAAK,EAAE,MAAM,EAAoB,CAAC","sourcesContent":["import * as Gtk from \"@gtkx/gi/gtk\";\nimport { scheduleNextFrame } from \"../frame-sync.js\";\nimport { getTypeTag } from \"../widget-getters.js\";\nimport { wrapEvent } from \"./event-wrapper.js\";\n\n/** A scroll distance in pixels along each axis. */\ntype ScrollDelta = {\n /** Distance added to the horizontal adjustment. */\n x?: number;\n /** Distance added to the vertical adjustment. */\n y?: number;\n};\n\ntype ScrollAdjustments = {\n horizontal: Gtk.Adjustment | null;\n vertical: Gtk.Adjustment | null;\n};\n\n/** Moves a range to a value. */\nconst slide = (widget: Gtk.Widget, value: number): Promise<void> =>\n wrapEvent(widget, () => {\n if (!(widget instanceof Gtk.Range)) {\n throw new TypeError(\n `userEvent.slide requires a Gtk.Range (e.g. Gtk.Scale), got ${getTypeTag(widget)}`,\n );\n }\n\n widget.emit(\"change-value\", Gtk.ScrollType.JUMP, value);\n });\n\nconst resolveScrollAdjustments = (widget: Gtk.Widget): ScrollAdjustments | null => {\n for (let current: Gtk.Widget | null = widget; current; current = current.getParent()) {\n if (current instanceof Gtk.ScrolledWindow) {\n return { horizontal: current.getHadjustment(), vertical: current.getVadjustment() };\n }\n\n if (current instanceof Gtk.Scrollable) {\n return { horizontal: current.getHadjustment(), vertical: current.getVadjustment() };\n }\n }\n\n return null;\n};\n\nconst stepToward = (adjustment: Gtk.Adjustment, target: number, step: number): number => {\n const value = adjustment.getValue();\n adjustment.setValue(value < target ? Math.min(value + step, target) : Math.max(value - step, target));\n\n return adjustment.getValue();\n};\n\nconst rampTo = (adjustment: Gtk.Adjustment, target: number, step: number): void => {\n let value = adjustment.getValue();\n\n while (value !== target) {\n const moved = stepToward(adjustment, target, step);\n\n if (moved === value) {\n return;\n }\n\n value = moved;\n }\n};\n\nconst applyScrollDelta = (adjustment: Gtk.Adjustment | null, delta: number): void => {\n if (!adjustment || delta === 0) {\n return;\n }\n\n const pageSize = adjustment.getPageSize();\n rampTo(adjustment, adjustment.getValue() + delta, pageSize > 0 ? pageSize : Math.abs(delta));\n};\n\n/** Scrolls the widget or its nearest scrollable ancestor. */\nconst scroll = (widget: Gtk.Widget, delta: ScrollDelta): Promise<void> =>\n wrapEvent(widget, async () => {\n const adjustments = resolveScrollAdjustments(widget);\n\n if (!adjustments) {\n throw new Error(\n \"userEvent.scroll: no Gtk.ScrolledWindow or Gtk.Scrollable found on the widget or its ancestors\",\n );\n }\n\n applyScrollDelta(adjustments.horizontal, delta.x ?? 0);\n applyScrollDelta(adjustments.vertical, delta.y ?? 0);\n await scheduleNextFrame(widget);\n });\n\nexport { slide, scroll, type ScrollDelta };\n"]}
|
|
@@ -3,49 +3,11 @@ type ClickPhase = "pressed" | "released";
|
|
|
3
3
|
declare const emitClickPhase: (widget: Gtk.Widget, controllers: Gtk.GestureClick[], nPress: number, phase: ClickPhase) => void;
|
|
4
4
|
declare const clickGestures: (widget: Gtk.Widget) => Gtk.GestureClick[];
|
|
5
5
|
declare const getAuthoredClickGestures: (widget: Gtk.Widget) => Gtk.GestureClick[];
|
|
6
|
-
/**
|
|
7
|
-
* Activates a widget that neither claims the click nor carries a click gesture of its own, and
|
|
8
|
-
* otherwise delivers a press and release. The press travels outwards from the clicked widget
|
|
9
|
-
* through every widget carrying a click gesture with a pressed or released handler, the way GTK
|
|
10
|
-
* hands the same press to each of them, and stops at the first Gtk.Button or indexed child of a
|
|
11
|
-
* list box or flow box, which claims it. A gesture GTK attached itself takes the press only when no
|
|
12
|
-
* widget below it handles one, and stops it there, so an expander or a notebook tab nested in a row
|
|
13
|
-
* opens instead of activating the row. Coordinates are the clicked widget's position in each
|
|
14
|
-
* carrier, so a gesture the container of an indexed child carries reads the child's position rather
|
|
15
|
-
* than the container's center. An indexed child that the press reaches is then activated, or
|
|
16
|
-
* exclusively selected when its container does not activate on a single click. A widget with the
|
|
17
|
-
* label role is never activated, but does consume the click when it carries a gesture of its own.
|
|
18
|
-
*
|
|
19
|
-
* The press also stops at a widget whose click GTK4 implements in C on a gesture it attached
|
|
20
|
-
* itself, reading a GdkEvent that off-screen synthesis cannot produce. Gestures that widget carries
|
|
21
|
-
* of its own still take the press and release, the way GTK hands them the press before its own
|
|
22
|
-
* gesture claims it, and the same outcome is then applied through the public action GTK's own
|
|
23
|
-
* handler invokes: a list, grid, or column-view row is focused and selected, and activated as well
|
|
24
|
-
* on a second press or when its view activates on a single click; an expandable tree expander
|
|
25
|
-
* toggles its expansion, once per press, and only when it is the widget clicked, so a click on its
|
|
26
|
-
* child falls through to the enclosing row; a notebook tab, clicked directly or through its label,
|
|
27
|
-
* focuses its notebook and switches to its page; a column header sorts by its column. Sorting goes
|
|
28
|
-
* through Gtk.ColumnView.sortByColumn, so the primary sort column and order match what a pointer
|
|
29
|
-
* produces while previously sorted columns are dropped rather than kept as secondary keys. A
|
|
30
|
-
* column-view cell and the row that carries the column headers stand in the way of the click rather
|
|
31
|
-
* than taking it, so a click on either reaches the row or the view behind it.
|
|
32
|
-
*/
|
|
6
|
+
/** Activates or presses and releases a widget. */
|
|
33
7
|
declare const click: (widget: Gtk.Widget) => Promise<void>;
|
|
34
|
-
/**
|
|
35
|
-
* Delivers a two-press click gesture the way {@link click} delivers a single press, without trying
|
|
36
|
-
* activation first. A list box row or flow box child the presses reach, clicked directly or through
|
|
37
|
-
* a descendant, is activated and exclusively selected, as GTK's double-click path does whether or
|
|
38
|
-
* not the container activates on a single click. A widget whose click GTK4 implements itself
|
|
39
|
-
* receives that outcome once per press, so a list, grid, or column-view row is selected and then
|
|
40
|
-
* activated by the second press, a tree expander ends back where it started, a notebook tab stays on
|
|
41
|
-
* the page the first press opened, and a column header sorts and then inverts its order.
|
|
42
|
-
*/
|
|
8
|
+
/** Delivers a double-click gesture. */
|
|
43
9
|
declare const dblClick: (widget: Gtk.Widget) => Promise<void>;
|
|
44
|
-
/**
|
|
45
|
-
* Delivers a three-press click gesture the same way a double click is delivered, applying the same
|
|
46
|
-
* outcome to a list box row or flow box child the presses reach, and applying the outcome GTK4
|
|
47
|
-
* implements itself once per press to a row, tree expander, notebook tab, or column header.
|
|
48
|
-
*/
|
|
10
|
+
/** Delivers a triple-click gesture. */
|
|
49
11
|
declare const tripleClick: (widget: Gtk.Widget) => Promise<void>;
|
|
50
12
|
export { clickGestures, emitClickPhase, getAuthoredClickGestures, click, dblClick, tripleClick };
|
|
51
13
|
//# sourceMappingURL=click.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"click.d.ts","sourceRoot":"","sources":["../../src/user-event/click.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AASpC,KAAK,UAAU,GAAG,SAAS,GAAG,UAAU,CAAC;AAmDzC,QAAA,MAAM,cAAc,GAChB,QAAQ,GAAG,CAAC,MAAM,EAClB,aAAa,GAAG,CAAC,YAAY,EAAE,EAC/B,QAAQ,MAAM,EACd,OAAO,UAAU,KAClB,IAEF,CAAC;AAyBF,QAAA,MAAM,aAAa,GAAI,QAAQ,GAAG,CAAC,MAAM,KAAG,GAAG,CAAC,YAAY,EACoC,CAAC;AAEjG,QAAA,MAAM,wBAAwB,GAAI,QAAQ,GAAG,CAAC,MAAM,KAAG,GAAG,CAAC,YAAY,EACC,CAAC;AA6JzE
|
|
1
|
+
{"version":3,"file":"click.d.ts","sourceRoot":"","sources":["../../src/user-event/click.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AASpC,KAAK,UAAU,GAAG,SAAS,GAAG,UAAU,CAAC;AAmDzC,QAAA,MAAM,cAAc,GAChB,QAAQ,GAAG,CAAC,MAAM,EAClB,aAAa,GAAG,CAAC,YAAY,EAAE,EAC/B,QAAQ,MAAM,EACd,OAAO,UAAU,KAClB,IAEF,CAAC;AAyBF,QAAA,MAAM,aAAa,GAAI,QAAQ,GAAG,CAAC,MAAM,KAAG,GAAG,CAAC,YAAY,EACoC,CAAC;AAEjG,QAAA,MAAM,wBAAwB,GAAI,QAAQ,GAAG,CAAC,MAAM,KAAG,GAAG,CAAC,YAAY,EACC,CAAC;AA6JzE,kDAAkD;AAClD,QAAA,MAAM,KAAK,GAAU,QAAQ,GAAG,CAAC,MAAM,KAAG,OAAO,CAAC,IAAI,CAMrD,CAAC;AAEF,uCAAuC;AACvC,QAAA,MAAM,QAAQ,GAAI,QAAQ,GAAG,CAAC,MAAM,KAAG,OAAO,CAAC,IAAI,CAA4B,CAAC;AAChF,uCAAuC;AACvC,QAAA,MAAM,WAAW,GAAI,QAAQ,GAAG,CAAC,MAAM,KAAG,OAAO,CAAC,IAAI,CAA4B,CAAC;AAEnF,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,wBAAwB,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC"}
|
package/dist/user-event/click.js
CHANGED
|
@@ -124,7 +124,7 @@ const applyContainerOutcome = (target, nPress) => {
|
|
|
124
124
|
return;
|
|
125
125
|
}
|
|
126
126
|
if (isActivatedByClick(container, nPress)) {
|
|
127
|
-
|
|
127
|
+
Gtk.Widget.prototype.activate.call(widget);
|
|
128
128
|
}
|
|
129
129
|
if (isSelectionReplacedByClick(container, nPress)) {
|
|
130
130
|
replaceContainerSelection(container, widget);
|
|
@@ -155,58 +155,20 @@ const tryActivate = async (widget) => {
|
|
|
155
155
|
}
|
|
156
156
|
let isActivated = false;
|
|
157
157
|
await wrapEvent(widget, () => {
|
|
158
|
-
isActivated =
|
|
158
|
+
isActivated = Gtk.Widget.prototype.activate.call(widget);
|
|
159
159
|
});
|
|
160
160
|
return isActivated;
|
|
161
161
|
};
|
|
162
|
-
/**
|
|
163
|
-
* Activates a widget that neither claims the click nor carries a click gesture of its own, and
|
|
164
|
-
* otherwise delivers a press and release. The press travels outwards from the clicked widget
|
|
165
|
-
* through every widget carrying a click gesture with a pressed or released handler, the way GTK
|
|
166
|
-
* hands the same press to each of them, and stops at the first Gtk.Button or indexed child of a
|
|
167
|
-
* list box or flow box, which claims it. A gesture GTK attached itself takes the press only when no
|
|
168
|
-
* widget below it handles one, and stops it there, so an expander or a notebook tab nested in a row
|
|
169
|
-
* opens instead of activating the row. Coordinates are the clicked widget's position in each
|
|
170
|
-
* carrier, so a gesture the container of an indexed child carries reads the child's position rather
|
|
171
|
-
* than the container's center. An indexed child that the press reaches is then activated, or
|
|
172
|
-
* exclusively selected when its container does not activate on a single click. A widget with the
|
|
173
|
-
* label role is never activated, but does consume the click when it carries a gesture of its own.
|
|
174
|
-
*
|
|
175
|
-
* The press also stops at a widget whose click GTK4 implements in C on a gesture it attached
|
|
176
|
-
* itself, reading a GdkEvent that off-screen synthesis cannot produce. Gestures that widget carries
|
|
177
|
-
* of its own still take the press and release, the way GTK hands them the press before its own
|
|
178
|
-
* gesture claims it, and the same outcome is then applied through the public action GTK's own
|
|
179
|
-
* handler invokes: a list, grid, or column-view row is focused and selected, and activated as well
|
|
180
|
-
* on a second press or when its view activates on a single click; an expandable tree expander
|
|
181
|
-
* toggles its expansion, once per press, and only when it is the widget clicked, so a click on its
|
|
182
|
-
* child falls through to the enclosing row; a notebook tab, clicked directly or through its label,
|
|
183
|
-
* focuses its notebook and switches to its page; a column header sorts by its column. Sorting goes
|
|
184
|
-
* through Gtk.ColumnView.sortByColumn, so the primary sort column and order match what a pointer
|
|
185
|
-
* produces while previously sorted columns are dropped rather than kept as secondary keys. A
|
|
186
|
-
* column-view cell and the row that carries the column headers stand in the way of the click rather
|
|
187
|
-
* than taking it, so a click on either reaches the row or the view behind it.
|
|
188
|
-
*/
|
|
162
|
+
/** Activates or presses and releases a widget. */
|
|
189
163
|
const click = async (widget) => {
|
|
190
164
|
if (!isSelfClickTarget(widget) && (await tryActivate(widget))) {
|
|
191
165
|
return;
|
|
192
166
|
}
|
|
193
167
|
await deliverClick(widget, 1);
|
|
194
168
|
};
|
|
195
|
-
/**
|
|
196
|
-
* Delivers a two-press click gesture the way {@link click} delivers a single press, without trying
|
|
197
|
-
* activation first. A list box row or flow box child the presses reach, clicked directly or through
|
|
198
|
-
* a descendant, is activated and exclusively selected, as GTK's double-click path does whether or
|
|
199
|
-
* not the container activates on a single click. A widget whose click GTK4 implements itself
|
|
200
|
-
* receives that outcome once per press, so a list, grid, or column-view row is selected and then
|
|
201
|
-
* activated by the second press, a tree expander ends back where it started, a notebook tab stays on
|
|
202
|
-
* the page the first press opened, and a column header sorts and then inverts its order.
|
|
203
|
-
*/
|
|
169
|
+
/** Delivers a double-click gesture. */
|
|
204
170
|
const dblClick = (widget) => deliverClick(widget, 2);
|
|
205
|
-
/**
|
|
206
|
-
* Delivers a three-press click gesture the same way a double click is delivered, applying the same
|
|
207
|
-
* outcome to a list box row or flow box child the presses reach, and applying the outcome GTK4
|
|
208
|
-
* implements itself once per press to a row, tree expander, notebook tab, or column header.
|
|
209
|
-
*/
|
|
171
|
+
/** Delivers a triple-click gesture. */
|
|
210
172
|
const tripleClick = (widget) => deliverClick(widget, 3);
|
|
211
173
|
export { clickGestures, emitClickPhase, getAuthoredClickGestures, click, dblClick, tripleClick };
|
|
212
174
|
//# sourceMappingURL=click.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"click.js","sourceRoot":"","sources":["../../src/user-event/click.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC7F,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACxH,OAAO,EAAE,kBAAkB,EAAoB,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAezF,MA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kH;AAClH,MAAM,WAAW,GAAG,KAAK,EAAE,MAAkB,EAAoB,EAAE;IAC/D,IAAI,MAAM,CAAC,iBAAiB,EAAE,KAAK,GAAG,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;QAC1D,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,IAAI,WAAW,GAAG,KAAK,CAAC;IAExB,MAAM,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE;QACzB,WAAW,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;IACpC,CAAC,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC;AACvB,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,KAAK,GAAG,KAAK,EAAE,MAAkB,EAAiB,EAAE;IACtD,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,WAAW,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;QAC5D,OAAO;IACX,CAAC;IAED,MAAM,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAClC,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,QAAQ,GAAG,CAAC,MAAkB,EAAiB,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAChF;;;;GAIG;AACH,MAAM,WAAW,GAAG,CAAC,MAAkB,EAAiB,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAEnF,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,wBAAwB,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC","sourcesContent":["import * as Gdk from \"@gtkx/gi/gdk\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { hasSignalListener } from \"@gtkx/runtime/internal\";\nimport { callBooleanGetter, getCallableMethod, hasWidgetMethod } from \"../widget-getters.js\";\nimport { queryAllControllers } from \"./controller.js\";\nimport { wrapEvent } from \"./event-wrapper.js\";\nimport { hasIndexedChildren, selectContainerChild, SELECTED_PROBE, unselectOtherChildren } from \"./indexed-children.js\";\nimport { isClickTransparent, type NativeClick, nativeClickFor } from \"./native-click.js\";\n\ntype PressPoint = { x: number; y: number };\ntype ClickPhase = \"pressed\" | \"released\";\ntype ClickSite = { gestures: Gtk.GestureClick[]; point: PressPoint };\ntype ClickScope = { isClicked: boolean; isInternalAllowed: boolean };\n\ntype ClickTarget = {\n widget: Gtk.Widget;\n container: Gtk.Widget | null;\n gestures: Gtk.GestureClick[];\n isClaiming: boolean;\n native: NativeClick | null;\n};\n\nconst CLICK_SIGNALS = [\"pressed\", \"released\"];\nconst PRIMARY_BUTTONS: Set<number> = new Set([0, Gdk.BUTTON_PRIMARY]);\n\nconst getCenterPoint = (widget: Gtk.Widget): PressPoint => {\n const width = widget.getWidth();\n const height = widget.getHeight();\n\n if (width > 0 && height > 0) {\n return { x: width / 2, y: height / 2 };\n }\n\n return { x: 0, y: 0 };\n};\n\nconst getClickPoint = (clicked: Gtk.Widget, carrier: Gtk.Widget): PressPoint => {\n if (clicked === carrier) {\n return getCenterPoint(clicked);\n }\n\n const [isComputed, bounds] = clicked.computeBounds(carrier);\n\n if (!isComputed) {\n return getCenterPoint(carrier);\n }\n\n return { x: bounds.getX() + bounds.getWidth() / 2, y: bounds.getY() + bounds.getHeight() / 2 };\n};\n\nconst emitGesture = (\n point: PressPoint,\n controllers: Gtk.GestureClick[],\n nPress: number,\n signal: ClickPhase,\n): void => {\n for (const controller of controllers) {\n controller.emit(signal, nPress, point.x, point.y);\n }\n};\n\nconst emitClickPhase = (\n widget: Gtk.Widget,\n controllers: Gtk.GestureClick[],\n nPress: number,\n phase: ClickPhase,\n): void => {\n emitGesture(getCenterPoint(widget), controllers, nPress, phase);\n};\n\nconst emitSitePhase = (sites: ClickSite[], nPress: number, phase: ClickPhase): void => {\n for (const site of sites) {\n emitGesture(site.point, site.gestures, nPress, phase);\n }\n};\n\nconst emitClickSequence = (sites: ClickSite[], nPress: number): void => {\n for (let i = 1; i <= nPress; i++) {\n emitSitePhase(sites, i, \"pressed\");\n emitSitePhase(sites, i, \"released\");\n }\n};\n\nconst containerFor = (widget: Gtk.Widget): Gtk.Widget | null => {\n const parent = widget.getParent();\n\n return parent !== null && hasWidgetMethod(widget, SELECTED_PROBE) && hasIndexedChildren(parent) ? parent : null;\n};\n\nconst hasClickHandlers = (gesture: Gtk.GestureClick): boolean => hasSignalListener(gesture, CLICK_SIGNALS);\nconst isInternalGesture = (gesture: Gtk.GestureClick): boolean => !hasSignalListener(gesture);\nconst isPrimaryGesture = (gesture: Gtk.GestureClick): boolean => PRIMARY_BUTTONS.has(gesture.getButton());\n\nconst clickGestures = (widget: Gtk.Widget): Gtk.GestureClick[] =>\n queryAllControllers(widget, Gtk.GestureClick).filter((gesture) => isPrimaryGesture(gesture));\n\nconst getAuthoredClickGestures = (widget: Gtk.Widget): Gtk.GestureClick[] =>\n clickGestures(widget).filter((gesture) => hasClickHandlers(gesture));\n\nconst isClaimingTarget = (widget: Gtk.Widget): boolean =>\n widget instanceof Gtk.Button || containerFor(widget) !== null;\n\nconst gestureTargetFor = (widget: Gtk.Widget, isInternalAllowed: boolean): ClickTarget | null => {\n const gestures = clickGestures(widget);\n\n if (isClaimingTarget(widget)) {\n return { widget, container: containerFor(widget), gestures, isClaiming: true, native: null };\n }\n\n const authored = gestures.filter((gesture) => hasClickHandlers(gesture));\n\n if (authored.length > 0) {\n return { widget, container: null, gestures: authored, isClaiming: false, native: null };\n }\n\n if (isInternalAllowed && gestures.some((gesture) => isInternalGesture(gesture))) {\n return { widget, container: null, gestures, isClaiming: true, native: null };\n }\n\n return null;\n};\n\nconst clickTargetFor = (widget: Gtk.Widget, scope: ClickScope): ClickTarget | null => {\n if (isClickTransparent(widget)) {\n return null;\n }\n\n const native = nativeClickFor(widget, scope.isClicked);\n\n if (native !== null) {\n return { widget, container: null, gestures: getAuthoredClickGestures(widget), isClaiming: true, native };\n }\n\n return gestureTargetFor(widget, scope.isInternalAllowed);\n};\n\nconst isSelfClickTarget = (widget: Gtk.Widget): boolean =>\n isClickTransparent(widget) || clickTargetFor(widget, { isClicked: true, isInternalAllowed: false }) !== null;\n\nconst nextClickWidget = (current: Gtk.Widget, target: ClickTarget | null): Gtk.Widget | null =>\n target?.isClaiming === true ? null : current.getParent();\n\nconst collectClickTargets = (widget: Gtk.Widget): ClickTarget[] => {\n const targets: ClickTarget[] = [];\n let current: Gtk.Widget | null = widget;\n\n while (current !== null) {\n const isClicked = current === widget;\n const scope = { isClicked, isInternalAllowed: !isClicked && targets.length === 0 };\n const target = clickTargetFor(current, scope);\n const next = nextClickWidget(current, target);\n\n if (target !== null) {\n targets.push(target);\n }\n\n current = next;\n }\n\n return targets;\n};\n\nconst targetSites = (clicked: Gtk.Widget, target: ClickTarget): ClickSite[] => {\n const { container } = target;\n const site = { gestures: target.gestures, point: getClickPoint(clicked, target.widget) };\n\n if (container === null) {\n return [site];\n }\n\n return [site, { gestures: getAuthoredClickGestures(container), point: getClickPoint(clicked, container) }];\n};\n\nconst isSingleClickActivating = (container: Gtk.Widget): boolean =>\n callBooleanGetter(container, \"getActivateOnSingleClick\") ?? true;\n\nconst isMultipleSelection = (container: Gtk.Widget): boolean =>\n getCallableMethod<[], Gtk.SelectionMode>(container, \"getSelectionMode\")?.() === Gtk.SelectionMode.MULTIPLE;\n\nconst isChildSelectable = (child: Gtk.Widget): boolean => callBooleanGetter(child, \"getSelectable\") ?? true;\n\nconst replaceContainerSelection = (container: Gtk.Widget, child: Gtk.Widget): void => {\n if (!isChildSelectable(child)) {\n return;\n }\n\n selectContainerChild(container, child);\n\n if (isMultipleSelection(container)) {\n unselectOtherChildren(container, child);\n }\n};\n\nconst isActivatedByClick = (container: Gtk.Widget, nPress: number): boolean =>\n isSingleClickActivating(container) || nPress > 1;\n\nconst isSelectionReplacedByClick = (container: Gtk.Widget, nPress: number): boolean =>\n nPress > 1 || !isSingleClickActivating(container);\n\nconst applyContainerOutcome = (target: ClickTarget, nPress: number): void => {\n const { container, widget } = target;\n\n if (container === null || widget.getParent() !== container) {\n return;\n }\n\n if (isActivatedByClick(container, nPress)) {\n widget.activate();\n }\n\n if (isSelectionReplacedByClick(container, nPress)) {\n replaceContainerSelection(container, widget);\n }\n};\n\nconst applyClickOutcome = (target: ClickTarget, nPress: number): void => {\n if (target.native === null) {\n applyContainerOutcome(target, nPress);\n\n return;\n }\n\n target.native(target.widget, nPress);\n};\n\nconst applyClickOutcomes = (targets: ClickTarget[], nPress: number): void => {\n for (const target of targets) {\n applyClickOutcome(target, nPress);\n }\n};\n\nconst deliverClick = (widget: Gtk.Widget, nPress: number): Promise<void> =>\n wrapEvent(widget, () => {\n const targets = collectClickTargets(widget);\n const sites = targets.flatMap((target) => targetSites(widget, target));\n emitClickSequence(sites, nPress);\n applyClickOutcomes(targets, nPress);\n });\n\n/* eslint-disable-next-line unicorn/consistent-boolean-name -- the boolean reports whether activation succeeded */\nconst tryActivate = async (widget: Gtk.Widget): Promise<boolean> => {\n if (widget.getAccessibleRole() === Gtk.AccessibleRole.LABEL) {\n return false;\n }\n\n let isActivated = false;\n\n await wrapEvent(widget, () => {\n isActivated = widget.activate();\n });\n\n return isActivated;\n};\n\n/**\n * Activates a widget that neither claims the click nor carries a click gesture of its own, and\n * otherwise delivers a press and release. The press travels outwards from the clicked widget\n * through every widget carrying a click gesture with a pressed or released handler, the way GTK\n * hands the same press to each of them, and stops at the first Gtk.Button or indexed child of a\n * list box or flow box, which claims it. A gesture GTK attached itself takes the press only when no\n * widget below it handles one, and stops it there, so an expander or a notebook tab nested in a row\n * opens instead of activating the row. Coordinates are the clicked widget's position in each\n * carrier, so a gesture the container of an indexed child carries reads the child's position rather\n * than the container's center. An indexed child that the press reaches is then activated, or\n * exclusively selected when its container does not activate on a single click. A widget with the\n * label role is never activated, but does consume the click when it carries a gesture of its own.\n *\n * The press also stops at a widget whose click GTK4 implements in C on a gesture it attached\n * itself, reading a GdkEvent that off-screen synthesis cannot produce. Gestures that widget carries\n * of its own still take the press and release, the way GTK hands them the press before its own\n * gesture claims it, and the same outcome is then applied through the public action GTK's own\n * handler invokes: a list, grid, or column-view row is focused and selected, and activated as well\n * on a second press or when its view activates on a single click; an expandable tree expander\n * toggles its expansion, once per press, and only when it is the widget clicked, so a click on its\n * child falls through to the enclosing row; a notebook tab, clicked directly or through its label,\n * focuses its notebook and switches to its page; a column header sorts by its column. Sorting goes\n * through Gtk.ColumnView.sortByColumn, so the primary sort column and order match what a pointer\n * produces while previously sorted columns are dropped rather than kept as secondary keys. A\n * column-view cell and the row that carries the column headers stand in the way of the click rather\n * than taking it, so a click on either reaches the row or the view behind it.\n */\nconst click = async (widget: Gtk.Widget): Promise<void> => {\n if (!isSelfClickTarget(widget) && (await tryActivate(widget))) {\n return;\n }\n\n await deliverClick(widget, 1);\n};\n\n/**\n * Delivers a two-press click gesture the way {@link click} delivers a single press, without trying\n * activation first. A list box row or flow box child the presses reach, clicked directly or through\n * a descendant, is activated and exclusively selected, as GTK's double-click path does whether or\n * not the container activates on a single click. A widget whose click GTK4 implements itself\n * receives that outcome once per press, so a list, grid, or column-view row is selected and then\n * activated by the second press, a tree expander ends back where it started, a notebook tab stays on\n * the page the first press opened, and a column header sorts and then inverts its order.\n */\nconst dblClick = (widget: Gtk.Widget): Promise<void> => deliverClick(widget, 2);\n/**\n * Delivers a three-press click gesture the same way a double click is delivered, applying the same\n * outcome to a list box row or flow box child the presses reach, and applying the outcome GTK4\n * implements itself once per press to a row, tree expander, notebook tab, or column header.\n */\nconst tripleClick = (widget: Gtk.Widget): Promise<void> => deliverClick(widget, 3);\n\nexport { clickGestures, emitClickPhase, getAuthoredClickGestures, click, dblClick, tripleClick };\n"]}
|
|
1
|
+
{"version":3,"file":"click.js","sourceRoot":"","sources":["../../src/user-event/click.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,iBA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AE,CAAC,CAAC,CAAC;AAChF,uCAAuC;AACvC,MAAM,WAAW,GAAG,CAAC,MAAkB,EAAiB,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAEnF,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,wBAAwB,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC","sourcesContent":["import * as Gdk from \"@gtkx/gi/gdk\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { hasSignalListener } from \"@gtkx/runtime/internal\";\nimport { callBooleanGetter, getCallableMethod, hasWidgetMethod } from \"../widget-getters.js\";\nimport { queryAllControllers } from \"./controller.js\";\nimport { wrapEvent } from \"./event-wrapper.js\";\nimport { hasIndexedChildren, selectContainerChild, SELECTED_PROBE, unselectOtherChildren } from \"./indexed-children.js\";\nimport { isClickTransparent, type NativeClick, nativeClickFor } from \"./native-click.js\";\n\ntype PressPoint = { x: number; y: number };\ntype ClickPhase = \"pressed\" | \"released\";\ntype ClickSite = { gestures: Gtk.GestureClick[]; point: PressPoint };\ntype ClickScope = { isClicked: boolean; isInternalAllowed: boolean };\n\ntype ClickTarget = {\n widget: Gtk.Widget;\n container: Gtk.Widget | null;\n gestures: Gtk.GestureClick[];\n isClaiming: boolean;\n native: NativeClick | null;\n};\n\nconst CLICK_SIGNALS = [\"pressed\", \"released\"];\nconst PRIMARY_BUTTONS: Set<number> = new Set([0, Gdk.BUTTON_PRIMARY]);\n\nconst getCenterPoint = (widget: Gtk.Widget): PressPoint => {\n const width = widget.getWidth();\n const height = widget.getHeight();\n\n if (width > 0 && height > 0) {\n return { x: width / 2, y: height / 2 };\n }\n\n return { x: 0, y: 0 };\n};\n\nconst getClickPoint = (clicked: Gtk.Widget, carrier: Gtk.Widget): PressPoint => {\n if (clicked === carrier) {\n return getCenterPoint(clicked);\n }\n\n const [isComputed, bounds] = clicked.computeBounds(carrier);\n\n if (!isComputed) {\n return getCenterPoint(carrier);\n }\n\n return { x: bounds.getX() + bounds.getWidth() / 2, y: bounds.getY() + bounds.getHeight() / 2 };\n};\n\nconst emitGesture = (\n point: PressPoint,\n controllers: Gtk.GestureClick[],\n nPress: number,\n signal: ClickPhase,\n): void => {\n for (const controller of controllers) {\n controller.emit(signal, nPress, point.x, point.y);\n }\n};\n\nconst emitClickPhase = (\n widget: Gtk.Widget,\n controllers: Gtk.GestureClick[],\n nPress: number,\n phase: ClickPhase,\n): void => {\n emitGesture(getCenterPoint(widget), controllers, nPress, phase);\n};\n\nconst emitSitePhase = (sites: ClickSite[], nPress: number, phase: ClickPhase): void => {\n for (const site of sites) {\n emitGesture(site.point, site.gestures, nPress, phase);\n }\n};\n\nconst emitClickSequence = (sites: ClickSite[], nPress: number): void => {\n for (let i = 1; i <= nPress; i++) {\n emitSitePhase(sites, i, \"pressed\");\n emitSitePhase(sites, i, \"released\");\n }\n};\n\nconst containerFor = (widget: Gtk.Widget): Gtk.Widget | null => {\n const parent = widget.getParent();\n\n return parent !== null && hasWidgetMethod(widget, SELECTED_PROBE) && hasIndexedChildren(parent) ? parent : null;\n};\n\nconst hasClickHandlers = (gesture: Gtk.GestureClick): boolean => hasSignalListener(gesture, CLICK_SIGNALS);\nconst isInternalGesture = (gesture: Gtk.GestureClick): boolean => !hasSignalListener(gesture);\nconst isPrimaryGesture = (gesture: Gtk.GestureClick): boolean => PRIMARY_BUTTONS.has(gesture.getButton());\n\nconst clickGestures = (widget: Gtk.Widget): Gtk.GestureClick[] =>\n queryAllControllers(widget, Gtk.GestureClick).filter((gesture) => isPrimaryGesture(gesture));\n\nconst getAuthoredClickGestures = (widget: Gtk.Widget): Gtk.GestureClick[] =>\n clickGestures(widget).filter((gesture) => hasClickHandlers(gesture));\n\nconst isClaimingTarget = (widget: Gtk.Widget): boolean =>\n widget instanceof Gtk.Button || containerFor(widget) !== null;\n\nconst gestureTargetFor = (widget: Gtk.Widget, isInternalAllowed: boolean): ClickTarget | null => {\n const gestures = clickGestures(widget);\n\n if (isClaimingTarget(widget)) {\n return { widget, container: containerFor(widget), gestures, isClaiming: true, native: null };\n }\n\n const authored = gestures.filter((gesture) => hasClickHandlers(gesture));\n\n if (authored.length > 0) {\n return { widget, container: null, gestures: authored, isClaiming: false, native: null };\n }\n\n if (isInternalAllowed && gestures.some((gesture) => isInternalGesture(gesture))) {\n return { widget, container: null, gestures, isClaiming: true, native: null };\n }\n\n return null;\n};\n\nconst clickTargetFor = (widget: Gtk.Widget, scope: ClickScope): ClickTarget | null => {\n if (isClickTransparent(widget)) {\n return null;\n }\n\n const native = nativeClickFor(widget, scope.isClicked);\n\n if (native !== null) {\n return { widget, container: null, gestures: getAuthoredClickGestures(widget), isClaiming: true, native };\n }\n\n return gestureTargetFor(widget, scope.isInternalAllowed);\n};\n\nconst isSelfClickTarget = (widget: Gtk.Widget): boolean =>\n isClickTransparent(widget) || clickTargetFor(widget, { isClicked: true, isInternalAllowed: false }) !== null;\n\nconst nextClickWidget = (current: Gtk.Widget, target: ClickTarget | null): Gtk.Widget | null =>\n target?.isClaiming === true ? null : current.getParent();\n\nconst collectClickTargets = (widget: Gtk.Widget): ClickTarget[] => {\n const targets: ClickTarget[] = [];\n let current: Gtk.Widget | null = widget;\n\n while (current !== null) {\n const isClicked = current === widget;\n const scope = { isClicked, isInternalAllowed: !isClicked && targets.length === 0 };\n const target = clickTargetFor(current, scope);\n const next = nextClickWidget(current, target);\n\n if (target !== null) {\n targets.push(target);\n }\n\n current = next;\n }\n\n return targets;\n};\n\nconst targetSites = (clicked: Gtk.Widget, target: ClickTarget): ClickSite[] => {\n const { container } = target;\n const site = { gestures: target.gestures, point: getClickPoint(clicked, target.widget) };\n\n if (container === null) {\n return [site];\n }\n\n return [site, { gestures: getAuthoredClickGestures(container), point: getClickPoint(clicked, container) }];\n};\n\nconst isSingleClickActivating = (container: Gtk.Widget): boolean =>\n callBooleanGetter(container, \"getActivateOnSingleClick\") ?? true;\n\nconst isMultipleSelection = (container: Gtk.Widget): boolean =>\n getCallableMethod<[], Gtk.SelectionMode>(container, \"getSelectionMode\")?.() === Gtk.SelectionMode.MULTIPLE;\n\nconst isChildSelectable = (child: Gtk.Widget): boolean => callBooleanGetter(child, \"getSelectable\") ?? true;\n\nconst replaceContainerSelection = (container: Gtk.Widget, child: Gtk.Widget): void => {\n if (!isChildSelectable(child)) {\n return;\n }\n\n selectContainerChild(container, child);\n\n if (isMultipleSelection(container)) {\n unselectOtherChildren(container, child);\n }\n};\n\nconst isActivatedByClick = (container: Gtk.Widget, nPress: number): boolean =>\n isSingleClickActivating(container) || nPress > 1;\n\nconst isSelectionReplacedByClick = (container: Gtk.Widget, nPress: number): boolean =>\n nPress > 1 || !isSingleClickActivating(container);\n\nconst applyContainerOutcome = (target: ClickTarget, nPress: number): void => {\n const { container, widget } = target;\n\n if (container === null || widget.getParent() !== container) {\n return;\n }\n\n if (isActivatedByClick(container, nPress)) {\n Gtk.Widget.prototype.activate.call(widget);\n }\n\n if (isSelectionReplacedByClick(container, nPress)) {\n replaceContainerSelection(container, widget);\n }\n};\n\nconst applyClickOutcome = (target: ClickTarget, nPress: number): void => {\n if (target.native === null) {\n applyContainerOutcome(target, nPress);\n\n return;\n }\n\n target.native(target.widget, nPress);\n};\n\nconst applyClickOutcomes = (targets: ClickTarget[], nPress: number): void => {\n for (const target of targets) {\n applyClickOutcome(target, nPress);\n }\n};\n\nconst deliverClick = (widget: Gtk.Widget, nPress: number): Promise<void> =>\n wrapEvent(widget, () => {\n const targets = collectClickTargets(widget);\n const sites = targets.flatMap((target) => targetSites(widget, target));\n emitClickSequence(sites, nPress);\n applyClickOutcomes(targets, nPress);\n });\n\n/* eslint-disable-next-line unicorn/consistent-boolean-name -- the boolean reports whether activation succeeded */\nconst tryActivate = async (widget: Gtk.Widget): Promise<boolean> => {\n if (widget.getAccessibleRole() === Gtk.AccessibleRole.LABEL) {\n return false;\n }\n\n let isActivated = false;\n\n await wrapEvent(widget, () => {\n isActivated = Gtk.Widget.prototype.activate.call(widget);\n });\n\n return isActivated;\n};\n\n/** Activates or presses and releases a widget. */\nconst click = async (widget: Gtk.Widget): Promise<void> => {\n if (!isSelfClickTarget(widget) && (await tryActivate(widget))) {\n return;\n }\n\n await deliverClick(widget, 1);\n};\n\n/** Delivers a double-click gesture. */\nconst dblClick = (widget: Gtk.Widget): Promise<void> => deliverClick(widget, 2);\n/** Delivers a triple-click gesture. */\nconst tripleClick = (widget: Gtk.Widget): Promise<void> => deliverClick(widget, 3);\n\nexport { clickGestures, emitClickPhase, getAuthoredClickGestures, click, dblClick, tripleClick };\n"]}
|
|
@@ -30,57 +30,23 @@ type DragOptions = {
|
|
|
30
30
|
/** Explicit intermediate offsets emitted before the requested one, used instead of `steps`. */
|
|
31
31
|
offsets?: DragOffset[];
|
|
32
32
|
};
|
|
33
|
-
/**
|
|
33
|
+
/** Enters a widget. */
|
|
34
34
|
declare const hover: (widget: Gtk.Widget) => Promise<void>;
|
|
35
|
-
/**
|
|
35
|
+
/** Leaves a widget. */
|
|
36
36
|
declare const unhover: (widget: Gtk.Widget) => Promise<void>;
|
|
37
|
-
/**
|
|
38
|
-
* Emits `angle-changed` on the widget's rotate gestures.
|
|
39
|
-
*
|
|
40
|
-
* @param angle Current angle, in radians.
|
|
41
|
-
* @param deltaAngle Difference from the angle the gesture started at; defaults to `angle`.
|
|
42
|
-
* @throws When the widget has no Gtk.GestureRotate.
|
|
43
|
-
*/
|
|
37
|
+
/** Rotates a widget's gestures. */
|
|
44
38
|
declare const rotate: (widget: Gtk.Widget, angle: number, deltaAngle?: number) => Promise<void>;
|
|
45
|
-
/**
|
|
46
|
-
* Emits `scale-changed` with the given scale delta on the widget's zoom gestures.
|
|
47
|
-
*
|
|
48
|
-
* @throws When the widget has no Gtk.GestureZoom.
|
|
49
|
-
*/
|
|
39
|
+
/** Zooms a widget's gestures. */
|
|
50
40
|
declare const zoom: (widget: Gtk.Widget, scale: number) => Promise<void>;
|
|
51
|
-
/**
|
|
52
|
-
* Emits `swipe` with the given per-axis velocity, in pixels per second, on the widget's swipe gestures.
|
|
53
|
-
*
|
|
54
|
-
* @throws When the widget has no Gtk.GestureSwipe.
|
|
55
|
-
*/
|
|
41
|
+
/** Swipes a widget's gestures. */
|
|
56
42
|
declare const swipe: (widget: Gtk.Widget, velocityX: number, velocityY: number) => Promise<void>;
|
|
57
|
-
/**
|
|
58
|
-
* Emits `pressed` at the given point in widget coordinates on the widget's long-press gestures.
|
|
59
|
-
*
|
|
60
|
-
* @throws When the widget has no Gtk.GestureLongPress.
|
|
61
|
-
*/
|
|
43
|
+
/** Long-presses a widget. */
|
|
62
44
|
declare const longPress: (widget: Gtk.Widget, x?: number, y?: number) => Promise<void>;
|
|
63
|
-
/**
|
|
64
|
-
* Runs a `drag-begin`, `drag-update`, `drag-end` sequence ending at the offset `dx`, `dy` on the
|
|
65
|
-
* widget's drag gestures, overriding each gesture's start point and offset for the duration so
|
|
66
|
-
* handlers read the simulated values back.
|
|
67
|
-
*
|
|
68
|
-
* @throws When the widget is a Gtk.Range, whose slider reads pointer coordinates from the display,
|
|
69
|
-
* or when it has no Gtk.GestureDrag.
|
|
70
|
-
*/
|
|
45
|
+
/** Drags a widget by an offset. */
|
|
71
46
|
declare const drag: (widget: Gtk.Widget, dx: number, dy: number, options?: DragOptions) => Promise<void>;
|
|
72
|
-
/**
|
|
73
|
-
* Emits `drop` with the given content on every drop target attached to the widget.
|
|
74
|
-
*
|
|
75
|
-
* @throws When the widget has no Gtk.DropTarget.
|
|
76
|
-
*/
|
|
47
|
+
/** Drops content on a widget. */
|
|
77
48
|
declare const drop: (widget: Gtk.Widget, content: DropContent, options?: DropOptions) => Promise<void>;
|
|
78
|
-
/**
|
|
79
|
-
* Emits `drop` with the given content on the target's drop targets, after checking that the source
|
|
80
|
-
* carries a drag source.
|
|
81
|
-
*
|
|
82
|
-
* @throws When the source has no Gtk.DragSource, or the target no Gtk.DropTarget.
|
|
83
|
-
*/
|
|
49
|
+
/** Drags content from one widget and drops it on another. */
|
|
84
50
|
declare const dragAndDrop: (source: Gtk.Widget, target: Gtk.Widget, content: DropContent, options?: DropOptions) => Promise<void>;
|
|
85
51
|
export { hover, unhover, rotate, zoom, swipe, longPress, drag, drop, dragAndDrop, type DropContent, type DropOptions, type DragOffset, type DragOptions, };
|
|
86
52
|
//# sourceMappingURL=gesture.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gesture.d.ts","sourceRoot":"","sources":["../../src/user-event/gesture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAKpC,qHAAqH;AACrH,KAAK,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC;AAE7D,kEAAkE;AAClE,KAAK,WAAW,GAAG;IACf,+DAA+D;IAC/D,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,6DAA6D;IAC7D,CAAC,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAIF,sDAAsD;AACtD,KAAK,UAAU,GAAG;IACd,gEAAgE;IAChE,CAAC,EAAE,MAAM,CAAC;IACV,8DAA8D;IAC9D,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;;GAGG;AACH,KAAK,WAAW,GAAG;IACf,+DAA+D;IAC/D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4GAA4G;IAC5G,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+FAA+F;IAC/F,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC;CAC1B,CAAC;AA6CF,
|
|
1
|
+
{"version":3,"file":"gesture.d.ts","sourceRoot":"","sources":["../../src/user-event/gesture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAKpC,qHAAqH;AACrH,KA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