Subject: bug#35059: window-setup-hook not working with the new frame parameters

From: Eli Zaretskii <[email-masked]>
Date: Sun, 31 Mar 2019 11:20:35 +0300

On March 31, 2019 8:57:18 AM GMT+03:00, Michael Wu <[email-masked]> wrote:
> See this StackOverflow thread:
> https://emacs.stackexchange.com/questions/48645/if-start-with-maximized-frame-why-do-windows-open-top-bottom-not-side-by-side
> 
> as well as Stefan's answer, and comments on that answer. Essentially,
> I
> do not believe window-setup-hook is properly running after all frame
> parameters have been set, as is suggested in the documentation here:
> 
> https://www.gnu.org/software/emacs/manual/html_node/elisp/Startup-Summary.html

There's nothing wrong with window-setup-hook, AFAICT, it indeed runs after all the parameters of the frame have been set according to your customizations.

The problem is in your apparent assumption that frame maximization happens immediately after you put the fullscreen parameter into frame-parametets.  But actually, frame maximization is performed through interaction with the window-manager, which generally happens asynchronously and takes some short, but non-zero time.

Add to your hook  a call to 'message' that displays the width and height of the selected window, and you will see why you get windows split vertically.

The conclusion is that if you want to see windows split like you expected, you need to insert a wait into your  emacs.  Or just split horizontally by an explicit command.