* [PATCH] gitk - enable selected patch text on Windows
@ 2007-08-06 22:45 Mark Levedahl
2007-08-06 22:45 ` [PATCH] gitk - Handle MouseWheel events " Mark Levedahl
2007-08-08 1:40 ` [PATCH] gitk - enable selected patch text " Mark Levedahl
0 siblings, 2 replies; 6+ messages in thread
From: Mark Levedahl @ 2007-08-06 22:45 UTC (permalink / raw)
To: Paul Mackerras; +Cc: Git Mailing List, Mark Levedahl
On windows, mouse input follows the keyboard focus, so to allow selecting
text from the patch canvas we must not shift focus back to the top level.
This change has no negative impact on X, so we don't explicitly test
for Win32 on this change. This provides similar selection capability
as already available using X-Windows.
Signed-off-by: Mark Levedahl <mdl123@verizon.net>
---
gitk | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/gitk b/gitk
index f74ce51..08ff5df 100755
--- a/gitk
+++ b/gitk
@@ -955,8 +955,8 @@ proc bindkey {ev script} {
# set the focus back to the toplevel for any click outside
# the entry widgets
proc click {w} {
- global entries
- foreach e $entries {
+ global ctext entries
+ foreach e [concat $entries $ctext] {
if {$w == $e} return
}
focus .
--
1.5.3.rc4.5.g4f0b5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] gitk - Handle MouseWheel events on Windows
2007-08-06 22:45 [PATCH] gitk - enable selected patch text on Windows Mark Levedahl
@ 2007-08-06 22:45 ` Mark Levedahl
2007-08-08 1:40 ` [PATCH] gitk - enable selected patch text " Mark Levedahl
1 sibling, 0 replies; 6+ messages in thread
From: Mark Levedahl @ 2007-08-06 22:45 UTC (permalink / raw)
To: Paul Mackerras; +Cc: Git Mailing List, Mark Levedahl
Windows, unlike X-Windows, sends mousewheel events by default to the
window that has keyboard focus and uses the MouseWheel event to do so.
The window to be scrolled must be able to take focus, but gitk's panels
are disabled so cannot take focus. For all these reasons, a different
design is needed to use the mousewheel on Windows. The approach here is
to bind the mousewheel events to the top level window and redirect them
based upon the current mouse position.
Signed-off-by: Mark Levedahl <mdl123@verizon.net>
---
gitk | 33 +++++++++++++++++++++++++++++++--
1 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/gitk b/gitk
index 08ff5df..f6fca9b 100755
--- a/gitk
+++ b/gitk
@@ -823,8 +823,13 @@ proc makewindow {} {
pack .ctop -fill both -expand 1
bindall <1> {selcanvline %W %x %y}
#bindall <B1-Motion> {selcanvline %W %x %y}
- bindall <ButtonRelease-4> "allcanvs yview scroll -5 units"
- bindall <ButtonRelease-5> "allcanvs yview scroll 5 units"
+ if {[tk windowingsystem] == "win32"} {
+ bind . <MouseWheel> { windows_mousewheel_redirector %W %X %Y %D }
+ bind $ctext <MouseWheel> { windows_mousewheel_redirector %W %X %Y %D ; break }
+ } else {
+ bindall <ButtonRelease-4> "allcanvs yview scroll -5 units"
+ bindall <ButtonRelease-5> "allcanvs yview scroll 5 units"
+ }
bindall <2> "canvscan mark %W %x %y"
bindall <B2-Motion> "canvscan dragto %W %x %y"
bindkey <Home> selfirstline
@@ -918,6 +923,30 @@ proc makewindow {} {
-command rmbranch
}
+# Windows sends all mouse wheel events to the current focused window, not the one where
+# the mouse hovers, so instead bind mouse to the top level window and redirect
+proc windows_mousewheel_redirector {W X Y D} {
+ global canv canv2 canv3
+ set w [winfo containing -displayof $W $X $Y]
+ if {$w ne ""} {
+ if {$w == $canv || $w == $canv2 || $w == $canv3} {
+ if {$D < 0} {
+ allcanvs yview scroll 5 units
+ } else {
+ allcanvs yview scroll -5 units
+ }
+ } else {
+ catch {
+ if {$D < 0} {
+ $w yview scroll 5 units
+ } else {
+ $w yview scroll -5 units
+ }
+ }
+ }
+ }
+}
+
# mouse-2 makes all windows scan vertically, but only the one
# the cursor is in scans horizontally
proc canvscan {op w x y} {
--
1.5.3.rc4.5.g4f0b5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] gitk - enable selected patch text on Windows
2007-08-06 22:45 [PATCH] gitk - enable selected patch text on Windows Mark Levedahl
2007-08-06 22:45 ` [PATCH] gitk - Handle MouseWheel events " Mark Levedahl
@ 2007-08-08 1:40 ` Mark Levedahl
2007-08-08 1:40 ` [PATCH] gitk - Handle MouseWheel events " Mark Levedahl
1 sibling, 1 reply; 6+ messages in thread
From: Mark Levedahl @ 2007-08-08 1:40 UTC (permalink / raw)
To: Paul Mackerras; +Cc: Git Mailing List, Mark Levedahl
On windows, mouse input follows the keyboard focus, so to allow selecting
text from the patch canvas we must not shift focus back to the top level.
This change has no negative impact on X, so we don't explicitly test
for Win32 on this change. This provides similar selection capability
as already available using X-Windows.
Signed-off-by: Mark Levedahl <mdl123@verizon.net>
---
This version enforces setting focus to the top level window whenever a
scrolling command is issued. The first version lacked that and could allow
some letters to erroneously appear in the patch window. This was purely
cosmetic but annoying to one co-worker on a very slow machine.
gitk | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/gitk b/gitk
index f74ce51..84f5ee4 100755
--- a/gitk
+++ b/gitk
@@ -955,8 +955,8 @@ proc bindkey {ev script} {
# set the focus back to the toplevel for any click outside
# the entry widgets
proc click {w} {
- global entries
- foreach e $entries {
+ global ctext entries
+ foreach e [concat $entries $ctext] {
if {$w == $e} return
}
focus .
@@ -4565,6 +4565,7 @@ proc sellastline {} {
proc selnextline {dir} {
global selectedline
+ focus .
if {![info exists selectedline]} return
set l [expr {$selectedline + $dir}]
unmarkmatches
@@ -4645,6 +4646,7 @@ proc godo {elt} {
proc goback {} {
global history historyindex
+ focus .
if {$historyindex > 1} {
incr historyindex -1
@@ -4658,6 +4660,7 @@ proc goback {} {
proc goforw {} {
global history historyindex
+ focus .
if {$historyindex < [llength $history]} {
set cmd [lindex $history $historyindex]
--
1.5.3.rc4.25.gade7b9
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] gitk - Handle MouseWheel events on Windows
2007-08-08 1:40 ` [PATCH] gitk - enable selected patch text " Mark Levedahl
@ 2007-08-08 1:40 ` Mark Levedahl
2007-08-11 12:23 ` Mark Levedahl
0 siblings, 1 reply; 6+ messages in thread
From: Mark Levedahl @ 2007-08-08 1:40 UTC (permalink / raw)
To: Paul Mackerras; +Cc: Git Mailing List, Mark Levedahl
Windows, unlike X-Windows, sends mousewheel events by default to the
window that has keyboard focus and uses the MouseWheel event to do so.
The window to be scrolled must be able to take focus, but gitk's panels
are disabled so cannot take focus. For all these reasons, a different
design is needed to use the mousewheel on Windows. The approach here is
to bind the mousewheel events to the top level window and redirect them
based upon the current mouse position.
Signed-off-by: Mark Levedahl <mdl123@verizon.net>
---
This version is a slight clean-up of the original, collapsing two
if/else blocks into a single conditional assignment.
gitk | 27 +++++++++++++++++++++++++--
1 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/gitk b/gitk
index 84f5ee4..eb2b194 100755
--- a/gitk
+++ b/gitk
@@ -823,8 +823,13 @@ proc makewindow {} {
pack .ctop -fill both -expand 1
bindall <1> {selcanvline %W %x %y}
#bindall <B1-Motion> {selcanvline %W %x %y}
- bindall <ButtonRelease-4> "allcanvs yview scroll -5 units"
- bindall <ButtonRelease-5> "allcanvs yview scroll 5 units"
+ if {[tk windowingsystem] == "win32"} {
+ bind . <MouseWheel> { windows_mousewheel_redirector %W %X %Y %D }
+ bind $ctext <MouseWheel> { windows_mousewheel_redirector %W %X %Y %D ; break }
+ } else {
+ bindall <ButtonRelease-4> "allcanvs yview scroll -5 units"
+ bindall <ButtonRelease-5> "allcanvs yview scroll 5 units"
+ }
bindall <2> "canvscan mark %W %x %y"
bindall <B2-Motion> "canvscan dragto %W %x %y"
bindkey <Home> selfirstline
@@ -918,6 +923,24 @@ proc makewindow {} {
-command rmbranch
}
+# Windows sends all mouse wheel events to the current focused window, not
+# the one where the mouse hovers, so bind those events here and redirect
+# to the correct window
+proc windows_mousewheel_redirector {W X Y D} {
+ global canv canv2 canv3
+ set w [winfo containing -displayof $W $X $Y]
+ if {$w ne ""} {
+ set u [expr {$D < 0 ? 5 : -5}]
+ if {$w == $canv || $w == $canv2 || $w == $canv3} {
+ allcanvs yview scroll $u units
+ } else {
+ catch {
+ $w yview scroll $u units
+ }
+ }
+ }
+}
+
# mouse-2 makes all windows scan vertically, but only the one
# the cursor is in scans horizontally
proc canvscan {op w x y} {
--
1.5.3.rc4.25.gade7b9
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] gitk - Handle MouseWheel events on Windows
2007-08-08 1:40 ` [PATCH] gitk - Handle MouseWheel events " Mark Levedahl
@ 2007-08-11 12:23 ` Mark Levedahl
2007-08-11 16:58 ` Steffen Prohaska
0 siblings, 1 reply; 6+ messages in thread
From: Mark Levedahl @ 2007-08-11 12:23 UTC (permalink / raw)
To: Paul Mackerras, Junio C Hamano; +Cc: Mark Levedahl, Git Mailing List
Ping - any chance of getting these two patches into 1.5.3? They fix a
pair of long-standing frustrations for
Cygwin (and now msys/Windows) users:
[PATCH] gitk - enable selected patch text on Windows
[PATCH] gitk - Handle MouseWheel events on Windows
Mark
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gitk - Handle MouseWheel events on Windows
2007-08-11 12:23 ` Mark Levedahl
@ 2007-08-11 16:58 ` Steffen Prohaska
0 siblings, 0 replies; 6+ messages in thread
From: Steffen Prohaska @ 2007-08-11 16:58 UTC (permalink / raw)
To: Paul Mackerras, Junio C Hamano; +Cc: Git Mailing List
On Aug 11, 2007, at 2:23 PM, Mark Levedahl wrote:
> Ping - any chance of getting these two patches into 1.5.3? They fix
> a pair of long-standing frustrations for
> Cygwin (and now msys/Windows) users:
>
> [PATCH] gitk - enable selected patch text on Windows
> [PATCH] gitk - Handle MouseWheel events on Windows
Both work for me in msysgit.
Would be really, really nice to have them. Missing copy
text from gitk is a bug in my opinion, which is fixed
by the first patch. Support for MouseWheel is also nice
to have.
Steffen
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-08-11 16:58 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-06 22:45 [PATCH] gitk - enable selected patch text on Windows Mark Levedahl
2007-08-06 22:45 ` [PATCH] gitk - Handle MouseWheel events " Mark Levedahl
2007-08-08 1:40 ` [PATCH] gitk - enable selected patch text " Mark Levedahl
2007-08-08 1:40 ` [PATCH] gitk - Handle MouseWheel events " Mark Levedahl
2007-08-11 12:23 ` Mark Levedahl
2007-08-11 16:58 ` Steffen Prohaska
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).