From cb51e2aa10f1083b4c66a40103fac09a4b12ef15 Mon Sep 17 00:00:00 2001 From: vcaesar Date: Tue, 17 Sep 2024 12:59:15 -0700 Subject: [PATCH 1/2] Update: cleary some code style --- screen/screengrab_c.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/screen/screengrab_c.h b/screen/screengrab_c.h index 3007fb73..32c30f7c 100644 --- a/screen/screengrab_c.h +++ b/screen/screengrab_c.h @@ -24,6 +24,7 @@ dispatch_semaphore_signal(semaphore); return; } + SCDisplay* target = nil; for (SCDisplay *display in content.displays) { if (display.displayID == id) { @@ -41,16 +42,18 @@ config.sourceRect = diIntersectDisplayLocal; config.width = diIntersectDisplayLocal.size.width; config.height = diIntersectDisplayLocal.size.height; + [SCScreenshotManager captureImageWithFilter:filter - configuration:config - completionHandler:^(CGImageRef img, NSError* error) { - if (!error) { - image1 = CGImageCreateCopyWithColorSpace(img, colorSpace); - } - dispatch_semaphore_signal(semaphore); + configuration:config + completionHandler:^(CGImageRef img, NSError* error) { + if (!error) { + image1 = CGImageCreateCopyWithColorSpace(img, colorSpace); + } + dispatch_semaphore_signal(semaphore); }]; } }]; + dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER); dispatch_release(semaphore); return image1; From 3e5b10f7208312e1ac2cdc1fcad415cac8410077 Mon Sep 17 00:00:00 2001 From: vcaesar Date: Tue, 17 Sep 2024 13:11:02 -0700 Subject: [PATCH 2/2] Add: export XClose main display function --- robotgo.go | 5 +++++ screen/goScreen.h | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/robotgo.go b/robotgo.go index 7c79bd4c..5ac065a6 100644 --- a/robotgo.go +++ b/robotgo.go @@ -457,6 +457,11 @@ func GetXDisplayName() string { return gname } +// CloseMainDisplay close the main X11 display +func CloseMainDisplay() { + C.close_main_display() +} + // Deprecated: use the ScaledF(), // // ScaleX get the primary display horizontal DPI scale factor, drop diff --git a/screen/goScreen.h b/screen/goScreen.h index 24321bf6..d4349a5a 100644 --- a/screen/goScreen.h +++ b/screen/goScreen.h @@ -79,6 +79,14 @@ char* get_XDisplay_name() { #endif } +void close_main_display() { + #if defined(USE_X11) + XCloseMainDisplay(); + #else + // + #endif +} + uint32_t get_num_displays() { #if defined(IS_MACOSX) uint32_t count = 0;