home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 7.3 / 7.3.011 < prev    next >
Encoding:
Internet Message Format  |  2012-11-20  |  8.6 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 7.3.011
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 7.3.011
  11. Problem:    X11 clipboard doesn't work in Athena/Motif GUI.  First selection
  12.         after a shell command doesn't work.
  13. Solution:   When using the GUI use XtLastTimestampProcessed() instead of
  14.         changing a property.  (partly by Toni Ronkko)
  15.         When executing a shell command disown the selection.
  16. Files:        src/ui.c, src/os_unix.c
  17.  
  18.  
  19. *** ../vim-7.3.010/src/ui.c    2010-08-15 21:57:31.000000000 +0200
  20. --- src/ui.c    2010-09-21 22:08:22.000000000 +0200
  21. ***************
  22. *** 469,475 ****
  23.        */
  24.   #ifdef FEAT_X11
  25.       /* Always own the selection, we might have lost it without being
  26. !      * notified. */
  27.       if (cbd->available)
  28.       {
  29.       int was_owned = cbd->owned;
  30. --- 469,475 ----
  31.        */
  32.   #ifdef FEAT_X11
  33.       /* Always own the selection, we might have lost it without being
  34. !      * notified, e.g. during a ":sh" command. */
  35.       if (cbd->available)
  36.       {
  37.       int was_owned = cbd->owned;
  38. ***************
  39. *** 1944,1953 ****
  40.    */
  41.   
  42.   static Boolean    clip_x11_convert_selection_cb __ARGS((Widget, Atom *, Atom *, Atom *, XtPointer *, long_u *, int *));
  43.   static void  clip_x11_lose_ownership_cb __ARGS((Widget, Atom *));
  44.   static void clip_x11_timestamp_cb __ARGS((Widget w, XtPointer n, XEvent *event, Boolean *cont));
  45.   
  46.   /*
  47.    * Property callback to get a timestamp for XtOwnSelection.
  48. --- 1944,1952 ----
  49.    */
  50.   
  51.   static Boolean    clip_x11_convert_selection_cb __ARGS((Widget, Atom *, Atom *, Atom *, XtPointer *, long_u *, int *));
  52.   static void  clip_x11_lose_ownership_cb __ARGS((Widget, Atom *));
  53.   static void clip_x11_timestamp_cb __ARGS((Widget w, XtPointer n, XEvent *event, Boolean *cont));
  54. + static void  clip_x11_request_selection_cb __ARGS((Widget, XtPointer, Atom *, Atom *, XtPointer, long_u *, int *));
  55.   
  56.   /*
  57.    * Property callback to get a timestamp for XtOwnSelection.
  58. ***************
  59. *** 1985,1992 ****
  60.       return;
  61.   
  62.       /* Get the selection, using the event timestamp. */
  63. !     XtOwnSelection(w, xproperty->atom, xproperty->time,
  64. !         clip_x11_convert_selection_cb, clip_x11_lose_ownership_cb, NULL);
  65.   }
  66.   
  67.       void
  68. --- 1984,2000 ----
  69.       return;
  70.   
  71.       /* Get the selection, using the event timestamp. */
  72. !     if (XtOwnSelection(w, xproperty->atom, xproperty->time,
  73. !         clip_x11_convert_selection_cb, clip_x11_lose_ownership_cb,
  74. !         NULL) == OK)
  75. !     {
  76. !     /* Set the "owned" flag now, there may have been a call to
  77. !      * lose_ownership_cb in between. */
  78. !     if (xproperty->atom == clip_plus.sel_atom)
  79. !         clip_plus.owned = TRUE;
  80. !     else
  81. !         clip_star.owned = TRUE;
  82. !     }
  83.   }
  84.   
  85.       void
  86. ***************
  87. *** 1997,2004 ****
  88.           /*(XtEventHandler)*/clip_x11_timestamp_cb, (XtPointer)NULL);
  89.   }
  90.   
  91. - static void  clip_x11_request_selection_cb __ARGS((Widget, XtPointer, Atom *, Atom *, XtPointer, long_u *, int *));
  92.       static void
  93.   clip_x11_request_selection_cb(w, success, sel_atom, type, value, length,
  94.                     format)
  95. --- 2005,2010 ----
  96. ***************
  97. *** 2336,2342 ****
  98.   
  99.       void
  100.   clip_x11_lose_selection(myShell, cbd)
  101. !     Widget    myShell;
  102.       VimClipboard    *cbd;
  103.   {
  104.       XtDisownSelection(myShell, cbd->sel_atom, CurrentTime);
  105. --- 2342,2348 ----
  106.   
  107.       void
  108.   clip_x11_lose_selection(myShell, cbd)
  109. !     Widget        myShell;
  110.       VimClipboard    *cbd;
  111.   {
  112.       XtDisownSelection(myShell, cbd->sel_atom, CurrentTime);
  113. ***************
  114. *** 2344,2357 ****
  115.   
  116.       int
  117.   clip_x11_own_selection(myShell, cbd)
  118. !     Widget    myShell;
  119.       VimClipboard    *cbd;
  120.   {
  121. !     /* Get the time by a zero-length append, clip_x11_timestamp_cb will be
  122. !      * called with the current timestamp.  */
  123. !     if (!XChangeProperty(XtDisplay(myShell), XtWindow(myShell), cbd->sel_atom,
  124. !         timestamp_atom, 32, PropModeAppend, NULL, 0))
  125.       return FAIL;
  126.       /* Flush is required in a terminal as nothing else is doing it. */
  127.       XFlush(XtDisplay(myShell));
  128.       return OK;
  129. --- 2350,2378 ----
  130.   
  131.       int
  132.   clip_x11_own_selection(myShell, cbd)
  133. !     Widget        myShell;
  134.       VimClipboard    *cbd;
  135.   {
  136. !     /* When using the GUI we have proper timestamps, use the one of the last
  137. !      * event.  When in the console we don't get events (the terminal gets
  138. !      * them), Get the time by a zero-length append, clip_x11_timestamp_cb will
  139. !      * be called with the current timestamp.  */
  140. ! #ifdef FEAT_GUI
  141. !     if (gui.in_use)
  142. !     {
  143. !     if (XtOwnSelection(myShell, cbd->sel_atom,
  144. !            XtLastTimestampProcessed(XtDisplay(myShell)),
  145. !            clip_x11_convert_selection_cb, clip_x11_lose_ownership_cb,
  146. !            NULL) == False)
  147.       return FAIL;
  148. +     }
  149. +     else
  150. + #endif
  151. +     {
  152. +     if (!XChangeProperty(XtDisplay(myShell), XtWindow(myShell),
  153. +           cbd->sel_atom, timestamp_atom, 32, PropModeAppend, NULL, 0))
  154. +     return FAIL;
  155. +     }
  156.       /* Flush is required in a terminal as nothing else is doing it. */
  157.       XFlush(XtDisplay(myShell));
  158.       return OK;
  159. *** ../vim-7.3.010/src/os_unix.c    2010-08-15 21:57:30.000000000 +0200
  160. --- src/os_unix.c    2010-09-21 21:59:25.000000000 +0200
  161. ***************
  162. *** 1123,1128 ****
  163. --- 1123,1152 ----
  164.   }
  165.   #endif
  166.   
  167. + # if defined(FEAT_CLIPBOARD) && defined(FEAT_X11)
  168. + static void loose_clipboard __ARGS((void));
  169. + /*
  170. +  * Called when Vim is going to sleep or execute a shell command.
  171. +  * We can't respond to requests for the X selections.  Lose them, otherwise
  172. +  * other applications will hang.  But first copy the text to cut buffer 0.
  173. +  */
  174. +     static void
  175. + loose_clipboard()
  176. + {
  177. +     if (clip_star.owned || clip_plus.owned)
  178. +     {
  179. +     x11_export_final_selection();
  180. +     if (clip_star.owned)
  181. +         clip_lose_selection(&clip_star);
  182. +     if (clip_plus.owned)
  183. +         clip_lose_selection(&clip_plus);
  184. +     if (x11_display != NULL)
  185. +         XFlush(x11_display);
  186. +     }
  187. + }
  188. + #endif
  189.   /*
  190.    * If the machine has job control, use it to suspend the program,
  191.    * otherwise fake it by starting a new shell.
  192. ***************
  193. *** 1137,1155 ****
  194.       out_flush();        /* needed to disable mouse on some systems */
  195.   
  196.   # if defined(FEAT_CLIPBOARD) && defined(FEAT_X11)
  197. !     /* Since we are going to sleep, we can't respond to requests for the X
  198. !      * selections.  Lose them, otherwise other applications will hang.  But
  199. !      * first copy the text to cut buffer 0. */
  200. !     if (clip_star.owned || clip_plus.owned)
  201. !     {
  202. !     x11_export_final_selection();
  203. !     if (clip_star.owned)
  204. !         clip_lose_selection(&clip_star);
  205. !     if (clip_plus.owned)
  206. !         clip_lose_selection(&clip_plus);
  207. !     if (x11_display != NULL)
  208. !         XFlush(x11_display);
  209. !     }
  210.   # endif
  211.   
  212.   # if defined(_REENTRANT) && defined(SIGCONT)
  213. --- 1161,1167 ----
  214.       out_flush();        /* needed to disable mouse on some systems */
  215.   
  216.   # if defined(FEAT_CLIPBOARD) && defined(FEAT_X11)
  217. !     loose_clipboard();
  218.   # endif
  219.   
  220.   # if defined(_REENTRANT) && defined(SIGCONT)
  221. ***************
  222. *** 3706,3711 ****
  223. --- 3718,3727 ----
  224.       if (options & SHELL_COOKED)
  225.       settmode(TMODE_COOK);        /* set to normal mode */
  226.   
  227. + # if defined(FEAT_CLIPBOARD) && defined(FEAT_X11)
  228. +     loose_clipboard();
  229. + # endif
  230.   # ifdef __EMX__
  231.       if (cmd == NULL)
  232.       x = system("");    /* this starts an interactive shell in emx */
  233. ***************
  234. *** 3814,3826 ****
  235.   # endif
  236.       int        did_settmode = FALSE;    /* settmode(TMODE_RAW) called */
  237.   
  238.       out_flush();
  239.       if (options & SHELL_COOKED)
  240.       settmode(TMODE_COOK);        /* set to normal mode */
  241.   
  242. !     newcmd = vim_strsave(p_sh);
  243. !     if (newcmd == NULL)        /* out of memory */
  244. !     goto error;
  245.   
  246.       /*
  247.        * Do this loop twice:
  248. --- 3830,3846 ----
  249.   # endif
  250.       int        did_settmode = FALSE;    /* settmode(TMODE_RAW) called */
  251.   
  252. +     newcmd = vim_strsave(p_sh);
  253. +     if (newcmd == NULL)        /* out of memory */
  254. +     goto error;
  255.       out_flush();
  256.       if (options & SHELL_COOKED)
  257.       settmode(TMODE_COOK);        /* set to normal mode */
  258.   
  259. ! # if defined(FEAT_CLIPBOARD) && defined(FEAT_X11)
  260. !     loose_clipboard();
  261. ! # endif
  262.   
  263.       /*
  264.        * Do this loop twice:
  265. *** ../vim-7.3.010/src/version.c    2010-09-21 17:34:26.000000000 +0200
  266. --- src/version.c    2010-09-21 20:45:02.000000000 +0200
  267. ***************
  268. *** 716,717 ****
  269. --- 716,719 ----
  270.   {   /* Add new patch number below this line */
  271. + /**/
  272. +     11,
  273.   /**/
  274.  
  275. -- 
  276. hundred-and-one symptoms of being an internet addict:
  277. 184. You no longer ask prospective dates what their sign is, instead
  278.      your line is "Hi, what's your URL?"
  279.  
  280.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  281. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  282. \\\        download, build and distribute -- http://www.A-A-P.org        ///
  283.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  284.