From 48f3e9de550c32ca35b9f1f1e009b774e722d189 Mon Sep 17 00:00:00 2001
From: licui
Date: Tue, 22 Jan 2019 14:39:45 -0500
Subject: [PATCH 1/2] Add missing function type: System.getRuntimeInfo
---
types/openfin/index.d.ts | 5 +++++
types/openfin/openfin-tests.ts | 7 +++++++
2 files changed, 12 insertions(+)
diff --git a/types/openfin/index.d.ts b/types/openfin/index.d.ts
index 78b1801b0b..40f921a3fe 100644
--- a/types/openfin/index.d.ts
+++ b/types/openfin/index.d.ts
@@ -62,6 +62,7 @@ declare namespace fin {
type ProcessInfo = import('./_v2/api/system/process').ProcessInfo;
type ProxyInfo = import('./_v2/api/system/proxy').ProxyInfo;
type RegistryInfo = import('./_v2/api/system/registry-info').RegistryInfo;
+ type RuntimeInfo = import('./_v2/api/system/runtime-info').RuntimeInfo;
type RVMInfo = import('./_v2/api/system/rvm').RVMInfo;
type WindowDetail = import('./_v2/api/system/window').WindowDetail;
type WindowInfo = import('./_v2/api/system/window').WindowInfo;
@@ -581,6 +582,10 @@ declare namespace fin {
* Retrieves the Proxy settings.
*/
getProxySettings(callback?: (proxy: ProxyInfo) => void, errorCallback?: (reason: string) => void): void;
+ /**
+ * Returns information about the running Runtime in an object.
+ */
+ getRuntimeInfo(callback?: (rvmInfo: RuntimeInfo) => void, errorCallback?: (reason: string) => void): void;
/**
* Returns information about the running RVM in an object.
*/
diff --git a/types/openfin/openfin-tests.ts b/types/openfin/openfin-tests.ts
index e4430ff9c2..fb9e216d04 100644
--- a/types/openfin/openfin-tests.ts
+++ b/types/openfin/openfin-tests.ts
@@ -376,6 +376,13 @@ function test_system() {
fin.desktop.System.getProxySettings(proxy => {
console.log(proxy);
});
+ // getRuntimeInfo
+ fin.desktop.System.getRuntimeInfo(runtimeInfoObject => {
+ console.log("Runtime version:", runtimeInfoObject.version);
+ console.log("Runtime architecture:", runtimeInfoObject["architecture"]);
+ }, err => {
+ console.log("Failed to get runtime info, error message:", err);
+ });
// getRvmInfo
fin.desktop.System.getRvmInfo(rvmInfoObject => {
console.log("RVM version:", rvmInfoObject.version);
From 2ef9b10032cbfde0c67802f52bc78e54b1faa2a6 Mon Sep 17 00:00:00 2001
From: licui
Date: Tue, 22 Jan 2019 16:13:49 -0500
Subject: [PATCH 2/2] Add types for GlobalHotkey
---
types/openfin/index.d.ts | 58 ++++++++++++++++++++++++++++++++++
types/openfin/openfin-tests.ts | 45 ++++++++++++++++++++++++++
2 files changed, 103 insertions(+)
diff --git a/types/openfin/index.d.ts b/types/openfin/index.d.ts
index 40f921a3fe..b5d04f1a27 100644
--- a/types/openfin/index.d.ts
+++ b/types/openfin/index.d.ts
@@ -78,6 +78,7 @@ declare namespace fin {
main(f: () => any): void;
Application: OpenFinApplicationStatic;
ExternalApp: OpenFinExternalApplicationStatic;
+ GlobalHotkey: OpenFinGlobalHotkey;
InterApplicationBus: OpenFinInterApplicationBus;
Notification: OpenFinNotificationStatic;
System: OpenFinSystem;
@@ -312,6 +313,45 @@ declare namespace fin {
errorCallback?: (reason: string, error: ErrorInfo) => void): void;
}
+ /**
+ * GlobalHotkey
+ * The Global Hotkey allows the registration and unregistration of given hotkeys at the OS level, meaning a Window/Application will receive the events regardless of focused state.
+ */
+ interface OpenFinGlobalHotkey {
+ /**
+ * Registers an event listener on the specified event.
+ */
+ addEventListener(
+ type: OpenFinGlobalHotkeyEventType,
+ listener: (event: GlobalHotkeyEvent) => void,
+ callback?: () => void,
+ errorCallback?: (reason: string, error: ErrorInfo) => void): void;
+ /**
+ * Checks if a given hotkey has been registered
+ */
+ isRegistered(hotkey: string, callback?: (registered: boolean) => void, errorCallback?: (reason: string, error: ErrorInfo) => void): void;
+ /**
+ * Registers a global hotkey with the operating system.
+ */
+ register(hotkey: string, listener: () => void, callback?: () => void, errorCallback?: (reason: string, error: ErrorInfo) => void): void;
+ /**
+ * Removes a previously registered event listener from the specified event.
+ */
+ removeEventListener(
+ type: OpenFinGlobalHotkeyEventType,
+ listener: (event: GlobalHotkeyEvent) => void,
+ callback?: () => void,
+ errorCallback?: (reason: string, error: ErrorInfo) => void): void;
+ /**
+ * Unregisters a global hotkey with the operating system.
+ */
+ unregister(hotkey: string, callback?: () => void, errorCallback?: (reason: string, error: ErrorInfo) => void): void;
+ /**
+ * Unregisters all global hotkeys for the current application.
+ */
+ unregisterAll(callback?: () => void, errorCallback?: (reason: string, error: ErrorInfo) => void): void;
+ }
+
/**
* InterApplicationBus
* A messaging bus that allows for pub/sub messaging between different applications.
@@ -982,6 +1022,21 @@ declare namespace fin {
uuid: string;
}
+ interface GlobalHotkeyEvent {
+ topic: string;
+ type: OpenFinGlobalHotkeyEventType;
+ /**
+ * The Identity that has just registered the hotkey
+ */
+ identity: {
+ name: string;
+ uuid: string;
+ parentFrame: string;
+ entityType: string;
+ },
+ hotkey: string;
+ }
+
interface DesktopIconClickedEvent {
mouse: {
/**
@@ -1211,6 +1266,9 @@ declare namespace fin {
type OpenFinExternalApplicationEventType = "connected"
| "disconnected";
+ type OpenFinGlobalHotkeyEventType = "registered"
+ | "unregistered";
+
type OpenFinSystemEventType = "application-closed"
| "application-crashed"
| "application-created"
diff --git a/types/openfin/openfin-tests.ts b/types/openfin/openfin-tests.ts
index fb9e216d04..5367823dae 100644
--- a/types/openfin/openfin-tests.ts
+++ b/types/openfin/openfin-tests.ts
@@ -164,6 +164,51 @@ function test_external_application() {
}, err => console.log(err));
}
+function test_global_hot_key() {
+ // addEventListener
+ fin.desktop.GlobalHotkey.addEventListener('registered', (event) => {
+ console.log(` window ${event.identity.name} has registered ${event.hotkey}`, event);
+ }, () => {
+ console.log('The registration was successful');
+ }, (reason, err) => {
+ console.log(`Error Message: ${err.message} Error Stack: ${err.stack}`);
+ });
+ // isRegister
+ const hotkey = 'CommandOrControl+X';
+ fin.desktop.GlobalHotkey.isRegistered(hotkey, registered => {
+ console.log(`hotkey ${hotkey} is registered ? ${registered}`);
+ }, (reason, err) => {
+ console.log('Error unregistering the hotkey', err);
+ });
+ // register
+ fin.desktop.GlobalHotkey.register(hotkey, () => {
+ console.log(`${hotkey} pressed`);
+ }, () => {
+ console.log('Success');
+ }, (reason, err) => {
+ console.log('Error registering the hotkey', err);
+ });
+ // removeEventListener
+ const previousCallback = () => { };
+ fin.desktop.GlobalHotkey.removeEventListener('registered', previousCallback, () => {
+ console.log('The unregistration was successful');
+ }, (reason, err) => {
+ console.log(`Error Message: ${err.message} Error Stack: ${err.stack}`);
+ });
+ // unregister
+ fin.desktop.GlobalHotkey.unregister(hotkey, () => {
+ console.log('Success');
+ }, (reason, err) => {
+ console.log('Error unregistering the hotkey', err);
+ });
+ // unregisterAll
+ fin.desktop.GlobalHotkey.unregisterAll(() => {
+ console.log('Success');
+ }, (reason, err) => {
+ console.log('Error unregistering all hotkeys for this application', err);
+ });
+}
+
function test_inter_application_bus() {
// addSubscribeListener
fin.desktop.InterApplicationBus.addSubscribeListener((uuid, topic, name) => {