{"thread":{"id":"9412","subject":"[PATCH] gitk - enable selected patch text on Windows","startedAt":"2007-08-06T22:45:51Z","lastAt":"2007-08-11T16:58:06Z","messageCount":6,"participants":["Mark Levedahl","Steffen Prohaska"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"50051","messageId":"1186440352826-git-send-email-mdl123@verizon.net","threadId":"9412","inReplyTo":null,"subject":"[PATCH] gitk - enable selected patch text on Windows","fromName":"Mark Levedahl","fromEmail":"mdl123@verizon.net","sentAt":"2007-08-06T22:45:51Z","receivedAt":"2007-08-06T22:45:51Z","isPatch":true,"sender":{"key":"mdl123@verizon.net","avatar":"https://avatars.githubusercontent.com/u/5302462?v=4"},"body":"On windows, mouse input follows the keyboard focus, so to allow selecting\ntext from the patch canvas we must not shift focus back to the top level.\nThis change has no negative impact on X, so we don't explicitly test\nfor Win32 on this change. This provides similar selection capability\nas already available using X-Windows.\n\nSigned-off-by: Mark Levedahl <mdl123@verizon.net>\n---\n gitk |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/gitk b/gitk\nindex f74ce51..08ff5df 100755\n--- a/gitk\n+++ b/gitk\n@@ -955,8 +955,8 @@ proc bindkey {ev script} {\n # set the focus back to the toplevel for any click outside\n # the entry widgets\n proc click {w} {\n-    global entries\n-    foreach e $entries {\n+    global ctext entries\n+    foreach e [concat $entries $ctext] {\n \tif {$w == $e} return\n     }\n     focus .\n-- \n1.5.3.rc4.5.g4f0b5\n"},{"id":"50052","messageId":"11864403541120-git-send-email-mdl123@verizon.net","threadId":"9412","inReplyTo":"1186440352826-git-send-email-mdl123@verizon.net","subject":"[PATCH] gitk - Handle MouseWheel events on Windows","fromName":"Mark Levedahl","fromEmail":"mdl123@verizon.net","sentAt":"2007-08-06T22:45:52Z","receivedAt":"2007-08-06T22:45:52Z","isPatch":true,"sender":{"key":"mdl123@verizon.net","avatar":"https://avatars.githubusercontent.com/u/5302462?v=4"},"body":"Windows, unlike X-Windows, sends mousewheel events by default to the\nwindow that has keyboard focus and uses the MouseWheel event to do so.\nThe window to be scrolled must be able to take focus, but gitk's panels\nare disabled so cannot take focus. For all these reasons, a different\ndesign is needed to use the mousewheel on Windows. The approach here is\nto bind the mousewheel events to the top level window and redirect them\nbased upon the current mouse position.\n\nSigned-off-by: Mark Levedahl <mdl123@verizon.net>\n---\n gitk |   33 +++++++++++++++++++++++++++++++--\n 1 files changed, 31 insertions(+), 2 deletions(-)\n\ndiff --git a/gitk b/gitk\nindex 08ff5df..f6fca9b 100755\n--- a/gitk\n+++ b/gitk\n@@ -823,8 +823,13 @@ proc makewindow {} {\n     pack .ctop -fill both -expand 1\n     bindall <1> {selcanvline %W %x %y}\n     #bindall <B1-Motion> {selcanvline %W %x %y}\n-    bindall <ButtonRelease-4> \"allcanvs yview scroll -5 units\"\n-    bindall <ButtonRelease-5> \"allcanvs yview scroll 5 units\"\n+    if {[tk windowingsystem] == \"win32\"} {\n+\tbind . <MouseWheel> { windows_mousewheel_redirector %W %X %Y %D }\n+\tbind $ctext <MouseWheel> { windows_mousewheel_redirector %W %X %Y %D ; break }\n+    } else {\n+\tbindall <ButtonRelease-4> \"allcanvs yview scroll -5 units\"\n+\tbindall <ButtonRelease-5> \"allcanvs yview scroll 5 units\"\n+    }\n     bindall <2> \"canvscan mark %W %x %y\"\n     bindall <B2-Motion> \"canvscan dragto %W %x %y\"\n     bindkey <Home> selfirstline\n@@ -918,6 +923,30 @@ proc makewindow {} {\n \t-command rmbranch\n }\n \n+# Windows sends all mouse wheel events to the current focused window, not the one where\n+# the mouse hovers, so instead bind mouse to the top level window and redirect\n+proc windows_mousewheel_redirector {W X Y D} {\n+    global canv canv2 canv3\n+    set w [winfo containing -displayof $W $X $Y]\n+    if {$w ne \"\"} {\n+\tif {$w == $canv || $w == $canv2 || $w == $canv3} {\n+\t    if {$D < 0} {\n+\t\tallcanvs yview scroll 5 units\n+\t    } else {\n+\t\tallcanvs yview scroll -5 units\n+\t    }\n+\t} else {\n+\t    catch {\n+\t\tif {$D < 0} {\n+\t\t    $w yview scroll 5 units\n+\t\t} else {\n+\t\t    $w yview scroll -5 units\n+\t\t}\n+\t    }\n+\t}\n+    }\n+}\n+\n # mouse-2 makes all windows scan vertically, but only the one\n # the cursor is in scans horizontally\n proc canvscan {op w x y} {\n-- \n1.5.3.rc4.5.g4f0b5\n"},{"id":"50161","messageId":"11865372352543-git-send-email-mdl123@verizon.net","threadId":"9412","inReplyTo":"1186440352826-git-send-email-mdl123@verizon.net","subject":"[PATCH] gitk - enable selected patch text on Windows","fromName":"Mark Levedahl","fromEmail":"mdl123@verizon.net","sentAt":"2007-08-08T01:40:34Z","receivedAt":"2007-08-08T01:40:34Z","isPatch":true,"sender":{"key":"mdl123@verizon.net","avatar":"https://avatars.githubusercontent.com/u/5302462?v=4"},"body":"On windows, mouse input follows the keyboard focus, so to allow selecting\ntext from the patch canvas we must not shift focus back to the top level.\nThis change has no negative impact on X, so we don't explicitly test\nfor Win32 on this change. This provides similar selection capability\nas already available using X-Windows.\n\nSigned-off-by: Mark Levedahl <mdl123@verizon.net>\n---\n\nThis version enforces setting focus to the top level window whenever a\nscrolling command is issued. The first version lacked that and could allow\nsome letters to erroneously appear in the patch window. This was purely\ncosmetic but annoying to one co-worker on a very slow machine.\n\n gitk |    7 +++++--\n 1 files changed, 5 insertions(+), 2 deletions(-)\n\ndiff --git a/gitk b/gitk\nindex f74ce51..84f5ee4 100755\n--- a/gitk\n+++ b/gitk\n@@ -955,8 +955,8 @@ proc bindkey {ev script} {\n # set the focus back to the toplevel for any click outside\n # the entry widgets\n proc click {w} {\n-    global entries\n-    foreach e $entries {\n+    global ctext entries\n+    foreach e [concat $entries $ctext] {\n \tif {$w == $e} return\n     }\n     focus .\n@@ -4565,6 +4565,7 @@ proc sellastline {} {\n\n proc selnextline {dir} {\n     global selectedline\n+    focus .\n     if {![info exists selectedline]} return\n     set l [expr {$selectedline + $dir}]\n     unmarkmatches\n@@ -4645,6 +4646,7 @@ proc godo {elt} {\n\n proc goback {} {\n     global history historyindex\n+    focus .\n\n     if {$historyindex > 1} {\n \tincr historyindex -1\n@@ -4658,6 +4660,7 @@ proc goback {} {\n\n proc goforw {} {\n     global history historyindex\n+    focus .\n\n     if {$historyindex < [llength $history]} {\n \tset cmd [lindex $history $historyindex]\n--\n1.5.3.rc4.25.gade7b9\n"},{"id":"50162","messageId":"11865372381125-git-send-email-mdl123@verizon.net","threadId":"9412","inReplyTo":"11865372352543-git-send-email-mdl123@verizon.net","subject":"[PATCH] gitk - Handle MouseWheel events on Windows","fromName":"Mark Levedahl","fromEmail":"mdl123@verizon.net","sentAt":"2007-08-08T01:40:35Z","receivedAt":"2007-08-08T01:40:35Z","isPatch":true,"sender":{"key":"mdl123@verizon.net","avatar":"https://avatars.githubusercontent.com/u/5302462?v=4"},"body":"Windows, unlike X-Windows, sends mousewheel events by default to the\nwindow that has keyboard focus and uses the MouseWheel event to do so.\nThe window to be scrolled must be able to take focus, but gitk's panels\nare disabled so cannot take focus. For all these reasons, a different\ndesign is needed to use the mousewheel on Windows. The approach here is\nto bind the mousewheel events to the top level window and redirect them\nbased upon the current mouse position.\n\nSigned-off-by: Mark Levedahl <mdl123@verizon.net>\n---\n\nThis version is a slight clean-up of the original, collapsing two\nif/else blocks into a single conditional assignment.\n\n gitk |   27 +++++++++++++++++++++++++--\n 1 files changed, 25 insertions(+), 2 deletions(-)\n\ndiff --git a/gitk b/gitk\nindex 84f5ee4..eb2b194 100755\n--- a/gitk\n+++ b/gitk\n@@ -823,8 +823,13 @@ proc makewindow {} {\n     pack .ctop -fill both -expand 1\n     bindall <1> {selcanvline %W %x %y}\n     #bindall <B1-Motion> {selcanvline %W %x %y}\n-    bindall <ButtonRelease-4> \"allcanvs yview scroll -5 units\"\n-    bindall <ButtonRelease-5> \"allcanvs yview scroll 5 units\"\n+    if {[tk windowingsystem] == \"win32\"} {\n+\tbind . <MouseWheel> { windows_mousewheel_redirector %W %X %Y %D }\n+\tbind $ctext <MouseWheel> { windows_mousewheel_redirector %W %X %Y %D ; break }\n+    } else {\n+\tbindall <ButtonRelease-4> \"allcanvs yview scroll -5 units\"\n+\tbindall <ButtonRelease-5> \"allcanvs yview scroll 5 units\"\n+    }\n     bindall <2> \"canvscan mark %W %x %y\"\n     bindall <B2-Motion> \"canvscan dragto %W %x %y\"\n     bindkey <Home> selfirstline\n@@ -918,6 +923,24 @@ proc makewindow {} {\n \t-command rmbranch\n }\n\n+# Windows sends all mouse wheel events to the current focused window, not\n+# the one where the mouse hovers, so bind those events here and redirect\n+# to the correct window\n+proc windows_mousewheel_redirector {W X Y D} {\n+    global canv canv2 canv3\n+    set w [winfo containing -displayof $W $X $Y]\n+    if {$w ne \"\"} {\n+\tset u [expr {$D < 0 ? 5 : -5}]\n+\tif {$w == $canv || $w == $canv2 || $w == $canv3} {\n+\t    allcanvs yview scroll $u units\n+\t} else {\n+\t    catch {\n+\t\t$w yview scroll $u units\n+\t    }\n+\t}\n+    }\n+}\n+\n # mouse-2 makes all windows scan vertically, but only the one\n # the cursor is in scans horizontally\n proc canvscan {op w x y} {\n--\n1.5.3.rc4.25.gade7b9\n"},{"id":"50478","messageId":"46BDAA49.40802@verizon.net","threadId":"9412","inReplyTo":"11865372381125-git-send-email-mdl123@verizon.net","subject":"Re: [PATCH] gitk - Handle MouseWheel events on Windows","fromName":"Mark Levedahl","fromEmail":"mdl123@verizon.net","sentAt":"2007-08-11T12:23:37Z","receivedAt":"2007-08-11T12:23:37Z","isPatch":true,"sender":{"key":"mdl123@verizon.net","avatar":"https://avatars.githubusercontent.com/u/5302462?v=4"},"body":"Ping - any chance of getting these two patches into 1.5.3? They fix a \npair of long-standing frustrations for\nCygwin (and now msys/Windows) users:\n\n[PATCH] gitk - enable selected patch text on Windows\n[PATCH] gitk - Handle MouseWheel events on Windows\n\nMark\n"},{"id":"50485","messageId":"6F740E93-EE08-4CBD-9E8E-1E891D82A30B@zib.de","threadId":"9412","inReplyTo":"46BDAA49.40802@verizon.net","subject":"Re: [PATCH] gitk - Handle MouseWheel events on Windows","fromName":"Steffen Prohaska","fromEmail":"prohaska@zib.de","sentAt":"2007-08-11T16:58:06Z","receivedAt":"2007-08-11T16:58:06Z","isPatch":true,"sender":{"key":"prohaska@zib.de","avatar":"https://avatars.githubusercontent.com/u/217580?v=4"},"body":"\nOn Aug 11, 2007, at 2:23 PM, Mark Levedahl wrote:\n\n> Ping - any chance of getting these two patches into 1.5.3? They fix  \n> a pair of long-standing frustrations for\n> Cygwin (and now msys/Windows) users:\n>\n> [PATCH] gitk - enable selected patch text on Windows\n> [PATCH] gitk - Handle MouseWheel events on Windows\n\nBoth work for me in msysgit.\n\nWould be really, really nice to have them. Missing copy\ntext from gitk is a bug in my opinion, which is fixed\nby the first patch. Support for MouseWheel is also nice\nto have.\n\n\tSteffen\n"}]}