Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot start git-bash maximized #1865

Closed
Bilge opened this issue Oct 5, 2018 · 18 comments
Closed

Cannot start git-bash maximized #1865

Bilge opened this issue Oct 5, 2018 · 18 comments

Comments

@Bilge
Copy link

Bilge commented Oct 5, 2018

Although the operating system provides a mechanism to specify the window mode when the application starts up (normal/minimized/maximized), git-bash ignores this user preference and always starts in windowed (normal) mode.

image

If the user wishes to start git-bash maximized, this setting should be respected.


N.B. @mintty has confirmed this is not a mintty limitation.

@PhilipOakley
Copy link

A Quick web search indicated that for other programmes this is a tricky thing.

One does need to distinguish between "Full Screen" (The F11 thing in Internet Explorer), and simply 'Maximised' to the current screen size.

The web search indicated that (at least for more recent Win versions) it is for the user to maximise the application, and then close it at that size. Then on next re-opening it should return to that size (maybe also needing the setting you indicated). The articles/threads indicated that Windows (or the app) will remember in the registry the last window (screen) size and start at that value. [By implication, it maybe that the control is from good old basic 32-bit Windows days, XP and before ;-)]

How you managed to find any indication of how to achieve what is expected that could be programmatically achieved?

@mintty
Copy link

mintty commented Oct 5, 2018

The request is simply about configuring maximized mode initially, not further intelligence.
@Bilge, did you try to add an explicit -w max parameter to git-bash?
Otherwise, the wrapper may detect shortcut properties, using the GetStartupInfo function, and maybe pass on the desired window state to mintty via command line parameter (or STARTUPINFO again...).

@Bilge
Copy link
Author

Bilge commented Oct 5, 2018

Passing -w max to git-bash causes it to close immediately after it starts (the window flashes up for but a brief moment).

@dscho
Copy link
Member

dscho commented Oct 5, 2018

@Bilge you will need to edit the resources of git-bash.exe, using the edit-git-bash.exe that is included in the installer (but it is removed after installing).

Or you use ResEdit.

@Bilge
Copy link
Author

Bilge commented Oct 5, 2018

@dscho That doesn't seem very intuitive or user-friendly.

@dscho
Copy link
Member

dscho commented Oct 9, 2018

@Bilge I agree. What I tried to give to you is a way to test this method. And once it works, I can help you turn it into an option in the Git for Windows installer (that will be remembered across upgrades). Are you up to the challenge?

@Bilge
Copy link
Author

Bilge commented Oct 9, 2018 via email

@PhilipOakley
Copy link

@Bilge, it still needs coding though, as the mintty response indicated. It's the old itchy and scratchy problem ;-)

@dscho
Copy link
Member

dscho commented Oct 10, 2018

No, I'm busy.

Well, I tried to help. Let us know when your situation changes.

And it shouldn't be an installer option, it should work as expected with zero configuration, by respecting the shortcut specification.

Since you know much more about this than I do (obviously!), you are in a much better position to work on this than I am.

Besides, this is open source, baby ;-)

@galaxylegand
Copy link

galaxylegand commented Oct 10, 2018 via email

@mintty
Copy link

mintty commented Oct 10, 2018

I tried to find the source of the git-bash wrapper yesterday to check if I can help out but it's well hidden in the project dungeons...

@PhilipOakley
Copy link

It will be in the https://github.com/git-for-windows/build-extra repository, but I haven't had a delve to find the particular location. Maybe start at the Installer directory

@dscho
Copy link
Member

dscho commented Oct 23, 2018

I tried to find the source of the git-bash wrapper yesterday to check if I can help out but it's well hidden in the project dungeons...

@mintty It is built as part of the mingw-w64-git package:

@mintty
Copy link

mintty commented Oct 23, 2018

You may try the patch below. As I don't have a git-for-windows development environment, I cannot test it myself.

--- orig/git-wrapper.c	2018-10-23 11:37:06.425924800 +0000
+++ ./git-wrapper.c	2018-10-23 12:05:20.739796000 +0000
@@ -509,6 +509,22 @@ static void initialize_top_level_path(LP
 
 int main(void)
 {
+	// retrieve ShowWindow properties
+	STARTUPINFOW sui;
+	GetStartupInfoW(&sui);
+	WORD showWindow = sui.dwFlags & STARTF_USESHOWWINDOW
+			? sui.wShowWindow
+			: SW_SHOW;
+	// retrieve further Startup properties that could be useful
+	int invoked_with_appid = sui.dwFlags & STARTF_TITLEISAPPID;
+	int invoked_from_shortcut = sui.dwFlags & STARTF_TITLEISLINKNAME;
+	if (invoked_from_shortcut) {
+		// icon could be retrieved from sui.lpTitle
+	}
+	// optionally manipulate showWindow otherwise, e.g. from cmd parameters
+	// if (max) showWindow = SW_SHOWMAXIMIZED;
+	// if (...) showWindow = ...;
+
 	int r = 1, wait = 1, prefix_args_len = -1, needs_env_setup = 1,
 		is_git_command = 1, full_path = 1, skip_arguments = 0,
 		allocate_console = 0, show_console = 0,
@@ -653,7 +669,7 @@ int main(void)
 		}
 		if (show_console) {
 			si.dwFlags |= STARTF_USESHOWWINDOW;
-			si.wShowWindow = SW_SHOW;
+			si.wShowWindow = showWindow;
 		}
 		br = CreateProcess(/* module: null means use command line */
 				exep,

@dscho
Copy link
Member

dscho commented Oct 31, 2018

This feature will need somebody who wants it badly enough to actually put in some effort.

@DarkMikey
Copy link

I was searching for a solution, when I found this. Top answer took 30 seconds and works for me.
https://stackoverflow.com/questions/33991079/git-bash-mintty-how-to-open-maximized?answertab=votes#tab-top

@mintty
Copy link

mintty commented Nov 15, 2018

If you make your own wrapper anyway, you could also try the patch I suggested above, so the "max" setting would not need to be fixed but could automatically depend on the shortcut configuration.
On the other hand, if adding some parameters is all the wrapper needs to do, you could as well invoke mintty directly in the shortcut, adding those parameters, and add -w max as you like, dropping the wrapper altogether. And git.exe will be found implicitly if you copy it into usr/bin/; don't know why it's kept separately in bin/.

@dscho
Copy link
Member

dscho commented Nov 28, 2018

Top answer took 30 seconds and works for me.
https://stackoverflow.com/questions/33991079/git-bash-mintty-how-to-open-maximized?answertab=votes#tab-top

For the record, this suggests to put

Window=max

into e.g. ~/.minttyrc.

Which sounds like a pretty painless solution, in particular given the reluctance to work with @mintty to try any patches and give feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants