Skip to content

Commit

Permalink
[linux] support for simple xselection pasting
Browse files Browse the repository at this point in the history
29 Apr 2016, Sérgio Basto - Do not create a display when already exist one.

First version: Matthias Kortstiege <mkortstiege@kodi.tv> 4 Jul 2015
  • Loading branch information
sergiomb2 committed Apr 29, 2016
1 parent 4982009 commit cb0a44a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
39 changes: 39 additions & 0 deletions xbmc/windowing/X11/WinSystemX11.cpp
Expand Up @@ -46,6 +46,8 @@
#include "../WinEventsX11.h"
#include "input/InputManager.h"

#include <limits.h>

#define EGL_NO_CONFIG (EGLConfig)0

CWinSystemX11::CWinSystemX11() : CWinSystemBase()
Expand Down Expand Up @@ -834,6 +836,11 @@ void CWinSystemX11::NotifyAppFocusChange(bool bGaining)
}
if (!bGaining)
m_bIgnoreNextFocusMessage = false;
else
{
Atom utf8_string = XInternAtom(m_dpy, "UTF8_STRING", False);
XConvertSelection(m_dpy, XA_PRIMARY, utf8_string, None, m_glWindow, CurrentTime);
}
}

bool CWinSystemX11::Minimize()
Expand Down Expand Up @@ -1479,4 +1486,36 @@ void CWinSystemX11::UpdateCrtc()
g_graphicsContext.SetFPS(fps);
}

std::string CWinSystemX11::GetClipboardText(void)
{
if (!m_dpy)
return "";

std::string result;
for(unsigned long offset = 0;;)
{
Atom real_type = None;
unsigned char *data;
unsigned long items_read, items_left = 0;
int real_format = 0;

Atom utf8_string = XInternAtom(m_dpy, "UTF8_STRING", False);
XGetWindowProperty(m_dpy, m_glWindow, utf8_string, offset, INT_MAX, False,
AnyPropertyType, &real_type, &real_format, &items_read, &items_left, &data);

if(items_read)
{
result.append(reinterpret_cast<const char*>(data), items_read);
offset += items_read;
}

XDeleteProperty(m_dpy, m_glWindow, utf8_string);

if(!items_left)
break;
}

return result;
}

#endif
2 changes: 2 additions & 0 deletions xbmc/windowing/X11/WinSystemX11.h
Expand Up @@ -89,6 +89,8 @@ class CWinSystemX11 : public CWinSystemBase
void RecreateWindow();
int GetCrtc() { return m_crtc; }

std::string GetClipboardText(void);

protected:
bool RefreshGlxContext(bool force);
void OnLostDevice();
Expand Down

0 comments on commit cb0a44a

Please sign in to comment.