Attached is a small patch that adds a v:windowid variable which is set whenever an X11 based GUI is running; it is 0 in all other cases.
The reason I wrote this patch is that I wanted to be able to automate maximizing newly started gVim windows under X, and it's MUCH easier to accomplish this if gVim can tell me its window ID.
An example usage of v:windowid would be to start a gVim instance under X and type:
:echo system('xwininfo -id ' . v:windowid) - Christian -- Polarize: What penguins see with. Christian J. Robinson <hept...@gmail.com> http://christianrobinson.name/ -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php
diff -r 10ce04af8c5b runtime/doc/eval.txt --- a/runtime/doc/eval.txt Sun Oct 10 17:08:43 2010 +0200 +++ b/runtime/doc/eval.txt Mon Oct 11 18:27:28 2010 -0600 @@ -1657,6 +1657,10 @@ *v:warningmsg* *warningmsg-variable* v:warningmsg Last given warning message. It's allowed to set this variable. + *v:windowid* *windowid-variable* +v:windowid When any X11 based GUI is running this will be set to the + window ID, the value is 0 in all other cases. + ============================================================================== 4. Builtin Functions *functions* diff -r 10ce04af8c5b src/eval.c --- a/src/eval.c Sun Oct 10 17:08:43 2010 +0200 +++ b/src/eval.c Mon Oct 11 18:27:28 2010 -0600 @@ -362,6 +362,7 @@ {VV_NAME("operator", VAR_STRING), VV_RO}, {VV_NAME("searchforward", VAR_NUMBER), 0}, {VV_NAME("oldfiles", VAR_LIST), 0}, + {VV_NAME("windowid", VAR_NUMBER), VV_RO}, }; /* shorthand */ diff -r 10ce04af8c5b src/gui.c --- a/src/gui.c Sun Oct 10 17:08:43 2010 +0200 +++ b/src/gui.c Mon Oct 11 18:27:28 2010 -0600 @@ -65,6 +65,11 @@ #endif static int recursive = 0; +#if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11) + Window x11_window = 0; + Display *x11_display = NULL; +#endif + old_term = vim_strsave(T_NAME); /* @@ -105,8 +110,19 @@ #if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11) if (gui.in_use) + { +# ifdef FEAT_EVAL + set_vim_var_nr(VV_WINDOWID, 0); + + if (gui_get_x11_windis(&x11_window, &x11_display) == OK) + { + set_vim_var_nr(VV_WINDOWID, x11_window); + } +# endif + /* Display error messages in a dialog now. */ display_errors(); + } #endif #if defined(MAY_FORK) && !defined(__QNXNTO__) diff -r 10ce04af8c5b src/vim.h --- a/src/vim.h Sun Oct 10 17:08:43 2010 +0200 +++ b/src/vim.h Mon Oct 11 18:27:28 2010 -0600 @@ -1842,7 +1842,8 @@ #define VV_OP 52 #define VV_SEARCHFORWARD 53 #define VV_OLDFILES 54 -#define VV_LEN 55 /* number of v: vars */ +#define VV_WINDOWID 55 +#define VV_LEN 56 /* number of v: vars */ #ifdef FEAT_CLIPBOARD