Author Topic: Highlight disappears when using mouse drag scroll with right key  (Read 8007 times)

Offline Quiss

  • Multiple posting newcomer
  • *
  • Posts: 76
Highlight disappears when using mouse drag scroll with right key
« on: September 06, 2018, 02:05:03 pm »
- Select "Mouse Key To Use: Right" in Settings-Editor-Mouse Drag Scrolling
- Double click (or select) some repeating word like "std" or "vector" in a file. All "std" highlighted.
- Hold and move (up or down) right key of mouse to scroll. As soon as right key down, highlights disappear.
- Scrolling with mouse wheel ok.
- Using mouse drag scroll with "middle key" instead of "right key" ok. Unfortunatelly I've been using right key :(.

Windows 10, wx3.0.4, svn 11454.

11395 has this problem.
11317 doesn't have this problem.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Highlight disappears when using mouse drag scroll with right key
« Reply #1 on: September 06, 2018, 03:14:38 pm »
There is a big gab between your revisions. Can you do a bisect and tell us which revision broke this?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Quiss

  • Multiple posting newcomer
  • *
  • Posts: 76
Re: Highlight disappears when using mouse drag scroll with right key
« Reply #2 on: September 07, 2018, 08:12:49 am »
11334 has this problem.
11321 does not.

The revisions between them can't be built. I think 11334 fixed error:
Code
In file included from F:\cb\codeblocks_sf\src\sdk\wxscintilla\src\ScintillaWX.cpp:51:0:
F:\cb\codeblocks_sf\src\sdk\wxscintilla\src\ScintillaWX.cpp: In member function 'bool ScintillaWX::CreateSystemCaret()':
F:\cb\codeblocks_sf\src\sdk\wxscintilla\src\ScintillaWX.cpp:737:27: error: 'sci' was not declared in this scope
     ::ShowCaret(GetHwndOf(sci));
                           ^
F:\wxWidgets-3.0.4\include/wx/msw/private.h:824:42: note: in definition of macro 'GetHwndOf'
 #define GetHwndOf(win)          ((HWND)((win)->GetHWND()))
                                          ^
F:\cb\codeblocks_sf\src\sdk\wxscintilla\src\ScintillaWX.cpp: In member function 'bool ScintillaWX::DestroySystemCaret()':
F:\cb\codeblocks_sf\src\sdk\wxscintilla\src\ScintillaWX.cpp:748:31: error: 'sci' was not declared in this scope
         ::HideCaret(GetHwndOf(sci));
                               ^
F:\wxWidgets-3.0.4\include/wx/msw/private.h:824:42: note: in definition of macro 'GetHwndOf'
 #define GetHwndOf(win)          ((HWND)((win)->GetHWND()))

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Highlight disappears when using mouse drag scroll with right key
« Reply #3 on: September 07, 2018, 11:15:53 am »
OK, it seems the update of scintilla has caused this.
Unfortunately I cannot reproduce this on my linux, but I had to increase the time for detection of unix context menu.

Does right clicking in the editor clear the selection for you?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Quiss

  • Multiple posting newcomer
  • *
  • Posts: 76
Re: Highlight disappears when using mouse drag scroll with right key
« Reply #4 on: September 07, 2018, 11:28:48 am »
Yes. But when you right click and "release" button (right click menu pops up), both versions clear the selection.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Highlight disappears when using mouse drag scroll with right key
« Reply #5 on: September 07, 2018, 11:51:39 am »
Do you see selection clear only on right button down (if you press and hold the button)?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Quiss

  • Multiple posting newcomer
  • *
  • Posts: 76
Re: Highlight disappears when using mouse drag scroll with right key
« Reply #6 on: September 07, 2018, 11:56:40 am »
Yes, if you press and hold, selection cleared. It has nothing to do with drag scroll then?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Highlight disappears when using mouse drag scroll with right key
« Reply #7 on: September 07, 2018, 12:13:31 pm »
No, idea, someone has to debug why this happens.
On linux if I press and hold the selection doesn't clear.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Quiss

  • Multiple posting newcomer
  • *
  • Posts: 76
Re: Highlight disappears when using mouse drag scroll with right key
« Reply #8 on: September 07, 2018, 01:38:06 pm »
Ok, I've built a fresh one without drag scroll (and without any other contrib plugins), the problem still exists.

