New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[linux] support for simple xselection pasting #9631
Conversation
X11 does already poll XNextEvent. Makes no sense to do the same at a different location. I also has a main window, no need to create an additional one. |
Hello, I just want paste clipboard into kodi , it is very useful and this patch works , I will try make a better patch but if you suggest on coding, by examples, it is very welcome . |
check out https://github.com/xbmc/xbmc/blob/master/xbmc/windowing/WinEventsX11.cpp#L322 |
e141cbf
to
f7f9327
Compare
Patch updated , works for me , I don't know what should be used in window var , if m_glWindow or m_mainWindow , or if I should create a new one in line fa1b9c7#diff-f78301169cdbe1580bc520b8848e536cR1082 and line fa1b9c7#diff-f78301169cdbe1580bc520b8848e536cR1096 |
hmm, you seem to have ignored my comments: no additional window, no additional XNextEvent |
Hi, I done another patch sergiomb2@cb0a44a
My option was add XConvertSelection to CWinSystemX11::NotifyAppFocusChange when it is gaining focus, in my tests seems that works well . git master updated, ready to be merged ! |
else | ||
{ | ||
Atom utf8_string = XInternAtom(m_dpy, "UTF8_STRING", False); | ||
XConvertSelection(m_dpy, XA_PRIMARY, utf8_string, None, m_glWindow, CurrentTime); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
check out what SDL does: http://www.libsdl.org/tmp/SDL/src/video/x11/SDL_x11clipboard.c |
I will try change and test XA_PRIMARY to XA_CLIPBOARD. |
Hello I found one method (EnableTextInput) where I could put the XConvertSelection , I also could read just CLIPBOARD instead XA_PRIMARY, so now for me my patch looks good to be applied, all code seems in right place. |
This code may work, somehow, but it is rather hacky. We had too many of those "it works somehow hacks" in the past that made architecture decay. There are many locations in this PR that need rework. |
It looks good to me have XConvertSelection in EnableTextInput ... , today I understand better SDL code (after yesterday read much documentation) , SDL code do all in same function , after XConvertSelection, do something that I don't know how to do, which is :
SDL code waits for selection ... how we may do this ( I will google it) . About "it works somehow hacks" , I understand you very well , but know I don't think my patch is a hack , when X enables a text input we call XConvertSelection , looked good to me . |
g_Windowing.EnableTextInput is called by Kod's edit control when it gets focus. Nothing related to X. |
exactly the same way. Call MessagePump for a given time. |
Done ! , now I think it it by the book. Thanks. |
why don't you call MessagePump as I suggested? |
|
// clipboard content requesting is inherently slow on x11, it | ||
// often takes 50ms or more so... | ||
int count = 20; // will wait at most for 200 ms | ||
while (--count >= 0) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
int count = 20; // will wait at most for 200 ms | ||
while (--count >= 0) | ||
{ | ||
if (CWinEventsX11Imp::MessagePump()) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
https://www.jwz.org/doc/x-cut-and-paste.html I don't know how translate : I can add checks to atom like this:
owner = X11_XGetSelectionOwner(display, XA_CLIPBOARD);
Also I'm not seeing what we need , MessagePump returns true or false , if we process one event ... |
you don't want to wait for any event but for a specific one. hence you need to modify MessagePump to signal this specific event. while waiting for this event MessagePump will deliver other events to application |
Keep it simple, we just need call MessagePump once , when MessagePump returns all events are processed, I think. |
XConvertSelection(m_dpy, clipboard, utf8_string, None, m_glWindow, CurrentTime); | ||
CWinEventsX11Imp::MessagePump(); | ||
|
||
for(unsigned long offset = 0;;) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
keep is simple is good, but first it needs to be correct. |
After test it , I saw that we need wait for one MessagePump positive. About X11_XGetSelectionOwner and when owner == window , for what I understood this is just applicable on SDL or other cases where windows have selection saved as one property , which is not applicable to X11. |
You don't get around modifying MessagePump. It does not return true an any event and you current code just times out every time. |
20e5730
to
9fb91d4
Compare
Now patch verify:
Adding catch SelectionNotify and return true like this :
Without catch SelectionNotify, MessagePump was called 10 or 11 times , with SelectionNotify catch, MessagePump is called only 2 times ! Best regards. |
02 May 2016 - Don't create an additional window and also don't use XNextEvent, we already have XNextEvent a different location. Wait for event SelectionNotify at most for 200 ms and use function MessagePump, as suggested, to check it. First version: Matthias Kortstiege <mkortstiege@kodi.tv> 4 Jul 2015 https://github.com/mkortstiege/xbmc/tree/linux-paste mkortstiege@62e56b7
Getting closer :) but I see no need for guessing ind praying that things go right now and in future. We can set an event/flag on SelectionNotify and wait on that event in WinSystemX11 |
From: Matthias Kortstiege mkortstiege@kodi.tv
Date: Sat, 4 Jul 2015 16:51:06 +0200
Subject: [PATCH] [linux] support for simple xselection pasting
in http://forum.kodi.tv/showthread.php?tid=231227 says to patch kodi with
mkortstiege@62e56b7
I test it works and no regressions noted . Kodi don't have copy and paste working on Linux !