Skip to content

Commit 0110b85

Browse files
authored
Merge pull request #684 from go-vgo/bitmap-pr
Add: export xClose main display function
2 parents 85f2702 + 3e5b10f commit 0110b85

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

robotgo.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,11 @@ func GetXDisplayName() string {
457457
return gname
458458
}
459459

460+
// CloseMainDisplay close the main X11 display
461+
func CloseMainDisplay() {
462+
C.close_main_display()
463+
}
464+
460465
// Deprecated: use the ScaledF(),
461466
//
462467
// ScaleX get the primary display horizontal DPI scale factor, drop

screen/goScreen.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ char* get_XDisplay_name() {
7979
#endif
8080
}
8181

82+
void close_main_display() {
83+
#if defined(USE_X11)
84+
XCloseMainDisplay();
85+
#else
86+
//
87+
#endif
88+
}
89+
8290
uint32_t get_num_displays() {
8391
#if defined(IS_MACOSX)
8492
uint32_t count = 0;

screen/screengrab_c.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
dispatch_semaphore_signal(semaphore);
2525
return;
2626
}
27+
2728
SCDisplay* target = nil;
2829
for (SCDisplay *display in content.displays) {
2930
if (display.displayID == id) {
@@ -41,16 +42,18 @@
4142
config.sourceRect = diIntersectDisplayLocal;
4243
config.width = diIntersectDisplayLocal.size.width;
4344
config.height = diIntersectDisplayLocal.size.height;
45+
4446
[SCScreenshotManager captureImageWithFilter:filter
45-
configuration:config
46-
completionHandler:^(CGImageRef img, NSError* error) {
47-
if (!error) {
48-
image1 = CGImageCreateCopyWithColorSpace(img, colorSpace);
49-
}
50-
dispatch_semaphore_signal(semaphore);
47+
configuration:config
48+
completionHandler:^(CGImageRef img, NSError* error) {
49+
if (!error) {
50+
image1 = CGImageCreateCopyWithColorSpace(img, colorSpace);
51+
}
52+
dispatch_semaphore_signal(semaphore);
5153
}];
5254
}
5355
}];
56+
5457
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
5558
dispatch_release(semaphore);
5659
return image1;

0 commit comments

Comments
 (0)