One other thing: If you right click and hold onto the initial selection you've made, it's NOT cleared.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Highlight disappears when using mouse drag scroll with right key
« Reply #9 on: September 07, 2018, 02:45:25 pm »
One thing you could try is build wxwidgets and the stc sample and try to see if this selection behaviour happens there. If it doesn't then it is something caused by C::B.

A simpler thing is probably testing if this same thing happens in scite.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Highlight disappears when using mouse drag scroll with right key
« Reply #10 on: September 07, 2018, 07:37:37 pm »
i try to look into it. Things i can say so far:
1) The problem is that the selection gets reseted after pressing the right mouse button.
1.1) Normal would be to reset the selection after the release of the mouse button
2) This does not happen before the scintilla update as OP posted the failing revision
3) The wxWidgets 3.0.4 STC sample does not show this behavior --> The selection is not cleared after clicking the right mouse button
4) The selection is not cleared if the right click occurs on top of the selection and the context menu pops open...

i don't know where to search... is this a miss fired event?
I have no contrib plugins activated (only mouse drag and the provided plugins)
« Last Edit: September 07, 2018, 07:39:19 pm by BlueHazzard »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Highlight disappears when using mouse drag scroll with right key
« Reply #11 on: September 07, 2018, 07:49:12 pm »
Probably put a breakpoint in the scintilla calls which handle selections and see why are they called on right-down instead of right-up/press.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Highlight disappears when using mouse drag scroll with right key
« Reply #12 on: September 07, 2018, 07:56:18 pm »
some small update
i can observe that in the old version a wxEVT_SCI_MODIFIED event is fired on the right button release, on the new version on the right button press...

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Highlight disappears when using mouse drag scroll with right key
« Reply #13 on: September 07, 2018, 10:29:10 pm »
I don't see a modified event posted on right click (on linux).
Can you post the full callstack? What is happening in the modified handler?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Highlight disappears when using mouse drag scroll with right key
« Reply #14 on: September 07, 2018, 11:21:14 pm »
not quite sure if this is the culprit...

