diff --git a/src/MacVim/gui_macvim.m b/src/MacVim/gui_macvim.m index 1f4155bd65..b93fbd6d98 100644 --- a/src/MacVim/gui_macvim.m +++ b/src/MacVim/gui_macvim.m @@ -110,6 +110,30 @@ gui_mch_prepare(int *argc, char **argv) } +/* Called directly after forking (even if we didn't fork). */ + void +gui_macvim_after_fork_init() +{ + ASLInit(); + ASLogDebug(@""); + + // Restore autosaved rows & columns + CFIndex rows, cols; + Boolean rowsValid, colsValid; + rows = CFPreferencesGetAppIntegerValue((CFStringRef)MMAutosaveRowsKey, + kCFPreferencesCurrentApplication, + &rowsValid); + cols = CFPreferencesGetAppIntegerValue((CFStringRef)MMAutosaveColumnsKey, + kCFPreferencesCurrentApplication, + &colsValid); + if (rowsValid && colsValid + && (rows > 4 && rows < 1000 && cols > 29 && cols < 4000)) { + gui.num_rows = rows; + gui.num_cols = cols; + } +} + + /* * Check if the GUI can be started. Called before gvimrc is sourced. * Return OK or FAIL. @@ -117,29 +141,6 @@ gui_mch_prepare(int *argc, char **argv) int gui_mch_init_check(void) { - ASLInit(); - ASLogDebug(@""); - - // Restore autosaved rows & columns - CFNumberRef rowsRef, colsRef; - rowsRef = CFPreferencesCopyAppValue((CFStringRef)MMAutosaveRowsKey, - kCFPreferencesCurrentApplication); - colsRef = CFPreferencesCopyAppValue((CFStringRef)MMAutosaveColumnsKey, - kCFPreferencesCurrentApplication); - if (rowsRef && colsRef) { - int rows, cols; - if (CFNumberGetValue(rowsRef, kCFNumberIntType, &rows) - && CFNumberGetValue(colsRef, kCFNumberIntType, &cols)) { - if (rows > 4 && rows < 1000 && cols > 29 && cols < 4000) { - Rows = rows; - Columns = cols; - } else { - ASLogWarn(@"Autosaved window dimensions invalid: %dx%d", - cols, rows); - } - } - } - return OK; } diff --git a/src/main.c b/src/main.c index 9ad32b8bb9..6ffb975c28 100644 --- a/src/main.c +++ b/src/main.c @@ -363,6 +363,9 @@ main #ifdef MACOS_X if (gui.starting && gui.dofork) macosx_fork(); /* Never returns */ +# ifdef FEAT_GUI_MACVIM + gui_macvim_after_fork_init(); +# endif #endif /* @@ -452,7 +455,8 @@ main * For GTK we can't be sure, but when started from the desktop it doesn't * make sense to try using a terminal. */ -#if defined(ALWAYS_USE_GUI) || defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) +#if defined(ALWAYS_USE_GUI) || defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) \ + || defined(FEAT_GUI_MACVIM) if (gui.starting # ifdef FEAT_GUI_GTK && !isatty(2) @@ -461,7 +465,7 @@ main params.want_full_screen = FALSE; #endif -#if (defined(FEAT_GUI_MAC) || defined(FEAT_GUI_MACVIM)) && defined(MACOS_X_UNIX) +#if defined(FEAT_GUI_MAC) && defined(MACOS_X_UNIX) /* When the GUI is started from Finder, need to display messages in a * message box. isatty(2) returns TRUE anyway, thus we need to check the * name to know we're not started from a terminal. */ @@ -469,7 +473,6 @@ main { params.want_full_screen = FALSE; -# ifndef FEAT_GUI_MACVIM /* Avoid always using "/" as the current directory. Note that when * started from Finder the arglist will be filled later in * HandleODocAE() and "fname" will be NULL. */ @@ -484,7 +487,6 @@ main vim_chdir(NameBuff); } } -# endif } #endif diff --git a/src/proto/gui_macvim.pro b/src/proto/gui_macvim.pro index 2cb1fd5cbe..66f0b85bf6 100644 --- a/src/proto/gui_macvim.pro +++ b/src/proto/gui_macvim.pro @@ -3,6 +3,8 @@ macvim_early_init(); void gui_mch_prepare(int *argc, char **argv); + void +gui_macvim_after_fork_init(); int gui_mch_init_check(void); int diff --git a/src/ui.c b/src/ui.c index 662266b396..2e18638cf2 100644 --- a/src/ui.c +++ b/src/ui.c @@ -308,7 +308,11 @@ ui_get_shellsize() int retval; #ifdef FEAT_GUI - if (gui.in_use) + if (gui.in_use +# ifdef FEAT_GUI_MACVIM + || gui.starting /* TODO: Do this check for all GUIs? */ +# endif + ) retval = gui_get_shellsize(); else #endif