aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/window/window.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/src/window/window.c b/src/window/window.c
index 6927992..df56c94 100644
--- a/src/window/window.c
+++ b/src/window/window.c
@@ -727,6 +727,11 @@ static void mgl_window_on_receive_event(mgl_window *self, XEvent *xev, mgl_event
return;
}
case SelectionClear: {
+ if(self->clipboard_string) {
+ free(self->clipboard_string);
+ self->clipboard_string = NULL;
+ self->clipboard_size = 0;
+ }
event->type = MGL_EVENT_UNKNOWN;
return;
}
@@ -1134,23 +1139,14 @@ bool mgl_window_get_clipboard(mgl_window *self, mgl_clipboard_callback callback,
}
} else if(xev.xselection.target == requested_clipboard_type) {
bool got_data = false;
- long chunk_size = 65536;
-
- //XDeleteProperty(context->connection, self->window, x11_context->incr_atom);
- //XFlush(context->connection);
while(mgl_clock_get_elapsed_time_seconds(&timeout_timer) < timeout_seconds) {
- unsigned long offset = 0;
-
- /* offset is specified in XGetWindowProperty as a multiple of 32-bit (4 bytes) */
/* TODO: Wait for PropertyNotify event instead */
- while(XGetWindowProperty(context->connection, xev.xselection.requestor, xev.xselection.property, offset/4, chunk_size, True, PropertyNewValue, &type, &format, &items, &remaining_bytes, &data) == Success) {
+ while(XGetWindowProperty(context->connection, xev.xselection.requestor, xev.xselection.property, 0, 0x1fffffff, True, PropertyNewValue, &type, &format, &items, &remaining_bytes, &data) == Success) {
if(mgl_clock_get_elapsed_time_seconds(&timeout_timer) >= timeout_seconds)
break;
if(type == x11_context->incr_atom) {
- if(data)
- chunk_size = *(long*)data;
XDeleteProperty(context->connection, self->window, x11_context->incr_atom);
XFlush(context->connection);
XFree(data);
@@ -1180,20 +1176,16 @@ bool mgl_window_get_clipboard(mgl_window *self, mgl_clipboard_callback callback,
}
}
}
- offset += num_items_bytes;
if(data) {
XFree(data);
data = NULL;
}
- if(got_data && num_items_bytes == 0/* && format == 8*/) {
+ if(got_data && items == 0) {
success = true;
goto done;
}
-
- if(remaining_bytes == 0)
- break;
}
}
@@ -1203,8 +1195,10 @@ bool mgl_window_get_clipboard(mgl_window *self, mgl_clipboard_callback callback,
}
done:
- if(requested_clipboard_type)
+ if(requested_clipboard_type) {
XDeleteProperty(context->connection, self->window, requested_clipboard_type);
+ XFlush(context->connection);
+ }
return success;
}