all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Chong Yidong <cyd@stupidchicken.com>
To: "Jan Djärv" <jan.h.d@swipnet.se>
Cc: 8869@debbugs.gnu.org
Subject: bug#8869: Unjustified selection time-out
Date: Sun, 19 Jun 2011 15:59:26 -0400	[thread overview]
Message-ID: <yyx8vsxmw2p.fsf@fencepost.gnu.org> (raw)
In-Reply-To: <4DFDCEF0.5060509@swipnet.se> ("Jan Djärv"'s message of "Sun, 19 Jun 2011 12:26:56 +0200")

Jan Djärv <jan.h.d@swipnet.se> writes:

> 1) Emacs sends SAVE_TARGET and starts to wait for SelectionNotify.
> 2) The clipboard manager tries to get the CLIPBOARD selection with a
>    SelectionRequest.
> 3) Emacs receives this but does not reply to it, as it is only intereted in
>    SelectionNotify.
> 4) If an input event, such as mouse move, occurs, the loop is broken and all
>    queued X Events are handeled, including SelectionRequest.
> 5) The clipboard manager has gotten the clipboard from Emacs and only now
>    sends SelectionNotify.
>
> Thus, if there isn't any input in 4), the exit will time out.
> Emacs must handle SelectionRequest in 3) to work correctly.

Ah, thanks for this observation; now I can reproduce the problem, by
deleting the selection-owning frame using the mouse instead of a
keystroke.

The behavior of wait_reading_process_output is indeed problematic, but
perhaps it's better to work around it in x_get_foreign_selection,
instead of changing wait_reading_process_output itself.  The following
patch, for example, changes x_get_foreign_selection to loop calling
wait_reading_process_output with 1ms intervals.  That allows the
selection events be handled even if no keyboard input is supplied.
WDYT?


*** src/xselect.c       2011-06-06 19:43:39 +0000
--- src/xselect.c       2011-06-19 19:49:23 +0000
***************
*** 1207,1213 ****
    Atom type_atom = (CONSP (target_type)
             ? symbol_to_x_atom (dpyinfo, XCAR (target_type))
                   : symbol_to_x_atom (dpyinfo, target_type));
-   int secs, usecs;
  
    if (!FRAME_LIVE_P (f))
      return Qnil;
--- 1207,1212 ----
***************
*** 1243,1253 ****
    UNBLOCK_INPUT;
  
    /* This allows quits.  Also, don't wait forever.  */
-   secs = x_selection_timeout / 1000;
-   usecs = (x_selection_timeout % 1000) * 1000;
    TRACE1 ("  Start waiting %d secs for SelectionNotify", secs);
!   wait_reading_process_output (secs, usecs, 0, 0,
!                                             reading_selection_reply,
NULL, 0);
    TRACE1 ("  Got event = %d", !NILP (XCAR (reading_selection_reply)));
  
    if (NILP (XCAR (reading_selection_reply)))
--- 1242,1258 ----
    UNBLOCK_INPUT;
  
    /* This allows quits.  Also, don't wait forever.  */
    TRACE1 ("  Start waiting %d secs for SelectionNotify", secs);
!   {
!     int j, periods = max (1, x_selection_timeout);
!     for (j = 0; j < periods; j++)
!       {
!       wait_reading_process_output (0, 1000, 0, 0,
!
    reading_selection_reply, NULL, 0);
!   if (!NILP (XCAR (reading_selection_reply)))
!     break;
!       }
!   }
    TRACE1 ("  Got event = %d", !NILP (XCAR (reading_selection_reply)));
  
    if (NILP (XCAR (reading_selection_reply)))





  parent reply	other threads:[~2011-06-19 19:59 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-15 15:42 bug#8869: Unjustified selection time-out Stefan Monnier
2011-06-16  1:00 ` David De La Harpe Golden
2011-06-16  6:58   ` Jan D.
2011-06-16 13:44   ` Stefan Monnier
2011-06-16 15:36     ` David De La Harpe Golden
2011-06-17  2:56       ` Stefan Monnier
2011-06-17 18:11         ` David De La Harpe Golden
2011-06-18 22:03           ` Chong Yidong
2011-06-19 10:26             ` Jan Djärv
2011-06-19 11:14               ` Jan Djärv
2011-06-26  3:40                 ` Chong Yidong
2011-06-26  8:36                   ` Jan Djärv
2011-06-26 19:30                     ` Chong Yidong
2011-07-01  1:32                       ` Stefan Monnier
2011-07-01  7:05                         ` Jan Djärv
2011-07-04 14:55                           ` Stefan Monnier
2011-07-06 13:29                           ` Stefan Monnier
2011-07-08  2:07                             ` David De La Harpe Golden
2011-07-08  2:20                               ` Stefan Monnier
2011-07-08  2:40                                 ` David De La Harpe Golden
2011-07-08 12:59                                   ` Stefan Monnier
2012-02-24  2:47                             ` Glenn Morris
2012-02-24  8:42                               ` Chong Yidong
2012-02-24 18:52                                 ` Glenn Morris
2012-02-24 23:52                                   ` Glenn Morris
2012-02-25  3:00                                   ` Chong Yidong
2011-06-19 19:59               ` Chong Yidong [this message]
2011-06-19 20:45                 ` Jan Djärv
2011-06-19 21:13                   ` Chong Yidong
2011-06-20  6:27                     ` Jan Djärv
2011-06-20 14:57                       ` Chong Yidong
2011-06-20 15:24                         ` Jan Djärv

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=yyx8vsxmw2p.fsf@fencepost.gnu.org \
    --to=cyd@stupidchicken.com \
    --cc=8869@debbugs.gnu.org \
    --cc=jan.h.d@swipnet.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.