threads / patch / 16766

patchgitk: force focus to main window

Subject: [PATCH] gitk: force focus to main window

## tl;dr

6 messages between Dec 17, 2008 and Dec 18, 2008. Diffs are folded; open one to read it.

replies: 5people: 4as markdown or json

Johannes Sixt· Dec 17, 2008, 11:50 UTC · lore
From: Johannes Schindelin <johannes.schindelin@gmx.de>

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.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
 gitk-git/gitk |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
Show changes to gitk-git/gitk +1 −0
diff --git a/gitk-git/gitk b/gitk-git/gitk
index 1c8d98e..b3d8219 100644
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -10898,4 +10898,5 @@ if {[info exists permviews]} {
 	addviewmenu $n
     }
 }
+focus -force .
 getcommits {}
-- 
1.6.1.rc3.980.ga0bb
Paul Mackerras· Dec 17, 2008, 21:38 UTC · re: Johannes Sixt · lore

Re: [PATCH] gitk: force focus to main window

Johannes Sixt writes:
> 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.
Johannes Schindelin· Dec 18, 2008, 03:14 UTC · re: Paul Mackerras · lore

Re: [PATCH] gitk: force focus to main window

Hi,
On Thu, 18 Dec 2008, Paul Mackerras wrote:
Show 9 quoted lines
> Johannes Sixt writes:
> 
> > 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.
> 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

Jeff King· Dec 18, 2008, 03:23 UTC · re: Johannes Schindelin · lore

Re: [PATCH] gitk: force focus to main window

On Thu, Dec 18, 2008 at 04:14:25AM +0100, Johannes Schindelin wrote:
Show 5 quoted 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
Paul Mackerras· Dec 18, 2008, 04:09 UTC · re: Johannes Schindelin · lore

Re: [PATCH] gitk: force focus to main window

Johannes Schindelin writes:
Show 5 quoted 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.
Johannes Sixt· Dec 18, 2008, 07:30 UTC · re: Paul Mackerras · lore

[PATCH v2] gitk: force the focus to the main window on Windows

From: Johannes Sixt <j6t@kdbg.org>

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.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
Paul Mackerras schrieb:
> 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(-)
Show changes to gitk +5 −0
diff --git a/gitk b/gitk
index b63109b..121b621 100644
--- a/gitk
+++ b/gitk
@@ -10898,4 +10898,9 @@ if {[info exists permviews]} {
 	addviewmenu $n
     }
 }
+
+if {[tk windowingsystem] eq "win32"} {
+    focus -force .
+}
+
 getcommits {}
-- 
1.6.1.rc3.950.g5dd2

← back to recent threads