mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-21 00:11:27 -07:00
Prepare Windows release and signing process (#16)
This commit is contained in:
@@ -21,17 +21,31 @@ import { WindowGeometry } from '../types';
|
||||
export type GeometryChangeCallback = (geometry: WindowGeometry) => void;
|
||||
export type WindowFoundCallback = (geometry: WindowGeometry) => void;
|
||||
export type WindowLostCallback = () => void;
|
||||
export type WindowFocusChangeCallback = (focused: boolean) => void;
|
||||
|
||||
export abstract class BaseWindowTracker {
|
||||
protected currentGeometry: WindowGeometry | null = null;
|
||||
protected windowFound: boolean = false;
|
||||
protected focusKnown: boolean = false;
|
||||
protected windowFocused: boolean = false;
|
||||
protected targetWindowFocused: boolean = false;
|
||||
public onGeometryChange: GeometryChangeCallback | null = null;
|
||||
public onWindowFound: WindowFoundCallback | null = null;
|
||||
public onWindowLost: WindowLostCallback | null = null;
|
||||
public onWindowFocusChange: WindowFocusChangeCallback | null = null;
|
||||
private onWindowFocusChangeCallback: ((focused: boolean) => void) | null = null;
|
||||
|
||||
public get onWindowFocusChange(): ((focused: boolean) => void) | null {
|
||||
return this.onWindowFocusChangeCallback;
|
||||
}
|
||||
|
||||
public set onWindowFocusChange(callback: ((focused: boolean) => void) | null) {
|
||||
this.onWindowFocusChangeCallback = callback;
|
||||
}
|
||||
|
||||
public get onTargetWindowFocusChange(): ((focused: boolean) => void) | null {
|
||||
return this.onWindowFocusChange;
|
||||
}
|
||||
|
||||
public set onTargetWindowFocusChange(callback: ((focused: boolean) => void) | null) {
|
||||
this.onWindowFocusChange = callback;
|
||||
}
|
||||
|
||||
abstract start(): void;
|
||||
abstract stop(): void;
|
||||
@@ -44,23 +58,28 @@ export abstract class BaseWindowTracker {
|
||||
return this.windowFound;
|
||||
}
|
||||
|
||||
isFocused(): boolean {
|
||||
return this.focusKnown ? this.windowFocused : this.windowFound;
|
||||
isTargetWindowFocused(): boolean {
|
||||
return this.targetWindowFocused;
|
||||
}
|
||||
|
||||
protected updateTargetWindowFocused(focused: boolean): void {
|
||||
if (this.targetWindowFocused === focused) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.targetWindowFocused = focused;
|
||||
this.onWindowFocusChangeCallback?.(focused);
|
||||
}
|
||||
|
||||
protected updateFocus(focused: boolean): void {
|
||||
const changed = !this.focusKnown || this.windowFocused !== focused;
|
||||
this.focusKnown = true;
|
||||
this.windowFocused = focused;
|
||||
if (changed) {
|
||||
this.onWindowFocusChange?.(focused);
|
||||
}
|
||||
this.updateTargetWindowFocused(focused);
|
||||
}
|
||||
|
||||
protected updateGeometry(newGeometry: WindowGeometry | null): void {
|
||||
if (newGeometry) {
|
||||
if (!this.windowFound) {
|
||||
this.windowFound = true;
|
||||
this.updateTargetWindowFocused(true);
|
||||
if (this.onWindowFound) this.onWindowFound(newGeometry);
|
||||
}
|
||||
|
||||
@@ -75,14 +94,9 @@ export abstract class BaseWindowTracker {
|
||||
if (this.onGeometryChange) this.onGeometryChange(newGeometry);
|
||||
}
|
||||
} else {
|
||||
const focusChanged = this.focusKnown && this.windowFocused;
|
||||
this.focusKnown = false;
|
||||
this.windowFocused = false;
|
||||
if (focusChanged) {
|
||||
this.onWindowFocusChange?.(false);
|
||||
}
|
||||
if (this.windowFound) {
|
||||
this.windowFound = false;
|
||||
this.updateTargetWindowFocused(false);
|
||||
this.currentGeometry = null;
|
||||
if (this.onWindowLost) this.onWindowLost();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user