To:
[email protected]
Subject: patch 5.4n.2 (was: * register - problem?)
Cc: VIM Developers List <
[email protected]>
In-Reply-To: <99070510225002.24245@tequila>
Fcc: outbox
From: Bram Moolenaar <
[email protected]>
------------
Thomas Geulig wrote:
[about the @* register (current selection) not working from a popup menu]
> some more information:
>
> I've upgraded to gtk 1.2.3, but the problem still exists.
>
> selecting a name inside gvim -> mapping and menu works
> selecting a name outside gvim (e.g. terminal window) -> only the keyboard
> mapping works
Suddenly I can now reproduce it. Running the debugger shows that Vim does
exactly the same in both situations: It tries to get the selection from the
other application. Just after using the PopUp menu this apparently fails.
Hmm, perhaps the button-up event from the mouse gets in the way. The
gtk_main() call would then return before the selection was received. This
depends on timing, which would explain that it sometimes works and sometimes
not.
I have made a patch for this specific problem. I suspect there might be more
actions in the GTK code that don't work, because they use gtk_main() to wait
for a specific event, but gtk_main() returns because of some other event. If
you notice one, let me know!
Patch 5.4n.2
Problem: GTK: When using the selection from a popup menu (@* in an
expression), would get an empty result. The button-up event
probably interrupts the waiting for the selection to arrive.
Solution: Added the did_receive_selection flag to keep waiting until the
selection has really been handled.
Files: src/gui_gtk_x11.c
*** ../vim-5.4n/src/gui_gtk_x11.c Sun Jul 4 20:35:52 1999
--- src/gui_gtk_x11.c Mon Jul 5 11:35:40 1999
***************
*** 418,423 ****
--- 418,425 ----
return TRUE;
}
+ static int did_receive_selection = FALSE;
+
/*ARGSUSED*/
static void
selection_received_event(GtkWidget * widget, GtkSelectionData * data)
***************
*** 426,431 ****
--- 428,435 ----
long_u len;
char_u *p;
+ did_receive_selection = TRUE;
+
if ((!data->data) || (data->length <= 0)) {
/* clip_free_selection(); ??? */
if (gtk_main_level() > 0)
***************
*** 2123,2135 ****
(void)gtk_selection_convert(gui.drawarea,
GDK_SELECTION_PRIMARY, clipboard.atom,
GDK_CURRENT_TIME);
! gtk_main(); /* wait until signal arrives */
/* Ok now try to get it out of the usual string selection. */
(void)gtk_selection_convert(gui.drawarea, GDK_SELECTION_PRIMARY,
GDK_TARGET_STRING,
GDK_CURRENT_TIME);
! gtk_main(); /* wait until signal arrives */
}
void
--- 2127,2143 ----
(void)gtk_selection_convert(gui.drawarea,
GDK_SELECTION_PRIMARY, clipboard.atom,
GDK_CURRENT_TIME);
! did_receive_selection = FALSE;
! while (!did_receive_selection)
! gtk_main(); /* wait until signal arrives */
/* Ok now try to get it out of the usual string selection. */
(void)gtk_selection_convert(gui.drawarea, GDK_SELECTION_PRIMARY,
GDK_TARGET_STRING,
GDK_CURRENT_TIME);
! did_receive_selection = FALSE;
! while (!did_receive_selection)
! gtk_main(); /* wait until signal arrives */
}
void
--
TALL KNIGHT: Firstly. You must get us another shrubbery!
OTHER KNIGHTS: More shrubberies! More shrubberies for the ex-Knights of Ni!
ARTHUR: Not another shrubbery -
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
--/-/---- Bram Moolenaar ----
[email protected] ----
[email protected] ---\-\--
\ \ www.vim.org/iccf www.moolenaar.net www.vim.org / /