forked from Blendman974/faceclaw
Context menus are centered and include window title
This commit is contained in:
1 parent
5158bc86ff
commit
b1493a353d
14 files changed
+55
-18
No files matched your search
@@ -136,6 +136,7 @@ type GamePhase = "playing" | "paused" | "game-over";
|
||||
type BlocksWindow = {
|
||||
windowId: string;
|
||||
surfaceId: string;
|
||||
title: string;
|
||||
viewportWidth: number;
|
||||
viewportHeight: number;
|
||||
foreground: boolean;
|
||||
@@ -181,6 +182,7 @@ global.onmessage = (event: { data: WorkerAppMessage }) => {
|
||||
const window: BlocksWindow = {
|
||||
windowId: message.windowId,
|
||||
surfaceId: message.surfaceId,
|
||||
title: message.title,
|
||||
viewportWidth: message.viewport.width,
|
||||
viewportHeight: message.viewport.height,
|
||||
foreground: false,
|
||||
@@ -303,6 +305,7 @@ function openWindowMenu(window: BlocksWindow): void {
|
||||
function windowMenu(window: BlocksWindow): WindowMenu {
|
||||
if (!window.menu) {
|
||||
window.menu = new WindowMenu({
|
||||
title: () => window.title,
|
||||
size: { width: window.viewportWidth, height: window.viewportHeight },
|
||||
paintBase: () => paintContent(window),
|
||||
isFocused: () => window.focused,
|
||||
|
||||
@@ -100,6 +100,7 @@ type Snapshot = {
|
||||
type FreecellWindow = {
|
||||
windowId: string;
|
||||
surfaceId: string;
|
||||
title: string;
|
||||
viewportWidth: number;
|
||||
viewportHeight: number;
|
||||
foreground: boolean;
|
||||
@@ -142,6 +143,7 @@ global.onmessage = (event: { data: WorkerAppMessage }) => {
|
||||
const window: FreecellWindow = {
|
||||
windowId: message.windowId,
|
||||
surfaceId: message.surfaceId,
|
||||
title: message.title,
|
||||
viewportWidth: message.viewport.width,
|
||||
viewportHeight: message.viewport.height,
|
||||
foreground: false,
|
||||
@@ -256,6 +258,7 @@ function openWindowMenu(window: FreecellWindow): void {
|
||||
function windowMenu(window: FreecellWindow): WindowMenu {
|
||||
if (!window.menu) {
|
||||
window.menu = new WindowMenu({
|
||||
title: () => window.title,
|
||||
size: { width: window.viewportWidth, height: window.viewportHeight },
|
||||
paintBase: () => paintContent(window),
|
||||
isFocused: () => window.focused,
|
||||
|
||||
@@ -94,6 +94,7 @@ type GamePhase = "playing" | "paused" | "won" | "lost";
|
||||
type MinesweeperWindow = {
|
||||
windowId: string;
|
||||
surfaceId: string;
|
||||
title: string;
|
||||
viewportWidth: number;
|
||||
viewportHeight: number;
|
||||
foreground: boolean;
|
||||
@@ -146,6 +147,7 @@ global.onmessage = (event: { data: WorkerAppMessage }) => {
|
||||
const window: MinesweeperWindow = {
|
||||
windowId: message.windowId,
|
||||
surfaceId: message.surfaceId,
|
||||
title: message.title,
|
||||
viewportWidth: message.viewport.width,
|
||||
viewportHeight: message.viewport.height,
|
||||
foreground: false,
|
||||
@@ -285,6 +287,7 @@ function openWindowMenu(window: MinesweeperWindow): void {
|
||||
function windowMenu(window: MinesweeperWindow): WindowMenu {
|
||||
if (!window.menu) {
|
||||
window.menu = new WindowMenu({
|
||||
title: () => window.title,
|
||||
size: { width: window.viewportWidth, height: window.viewportHeight },
|
||||
paintBase: () => paintContent(window),
|
||||
isFocused: () => window.focused,
|
||||
|
||||
@@ -59,6 +59,7 @@ type MapMode = "follow" | "overview";
|
||||
type NavWindow = {
|
||||
windowId: string;
|
||||
surfaceId: string;
|
||||
title: string;
|
||||
viewportWidth: number;
|
||||
viewportHeight: number;
|
||||
foreground: boolean;
|
||||
@@ -162,6 +163,7 @@ global.onmessage = (event: { data: WorkerAppMessage }) => {
|
||||
window = {
|
||||
windowId: message.windowId,
|
||||
surfaceId: message.surfaceId,
|
||||
title: message.title,
|
||||
viewportWidth: message.viewport.width,
|
||||
viewportHeight: message.viewport.height,
|
||||
foreground: false,
|
||||
@@ -612,6 +614,7 @@ function describeRouteStatus(): string {
|
||||
function windowMenu(win: NavWindow): WindowMenu {
|
||||
if (!win.menu) {
|
||||
win.menu = new WindowMenu({
|
||||
title: () => win.title,
|
||||
size: { width: win.viewportWidth, height: win.viewportHeight },
|
||||
paintBase: () => paintContent(win),
|
||||
isFocused: () => win.focused,
|
||||
|
||||
@@ -242,6 +242,7 @@ type Flipper = {
|
||||
type PinballWindow = {
|
||||
windowId: string;
|
||||
surfaceId: string;
|
||||
title: string;
|
||||
viewportWidth: number;
|
||||
viewportHeight: number;
|
||||
foreground: boolean;
|
||||
@@ -301,6 +302,7 @@ global.onmessage = (event: { data: WorkerAppMessage }) => {
|
||||
const window: PinballWindow = {
|
||||
windowId: message.windowId,
|
||||
surfaceId: message.surfaceId,
|
||||
title: message.title,
|
||||
viewportWidth: message.viewport.width,
|
||||
viewportHeight: message.viewport.height,
|
||||
foreground: false,
|
||||
@@ -469,6 +471,7 @@ function openWindowMenu(window: PinballWindow): void {
|
||||
function windowMenu(window: PinballWindow): WindowMenu {
|
||||
if (!window.menu) {
|
||||
window.menu = new WindowMenu({
|
||||
title: () => window.title,
|
||||
size: { width: window.viewportWidth, height: window.viewportHeight },
|
||||
paintBase: () => paintContent(window),
|
||||
isFocused: () => window.focused,
|
||||
|
||||
@@ -64,6 +64,7 @@ const smallFont = getDefaultSmallFont();
|
||||
type RoamWindow = {
|
||||
windowId: string;
|
||||
surfaceId: string;
|
||||
title: string;
|
||||
viewportWidth: number;
|
||||
viewportHeight: number;
|
||||
foreground: boolean;
|
||||
@@ -168,6 +169,7 @@ global.onmessage = (event: { data: WorkerAppMessage }) => {
|
||||
window = {
|
||||
windowId: message.windowId,
|
||||
surfaceId: message.surfaceId,
|
||||
title: message.title,
|
||||
viewportWidth: message.viewport.width,
|
||||
viewportHeight: message.viewport.height,
|
||||
foreground: false,
|
||||
@@ -327,6 +329,7 @@ function maybeRefreshStalePage(): void {
|
||||
function windowMenu(win: RoamWindow): WindowMenu {
|
||||
if (!win.menu) {
|
||||
win.menu = new WindowMenu({
|
||||
title: () => win.title,
|
||||
size: { width: win.viewportWidth, height: win.viewportHeight },
|
||||
paintBase: () => paintContent(win),
|
||||
isFocused: () => win.focused,
|
||||
|
||||
@@ -88,6 +88,8 @@ const NEW_CONNECTION_DRAFT_KEY = "terminal.newConnectionDraft";
|
||||
type BaseWindow = {
|
||||
windowId: string;
|
||||
surfaceId: string;
|
||||
/** Shell-side window title, echoed back in the open-window message. */
|
||||
title: string;
|
||||
/** Content viewport from the shell's open-window message; grid = viewport / cell. */
|
||||
viewportWidth: number;
|
||||
viewportHeight: number;
|
||||
@@ -304,7 +306,7 @@ global.onmessage = (event: { data: WorkerAppMessage }) => {
|
||||
const message = event.data;
|
||||
switch (message.type) {
|
||||
case "open-window":
|
||||
openWindow(message.windowId, message.surfaceId, message.viewport);
|
||||
openWindow(message.windowId, message.surfaceId, message.title, message.viewport);
|
||||
break;
|
||||
case "close-window":
|
||||
closeWindow(message.windowId);
|
||||
@@ -430,11 +432,11 @@ function cancelPendingReconnects(): void {
|
||||
}
|
||||
}
|
||||
|
||||
function openWindow(windowId: string, surfaceId: string, viewport: { width: number; height: number }): void {
|
||||
function openWindow(windowId: string, surfaceId: string, title: string, viewport: { width: number; height: number }): void {
|
||||
const pendingView = pendingViews.get(windowId);
|
||||
if (pendingView) {
|
||||
pendingViews.delete(windowId);
|
||||
windows.set(windowId, createViewWindow(windowId, surfaceId, viewport, pendingView));
|
||||
windows.set(windowId, createViewWindow(windowId, surfaceId, title, viewport, pendingView));
|
||||
renderHubWindows();
|
||||
return;
|
||||
}
|
||||
@@ -443,6 +445,7 @@ function openWindow(windowId: string, surfaceId: string, viewport: { width: numb
|
||||
kind: "hub",
|
||||
windowId,
|
||||
surfaceId,
|
||||
title,
|
||||
viewportWidth: viewport.width,
|
||||
viewportHeight: viewport.height,
|
||||
gridCols: Math.floor(viewport.width / hubCell.cellWidth),
|
||||
@@ -753,6 +756,7 @@ function noteSessionActivity(connectionId: string, socket: string): void {
|
||||
function createViewWindow(
|
||||
windowId: string,
|
||||
surfaceId: string,
|
||||
title: string,
|
||||
viewport: { width: number; height: number },
|
||||
view: PendingView,
|
||||
): ViewWindow {
|
||||
@@ -768,6 +772,7 @@ function createViewWindow(
|
||||
kind: "view",
|
||||
windowId,
|
||||
surfaceId,
|
||||
title,
|
||||
viewportWidth: viewport.width,
|
||||
viewportHeight: viewport.height,
|
||||
gridCols,
|
||||
@@ -900,6 +905,7 @@ function reconnectView(window: ViewWindow): void {
|
||||
function windowMenu(window: TerminalWindow): WindowMenu {
|
||||
if (!window.menu) {
|
||||
window.menu = new WindowMenu({
|
||||
title: () => window.title,
|
||||
size: { width: window.viewportWidth, height: window.viewportHeight },
|
||||
paintBase: () => paintContent(window),
|
||||
isFocused: () => window.focused,
|
||||
|
||||
@@ -42,6 +42,7 @@ type TimerView = "stopwatch" | "timers" | "editor";
|
||||
type TimerWindow = {
|
||||
windowId: string;
|
||||
surfaceId: string;
|
||||
title: string;
|
||||
viewportWidth: number;
|
||||
viewportHeight: number;
|
||||
foreground: boolean;
|
||||
@@ -132,6 +133,7 @@ global.onmessage = (event: { data: WorkerAppMessage }) => {
|
||||
windows.set(message.windowId, {
|
||||
windowId: message.windowId,
|
||||
surfaceId: message.surfaceId,
|
||||
title: message.title,
|
||||
viewportWidth: message.viewport.width,
|
||||
viewportHeight: message.viewport.height,
|
||||
foreground: false,
|
||||
@@ -296,6 +298,7 @@ function refreshWindowsAfterToolChange(): void {
|
||||
function windowMenu(window: TimerWindow): WindowMenu {
|
||||
if (!window.menu) {
|
||||
window.menu = new WindowMenu({
|
||||
title: () => window.title,
|
||||
size: { width: window.viewportWidth, height: window.viewportHeight },
|
||||
paintBase: () => paintContent(window),
|
||||
isFocused: () => window.focused,
|
||||
|
||||
Reference in new issue
Block a user