git-for-windows / git

A fork of Git containing Windows-specific patches.
http://gitforwindows.org/
Other
8.39k stars 2.54k forks source link

Cannot start git-bash maximized #1865

Closed Bilge closed 5 years ago

Bilge commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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

dscho commented 6 years ago

@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 commented 6 years ago

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

dscho commented 6 years ago

@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 commented 6 years ago

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

On Tue, 9 Oct 2018, 15:02 Johannes Schindelin, notifications@github.com wrote:

@Bilge https://github.com/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?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/git-for-windows/git/issues/1865#issuecomment-428203818, or mute the thread https://github.com/notifications/unsubscribe-auth/AAcuYthn_LBb_vpgnPMf0Jlnf20kMrB2ks5ujKxtgaJpZM4XKRkm .

PhilipOakley commented 6 years ago

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

dscho commented 6 years ago

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 commented 6 years ago

Maybe a little rusty on JavaScript or Java v's comd

On Wed, Oct 10, 2018, 4:28 AM Johannes Schindelin notifications@github.com wrote:

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 ;-)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/git-for-windows/git/issues/1865#issuecomment-428483860, or mute the thread https://github.com/notifications/unsubscribe-auth/Ao7Bv6E3CxetaZvDiVb44XjE6AmOZ0Bkks5uja-WgaJpZM4XKRkm .

mintty commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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

DarkMikey commented 6 years ago

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 commented 6 years ago

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 commented 5 years ago

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.