mailing-list for TeXmacs Users

Text archives Help


[TeXmacs] Patch: Cut and paste in KDE 4


Chronological Thread 
  • From: Norbert Nemec <address@hidden>
  • To: address@hidden
  • Subject: [TeXmacs] Patch: Cut and paste in KDE 4
  • Date: Thu, 22 Jan 2009 00:47:06 +0000

Hi everybody,

two hours of investigation into the issue of X11 copy-and-paste led me to the solution fo the immediate bug: TeXmacs did not handle the conversion of the selection correctly. The attached patch should handle this problem.

The more fundamental problem (primary selection vs. clipboard) is yet to be solved. For this, the TeXmacs-internal philosophy of selected vs. copied text first has to be resolved. In this issue, TeXmacs is caught in a strange mix of Emacs vs. Windows philosophy that needs to be sorted out properly.

Not tonight, though...

Greetings,
Norbert




Norbert Nemec wrote:
Hi David,

thanks for looking into it! Unfortunately your patch does not work, though :-(

The immediate problem, that would probably fairly easy to solve is that the conversion to text does not work (p.e. xclipboard complains when I have it running in parallel.

The more fundamental problem is that the distinction between the "primary" selection and the "clipboard" selection is not clear.

I think, this needs some serious sorting out. A few-line bugfix might solve the immediate problem, but I think TeXmacs never really handled cut-and-paste conforming to any standard, so it somehow interacts slightly different with every program...

I'll look into it a bit deeper, but I have no idea whether I get anywhere before I run out of time...

Greetings,
Norbert




David Allouche wrote:
On Wed, Jan 21, 2009 at 20:02, Norbert Nemec <address@hidden> wrote:
Cut and paste certainly is confusing. I spent a few minutes sorting through
the current state of affairs, but I didn't get far.

For anyone who wants to look into it, a good starting point seems to be:

http://www.freedesktop.org/wiki/Specifications/ClipboardsWiki

I think this is the behavior TeXmacs should aim at as well. Does the current
code already try to implement this standard? In that case, it seems to be
buggy in some details, but it is hard to sort through the strange behavior
in various situations, interacting with various other clients...

Here is a tentative patch.

I could not test it because any attempt to run a from-source build of
texmacs gives me the "Fatal error: Tex seems not to be installed
properly in 'load_tex'". Of course, I have a texmacs package
installed, so I have all the runtime dependencies. Running Ubuntu
Intrepid.

At least, it compiles.


commit 95b67144572986655f73c05b57dcb1f932d033b7
Author: Norbert Nemec <address@hidden>
Date:   Thu Jan 22 00:37:59 2009 +0000

    Correct conversion handling of X selecion.

diff --git a/src/src/Plugins/X11/x_loop.cpp b/src/src/Plugins/X11/x_loop.cpp
index 440dcfd..17919e3 100644
--- a/src/src/Plugins/X11/x_loop.cpp
+++ b/src/src/Plugins/X11/x_loop.cpp
@@ -275,26 +275,33 @@ x_gui_rep::process_event (x_window win, XEvent* ev) {
     }
   case SelectionRequest:
     {
-      bool flag=true;
       XSelectionRequestEvent& req= ev->xselectionrequest;
-      if (selection==NULL) flag=false;
-      if ((req.target!=AnyPropertyType) && (req.target!=XA_STRING)) flag=false;
-      if (flag)
-	XChangeProperty (dpy, req.requestor, req.property, XA_STRING,
-			 8, PropModeReplace,
-			 (unsigned char*) selection,
-			 strlen (selection));
       XSelectionEvent sel;
       sel.type      = SelectionNotify;
-      sel.serial    = req.serial;
-      sel.send_event= true;
-      sel.display   = dpy;
       sel.requestor = req.requestor;
       sel.selection = req.selection;
       sel.target    = req.target;
-      sel.property  = flag?req.property:None;
       sel.time      = req.time;
-      XSendEvent (dpy, InputFocus, false, 0, (XEvent*) &sel);
+      Atom XA_TARGETS = XInternAtom(dpy, "TARGETS", False);
+      if (selection==NULL)
+        sel.property  = None;
+      else if (req.target==XA_TARGETS) {
+        Atom targets[2];
+        targets[0] = XA_TARGETS;
+        targets[1] = XA_STRING;
+        XChangeProperty (dpy, req.requestor, req.property, XA_ATOM,
+                         32, PropModeReplace,
+                         (unsigned char*)&targets[0],2);
+        sel.property  = req.property;
+      } else if ((req.target==AnyPropertyType) || (req.target==XA_STRING)) {
+        XChangeProperty (dpy, req.requestor, req.property, XA_STRING,
+                         8, PropModeReplace,
+                         (unsigned char*) selection,
+                         strlen (selection));
+        sel.property  = req.property;
+      } else
+        sel.property  = None;
+      XSendEvent (dpy, sel.requestor, false, 0, (XEvent*) &sel);
       break;
     }
   case SelectionClear:



Archive powered by MHonArc 2.6.19.

Top of page