Code
[debug]#0  cbEditor::OnScintillaEvent (this=0x1828eb80, event=...) at [...]\codeblocks_sf\src\sdk\cbeditor.cpp:3441
[debug]#1  0x035b5a91 in cbEditor::OnEditorModified (this=0x1828eb80, event=...) at [...]\codeblocks_sf\src\sdk\cbeditor.cpp:3363
[debug]#2  0x0c454074 in wxAppConsoleBase::HandleEvent (this=0x3187a60, handler=0x1828eb80, func=(void (wxEvtHandler::*)(wxEvtHandler * const, wxEvent &)) 0x35b57f4 <cbEditor::OnEditorModified(wxScintillaEvent&)>, event=...) at ../../src/common/appbase.cpp:611
[debug]#3  0x0c4540d0 in wxAppConsoleBase::CallEventHandler (this=0x3187a60, handler=0x1828eb80, functor=..., event=...) at ../../src/common/appbase.cpp:623
[debug]#4  0x0c576f8d in wxEvtHandler::ProcessEventIfMatchesId (entry=..., handler=0x1828eb80, event=...) at ../../src/common/event.cpp:1390
[debug]#5  0x0c577bf8 in wxEvtHandler::SearchDynamicEventTable (this=0x1828eb80, event=...) at ../../src/common/event.cpp:1749
[debug]#6  0x0c57742b in wxEvtHandler::TryHereOnly (this=0x1828eb80, event=...) at ../../src/common/event.cpp:1583
[debug]#7  0x0cd6b70c in wxEvtHandler::TryBeforeAndHere (this=0x1828eb80, event=...) at ../../include/wx/event.h:3671
[debug]#8  0x0c577263 in wxEvtHandler::ProcessEventLocally (this=0x1828eb80, event=...) at ../../src/common/event.cpp:1520
[debug]#9  0x0c577204 in wxEvtHandler::ProcessEvent (this=0x1828eb80, event=...) at ../../src/common/event.cpp:1493
[debug]#10 0x0c7aa42a in wxWindowBase::TryAfter (this=0x201c2120, event=...) at ../../src/common/wincmn.cpp:3427
[debug]#11 0x0c57722f in wxEvtHandler::ProcessEvent (this=0x201c2120, event=...) at ../../src/common/event.cpp:1506
[debug]#12 0x03714135 in wxScintilla::NotifyParent (this=0x201c2120, _scn=0x28db5c) at [...]\codeblocks_sf\src\sdk\wxscintilla\src\wxscintilla.cpp:5666
[debug]#13 0x0371777d in ScintillaWX::NotifyParent (this=0x204d1ea0, scn=...) at [...]\codeblocks_sf\src\sdk\wxscintilla\src\ScintillaWX.cpp:498
[debug]#14 0x037d0daa in Editor::NotifyModified (this=0x204d1ea0, mh=...) at [...]\codeblocks_sf\src\sdk\wxscintilla\src\scintilla\src\Editor.cxx:2706
[debug]#15 0x038130b7 in Document::NotifyModified (this=0x204d2698, mh=...) at [...]\codeblocks_sf\src\sdk\wxscintilla\src\scintilla\src\Document.cxx:2331
[debug]#16 0x03812cf6 in Document::DecorationFillRange(int, int, int)@16 (this=0x204d2698, position=39, value=0, fillLength=2101) at [...]\codeblocks_sf\src\sdk\wxscintilla\src\scintilla\src\Document.cxx:2288
[debug]#17 0x037e609d in Editor::WndProc (this=0x204d1ea0, iMessage=2505, wParam=0, lParam=2215) at [...]\codeblocks_sf\src\sdk\wxscintilla\src\scintilla\src\Editor.cxx:7458
[debug]#18 0x037eeb1c in ScintillaBase::WndProc (this=0x204d1ea0, iMessage=2505, wParam=0, lParam=2215) at [...]\codeblocks_sf\src\sdk\wxscintilla\src\scintilla\src\ScintillaBase.cxx:1086
[debug]#19 0x03718fed in ScintillaWX::WndProc (this=0x204d1ea0, iMessage=2505, wParam=0, lParam=2215) at [...]\codeblocks_sf\src\sdk\wxscintilla\src\ScintillaWX.cpp:889
[debug]#20 0x03704e39 in wxScintilla::SendMsg (this=0x201c2120, msg=2505, wp=0, lp=2215) at [...]\codeblocks_sf\src\sdk\wxscintilla\src\wxscintilla.cpp:260
[debug]#21 0x0370dc2c in wxScintilla::IndicatorClearRange (this=0x201c2120, start=0, lengthClear=2215) at [...]\codeblocks_sf\src\sdk\wxscintilla\src\wxscintilla.cpp:3800
[debug]#22 0x70a42547 in Highlighter::HighlightOccurrencesOfSelection (this=0x20369c48, ctrl=0x1828eb80) at [...]\codeblocks_sf\src\plugins\occurrenceshighlighting\highlighter.cpp:314
[debug]#23 0x70a4143b in Highlighter::Call (this=0x20369c48, ctrl=0x1828eb80, event=...) at [...]\codeblocks_sf\src\plugins\occurrenceshighlighting\highlighter.cpp:54
[debug]#24 0x70a45e57 in OccurrencesHighlighting::OnEditorHook (this=0x18cb41a8, editor=0x1828eb80, event=...) at [...]\codeblocks_sf\src\plugins\occurrenceshighlighting\occurrenceshighlighting.cpp:352
[debug]#25 0x70a88e10 in EditorHooks::HookFunctor<OccurrencesHighlighting>::Call (this=0x1fe8a860, editor=0x1828eb80, event=...) at include/editor_hooks.h:61
[debug]#26 0x0362567f in EditorHooks::CallHooks (editor=0x1828eb80, event=...) at [...]\codeblocks_sf\src\sdk\editor_hooks.cpp:122
[debug]#27 0x035b648f in cbEditor::OnScintillaEvent (this=0x1828eb80, event=...) at [...]\codeblocks_sf\src\sdk\cbeditor.cpp:3464
[debug]#28 0x035b4a4d in cbEditor::OnEditorUpdateUI (this=0x1828eb80, event=...) at [...]\codeblocks_sf\src\sdk\cbeditor.cpp:3181
[debug]#29 0x0c454074 in wxAppConsoleBase::HandleEvent (this=0x3187a60, handler=0x1828eb80, func=(void (wxEvtHandler::*)(wxEvtHandler * const, wxEvent &)) 0x35b4966 <cbEditor::OnEditorUpdateUI(wxScintillaEvent&)>, event=...) at ../../src/common/appbase.cpp:611
still debugging..

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Highlight disappears when using mouse drag scroll with right key
« Reply #15 on: September 07, 2018, 11:55:01 pm »
You're missing frames. Type bt in the debugger console to see the real reason why this has happened.
But if your source code is the same as mine - there is either updateui or paint event causing this. :(
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Highlight disappears when using mouse drag scroll with right key
« Reply #16 on: September 08, 2018, 12:03:56 am »
Ok... found something:
in sdk/wxsintilla/src/scintillawx.cpp:1071
Code
void ScintillaWX::DoRightButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt) {
    if (!PointInSelection(pt)) {
        CancelModes();
        SetEmptySelection(PositionFromLocation(pt));
    }

    RightButtonDownWithModifiers(pt, curTime, ModifierFlags(shift, ctrl, alt));
}
the selection is set to empty...

