On API, might there be any way of reading the bounds of the active display – something like an {x,y,w,h}, so that we could then set the bounds of the Bike outlining document window, and an extension’s NSPanel ?
(Using Keyboard Maestro here to split the screen between an editing view and an extension display view, but wondering whether there’s scope for doing that inside the extension – I guess that not all users will want to turn to Keyboard Maestro, or continually reposition and resize by hand)
( I typically use, for example, a 1/3 ⇄ 2/3 horizontal split, but mileage will vary )
UPDATE
Ah, Webkit seems to give us that in the DOM via window.screen …
(I could then post it back to the app context – direct app context access to screen frame would be nice, but perhaps just a luxury
, and low priority )
If we could read screen frame dimension direcly from the app side, then perhaps we could launch the NSPanel immediately with the dimensions (and position) that we want, rather than adjusting them after learning the display coordinates from an app ⇄ dom exchange of messages ?
const panel = await bike.showPanel<SVGForestProtocol>({
script: 'view.js',
title: 'Forest Paths',
width: 900,
height: 700,
role: 'inspector',
hidesOnDeactivate: false
}, currentWindow);
But perhaps it isn’t straightforward, or even feasible, for PanelOptions to have x and y options ?
Otherwise I could perhaps do something from JS for Automation’s route to AppKit
Expand disclosure triangle to view JS source
(() => {
ObjC.import('AppKit');
return $.NSScreen.mainScreen.frame;
})()
or perhaps
Expand disclosure triangle to view JS source
(() => {
ObjC.import("AppKit");
// frameXYWH :: Bool -> Bool -> {x, y, width, height}
const frameXYWH = ofMainScreen =>
visibleOnly => {
const
screen = $.NSScreen,
// Primary screen or active screen ?
{ origin, size } = (
ofMainScreen
? screen.mainScreen
: scrreen.screens.firstObject
)[
// Visible only ?
visibleOnly
? "visibleFrame"
: "frame"
];
return Object.assign(origin, size);
};
return frameXYWH(true)(true);
})()