Skip to content

Commit

Permalink
Merge pull request #684 from go-vgo/bitmap-pr
Browse files Browse the repository at this point in the history
Add: export xClose main display function
  • Loading branch information
vcaesar authored Sep 17, 2024
2 parents 85f2702 + 3e5b10f commit 0110b85
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
5 changes: 5 additions & 0 deletions robotgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions screen/goScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 9 additions & 6 deletions screen/screengrab_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
dispatch_semaphore_signal(semaphore);
return;
}

SCDisplay* target = nil;
for (SCDisplay *display in content.displays) {
if (display.displayID == id) {
Expand All @@ -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;
Expand Down

0 comments on commit 0110b85

Please sign in to comment.