fix menu and submenu popup

This commit is contained in:
amrbashir 2024-10-18 04:39:31 +03:00
parent 4ed185fa31
commit b01da7f3ed
No known key found for this signature in database
GPG Key ID: BBD7A47A2003FF33
4 changed files with 7 additions and 6 deletions

File diff suppressed because one or more lines are too long

View File

@ -14,7 +14,7 @@ import { CheckMenuItem } from './checkMenuItem'
import { IconMenuItem } from './iconMenuItem'
import { PredefinedMenuItem } from './predefinedMenuItem'
import { Submenu } from './submenu'
import { type LogicalPosition, PhysicalPosition } from '../dpi'
import { type LogicalPosition, PhysicalPosition, Position } from '../dpi'
import { type Window } from '../window'
import { invoke } from '../core'
import { type ItemKind, MenuItemBase, newMenu } from './base'
@ -240,14 +240,14 @@ export class Menu extends MenuItemBase {
* If the position, is provided, it is relative to the window's top-left corner.
*/
async popup(
at?: PhysicalPosition | LogicalPosition,
at?: PhysicalPosition | LogicalPosition | Position,
window?: Window
): Promise<void> {
return invoke('plugin:menu|popup', {
rid: this.rid,
kind: this.kind,
window: window?.label ?? null,
at
at: at instanceof Position ? at : at ? new Position(at) : null
})
}

View File

@ -15,6 +15,7 @@ import { invoke } from '../core'
import { type LogicalPosition, PhysicalPosition, type Window } from '../window'
import { type ItemKind, MenuItemBase, newMenu } from './base'
import { type MenuOptions } from './menu'
import { Position } from '../dpi'
function itemFromKind([rid, id, kind]: [number, string, ItemKind]):
| Submenu
@ -247,7 +248,7 @@ export class Submenu extends MenuItemBase {
rid: this.rid,
kind: this.kind,
window: window?.label ?? null,
at
at: at instanceof Position ? at : at ? new Position(at) : null
})
}

View File

@ -2312,7 +2312,7 @@ async function availableMonitors(): Promise<Monitor[]> {
* The coordinates can be negative if the top-left hand corner of the window is outside of the visible screen region.
*/
async function cursorPosition(): Promise<PhysicalPosition> {
return invoke<{ x: number; y: number }>('plugin:window|cursor_position').then(
return invoke<PhysicalPosition>('plugin:window|cursor_position').then(
(v) => new PhysicalPosition(v)
)
}