[fixed] Fix pasting bug on X11 + linux

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
est31
Posts: 14
Joined: Wed Sep 02, 2015 7:17 am

[fixed] Fix pasting bug on X11 + linux

Post by est31 »

Before, you couldn't paste from external applications to Irrlicht based ones on Linux. This patch fixes this bug.
See also the report http://sourceforge.net/p/irrlicht/bugs/435/ and the downstream bug report https://github.com/minetest/minetest/issues/373 .

The fix is very simple, it corrects wrongly set parameters.

Code: Select all

 
diff --git a/source/Irrlicht/CIrrDeviceLinux.cpp b/source/Irrlicht/CIrrDeviceLinux.cpp
index 4c3dbeb..56418ca 100644
--- a/source/Irrlicht/CIrrDeviceLinux.cpp
+++ b/source/Irrlicht/CIrrDeviceLinux.cpp
@@ -2098,7 +2098,7 @@ const c8* CIrrDeviceLinux::getTextFromClipboard() const
    Clipboard = "";
    if (ownerWindow != None )
    {
-       XConvertSelection (XDisplay, X_ATOM_CLIPBOARD, XA_STRING, None, ownerWindow, CurrentTime);
+       XConvertSelection (XDisplay, X_ATOM_CLIPBOARD, XA_STRING, XA_PRIMARY, ownerWindow, CurrentTime);
        XFlush (XDisplay);
 
        // check for data
@@ -2107,7 +2107,7 @@ const c8* CIrrDeviceLinux::getTextFromClipboard() const
        unsigned long numItems, bytesLeft, dummy;
        unsigned char *data;
        XGetWindowProperty (XDisplay, ownerWindow,
-               XA_STRING, // property name
+               XA_PRIMARY, // property name
                0, // offset
                0, // length (we only check for data, so 0)
                0, // Delete 0==false
@@ -2120,7 +2120,7 @@ const c8* CIrrDeviceLinux::getTextFromClipboard() const
        if ( bytesLeft > 0 )
        {
            // there is some data to get
-           int result = XGetWindowProperty (XDisplay, ownerWindow, XA_STRING, 0,
+           int result = XGetWindowProperty (XDisplay, ownerWindow, XA_PRIMARY, 0,
                                        bytesLeft, 0, AnyPropertyType, &type, &format,
                                        &numItems, &dummy, &data);
            if (result == Success)
 
 
est31
Posts: 14
Joined: Wed Sep 02, 2015 7:17 am

Re: [patch] Fix pasting bug on X11 + linux

Post by est31 »

It would be great if the patch could be applied both to the 1.8 and 1.9 branches, the bug affects both.
est31
Posts: 14
Joined: Wed Sep 02, 2015 7:17 am

Re: [patch] Fix pasting bug on X11 + linux

Post by est31 »

Note that the patch might not apply cleanly. But its only a three-liner, so very easy to apply manually.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: [patch] Fix pasting bug on X11 + linux

Post by CuteAlien »

Thanks a lot for this patch. I've applied it to the 1.8 branch and trunk.
Only problem left now is that you probably need to get this fix into official repositories. And I suppose that means we need a new Irrlicht release for this :-/ (building releases is a pita...)
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
est31
Posts: 14
Joined: Wed Sep 02, 2015 7:17 am

Re: [fixed] Fix pasting bug on X11 + linux

Post by est31 »

Thanks for merging.
About making a release: it would surely get the fix to users faster, considering that Ubuntu 16.04 xenial (which is an LTS, so will exist for 5 years) has its feature freeze on Feb 18 2016, and irrlicht will take some time to get from released upstream to first debian packages, then to ubuntu packages, so I guess in order to be sure to get the fix into xenial one would have to make a release this year, or in the first half of january.
But yeah, I know from my own experience that releasing isn't precisely fun :)
If there is a release, it would be great, if there is none, its no problem either. After all, clipboard problems are not a very severe bug (unlike the frustrum spinning bug one can experience on xwayland).
Post Reply