|
Karsten Hopp |
b99a76 |
To: vim-dev@vim.org
|
|
Karsten Hopp |
b99a76 |
Subject: patch 7.1.095
|
|
Karsten Hopp |
b99a76 |
Fcc: outbox
|
|
Karsten Hopp |
b99a76 |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
Karsten Hopp |
b99a76 |
Mime-Version: 1.0
|
|
Karsten Hopp |
b99a76 |
Content-Type: text/plain; charset=ISO-8859-1
|
|
Karsten Hopp |
b99a76 |
Content-Transfer-Encoding: 8bit
|
|
Karsten Hopp |
b99a76 |
------------
|
|
Karsten Hopp |
b99a76 |
|
|
Karsten Hopp |
b99a76 |
Patch 7.1.095
|
|
Karsten Hopp |
b99a76 |
Problem: The FocusLost and FocusGained autocommands are triggered
|
|
Karsten Hopp |
b99a76 |
asynchronously in the GUI. This may cause arbitrary problems.
|
|
Karsten Hopp |
b99a76 |
Solution: Put the focus event in the input buffer and handle it when ready
|
|
Karsten Hopp |
b99a76 |
for it.
|
|
Karsten Hopp |
b99a76 |
Files: src/eval.c, src/getchar.c, src/gui.c, src/gui_gtk_x11.c,
|
|
Karsten Hopp |
b99a76 |
src/keymap.h
|
|
Karsten Hopp |
b99a76 |
|
|
Karsten Hopp |
b99a76 |
|
|
Karsten Hopp |
b99a76 |
*** ../vim-7.1.094/src/eval.c Thu Aug 30 11:10:38 2007
|
|
Karsten Hopp |
b99a76 |
--- src/eval.c Mon Sep 3 22:48:09 2007
|
|
Karsten Hopp |
b99a76 |
***************
|
|
Karsten Hopp |
b99a76 |
*** 9912,9929 ****
|
|
Karsten Hopp |
b99a76 |
|
|
Karsten Hopp |
b99a76 |
++no_mapping;
|
|
Karsten Hopp |
b99a76 |
++allow_keys;
|
|
Karsten Hopp |
b99a76 |
! if (argvars[0].v_type == VAR_UNKNOWN)
|
|
Karsten Hopp |
b99a76 |
! /* getchar(): blocking wait. */
|
|
Karsten Hopp |
b99a76 |
! n = safe_vgetc();
|
|
Karsten Hopp |
b99a76 |
! else if (get_tv_number_chk(&argvars[0], &error) == 1)
|
|
Karsten Hopp |
b99a76 |
! /* getchar(1): only check if char avail */
|
|
Karsten Hopp |
b99a76 |
! n = vpeekc();
|
|
Karsten Hopp |
b99a76 |
! else if (error || vpeekc() == NUL)
|
|
Karsten Hopp |
b99a76 |
! /* illegal argument or getchar(0) and no char avail: return zero */
|
|
Karsten Hopp |
b99a76 |
! n = 0;
|
|
Karsten Hopp |
b99a76 |
! else
|
|
Karsten Hopp |
b99a76 |
! /* getchar(0) and char avail: return char */
|
|
Karsten Hopp |
b99a76 |
! n = safe_vgetc();
|
|
Karsten Hopp |
b99a76 |
--no_mapping;
|
|
Karsten Hopp |
b99a76 |
--allow_keys;
|
|
Karsten Hopp |
b99a76 |
|
|
Karsten Hopp |
b99a76 |
--- 9912,9935 ----
|
|
Karsten Hopp |
b99a76 |
|
|
Karsten Hopp |
b99a76 |
++no_mapping;
|
|
Karsten Hopp |
b99a76 |
++allow_keys;
|
|
Karsten Hopp |
b99a76 |
! for (;;)
|
|
Karsten Hopp |
b99a76 |
! {
|
|
Karsten Hopp |
b99a76 |
! if (argvars[0].v_type == VAR_UNKNOWN)
|
|
Karsten Hopp |
b99a76 |
! /* getchar(): blocking wait. */
|
|
Karsten Hopp |
b99a76 |
! n = safe_vgetc();
|
|
Karsten Hopp |
b99a76 |
! else if (get_tv_number_chk(&argvars[0], &error) == 1)
|
|
Karsten Hopp |
b99a76 |
! /* getchar(1): only check if char avail */
|
|
Karsten Hopp |
b99a76 |
! n = vpeekc();
|
|
Karsten Hopp |
b99a76 |
! else if (error || vpeekc() == NUL)
|
|
Karsten Hopp |
b99a76 |
! /* illegal argument or getchar(0) and no char avail: return zero */
|
|
Karsten Hopp |
b99a76 |
! n = 0;
|
|
Karsten Hopp |
b99a76 |
! else
|
|
Karsten Hopp |
b99a76 |
! /* getchar(0) and char avail: return char */
|
|
Karsten Hopp |
b99a76 |
! n = safe_vgetc();
|
|
Karsten Hopp |
b99a76 |
! if (n == K_IGNORE)
|
|
Karsten Hopp |
b99a76 |
! continue;
|
|
Karsten Hopp |
b99a76 |
! break;
|
|
Karsten Hopp |
b99a76 |
! }
|
|
Karsten Hopp |
b99a76 |
--no_mapping;
|
|
Karsten Hopp |
b99a76 |
--allow_keys;
|
|
Karsten Hopp |
b99a76 |
|
|
Karsten Hopp |
b99a76 |
*** ../vim-7.1.094/src/getchar.c Thu May 10 18:43:02 2007
|
|
Karsten Hopp |
b99a76 |
--- src/getchar.c Wed Aug 29 22:38:49 2007
|
|
Karsten Hopp |
b99a76 |
***************
|
|
Karsten Hopp |
b99a76 |
*** 1596,1603 ****
|
|
Karsten Hopp |
b99a76 |
continue;
|
|
Karsten Hopp |
b99a76 |
}
|
|
Karsten Hopp |
b99a76 |
#endif
|
|
Karsten Hopp |
b99a76 |
-
|
|
Karsten Hopp |
b99a76 |
#ifdef FEAT_GUI
|
|
Karsten Hopp |
b99a76 |
/* Translate K_CSI to CSI. The special key is only used to avoid
|
|
Karsten Hopp |
b99a76 |
* it being recognized as the start of a special key. */
|
|
Karsten Hopp |
b99a76 |
if (c == K_CSI)
|
|
Karsten Hopp |
b99a76 |
--- 1596,1610 ----
|
|
Karsten Hopp |
b99a76 |
continue;
|
|
Karsten Hopp |
b99a76 |
}
|
|
Karsten Hopp |
b99a76 |
#endif
|
|
Karsten Hopp |
b99a76 |
#ifdef FEAT_GUI
|
|
Karsten Hopp |
b99a76 |
+ /* The caller doesn't need to know that the focus event is delayed
|
|
Karsten Hopp |
b99a76 |
+ * until getting a character. */
|
|
Karsten Hopp |
b99a76 |
+ if (c == K_FOCUSGAINED || c == K_FOCUSLOST)
|
|
Karsten Hopp |
b99a76 |
+ {
|
|
Karsten Hopp |
b99a76 |
+ ui_focus_change(c == K_FOCUSGAINED);
|
|
Karsten Hopp |
b99a76 |
+ continue;
|
|
Karsten Hopp |
b99a76 |
+ }
|
|
Karsten Hopp |
b99a76 |
+
|
|
Karsten Hopp |
b99a76 |
/* Translate K_CSI to CSI. The special key is only used to avoid
|
|
Karsten Hopp |
b99a76 |
* it being recognized as the start of a special key. */
|
|
Karsten Hopp |
b99a76 |
if (c == K_CSI)
|
|
Karsten Hopp |
b99a76 |
*** ../vim-7.1.094/src/gui.c Thu Aug 30 13:51:52 2007
|
|
Karsten Hopp |
b99a76 |
--- src/gui.c Thu Aug 30 14:10:48 2007
|
|
Karsten Hopp |
b99a76 |
***************
|
|
Karsten Hopp |
b99a76 |
*** 4519,4525 ****
|
|
Karsten Hopp |
b99a76 |
xim_set_focus(in_focus);
|
|
Karsten Hopp |
b99a76 |
# endif
|
|
Karsten Hopp |
b99a76 |
|
|
Karsten Hopp |
b99a76 |
! ui_focus_change(in_focus);
|
|
Karsten Hopp |
b99a76 |
#endif
|
|
Karsten Hopp |
b99a76 |
}
|
|
Karsten Hopp |
b99a76 |
|
|
Karsten Hopp |
b99a76 |
--- 4519,4536 ----
|
|
Karsten Hopp |
b99a76 |
xim_set_focus(in_focus);
|
|
Karsten Hopp |
b99a76 |
# endif
|
|
Karsten Hopp |
b99a76 |
|
|
Karsten Hopp |
b99a76 |
! /* Put events in the input queue only when allowed.
|
|
Karsten Hopp |
b99a76 |
! * ui_focus_change() isn't called directly, because it invokes
|
|
Karsten Hopp |
b99a76 |
! * autocommands and that must not happen asynchronously. */
|
|
Karsten Hopp |
b99a76 |
! if (!hold_gui_events)
|
|
Karsten Hopp |
b99a76 |
! {
|
|
Karsten Hopp |
b99a76 |
! char_u bytes[3];
|
|
Karsten Hopp |
b99a76 |
!
|
|
Karsten Hopp |
b99a76 |
! bytes[0] = CSI;
|
|
Karsten Hopp |
b99a76 |
! bytes[1] = KS_EXTRA;
|
|
Karsten Hopp |
b99a76 |
! bytes[2] = in_focus ? (int)KE_FOCUSGAINED : (int)KE_FOCUSLOST;
|
|
Karsten Hopp |
b99a76 |
! add_to_input_buf(bytes, 3);
|
|
Karsten Hopp |
b99a76 |
! }
|
|
Karsten Hopp |
b99a76 |
#endif
|
|
Karsten Hopp |
b99a76 |
}
|
|
Karsten Hopp |
b99a76 |
|
|
Karsten Hopp |
b99a76 |
*** ../vim-7.1.094/src/gui_gtk_x11.c Tue Jun 19 18:07:52 2007
|
|
Karsten Hopp |
b99a76 |
--- src/gui_gtk_x11.c Wed Aug 29 22:43:34 2007
|
|
Karsten Hopp |
b99a76 |
***************
|
|
Karsten Hopp |
b99a76 |
*** 813,822 ****
|
|
Karsten Hopp |
b99a76 |
if (blink_state == BLINK_NONE)
|
|
Karsten Hopp |
b99a76 |
gui_mch_start_blink();
|
|
Karsten Hopp |
b99a76 |
|
|
Karsten Hopp |
b99a76 |
! /* make sure keyboard input goes to the draw area (if this is focus for a window) */
|
|
Karsten Hopp |
b99a76 |
if (widget != gui.drawarea)
|
|
Karsten Hopp |
b99a76 |
gtk_widget_grab_focus(gui.drawarea);
|
|
Karsten Hopp |
b99a76 |
|
|
Karsten Hopp |
b99a76 |
return TRUE;
|
|
Karsten Hopp |
b99a76 |
}
|
|
Karsten Hopp |
b99a76 |
|
|
Karsten Hopp |
b99a76 |
--- 813,827 ----
|
|
Karsten Hopp |
b99a76 |
if (blink_state == BLINK_NONE)
|
|
Karsten Hopp |
b99a76 |
gui_mch_start_blink();
|
|
Karsten Hopp |
b99a76 |
|
|
Karsten Hopp |
b99a76 |
! /* make sure keyboard input goes to the draw area (if this is focus for a
|
|
Karsten Hopp |
b99a76 |
! * window) */
|
|
Karsten Hopp |
b99a76 |
if (widget != gui.drawarea)
|
|
Karsten Hopp |
b99a76 |
gtk_widget_grab_focus(gui.drawarea);
|
|
Karsten Hopp |
b99a76 |
|
|
Karsten Hopp |
b99a76 |
+ /* make sure the input buffer is read */
|
|
Karsten Hopp |
b99a76 |
+ if (gtk_main_level() > 0)
|
|
Karsten Hopp |
b99a76 |
+ gtk_main_quit();
|
|
Karsten Hopp |
b99a76 |
+
|
|
Karsten Hopp |
b99a76 |
return TRUE;
|
|
Karsten Hopp |
b99a76 |
}
|
|
Karsten Hopp |
b99a76 |
|
|
Karsten Hopp |
b99a76 |
***************
|
|
Karsten Hopp |
b99a76 |
*** 828,833 ****
|
|
Karsten Hopp |
b99a76 |
--- 833,842 ----
|
|
Karsten Hopp |
b99a76 |
|
|
Karsten Hopp |
b99a76 |
if (blink_state != BLINK_NONE)
|
|
Karsten Hopp |
b99a76 |
gui_mch_stop_blink();
|
|
Karsten Hopp |
b99a76 |
+
|
|
Karsten Hopp |
b99a76 |
+ /* make sure the input buffer is read */
|
|
Karsten Hopp |
b99a76 |
+ if (gtk_main_level() > 0)
|
|
Karsten Hopp |
b99a76 |
+ gtk_main_quit();
|
|
Karsten Hopp |
b99a76 |
|
|
Karsten Hopp |
b99a76 |
return TRUE;
|
|
Karsten Hopp |
b99a76 |
}
|
|
Karsten Hopp |
b99a76 |
*** ../vim-7.1.094/src/keymap.h Sat May 5 19:34:22 2007
|
|
Karsten Hopp |
b99a76 |
--- src/keymap.h Wed Aug 29 22:17:51 2007
|
|
Karsten Hopp |
b99a76 |
***************
|
|
Karsten Hopp |
b99a76 |
*** 254,259 ****
|
|
Karsten Hopp |
b99a76 |
--- 254,261 ----
|
|
Karsten Hopp |
b99a76 |
, KE_DROP /* DnD data is available */
|
|
Karsten Hopp |
b99a76 |
, KE_CURSORHOLD /* CursorHold event */
|
|
Karsten Hopp |
b99a76 |
, KE_NOP /* doesn't do something */
|
|
Karsten Hopp |
b99a76 |
+ , KE_FOCUSGAINED /* focus gained */
|
|
Karsten Hopp |
b99a76 |
+ , KE_FOCUSLOST /* focus lost */
|
|
Karsten Hopp |
b99a76 |
};
|
|
Karsten Hopp |
b99a76 |
|
|
Karsten Hopp |
b99a76 |
/*
|
|
Karsten Hopp |
b99a76 |
***************
|
|
Karsten Hopp |
b99a76 |
*** 445,450 ****
|
|
Karsten Hopp |
b99a76 |
--- 447,454 ----
|
|
Karsten Hopp |
b99a76 |
#define K_CMDWIN TERMCAP2KEY(KS_EXTRA, KE_CMDWIN)
|
|
Karsten Hopp |
b99a76 |
|
|
Karsten Hopp |
b99a76 |
#define K_DROP TERMCAP2KEY(KS_EXTRA, KE_DROP)
|
|
Karsten Hopp |
b99a76 |
+ #define K_FOCUSGAINED TERMCAP2KEY(KS_EXTRA, KE_FOCUSGAINED)
|
|
Karsten Hopp |
b99a76 |
+ #define K_FOCUSLOST TERMCAP2KEY(KS_EXTRA, KE_FOCUSLOST)
|
|
Karsten Hopp |
b99a76 |
|
|
Karsten Hopp |
b99a76 |
#define K_CURSORHOLD TERMCAP2KEY(KS_EXTRA, KE_CURSORHOLD)
|
|
Karsten Hopp |
b99a76 |
|
|
Karsten Hopp |
b99a76 |
*** ../vim-7.1.094/src/version.c Thu Aug 30 19:36:52 2007
|
|
Karsten Hopp |
b99a76 |
--- src/version.c Wed Sep 5 21:42:41 2007
|
|
Karsten Hopp |
b99a76 |
***************
|
|
Karsten Hopp |
b99a76 |
*** 668,669 ****
|
|
Karsten Hopp |
b99a76 |
--- 668,671 ----
|
|
Karsten Hopp |
b99a76 |
{ /* Add new patch number below this line */
|
|
Karsten Hopp |
b99a76 |
+ /**/
|
|
Karsten Hopp |
b99a76 |
+ 95,
|
|
Karsten Hopp |
b99a76 |
/**/
|
|
Karsten Hopp |
b99a76 |
|
|
Karsten Hopp |
b99a76 |
--
|
|
Karsten Hopp |
b99a76 |
ARTHUR: Who are you?
|
|
Karsten Hopp |
b99a76 |
TALL KNIGHT: We are the Knights Who Say "Ni"!
|
|
Karsten Hopp |
b99a76 |
BEDEVERE: No! Not the Knights Who Say "Ni"!
|
|
Karsten Hopp |
b99a76 |
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
|
|
Karsten Hopp |
b99a76 |
|
|
Karsten Hopp |
b99a76 |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
Karsten Hopp |
b99a76 |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
Karsten Hopp |
b99a76 |
\\\ download, build and distribute -- http://www.A-A-P.org ///
|
|
Karsten Hopp |
b99a76 |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|