On 13-Oct-2010 "Christian J. Robinson" <hept...@gmail.com> wrote: > On Wed, 13 Oct 2010, Bram Moolenaar wrote: [...] > >Can you move the declarations close to the call? Reduces the > >number of #ifdefs. > > Done. > > >Also, I don't think they need to be initialized. > > Force of habit, but you're right, so I removed the initializations. > > The revised patch is attached. > [...] > > /* shorthand */ > diff -r 10ce04af8c5b src/gui.c > --- a/src/gui.c Sun Oct 10 17:08:43 2010 +0200 > +++ b/src/gui.c Wed Oct 13 11:15:47 2010 -0600 > @@ -104,9 +104,23 @@ > vim_free(old_term); > > #if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11) > + Window x11_window; > + Display *x11_display; > + > if (gui.in_use) > + { > +# ifdef FEAT_EVAL
Vim is supposed to be compilable with a C89-compliant compiler. I moved the variables' declarations so as to make it possible. By the way, I haven't looked into variables' implementation, so forgive me if the answer is obvious, but is the value of the variable properly initialised under e.g. MS Windows or when GUI is not used? Thanks! -- Cheers, Lech -- 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 --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 9928f8b..d67bce9 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1657,6 +1657,10 @@ v:version Version number of Vim: Major version number times 100 plus *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 --git a/src/eval.c b/src/eval.c index 0f306d4..1f14bcb 100644 --- a/src/eval.c +++ b/src/eval.c @@ -362,6 +362,7 @@ static struct vimvar {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 --git a/src/gui.c b/src/gui.c index 6029e3b..07fb0e5 100644 --- a/src/gui.c +++ b/src/gui.c @@ -105,8 +105,22 @@ gui_start() #if defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11) if (gui.in_use) + { +# ifdef FEAT_EVAL + Window x11_window; + Display *x11_display; + + 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 --git a/src/vim.h b/src/vim.h index 6c846c1..5b74203 100644 --- a/src/vim.h +++ b/src/vim.h @@ -1842,7 +1842,8 @@ typedef int proftime_T; /* dummy for function prototypes */ #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