this seems to be a bug, but why does it work on linux? For me there should be a DoRightButtonUp...

[EDIT:]
This was introduced in the update to 3.7.2: https://github.com/wxWidgets/wxWidgets/pull/409/commits/2da2b9339663e5df2eaf03eaa444953d4425ca0a#diff-dea3c61f771e11ad01faf0c2c35da760
« Last Edit: September 08, 2018, 12:56:06 am by BlueHazzard »

Offline New Pagodi

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: Highlight disappears when using mouse drag scroll with right key
« Reply #17 on: September 08, 2018, 01:26:32 am »
I'm pretty sure I did this.  To the best of my recollection, the right mouse stuff was added in order to be able to handle the new MARGIN_RIGHT_CLICK notification that was added between whatever the previous version of Scintilla was and 3.72.

I think that function was basically adapted for the wx Platform from the windows platform code included with the Scintilla source
(ScintillaWin.cxx lines 1421-1433) and looks like this:

Code
sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
...
case WM_RBUTTONDOWN: {
::SetFocus(MainHWND());
Point pt = Point::FromLong(static_cast<long>(lParam));
if (!PointInSelection(pt)) {
CancelModes();
SetEmptySelection(PositionFromLocation(Point::FromLong(static_cast<long>(lParam))));
}

RightButtonDownWithModifiers(pt, ::GetMessageTime(), ModifierFlags((wParam & MK_SHIFT) != 0,
      (wParam & MK_CONTROL) != 0,
      Platform::IsKeyDown(VK_MENU)));
}
break;

The code for the GTK+ platform is similar (ScintillaGTK.cxx lines 1703-1724)

Code
		
