message: Keep the pop up windows/pickers etc, on the screen
diff: @@ -10,6 +10,12 @@ import { BoxLayout, Widget } from "qt-construct";
  import { Tab } from "../Tab.js";
  import { Window } from "../Window.js";
  +interface Rect {
  + top: number;
  + left: number;
  + width: number;
  + height: number;
  +}
  export class WindowPopOver {
  private _log: Logger = null;
  @@ -47,10 +53,17 @@ export class WindowPopOver {
  show(window: Window, tab: Tab): void {
  const tabRect = window.getTabGlobalGeometry(tab);
  - const width = 500; // px TODO: make it respect DPI
  + const width = Math.round(500 * window.getDpi() / 96);
  const leftOffset = (tabRect.width() - width ) /2;
  - this.#popUp.setGeometry(tabRect.left() + leftOffset, tabRect.top(), width, tabRect.height());
  + const pos = this.#keepOnScreen(window, {
  + left: tabRect.left() + leftOffset,
  + top: tabRect.top(),
  + width,
  + height: tabRect.height()
  + });
  +
  + this.#popUp.setGeometry(pos.left, pos.top, pos.width, pos.height);
  this.#popUp.raise();
  this.#popUp.show();
  }
  @@ -58,4 +71,19 @@ export class WindowPopOver {
  hide(): void {
  this.#popUp.hide();
  }
  +
  + #keepOnScreen(window: Window, rect: Rect): Rect {
  + const screen = window.getWidget().windowHandle().screen();
  + const size = screen.size();
  + const width = Math.min(rect.width, size.width());
  + const height = Math.min(rect.height, size.height());
  + const left = Math.min(size.width() - width, rect.left);
  + const top = Math.min(size.height() - height, rect.top);
  + return {
  + left,
  + top,
  + width,
  + height
  + };
  + }
  }
  