aboutsummaryrefslogtreecommitdiff
path: root/src/window
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-12-11 02:33:12 +0100
committerdec05eba <dec05eba@protonmail.com>2022-12-11 02:33:12 +0100
commit5bcf963ff721717463c576fac874561fc9827a45 (patch)
tree149d230e3b8a9239dc0c2ce4b3ba25a5ad13bf02 /src/window
parentf43d6e82c3fb59f25189c745c5ca5ff1d2e3c161 (diff)
Fix pasting text from mgl to other applications
Diffstat (limited to 'src/window')
-rw-r--r--src/window/window.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/window/window.c b/src/window/window.c
index 709f4b1..60f6277 100644
--- a/src/window/window.c
+++ b/src/window/window.c
@@ -758,21 +758,31 @@ static void mgl_window_on_receive_event(mgl_window *self, XEvent *xev, mgl_event
XChangeProperty(context->connection, selection_event.requestor, selection_event.property, XA_ATOM, 32, PropModeReplace, (unsigned char*)targets, num_targets);
selection_event.target = x11_context->targets_atom;
XSendEvent(context->connection, selection_event.requestor, True, NoEventMask, (XEvent*)&selection_event);
+ XFlush(context->connection);
+ event->type = MGL_EVENT_UNKNOWN;
+ return;
} else if(selection_event.target == XA_STRING || (!x11_context->utf8_string_atom && selection_event.target == x11_context->text_atom)) {
/* A client requested ascii clipboard */
XChangeProperty(context->connection, selection_event.requestor, selection_event.property, XA_STRING, 8, PropModeReplace, self->clipboard_string, self->clipboard_size);
selection_event.target = XA_STRING;
XSendEvent(context->connection, selection_event.requestor, True, NoEventMask, (XEvent*)&selection_event);
+ XFlush(context->connection);
+ event->type = MGL_EVENT_UNKNOWN;
+ return;
} else if(x11_context->utf8_string_atom && (selection_event.target == x11_context->utf8_string_atom || selection_event.target == x11_context->text_atom)) {
/* A client requested utf8 clipboard */
XChangeProperty(context->connection, selection_event.requestor, selection_event.property, x11_context->utf8_string_atom, 8, PropModeReplace, self->clipboard_string, self->clipboard_size);
selection_event.target = x11_context->utf8_string_atom;
XSendEvent(context->connection, selection_event.requestor, True, NoEventMask, (XEvent*)&selection_event);
+ XFlush(context->connection);
+ event->type = MGL_EVENT_UNKNOWN;
+ return;
}
}
selection_event.property = None;
XSendEvent(context->connection, selection_event.requestor, True, NoEventMask, (XEvent*)&selection_event);
+ XFlush(context->connection);
event->type = MGL_EVENT_UNKNOWN;
return;
}
@@ -784,6 +794,7 @@ static void mgl_window_on_receive_event(mgl_window *self, XEvent *xev, mgl_event
} else if(xev->xclient.format == 32 && (unsigned long)xev->xclient.data.l[0] == context->net_wm_ping_atom) {
xev->xclient.window = DefaultRootWindow(context->connection);
XSendEvent(context->connection, DefaultRootWindow(context->connection), False, SubstructureNotifyMask | SubstructureRedirectMask, xev);
+ XFlush(context->connection);
}
event->type = MGL_EVENT_UNKNOWN;
return;
@@ -989,6 +1000,7 @@ void mgl_window_set_clipboard(mgl_window *self, const char *str, size_t size) {
}
XSetSelectionOwner(context->connection, x11_context->clipboard_atom, self->window, CurrentTime);
+ XFlush(context->connection);
/* Check if setting the selection owner was successful */
if(XGetSelectionOwner(context->connection, x11_context->clipboard_atom) != self->window) {