From 860fe7db5d9015f120b1614a80a9fcca613d2d7c Mon Sep 17 00:00:00 2001 From: Ean Krenzin-Blank Date: Tue, 6 Jun 2023 15:46:45 -0700 Subject: [PATCH 01/12] add focus & resize window functions --- index.d.ts | 2 ++ permissionCheck.js | 2 ++ src/linux/window_manager.cc | 29 +++++++++++++++++++++++++++++ src/macos/window_manager.mm | 25 +++++++++++++++++++++++++ src/main.cc | 25 +++++++++++++++++++++++++ src/win32/window_manager.cc | 27 +++++++++++++++++++++++++++ src/window_manager.h | 19 +++++++++++++++++++ 7 files changed, 129 insertions(+) diff --git a/index.d.ts b/index.d.ts index d24bc9d..cc48377 100644 --- a/index.d.ts +++ b/index.d.ts @@ -51,5 +51,7 @@ export function getWindows(): number[]; export function getActiveWindow(): number; export function getWindowRect(handle: number): Rect; export function getWindowTitle(handle: number): string; +export function focusWindow(handle: number): void; +export function resizeWindow(handle: number, width: number, height: number): void; export const screen: Screen; diff --git a/permissionCheck.js b/permissionCheck.js index e0e9fa5..7bd8b27 100644 --- a/permissionCheck.js +++ b/permissionCheck.js @@ -57,6 +57,8 @@ try { "getActiveWindow", "getWindowRect", "getWindowTitle", + "focusWindow", + "resizeWindow" ]; const screenCaptureAccess = [ "getWindowTitle", diff --git a/src/linux/window_manager.cc b/src/linux/window_manager.cc index eebaf9c..e3fd048 100644 --- a/src/linux/window_manager.cc +++ b/src/linux/window_manager.cc @@ -68,3 +68,32 @@ MMRect getWindowRect(const WindowHandle windowHandle) { } return windowRect; } + +bool focusWindow(const WindowHandle windowHandle) { + Display* display = XGetMainDisplay(); + if (display != NULL && windowHandle >= 0) { + // Try to set the window to the foreground + XSetInputFocus(display, windowHandle, RevertToParent, CurrentTime); + XRaiseWindow(display, windowHandle); + XFlush(display); + + return true; + } + return false; +} + +bool resizeWindow(const WindowHandle windowHandle, int width, int height) { + Display* display = XGetMainDisplay(); + if (display != NULL && windowHandle >= 0) { + XWindowChanges changes; + changes.width = width; + changes.height = height; + + // Resize the window + XConfigureWindow(display, windowHandle, CWWidth | CWHeight, &changes); + XFlush(display); + + return true; + } + return false; +} \ No newline at end of file diff --git a/src/macos/window_manager.mm b/src/macos/window_manager.mm index 93c6154..682d798 100644 --- a/src/macos/window_manager.mm +++ b/src/macos/window_manager.mm @@ -92,3 +92,28 @@ MMRect getWindowRect(const WindowHandle windowHandle) { } return ""; } + +BOOL focusWindow(NSWindow *window) { + if (window) { + // Restore the window if it's minimized + if ([window isMiniaturized]) { + [window deminiaturize:nil]; + } + + // Try to set the window to the foreground + [window makeKeyAndOrderFront:nil]; + + return YES; + } + return NO; +} + +BOOL resizeWindow(NSWindow *window, int width, int height) { + if (window) { + NSRect frame = [window frame]; + frame.size = NSMakeSize(width, height); + [window setFrame:frame display:YES animate:NO]; + return YES; + } + return NO; +} \ No newline at end of file diff --git a/src/main.cc b/src/main.cc index e3a5c37..a554f8a 100644 --- a/src/main.cc +++ b/src/main.cc @@ -644,6 +644,29 @@ Napi::String _getWindowTitle(const Napi::CallbackInfo &info) { return Napi::String::New(env, getWindowTitle(windowHandle)); } +Napi::Boolean _focusWindow(const Napi::CallbackInfo &info) { + Napi::Env env = info.Env(); + + WindowHandle windowHandle = info[0].As().Int64Value(); + + bool result = focusWindow(windowHandle); + + return Napi::Boolean::New(env, result); +} + +Napi::Boolean _resizeWindow(const Napi::CallbackInfo &info) { + Napi::Env env = info.Env(); + + WindowHandle windowHandle = info[0].As().Int64Value(); + int width = info[1].As().Int32Value(); + int height = info[2].As().Int32Value(); + + bool result = resizeWindow(windowHandle, width, height); + + return Napi::Boolean::New(env, result); +} + + Napi::Object _captureScreen(const Napi::CallbackInfo &info) { Napi::Env env = info.Env(); @@ -725,6 +748,8 @@ Napi::Object Init(Napi::Env env, Napi::Object exports) { exports.Set(Napi::String::New(env, "getActiveWindow"), Napi::Function::New(env, _getActiveWindow)); exports.Set(Napi::String::New(env, "getWindowRect"), Napi::Function::New(env, _getWindowRect)); exports.Set(Napi::String::New(env, "getWindowTitle"), Napi::Function::New(env, _getWindowTitle)); + exports.Set(Napi::String::New(env, "focusWindow"), Napi::Function::New(env, _focusWindow)); + exports.Set(Napi::String::New(env, "resizeWindow"), Napi::Function::New(env, _resizeWindow)); exports.Set(Napi::String::New(env, "captureScreen"), Napi::Function::New(env, _captureScreen)); exports.Set(Napi::String::New(env, "getXDisplayName"), Napi::Function::New(env, _getXDisplayName)); exports.Set(Napi::String::New(env, "setXDisplayName"), Napi::Function::New(env, _setXDisplayName)); diff --git a/src/win32/window_manager.cc b/src/win32/window_manager.cc index 8daa663..e961999 100644 --- a/src/win32/window_manager.cc +++ b/src/win32/window_manager.cc @@ -51,3 +51,30 @@ std::string getWindowTitle(const WindowHandle windowHandle) { } return ""; } + +bool focusWindow(const WindowHandle windowHandle) { + HWND hWnd = reinterpret_cast(windowHandle); + if (IsWindow(hWnd)) { + // Restore the window if it's minimized + if (IsIconic(hWnd)) { + ShowWindow(hWnd, SW_RESTORE); + } + + // Try to set the window to the foreground + return SetForegroundWindow(hWnd); + } + return false; +} + +bool resizeWindow(const WindowHandle windowHandle, int width, int height) { + HWND hWnd = reinterpret_cast(windowHandle); + if (IsWindow(hWnd)) { + RECT rect; + if (GetWindowRect(hWnd, &rect)) { + int x = rect.left; + int y = rect.top; + return MoveWindow(hWnd, x, y, width, height, TRUE); + } + } + return false; +} \ No newline at end of file diff --git a/src/window_manager.h b/src/window_manager.h index dd4ec08..c9ca938 100644 --- a/src/window_manager.h +++ b/src/window_manager.h @@ -31,6 +31,25 @@ std::string getWindowTitle(const WindowHandle windowHandle); * That is, a window's top left position given as `x` and `y` coordinate, as well as it's window size given as `width` and `height` * The respective window handle may be aquired via `getWindows` or `getActiveWindow` */ +/** + * `focusWindow` focuses on the window specified by its window handle. + * It brings the specified window to the foreground and gives it input focus. + * The respective window handle may be acquired via `getWindows` or `getActiveWindow`. + * @param windowHandle The window handle of the window to be focused. + * @return Returns a boolean indicating whether the window focus operation was successful. + */ +bool focusWindow(const WindowHandle windowHandle); + +/** + * `resizeWindow` resizes the window specified by its window handle to the given width and height. + * The respective window handle may be acquired via `getWindows` or `getActiveWindow`. + * @param windowHandle The window handle of the window to be resized. + * @param width The new width of the window. + * @param height The new height of the window. + * @return Returns a boolean indicating whether the window resize operation was successful. + */ +bool resizeWindow(const WindowHandle windowHandle, int width, int height); + MMRect getWindowRect(const WindowHandle windowHandle); #endif From 1283f5b3f0b062c2a0d442e4e69d1fe0f7c5a676 Mon Sep 17 00:00:00 2001 From: Ean Krenzin-Blank Date: Wed, 14 Jun 2023 14:29:47 -0700 Subject: [PATCH 02/12] fix windows rect --- src/win32/window_manager.cc | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/win32/window_manager.cc b/src/win32/window_manager.cc index e961999..5e0da45 100644 --- a/src/win32/window_manager.cc +++ b/src/win32/window_manager.cc @@ -66,15 +66,18 @@ bool focusWindow(const WindowHandle windowHandle) { return false; } -bool resizeWindow(const WindowHandle windowHandle, int width, int height) { +bool resizeWindow(const WindowHandle windowHandle, const MMRect& rect) { HWND hWnd = reinterpret_cast(windowHandle); if (IsWindow(hWnd)) { - RECT rect; - if (GetWindowRect(hWnd, &rect)) { - int x = rect.left; - int y = rect.top; - return MoveWindow(hWnd, x, y, width, height, TRUE); - } + //size + int width = rect.size.width; + int height = rect.size.height; + + //origin + int x = rect.origin.x; + int y = rect.origin.y; + + return MoveWindow(hWnd, x, y, width, height, TRUE); } return false; -} \ No newline at end of file +} From 418880563a4a605550d8e27bc3862d643225ef48 Mon Sep 17 00:00:00 2001 From: Ean Date: Fri, 9 Jun 2023 16:10:14 -0700 Subject: [PATCH 03/12] rect object param --- index.d.ts | 24 ++++++++++++++++++++++-- src/linux/window_manager.cc | 16 +++++++++++----- src/macos/window_manager.mm | 34 +++++++++++++++++++++------------- src/main.cc | 35 +++++++++++++++++++++++++++-------- src/window_manager.h | 12 ++++++++---- 5 files changed, 89 insertions(+), 32 deletions(-) diff --git a/index.d.ts b/index.d.ts index cc48377..9d064c6 100644 --- a/index.d.ts +++ b/index.d.ts @@ -51,7 +51,27 @@ export function getWindows(): number[]; export function getActiveWindow(): number; export function getWindowRect(handle: number): Rect; export function getWindowTitle(handle: number): string; -export function focusWindow(handle: number): void; -export function resizeWindow(handle: number, width: number, height: number): void; + +/** + * Sets the focus to a specific window using its handle. + * + * @param {number} handle - The handle ID of the window to be focused. + * @returns {void} + */ +export function focusWindow(handle: number): void + +/** +* Resizes a window by its handle to the given width and height. +* The window is moved to the x & y coordinates if specified. +* +* @param {number} handle - The handle ID of the window to be resized. +* @param {Rect} rect - The new size of the window. +* @param {number} rect.x - The new x coordinate of the window. +* @param {number} rect.y - The new y coordinate of the window. +* @param {number} rect.width - The new width of the window. +* @param {number} rect.height - The new height of the window. +* @returns {void} +*/ +export function resizeWindow(handle: number, rect: Rect): void export const screen: Screen; diff --git a/src/linux/window_manager.cc b/src/linux/window_manager.cc index e3fd048..1e61970 100644 --- a/src/linux/window_manager.cc +++ b/src/linux/window_manager.cc @@ -82,15 +82,21 @@ bool focusWindow(const WindowHandle windowHandle) { return false; } -bool resizeWindow(const WindowHandle windowHandle, int width, int height) { +bool resizeWindow(const WindowHandle windowHandle, const MMRect& rect) { Display* display = XGetMainDisplay(); if (display != NULL && windowHandle >= 0) { XWindowChanges changes; - changes.width = width; - changes.height = height; + + //size + changes.width = rect.size.width; + changes.height = rect.size.height; + + //origin + changes.x = rect.origin.x; + changes.y = rect.origin.y; - // Resize the window - XConfigureWindow(display, windowHandle, CWWidth | CWHeight, &changes); + // Resize and move the window + XConfigureWindow(display, windowHandle, CWX | CWY | CWWidth | CWHeight, &changes); XFlush(display); return true; diff --git a/src/macos/window_manager.mm b/src/macos/window_manager.mm index 682d798..e28f149 100644 --- a/src/macos/window_manager.mm +++ b/src/macos/window_manager.mm @@ -94,26 +94,34 @@ MMRect getWindowRect(const WindowHandle windowHandle) { } BOOL focusWindow(NSWindow *window) { - if (window) { - // Restore the window if it's minimized - if ([window isMiniaturized]) { - [window deminiaturize:nil]; - } + // if (window) { + // // Restore the window if it's minimized + // if ([window isMiniaturized]) { + // [window deminiaturize:nil]; + // } - // Try to set the window to the foreground - [window makeKeyAndOrderFront:nil]; + // // Try to set the window to the foreground + // [window makeKeyAndOrderFront:nil]; - return YES; - } + // return YES; + // } return NO; } -BOOL resizeWindow(NSWindow *window, int width, int height) { +BOOL resizeWindow(NSWindow *window, MMRect rect) { if (window) { - NSRect frame = [window frame]; - frame.size = NSMakeSize(width, height); + NSRect frame; + + //size + frame.size.width = rect.size.width; + frame.size.height = rect.size.height; + + //origin + frame.origin.x = rect.origin.x; + frame.origin.y = rect.origin.y; + [window setFrame:frame display:YES animate:NO]; return YES; } return NO; -} \ No newline at end of file +} diff --git a/src/main.cc b/src/main.cc index a554f8a..60c6306 100644 --- a/src/main.cc +++ b/src/main.cc @@ -654,16 +654,35 @@ Napi::Boolean _focusWindow(const Napi::CallbackInfo &info) { return Napi::Boolean::New(env, result); } -Napi::Boolean _resizeWindow(const Napi::CallbackInfo &info) { +Napi::Value _resizeWindow(const Napi::CallbackInfo& info) { Napi::Env env = info.Env(); - WindowHandle windowHandle = info[0].As().Int64Value(); - int width = info[1].As().Int32Value(); - int height = info[2].As().Int32Value(); - - bool result = resizeWindow(windowHandle, width, height); - - return Napi::Boolean::New(env, result); + if (info.Length() < 2 || !info[0].IsNumber() || !info[1].IsObject()) { + Napi::TypeError::New(env, "Invalid arguments. Expected handle (number) and rect (object).").ThrowAsJavaScriptException(); + return Napi::Boolean::New(env, false); + } + + int64_t handle = info[0].As().Int64Value(); + Napi::Object rectObj = info[1].As(); + + int64_t x = 0; + int64_t y = 0; + int64_t width = 0; + int64_t height = 0; + + if (rectObj.Has("x")) + x = rectObj.Get("x").As().Int64Value(); + if (rectObj.Has("y")) + y = rectObj.Get("y").As().Int64Value(); + if (rectObj.Has("width")) + width = rectObj.Get("width").As().Int64Value(); + if (rectObj.Has("height")) + height = rectObj.Get("height").As().Int64Value(); + + MMRect rect = MMRectMake(x, y, width, height); + resizeWindow(handle, rect); + + return Napi::Boolean::New(env, true); } diff --git a/src/window_manager.h b/src/window_manager.h index c9ca938..6736892 100644 --- a/src/window_manager.h +++ b/src/window_manager.h @@ -31,6 +31,8 @@ std::string getWindowTitle(const WindowHandle windowHandle); * That is, a window's top left position given as `x` and `y` coordinate, as well as it's window size given as `width` and `height` * The respective window handle may be aquired via `getWindows` or `getActiveWindow` */ +MMRect getWindowRect(const WindowHandle windowHandle); + /** * `focusWindow` focuses on the window specified by its window handle. * It brings the specified window to the foreground and gives it input focus. @@ -44,12 +46,14 @@ bool focusWindow(const WindowHandle windowHandle); * `resizeWindow` resizes the window specified by its window handle to the given width and height. * The respective window handle may be acquired via `getWindows` or `getActiveWindow`. * @param windowHandle The window handle of the window to be resized. - * @param width The new width of the window. - * @param height The new height of the window. + * @param rect The new position and size of the window. + * @param rect.x The new x coordinate of the window's top left corner. + * @param rect.y The new y coordinate of the window's top left corner. + * @param rect.width The new width of the window. + * @param rect.height The new height of the window. * @return Returns a boolean indicating whether the window resize operation was successful. */ -bool resizeWindow(const WindowHandle windowHandle, int width, int height); +bool resizeWindow(const WindowHandle windowHandle, const MMRect& rect); -MMRect getWindowRect(const WindowHandle windowHandle); #endif From f8a5dd75cdea82a0caad6ca25e9d01ce19dd9224 Mon Sep 17 00:00:00 2001 From: Ean Date: Sat, 10 Jun 2023 09:58:07 -0700 Subject: [PATCH 04/12] fix focus window implementation on macos --- src/macos/window_manager.mm | 52 ++++++++++++++++----------------- src/main.cc | 58 ++++++++++++++++++------------------- src/win32/window_manager.cc | 4 +-- 3 files changed, 56 insertions(+), 58 deletions(-) diff --git a/src/macos/window_manager.mm b/src/macos/window_manager.mm index e28f149..dccfee8 100644 --- a/src/macos/window_manager.mm +++ b/src/macos/window_manager.mm @@ -93,35 +93,33 @@ MMRect getWindowRect(const WindowHandle windowHandle) { return ""; } -BOOL focusWindow(NSWindow *window) { - // if (window) { - // // Restore the window if it's minimized - // if ([window isMiniaturized]) { - // [window deminiaturize:nil]; - // } - - // // Try to set the window to the foreground - // [window makeKeyAndOrderFront:nil]; - - // return YES; - // } - return NO; +bool focusWindow(const WindowHandle windowHandle) { + CGWindowListOption listOptions = kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements; + CFArrayRef windowList = CGWindowListCopyWindowInfo(listOptions, kCGNullWindowID); + + for (NSDictionary *info in (NSArray *)windowList) { + NSNumber *ownerPid = info[(id)kCGWindowOwnerPID]; + NSNumber *windowNumber = info[(id)kCGWindowNumber]; + + if ([windowNumber intValue] == windowHandle) { + NSRunningApplication *app = [NSRunningApplication runningApplicationWithProcessIdentifier:[ownerPid intValue]]; + [app activateWithOptions:NSApplicationActivateIgnoringOtherApps]; + CFRelease(windowList); + return true; + } + } + + if (windowList) { + CFRelease(windowList); + } + return false; } -BOOL resizeWindow(NSWindow *window, MMRect rect) { - if (window) { - NSRect frame; - - //size - frame.size.width = rect.size.width; - frame.size.height = rect.size.height; - //origin - frame.origin.x = rect.origin.x; - frame.origin.y = rect.origin.y; +bool resizeWindow(const WindowHandle windowHandle, MMRect rect) { + if (windowHandle < 0) { + return false; + } - [window setFrame:frame display:YES animate:NO]; - return YES; - } - return NO; + return true; } diff --git a/src/main.cc b/src/main.cc index 60c6306..d336068 100644 --- a/src/main.cc +++ b/src/main.cc @@ -654,35 +654,35 @@ Napi::Boolean _focusWindow(const Napi::CallbackInfo &info) { return Napi::Boolean::New(env, result); } -Napi::Value _resizeWindow(const Napi::CallbackInfo& info) { - Napi::Env env = info.Env(); - - if (info.Length() < 2 || !info[0].IsNumber() || !info[1].IsObject()) { - Napi::TypeError::New(env, "Invalid arguments. Expected handle (number) and rect (object).").ThrowAsJavaScriptException(); - return Napi::Boolean::New(env, false); - } - - int64_t handle = info[0].As().Int64Value(); - Napi::Object rectObj = info[1].As(); - - int64_t x = 0; - int64_t y = 0; - int64_t width = 0; - int64_t height = 0; - - if (rectObj.Has("x")) - x = rectObj.Get("x").As().Int64Value(); - if (rectObj.Has("y")) - y = rectObj.Get("y").As().Int64Value(); - if (rectObj.Has("width")) - width = rectObj.Get("width").As().Int64Value(); - if (rectObj.Has("height")) - height = rectObj.Get("height").As().Int64Value(); - - MMRect rect = MMRectMake(x, y, width, height); - resizeWindow(handle, rect); - - return Napi::Boolean::New(env, true); +Napi::Boolean _resizeWindow(const Napi::CallbackInfo& info) { + // Napi::Env env = info.Env(); + + // if (info.Length() < 2 || !info[0].IsNumber() || !info[1].IsObject()) { + // Napi::TypeError::New(env, "Invalid arguments. Expected handle (number) and rect (object).").ThrowAsJavaScriptException(); + // return Napi::Boolean::New(env, false); + // } + + // int64_t handle = info[0].As().Int64Value(); + // Napi::Object rectObj = info[1].As(); + + // int64_t x = 0; + // int64_t y = 0; + // int64_t width = 0; + // int64_t height = 0; + + // if (rectObj.Has("x")) + // x = rectObj.Get("x").As().Int64Value(); + // if (rectObj.Has("y")) + // y = rectObj.Get("y").As().Int64Value(); + // if (rectObj.Has("width")) + // width = rectObj.Get("width").As().Int64Value(); + // if (rectObj.Has("height")) + // height = rectObj.Get("height").As().Int64Value(); + + // MMRect rect = MMRectMake(x, y, width, height); + // resizeWindow(handle, rect); + + // return Napi::Boolean::New(env, true); } diff --git a/src/win32/window_manager.cc b/src/win32/window_manager.cc index 5e0da45..83da4e6 100644 --- a/src/win32/window_manager.cc +++ b/src/win32/window_manager.cc @@ -52,7 +52,7 @@ std::string getWindowTitle(const WindowHandle windowHandle) { return ""; } -bool focusWindow(const WindowHandle windowHandle) { +std::bool focusWindow(const WindowHandle windowHandle) { HWND hWnd = reinterpret_cast(windowHandle); if (IsWindow(hWnd)) { // Restore the window if it's minimized @@ -66,7 +66,7 @@ bool focusWindow(const WindowHandle windowHandle) { return false; } -bool resizeWindow(const WindowHandle windowHandle, const MMRect& rect) { +std::bool resizeWindow(const WindowHandle windowHandle, const MMRect& rect) { HWND hWnd = reinterpret_cast(windowHandle); if (IsWindow(hWnd)) { //size From 01d47e9701c44af7959ab9dab4dc8ba6af76edd8 Mon Sep 17 00:00:00 2001 From: Ean Date: Wed, 14 Jun 2023 14:06:30 -0700 Subject: [PATCH 05/12] update focus window method --- src/macos/window_manager.mm | 87 ++++++++++++++++++++++--------------- 1 file changed, 51 insertions(+), 36 deletions(-) diff --git a/src/macos/window_manager.mm b/src/macos/window_manager.mm index dccfee8..94b4efc 100644 --- a/src/macos/window_manager.mm +++ b/src/macos/window_manager.mm @@ -1,11 +1,14 @@ +#include "../window_manager.h" +#import +#import #include #import -#import -#include "../window_manager.h" -NSDictionary* getWindowInfo(int64_t windowHandle) { - CGWindowListOption listOptions = kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements; - CFArrayRef windowList = CGWindowListCopyWindowInfo(listOptions, kCGNullWindowID); +NSDictionary *getWindowInfo(int64_t windowHandle) { + CGWindowListOption listOptions = + kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements; + CFArrayRef windowList = + CGWindowListCopyWindowInfo(listOptions, kCGNullWindowID); for (NSDictionary *info in (NSArray *)windowList) { NSNumber *windowNumber = info[(id)kCGWindowNumber]; @@ -25,14 +28,17 @@ } WindowHandle getActiveWindow() { - CGWindowListOption listOptions = kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements; - CFArrayRef windowList = CGWindowListCopyWindowInfo(listOptions, kCGNullWindowID); + CGWindowListOption listOptions = + kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements; + CFArrayRef windowList = + CGWindowListCopyWindowInfo(listOptions, kCGNullWindowID); for (NSDictionary *info in (NSArray *)windowList) { NSNumber *ownerPid = info[(id)kCGWindowOwnerPID]; NSNumber *windowNumber = info[(id)kCGWindowNumber]; - auto app = [NSRunningApplication runningApplicationWithProcessIdentifier: [ownerPid intValue]]; + auto app = [NSRunningApplication + runningApplicationWithProcessIdentifier:[ownerPid intValue]]; if (![app isActive]) { continue; @@ -49,8 +55,10 @@ WindowHandle getActiveWindow() { } std::vector getWindows() { - CGWindowListOption listOptions = kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements; - CFArrayRef windowList = CGWindowListCopyWindowInfo(listOptions, kCGNullWindowID); + CGWindowListOption listOptions = + kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements; + CFArrayRef windowList = + CGWindowListCopyWindowInfo(listOptions, kCGNullWindowID); std::vector windowHandles; @@ -58,7 +66,8 @@ WindowHandle getActiveWindow() { NSNumber *ownerPid = info[(id)kCGWindowOwnerPID]; NSNumber *windowNumber = info[(id)kCGWindowNumber]; - auto app = [NSRunningApplication runningApplicationWithProcessIdentifier: [ownerPid intValue]]; + auto app = [NSRunningApplication + runningApplicationWithProcessIdentifier:[ownerPid intValue]]; auto path = app ? [app.bundleURL.path UTF8String] : ""; if (app && path != "") { @@ -77,8 +86,10 @@ MMRect getWindowRect(const WindowHandle windowHandle) { auto windowInfo = getWindowInfo(windowHandle); if (windowInfo != nullptr && windowHandle >= 0) { CGRect windowRect; - if (CGRectMakeWithDictionaryRepresentation((CFDictionaryRef)windowInfo[(id)kCGWindowBounds], &windowRect)) { - return MMRectMake(windowRect.origin.x, windowRect.origin.y, windowRect.size.width, windowRect.size.height); + if (CGRectMakeWithDictionaryRepresentation( + (CFDictionaryRef)windowInfo[(id)kCGWindowBounds], &windowRect)) { + return MMRectMake(windowRect.origin.x, windowRect.origin.y, + windowRect.size.width, windowRect.size.height); } } return MMRectMake(0, 0, 0, 0); @@ -88,38 +99,42 @@ MMRect getWindowRect(const WindowHandle windowHandle) { auto windowInfo = getWindowInfo(windowHandle); if (windowInfo != nullptr && windowHandle >= 0) { NSString *windowName = windowInfo[(id)kCGWindowName]; - return std::string([windowName UTF8String], [windowName lengthOfBytesUsingEncoding:NSUTF8StringEncoding]); + return std::string( + [windowName UTF8String], + [windowName lengthOfBytesUsingEncoding:NSUTF8StringEncoding]); } return ""; } bool focusWindow(const WindowHandle windowHandle) { - CGWindowListOption listOptions = kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements; - CFArrayRef windowList = CGWindowListCopyWindowInfo(listOptions, kCGNullWindowID); - - for (NSDictionary *info in (NSArray *)windowList) { - NSNumber *ownerPid = info[(id)kCGWindowOwnerPID]; - NSNumber *windowNumber = info[(id)kCGWindowNumber]; - - if ([windowNumber intValue] == windowHandle) { - NSRunningApplication *app = [NSRunningApplication runningApplicationWithProcessIdentifier:[ownerPid intValue]]; - [app activateWithOptions:NSApplicationActivateIgnoringOtherApps]; - CFRelease(windowList); - return true; - } - } + CGWindowListOption listOptions = + kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements; + CFArrayRef windowList = + CGWindowListCopyWindowInfo(listOptions, kCGNullWindowID); - if (windowList) { - CFRelease(windowList); - } - return false; -} + bool activated = false; + + for (NSDictionary *info in (NSArray *)windowList) { + NSNumber *ownerPid = info[(id)kCGWindowOwnerPID]; + NSNumber *windowNumber = info[(id)kCGWindowNumber]; + if ([windowNumber intValue] == windowHandle) { + NSRunningApplication *app = [NSRunningApplication + runningApplicationWithProcessIdentifier:[ownerPid intValue]]; + [app activateWithOptions:NSApplicationActivateIgnoringOtherApps]; + activated = true; + } + } -bool resizeWindow(const WindowHandle windowHandle, MMRect rect) { - if (windowHandle < 0) { - return false; + if (windowList) { + CFRelease(windowList); } + return activated; +} + +bool resizeWindow(int64_t windowHandle, MMRect rect) { + //this method is complicated due to the accessibility requirements on macos + return true; } From 6dd08ad42584bed5236c82833fd89d9c9bc20e6e Mon Sep 17 00:00:00 2001 From: Ean Date: Wed, 14 Jun 2023 18:09:04 -0700 Subject: [PATCH 06/12] "working" implementation of resize on mac --- src/macos/window_manager.mm | 49 +++++++++++++++++++++++++++-- src/main.cc | 61 ++++++++++++++++++++----------------- src/window_manager.h | 2 +- 3 files changed, 80 insertions(+), 32 deletions(-) diff --git a/src/macos/window_manager.mm b/src/macos/window_manager.mm index 94b4efc..056fc85 100644 --- a/src/macos/window_manager.mm +++ b/src/macos/window_manager.mm @@ -1,5 +1,6 @@ #include "../window_manager.h" #import +#import #import #include #import @@ -133,8 +134,50 @@ bool focusWindow(const WindowHandle windowHandle) { return activated; } -bool resizeWindow(int64_t windowHandle, MMRect rect) { - //this method is complicated due to the accessibility requirements on macos +/* + This function takes an input windowhandle (a kCGWindowNumber) and a rect (size + & origin) and resizes the window to the given rect. +*/ +bool resizeWindow(const WindowHandle windowHandle, const MMRect rect) { - return true; + NSDictionary *windowInfo = getWindowInfo(windowHandle); + if (windowInfo == nullptr || windowHandle < 0) { + NSLog(@"Could not find window info for window handle %lld", windowHandle); + return false; + } + + pid_t pid = [[windowInfo objectForKey:(id)kCGWindowOwnerPID] intValue]; + AXUIElementRef app = AXUIElementCreateApplication(pid); + AXUIElementRef window; + AXError error = AXUIElementCopyAttributeValue(app, kAXFocusedWindowAttribute, + (CFTypeRef *)&window); + + if (error == kAXErrorSuccess) { + AXValueRef positionValue = AXValueCreate((AXValueType)kAXValueCGPointType, + (const void *)&rect.origin); + + // extract the size from the rect + + CGSize size = CGSizeMake(rect.size.width, rect.size.height); + AXValueRef sizeValue = + AXValueCreate((AXValueType)kAXValueCGSizeType, (const void *)&size); + + AXUIElementSetAttributeValue(window, kAXPositionAttribute, positionValue); + AXUIElementSetAttributeValue(window, kAXSizeAttribute, sizeValue); + + // log the position and size of the window + + CFRelease(positionValue); + CFRelease(sizeValue); + CFRelease(window); + CFRelease(app); + + return true; + } else { + NSLog(@"Could not resize window with window handle %lld", windowHandle); + CFRelease(app); + return false; + } + + return YES; } diff --git a/src/main.cc b/src/main.cc index d336068..c0edb68 100644 --- a/src/main.cc +++ b/src/main.cc @@ -655,34 +655,39 @@ Napi::Boolean _focusWindow(const Napi::CallbackInfo &info) { } Napi::Boolean _resizeWindow(const Napi::CallbackInfo& info) { - // Napi::Env env = info.Env(); - - // if (info.Length() < 2 || !info[0].IsNumber() || !info[1].IsObject()) { - // Napi::TypeError::New(env, "Invalid arguments. Expected handle (number) and rect (object).").ThrowAsJavaScriptException(); - // return Napi::Boolean::New(env, false); - // } - - // int64_t handle = info[0].As().Int64Value(); - // Napi::Object rectObj = info[1].As(); - - // int64_t x = 0; - // int64_t y = 0; - // int64_t width = 0; - // int64_t height = 0; - - // if (rectObj.Has("x")) - // x = rectObj.Get("x").As().Int64Value(); - // if (rectObj.Has("y")) - // y = rectObj.Get("y").As().Int64Value(); - // if (rectObj.Has("width")) - // width = rectObj.Get("width").As().Int64Value(); - // if (rectObj.Has("height")) - // height = rectObj.Get("height").As().Int64Value(); - - // MMRect rect = MMRectMake(x, y, width, height); - // resizeWindow(handle, rect); - - // return Napi::Boolean::New(env, true); + Napi::Env env = info.Env(); + + if (info.Length() < 2 || !info[0].IsNumber() || !info[1].IsObject()) { + Napi::TypeError::New(env, "Invalid arguments. Expected handle (number) and rect (object).").ThrowAsJavaScriptException(); + return Napi::Boolean::New(env, false); + } + + WindowHandle windowHandle = info[0].As().Int64Value(); + MMRect windowRect = getWindowRect(windowHandle); + Napi::Object rectObj = info[1].As(); + + int64_t x = 0; + int64_t y = 0; + int64_t width = 0; + int64_t height = 0; + + if (rectObj.Has("x")) + x = rectObj.Get("x").As().Int64Value(); + if (rectObj.Has("y")) + y = rectObj.Get("y").As().Int64Value(); + if (rectObj.Has("width")) + width = rectObj.Get("width").As().Int64Value(); + if (rectObj.Has("height")) + height = rectObj.Get("height").As().Int64Value(); + + windowRect.origin.x = x; + windowRect.origin.y = y; + windowRect.size.width = width; + windowRect.size.height = height; + + resizeWindow(windowHandle, windowRect); + + return Napi::Boolean::New(env, true); } diff --git a/src/window_manager.h b/src/window_manager.h index 6736892..dff37bd 100644 --- a/src/window_manager.h +++ b/src/window_manager.h @@ -53,7 +53,7 @@ bool focusWindow(const WindowHandle windowHandle); * @param rect.height The new height of the window. * @return Returns a boolean indicating whether the window resize operation was successful. */ -bool resizeWindow(const WindowHandle windowHandle, const MMRect& rect); +bool resizeWindow(const WindowHandle windowHandle, const MMRect rect); #endif From a8fbe487cebf6b188b392db693bd841629f325c0 Mon Sep 17 00:00:00 2001 From: Ean Date: Wed, 14 Jun 2023 23:11:32 -0700 Subject: [PATCH 07/12] individual window focusing --- src/macos/window_manager.mm | 61 ++++++++++++++++++++++++++----------- 1 file changed, 44 insertions(+), 17 deletions(-) diff --git a/src/macos/window_manager.mm b/src/macos/window_manager.mm index 056fc85..3cce19c 100644 --- a/src/macos/window_manager.mm +++ b/src/macos/window_manager.mm @@ -108,30 +108,57 @@ MMRect getWindowRect(const WindowHandle windowHandle) { } bool focusWindow(const WindowHandle windowHandle) { - CGWindowListOption listOptions = - kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements; - CFArrayRef windowList = - CGWindowListCopyWindowInfo(listOptions, kCGNullWindowID); - bool activated = false; + NSDictionary *windowInfo = getWindowInfo(windowHandle); + if (windowInfo == nullptr || windowHandle < 0) { + NSLog(@"Could not find window info for window handle %lld", windowHandle); + return false; + } - for (NSDictionary *info in (NSArray *)windowList) { - NSNumber *ownerPid = info[(id)kCGWindowOwnerPID]; - NSNumber *windowNumber = info[(id)kCGWindowNumber]; + pid_t pid = [[windowInfo objectForKey:(id)kCGWindowOwnerPID] intValue]; + AXUIElementRef app = AXUIElementCreateApplication(pid); + + NSString *targetWindowTitle = [windowInfo objectForKey:(id)kCGWindowName]; - if ([windowNumber intValue] == windowHandle) { - NSRunningApplication *app = [NSRunningApplication - runningApplicationWithProcessIdentifier:[ownerPid intValue]]; - [app activateWithOptions:NSApplicationActivateIgnoringOtherApps]; - activated = true; + CFArrayRef windowArray; + AXError error = AXUIElementCopyAttributeValue(app, kAXWindowsAttribute, + (CFTypeRef *)&windowArray); + if (error == kAXErrorSuccess) { + CFIndex count = CFArrayGetCount(windowArray); + for (CFIndex i = 0; i < count; i++) { + AXUIElementRef window = + (AXUIElementRef)CFArrayGetValueAtIndex(windowArray, i); + + CFTypeRef windowTitle; + AXUIElementCopyAttributeValue(window, kAXTitleAttribute, &windowTitle); + if (windowTitle && CFGetTypeID(windowTitle) == CFStringGetTypeID()) { + NSString *title = (__bridge NSString *)windowTitle; + if ([title isEqualToString:targetWindowTitle]) { + AXError error = AXUIElementPerformAction(window, kAXRaiseAction); + if (error == kAXErrorSuccess) { + NSLog(@"Successfully brought the window to front."); + } else { + NSLog(@"Failed to bring the window to front."); + NSLog(@"AXUIElementSetAttributeValue error: %d", error); + } + break; + } + } + if (windowTitle) { + CFRelease(windowTitle); + } } + CFRelease(windowArray); + } else { + NSLog(@"Failed to retrieve the window array."); } - if (windowList) { - CFRelease(windowList); - } + CFRelease(app); - return activated; + // log the window title + NSString *windowName = windowInfo[(id)kCGWindowName]; + NSLog(@"attempted to focus window: %@", windowName); + return true; } /* From 83b48be109ecdf9b2bdd7e20acc839cecf34aae7 Mon Sep 17 00:00:00 2001 From: Ean Krenzin-Blank Date: Wed, 14 Jun 2023 23:44:35 -0700 Subject: [PATCH 08/12] fix windows build --- src/win32/window_manager.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/win32/window_manager.cc b/src/win32/window_manager.cc index 83da4e6..868e751 100644 --- a/src/win32/window_manager.cc +++ b/src/win32/window_manager.cc @@ -52,7 +52,7 @@ std::string getWindowTitle(const WindowHandle windowHandle) { return ""; } -std::bool focusWindow(const WindowHandle windowHandle) { +bool focusWindow(const WindowHandle windowHandle) { HWND hWnd = reinterpret_cast(windowHandle); if (IsWindow(hWnd)) { // Restore the window if it's minimized @@ -66,7 +66,7 @@ std::bool focusWindow(const WindowHandle windowHandle) { return false; } -std::bool resizeWindow(const WindowHandle windowHandle, const MMRect& rect) { +bool resizeWindow(const WindowHandle windowHandle, const MMRect rect) { HWND hWnd = reinterpret_cast(windowHandle); if (IsWindow(hWnd)) { //size From 5c6fbbb702ce4ee79b38526c2ba4b9bd635fafe1 Mon Sep 17 00:00:00 2001 From: Ean Date: Wed, 14 Jun 2023 23:45:21 -0700 Subject: [PATCH 09/12] focus app on macos first for consistency --- src/macos/window_manager.mm | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/macos/window_manager.mm b/src/macos/window_manager.mm index 3cce19c..0f7625e 100644 --- a/src/macos/window_manager.mm +++ b/src/macos/window_manager.mm @@ -109,6 +109,25 @@ MMRect getWindowRect(const WindowHandle windowHandle) { bool focusWindow(const WindowHandle windowHandle) { + CGWindowListOption listOptions = + kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements; + CFArrayRef windowList = + CGWindowListCopyWindowInfo(listOptions, kCGNullWindowID); + bool activated = false; + for (NSDictionary *info in (NSArray *)windowList) { + NSNumber *ownerPid = info[(id)kCGWindowOwnerPID]; + NSNumber *windowNumber = info[(id)kCGWindowNumber]; + if ([windowNumber intValue] == windowHandle) { + NSRunningApplication *app = [NSRunningApplication + runningApplicationWithProcessIdentifier:[ownerPid intValue]]; + [app activateWithOptions:NSApplicationActivateIgnoringOtherApps]; + activated = true; + } + } + if (windowList) { + CFRelease(windowList); + } + NSDictionary *windowInfo = getWindowInfo(windowHandle); if (windowInfo == nullptr || windowHandle < 0) { NSLog(@"Could not find window info for window handle %lld", windowHandle); From 71baba8ce157b4364aefc8d184e24833429f593e Mon Sep 17 00:00:00 2001 From: Ean Date: Fri, 16 Jun 2023 10:32:40 -0700 Subject: [PATCH 10/12] add documentation and clean code --- src/macos/window_manager.mm | 84 +++++++++++++++++++++++++++---------- 1 file changed, 63 insertions(+), 21 deletions(-) diff --git a/src/macos/window_manager.mm b/src/macos/window_manager.mm index 0f7625e..66fe6bf 100644 --- a/src/macos/window_manager.mm +++ b/src/macos/window_manager.mm @@ -107,13 +107,30 @@ MMRect getWindowRect(const WindowHandle windowHandle) { return ""; } +/** + * Focuses on the window provided via its handle. + * + * This function collects a list of on-screen windows and matches the + * windowHandle with their window numbers. If found, the corresponding + * application is brought to foreground. The function then uses accessibility + * APIs to specifically focus the target window using its title. + * + * @param windowHandle Handle to the window that needs to be focused. + * + * @return bool If the function executes without any errors, it returns true. + * If it can't retrieve window information or windowHandle is + * invalid, it returns false. + */ bool focusWindow(const WindowHandle windowHandle) { + // Collect list of on-screen windows CGWindowListOption listOptions = kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements; CFArrayRef windowList = CGWindowListCopyWindowInfo(listOptions, kCGNullWindowID); bool activated = false; + + // Look for matching window and bring application to foreground for (NSDictionary *info in (NSArray *)windowList) { NSNumber *ownerPid = info[(id)kCGWindowOwnerPID]; NSNumber *windowNumber = info[(id)kCGWindowNumber]; @@ -124,24 +141,31 @@ bool focusWindow(const WindowHandle windowHandle) { activated = true; } } + + // Clean up window list if (windowList) { CFRelease(windowList); } - + + // Retrieve window info NSDictionary *windowInfo = getWindowInfo(windowHandle); if (windowInfo == nullptr || windowHandle < 0) { - NSLog(@"Could not find window info for window handle %lld", windowHandle); + // NSLog(@"Could not find window info for window handle %lld", windowHandle); return false; } + // Create application object for accessibility pid_t pid = [[windowInfo objectForKey:(id)kCGWindowOwnerPID] intValue]; AXUIElementRef app = AXUIElementCreateApplication(pid); + // Get target window title NSString *targetWindowTitle = [windowInfo objectForKey:(id)kCGWindowName]; CFArrayRef windowArray; AXError error = AXUIElementCopyAttributeValue(app, kAXWindowsAttribute, (CFTypeRef *)&windowArray); + + // Iterate through windows to find target and bring it to front if (error == kAXErrorSuccess) { CFIndex count = CFArrayGetCount(windowArray); for (CFIndex i = 0; i < count; i++) { @@ -155,75 +179,93 @@ bool focusWindow(const WindowHandle windowHandle) { if ([title isEqualToString:targetWindowTitle]) { AXError error = AXUIElementPerformAction(window, kAXRaiseAction); if (error == kAXErrorSuccess) { - NSLog(@"Successfully brought the window to front."); + // NSLog(@"Successfully brought the window to front."); } else { - NSLog(@"Failed to bring the window to front."); - NSLog(@"AXUIElementSetAttributeValue error: %d", error); + // NSLog(@"Failed to bring the window to front."); + // NSLog(@"AXUIElementSetAttributeValue error: %d", error); } break; } } + + // Clean up window title if (windowTitle) { CFRelease(windowTitle); } } + + // Clean up window array CFRelease(windowArray); } else { - NSLog(@"Failed to retrieve the window array."); + // NSLog(@"Failed to retrieve the window array."); } + // Clean up application object CFRelease(app); - // log the window title - NSString *windowName = windowInfo[(id)kCGWindowName]; - NSLog(@"attempted to focus window: %@", windowName); + // Successfully executed return true; } -/* - This function takes an input windowhandle (a kCGWindowNumber) and a rect (size - & origin) and resizes the window to the given rect. -*/ +/** + * Resizes and repositions the window provided via its handle to the specified rectangle. + * + * This function retrieves window information using the provided window handle, then uses + * macOS Accessibility APIs to resize and reposition the window to fit within the provided + * rectangle dimensions and location. + * + * @param windowHandle Handle to the window that needs to be resized. + * @param rect The rectangle area to which the window should be resized and repositioned. + * + * @return bool If the function executes without any errors and successfully resizes the + * window, it returns true. If it can't retrieve window information or + * windowHandle is invalid, or the window resizing operation fails, it returns false. + */ bool resizeWindow(const WindowHandle windowHandle, const MMRect rect) { + // Retrieve window info NSDictionary *windowInfo = getWindowInfo(windowHandle); if (windowInfo == nullptr || windowHandle < 0) { - NSLog(@"Could not find window info for window handle %lld", windowHandle); + // NSLog(@"Could not find window info for window handle %lld", windowHandle); return false; } + // Create application object for accessibility pid_t pid = [[windowInfo objectForKey:(id)kCGWindowOwnerPID] intValue]; AXUIElementRef app = AXUIElementCreateApplication(pid); AXUIElementRef window; + AXError error = AXUIElementCopyAttributeValue(app, kAXFocusedWindowAttribute, (CFTypeRef *)&window); - + + // If no error occurred, proceed with the resize and reposition operations if (error == kAXErrorSuccess) { + + // Create AXValue objects for position and size AXValueRef positionValue = AXValueCreate((AXValueType)kAXValueCGPointType, (const void *)&rect.origin); - - // extract the size from the rect - CGSize size = CGSizeMake(rect.size.width, rect.size.height); AXValueRef sizeValue = AXValueCreate((AXValueType)kAXValueCGSizeType, (const void *)&size); + // Set new position and size AXUIElementSetAttributeValue(window, kAXPositionAttribute, positionValue); AXUIElementSetAttributeValue(window, kAXSizeAttribute, sizeValue); - // log the position and size of the window - + // Clean up AXValue and AXUIElement objects CFRelease(positionValue); CFRelease(sizeValue); CFRelease(window); CFRelease(app); + // Return true to indicate successful resize return true; } else { - NSLog(@"Could not resize window with window handle %lld", windowHandle); + // NSLog(@"Could not resize window with window handle %lld", windowHandle); CFRelease(app); return false; } return YES; } + From b025e0ab020bd9e26c77b619956851b1889c2fa9 Mon Sep 17 00:00:00 2001 From: Ean Date: Fri, 7 Jul 2023 12:13:27 -0700 Subject: [PATCH 11/12] throw errors and return resize result properly --- src/main.cc | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/main.cc b/src/main.cc index c0edb68..d14af21 100644 --- a/src/main.cc +++ b/src/main.cc @@ -666,28 +666,24 @@ Napi::Boolean _resizeWindow(const Napi::CallbackInfo& info) { MMRect windowRect = getWindowRect(windowHandle); Napi::Object rectObj = info[1].As(); - int64_t x = 0; - int64_t y = 0; - int64_t width = 0; - int64_t height = 0; - - if (rectObj.Has("x")) - x = rectObj.Get("x").As().Int64Value(); - if (rectObj.Has("y")) - y = rectObj.Get("y").As().Int64Value(); - if (rectObj.Has("width")) - width = rectObj.Get("width").As().Int64Value(); - if (rectObj.Has("height")) - height = rectObj.Get("height").As().Int64Value(); + if (!rectObj.Has("x") || !rectObj.Has("y") || !rectObj.Has("width") || !rectObj.Has("height")) { + Napi::TypeError::New(env, "Invalid rect object. Must have 'x', 'y', 'width', and 'height' properties.").ThrowAsJavaScriptException(); + return Napi::Boolean::New(env, false); + } + + int64_t x = rectObj.Get("x").As().Int64Value(); + int64_t y = rectObj.Get("y").As().Int64Value(); + int64_t width = rectObj.Get("width").As().Int64Value(); + int64_t height = rectObj.Get("height").As().Int64Value(); windowRect.origin.x = x; windowRect.origin.y = y; windowRect.size.width = width; windowRect.size.height = height; - resizeWindow(windowHandle, windowRect); + bool resizeResult = resizeWindow(windowHandle, windowRect); - return Napi::Boolean::New(env, true); + return Napi::Boolean::New(env, resizeResult); } From d9f65cd7304ded3c4157525b2f59193e4f18e957 Mon Sep 17 00:00:00 2001 From: Ean Date: Fri, 7 Jul 2023 12:18:34 -0700 Subject: [PATCH 12/12] update resizeWindow rect documentation --- index.d.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/index.d.ts b/index.d.ts index 9d064c6..ef24a09 100644 --- a/index.d.ts +++ b/index.d.ts @@ -66,10 +66,6 @@ export function focusWindow(handle: number): void * * @param {number} handle - The handle ID of the window to be resized. * @param {Rect} rect - The new size of the window. -* @param {number} rect.x - The new x coordinate of the window. -* @param {number} rect.y - The new y coordinate of the window. -* @param {number} rect.width - The new width of the window. -* @param {number} rect.height - The new height of the window. * @returns {void} */ export function resizeWindow(handle: number, rect: Rect): void