gint ScintillaGTK::PressThis(GdkEventButton *event) {
....
} else if (event->button == 3) {
if (!PointInSelection(pt))
SetEmptySelection(PositionFromLocation(pt));
if (ShouldDisplayPopup(pt)) {
// PopUp menu
// Convert to screen
int ox = 0;
int oy = 0;
gdk_window_get_origin(PWindow(wMain), &ox, &oy);
ContextMenu(Point(pt.x + ox, pt.y + oy));
} else {
#if PLAT_GTK_MACOSX
bool meta = ctrl;
// GDK reports the Command modifer key as GDK_MOD2_MASK for button events,
// not GDK_META_MASK like in key events.
ctrl = (event->state & GDK_MOD2_MASK) != 0;
#else
bool meta = false;
#endif
RightButtonDownWithModifiers(pt, event->time, ModifierFlags(shift, ctrl, alt, meta));
return FALSE;
}

So I think the code from scintillawx.cpp is an accurate translation of the intended Scintilla behavior to the wx world.  It's just that it was lacking before because no one had handled the right down event prior to updating to 3.72 because nothing else used by wxSTC needed it.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Highlight disappears when using mouse drag scroll with right key
« Reply #18 on: September 08, 2018, 01:40:28 am »
Quote
I'm pretty sure I did this.  To the best of my recollection, the right mouse stuff was added in order to be able to handle the new MARGIN_RIGHT_CLICK notification that was added between whatever the previous version of Scintilla was and 3.72.
i am really not into the Scintilla code. And i don't know what the MARGIN_RIGHT_CLICK  is used for, and if codeblocks uses it. It is quite late now and i wanted to test this so i made this quick and DIRTY patch against the codeblocks code. So far all seems to work as it should.. I can right click without deleting the selection and for this the scrolling works as expected... I can right click and i get all context menus as expected (as far as i was able to test)...

Code
diff --git a/src/sdk/wxscintilla/src/ScintillaWX.cpp b/src/sdk/wxscintilla/src/ScintillaWX.cpp
index 4a56368f1..6ed963fe4 100644
--- a/src/sdk/wxscintilla/src/ScintillaWX.cpp
+++ b/src/sdk/wxscintilla/src/ScintillaWX.cpp
@@ -1069,12 +1069,14 @@ void ScintillaWX::DoLeftButtonDown(Point pt, unsigned int curTime, bool shift, b
 }
 
 void ScintillaWX::DoRightButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt) {
+    RightButtonDownWithModifiers(pt, curTime, ModifierFlags(shift, ctrl, alt));
+}
+
+void ScintillaWX::DoRightButtonUp(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt) {
     if (!PointInSelection(pt)) {
         CancelModes();
         SetEmptySelection(PositionFromLocation(pt));
     }
-
-    RightButtonDownWithModifiers(pt, curTime, ModifierFlags(shift, ctrl, alt));
 }
 
 void ScintillaWX::DoLeftButtonUp(Point pt, unsigned int curTime, bool ctrl) {
diff --git a/src/sdk/wxscintilla/src/ScintillaWX.h b/src/sdk/wxscintilla/src/ScintillaWX.h
index dae8d453d..ff8a1fd5e 100644
--- a/src/sdk/wxscintilla/src/ScintillaWX.h
+++ b/src/sdk/wxscintilla/src/ScintillaWX.h
@@ -173,6 +173,7 @@ public:
     void DoSysColourChange();
     void DoLeftButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt);
     void DoRightButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt);
+    void DoRightButtonUp(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt);
     void DoLeftButtonUp(Point pt, unsigned int curTime, bool ctrl);
     void DoLeftButtonMove(Point pt);
     void DoMiddleButtonUp(Point pt);
diff --git a/src/sdk/wxscintilla/src/wxscintilla.cpp b/src/sdk/wxscintilla/src/wxscintilla.cpp
index 9c86ae0e5..50ae43d6e 100644
--- a/src/sdk/wxscintilla/src/wxscintilla.cpp
+++ b/src/sdk/wxscintilla/src/wxscintilla.cpp
@@ -5305,6 +5305,8 @@ void wxScintilla::OnMouseLeftUp(wxMouseEvent& evt) {
 
 void wxScintilla::OnMouseRightUp(wxMouseEvent& evt) {
     wxPoint pt = evt.GetPosition();
+    m_swx->DoRightButtonUp(Point(pt.x, pt.y), m_stopWatch.Time(),
+                      evt.ShiftDown(), evt.ControlDown(), evt.AltDown());
     m_swx->DoContextMenu(Point(pt.x, pt.y));
 }
 

I really have not looked deep into the code to see what the functions do... so no guarantee for whatever...

Offline Quiss

  • Multiple posting newcomer
  • *
  • Posts: 76
Re: Highlight disappears when using mouse drag scroll with right key
« Reply #19 on: September 10, 2018, 08:26:09 am »
@BlueHazzard

I applied your patch on svn11454. I've been using it since then and it's ok. Thank you.

MARGIN_RIGHT_CLICK event defined in wxscintilla.cpp (line: 131) but never used.

Edit: Ok, there is a commit for DragScroll (svn11455 actually), it fixes the issue without modifying wxscintilla: https://github.com/obfuscated/codeblocks_sf/commit/40e313df4f7ffd7d4bcdb9bdc538e1377c1e2717

That's probably why oBFusCATed can't reproduce the issue in the first place.
« Last Edit: September 10, 2018, 10:07:49 am by Quiss »