Skip to content

Commit 08b9d79

Browse files
committed
all: test 42 times of clipboard open
1 parent 5f2192a commit 08b9d79

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

clipboard_linux.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,15 @@
1717
extern void syncStatus(uintptr_t handle, int status);
1818

1919
int clipboard_test() {
20-
Display *d = XOpenDisplay(0);
20+
Display* d = NULL;
21+
for (int i = 0; i < 42; i++) {
22+
d = XOpenDisplay(0);
23+
if (d == NULL) {
24+
continue;
25+
}
26+
break;
27+
}
28+
2129
if (d == NULL) {
2230
return -1;
2331
}
@@ -69,7 +77,7 @@ int clipboard_write(char *typ, unsigned char *buf, size_t n, uintptr_t handle) {
6977
XSelectionRequestEvent* xsr;
7078
int notified = 0;
7179
for (;;) {
72-
if (notified == 0) {
80+
if (notified == 0) {
7381
syncStatus(handle, 1); // notify Go side
7482
notified = 1;
7583
}
@@ -105,7 +113,7 @@ int clipboard_write(char *typ, unsigned char *buf, size_t n, uintptr_t handle) {
105113
ev.property = xsr->property;
106114

107115
if (ev.target == atomString && ev.target == target) {
108-
R = XChangeProperty(ev.display, ev.requestor, ev.property,
116+
R = XChangeProperty(ev.display, ev.requestor, ev.property,
109117
atomString, 8, PropModeReplace, buf, n);
110118
} else if (ev.target == atomImage && ev.target == target) {
111119
R = XChangeProperty(ev.display, ev.requestor, ev.property,

0 commit comments

Comments
 (0)