Skip to contentSkip to conversation

gitk: force focus to main window

PATCH In review Johannes Sixt 4 participants 6 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gitk: force focus to main window

From: Johannes Schindelin <[email protected]>

On msysGit, the focus is first on the (Tk) console. This console is then hidden, but keeps the focus. Work around that by forcing the focus onto the gitk window.

This fixes issue 14.

---
 gitk-git/gitk |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
gitk-git/gitk +1 -0
index 1c8d98e..b3d8219 100644
@@ -10898,4 +10898,5 @@ if {[info exists permviews]} {
 	addviewmenu $n
     }
 }
+focus -force .
 getcommits {}
Signature · 1 line
1.6.1.rc3.980.ga0bb
#1 lore raw
Quoted 3 lines · Johannes Sixt

On msysGit, the focus is first on the (Tk) console. This console is then hidden, but keeps the focus. Work around that by forcing the focus onto the gitk window.

Hmmm, I don't like doing focus -force unconditionally on all platforms. I hate it when applications decide they know best and override what the window manager decides.

At least put a if {[tk windowingsystem] eq "win32"} in there. (msysGit is a windows thing, isn't it?)

Paul.

#2 lore raw

PATCH v2 1/1 gitk: force the focus to the main window on Windows

From: Johannes Sixt <[email protected]>

On msysGit, the focus is first on the (Tk) console. This console is then hidden, but keeps the focus. Work around that by forcing the focus onto the gitk window.

This fixes msysGit issue 14. Diagnosed and originally fixed by Johannes Schindelin.

---

Quoted 2 lines · Paul Mackerras

At least put a if {[tk windowingsystem] eq "win32"} in there. (msysGit is a windows thing, isn't it?)

I did that.

-- Hannes

 gitk |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
gitk +5 -0
index b63109b..121b621 100644
@@ -10898,4 +10898,9 @@ if {[info exists permviews]} {
 	addviewmenu $n
     }
 }
+
+if {[tk windowingsystem] eq "win32"} {
+    focus -force .
+}
+
 getcommits {}
Signature · 1 line
1.6.1.rc3.950.g5dd2
#3 lore raw
In reply to Paul Mackerras

Hi,

Quoted 11 lines · Paul Mackerras
Quoted 3 lines · Johannes Sixt

On msysGit, the focus is first on the (Tk) console. This console is then hidden, but keeps the focus. Work around that by forcing the focus onto the gitk window.

Hmmm, I don't like doing focus -force unconditionally on all platforms. I hate it when applications decide they know best and override what the window manager decides.

From my previous experience with my patches to gitk, I did not expect

otherwise. That is why I did not even bother with this one.

Quoted 2 lines

At least put a if {[tk windowingsystem] eq "win32"} in there. (msysGit is a windows thing, isn't it?)

Yeah, because on other platforms, when you start gitk, you don't want it to take focus. Yeah, right.

Ciao,
Dscho

#4 lore raw
Quoted 5 lines · Johannes Schindelin
Quoted 2 lines

At least put a if {[tk windowingsystem] eq "win32"} in there. (msysGit is a windows thing, isn't it?)

Yeah, because on other platforms, when you start gitk, you don't want it to take focus. Yeah, right.

No - on other platforms I have a window manager that gives focus to new applications automatically. Or, if I don't want new applications to grab the focus, I tell the window manager that that's what the policy should be. Either way the application shouldn't forcibly and unilaterally grab the focus.

I'm prepared (predisposed, even :-) to believe that windows sucks, so I'll take the patch if it only affects windows.

Paul.

#5 lore raw
In reply to Johannes Schindelin
Quoted 5 lines · Johannes Schindelin
Quoted 2 lines

At least put a if {[tk windowingsystem] eq "win32"} in there. (msysGit is a windows thing, isn't it?)

Yeah, because on other platforms, when you start gitk, you don't want it to take focus. Yeah, right.

That is _exactly_ what I want on my platform: no window should steal the focus when I am in the middle of typing in some other window. And to that end, my window manager does not shift the focus until I tell it to do so.

So yes, this patch _does_ break at least my setup. But more importantly, it is an application making a decision about focus policy that should be made by the window manager. I understand that the window manager in Windows sucks, and that this is a workaround that makes things better there. But please don't inflict this braindeadedness on the rest of us.

-Peff