Bug 545073 - [GTK] MouseNavigation pastes text on middle click
Summary: [GTK] MouseNavigation pastes text on middle click
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.11   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Laurent CARON CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2019-03-05 09:27 EST by Eric Williams CLA
Modified: 2020-02-20 06:22 EST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Williams CLA 2019-03-05 09:27:49 EST
When using a StyledText with MouseNavigation enabled, clicking the middle mouse button will paste the contents of the clipboard into the StyledText widget. This is undesired behaviour -- the middle mouse button should only scroll and not modify the contents of the widget.
Comment 1 Sravan Kumar Lakkimsetti CLA 2019-03-05 23:09:13 EST
In Gnome the middle button is used for paste operation. This causing undesired behaviour for eclipse. I see two options for us

1. Disable paste operation on mouse middle button click in GUI. users can use right click paste for paste operation
2. Clear clipboard when we enable mouse navigator

The second one will cover only half of the cases. We should go with the first option. We should disable paste operation on linux on middle button click on linux
Comment 2 Thomas Wolf CLA 2019-03-06 02:18:00 EST
Only if MouseNavigation is enabled, please.
Comment 3 Andrey Loskutov CLA 2019-03-06 02:48:13 EST
(In reply to Sravan Kumar Lakkimsetti from comment #1)
> In Gnome the middle button is used for paste operation. This causing
> undesired behaviour for eclipse. I see two options for us
> 
> 1. Disable paste operation on mouse middle button click in GUI. users can
> use right click paste for paste operation

This would be a no-go for long term Linux users (me and my lab). Middle click is *the* killer feature on Linux.

> 2. Clear clipboard when we enable mouse navigator
> 
> The second one will cover only half of the cases. We should go with the
> first option. We should disable paste operation on linux on middle button
> click on linux

Not sure if this is meant only *during* the mouse navigation in StyledText? Could you elaborate a bit more, how exactly you plan to disable the mouse middle button click, and if this will mean, usual text editing in Java code will have no "paste on middle click" feature *at all*? In this case I strongly disagree.
Comment 4 Sravan Kumar Lakkimsetti CLA 2019-03-06 03:00:04 EST
(In reply to Andrey Loskutov from comment #3)
> (In reply to Sravan Kumar Lakkimsetti from comment #1)
> > In Gnome the middle button is used for paste operation. This causing
> > undesired behaviour for eclipse. I see two options for us
> > 
> > 1. Disable paste operation on mouse middle button click in GUI. users can
> > use right click paste for paste operation
> 
> This would be a no-go for long term Linux users (me and my lab). Middle
> click is *the* killer feature on Linux.
> 
> > 2. Clear clipboard when we enable mouse navigator
> > 
> > The second one will cover only half of the cases. We should go with the
> > first option. We should disable paste operation on linux on middle button
> > click on linux
> 
> Not sure if this is meant only *during* the mouse navigation in StyledText?
> Could you elaborate a bit more, how exactly you plan to disable the mouse
> middle button click, and if this will mean, usual text editing in Java code
> will have no "paste on middle click" feature *at all*? In this case I
> strongly disagree.

We have to enable mouse navigation using an api. My suggestion is when we enable mouse navigation we need to "disable paste on middle click" for that widget. 

We should not disable paste operation on other widgets.
Comment 5 Andrey Loskutov CLA 2019-03-06 03:14:23 EST
(In reply to Sravan Kumar Lakkimsetti from comment #4)
> We have to enable mouse navigation using an api. My suggestion is when we
> enable mouse navigation we need to "disable paste on middle click" for that
> widget. 

But this will mean, that if text editors start using mouse navigation, they will stop supporting "paste on middle click". So we accept a breaking change to support a "nice to have" feature.

Do I understand it right, "middle click" is the hard-coded shortcut to enable this mouse navigation? Can't we configure that, or at least allow user to disable that shortcut which changes default system behavior?

Can you please link this bug to the one where the "mouse navigation" feature was introduced?
Comment 6 Sravan Kumar Lakkimsetti CLA 2019-03-06 03:56:59 EST
(In reply to Andrey Loskutov from comment #5)
> (In reply to Sravan Kumar Lakkimsetti from comment #4)
> > We have to enable mouse navigation using an api. My suggestion is when we
> > enable mouse navigation we need to "disable paste on middle click" for that
> > widget. 
> 
> But this will mean, that if text editors start using mouse navigation, they
> will stop supporting "paste on middle click". So we accept a breaking change
> to support a "nice to have" feature.
> 
> Do I understand it right, "middle click" is the hard-coded shortcut to
> enable this mouse navigation? Can't we configure that, or at least allow
> user to disable that shortcut which changes default system behavior?
> 
> Can you please link this bug to the one where the "mouse navigation" feature
> was introduced?

Very good points here. Configuring the shortcut may be a good idea.

@laurent what do you think?
Comment 7 Andrey Loskutov CLA 2019-03-06 04:15:05 EST
Just found bug 544616 for preferences.
Comment 8 Eric Williams CLA 2019-03-06 08:57:16 EST
If MouseNavigation is enabled then middle click will be meant for bringing up the navigation icon...not pasting. We had a working fix before, and it was to block the paste action in StyledText upon middle button mouse down.

IMO Andrey's idea is best, just allow users to enable/disable MouseNavigation for editors in some preference, and then we can keep the middle click paste for those who want it. I think MouseNavigation should be disabled by default, that way we don't break middle click pasting for all those who use it.
Comment 9 Laurent CARON CLA 2019-03-06 11:08:57 EST
Well, when I worked on this feature I did not think about the "copy with middle click" behaviour :(

I can see 2 solutions for this problem :

a) On linux, activate the mouse scrolling only if a key is pressed (for example shift+middle click)


b) Or enable the "mouse navigation" only if a "longer click" is fired. 
     * If the user clicks quickly on the middle button, the content of the clipboard is pasted
     * If the user clicks more than 100 ms the "navigation cross" is displayed and the user can scroll through the StyledText

Solution a) is pretty easy to implement (with state mask) but in this case users can be puzzled when switching operating system (activation by clicking on the middle button on mac & windows and shift+middle button on Linux)

What do you think ?
Comment 10 Andrey Loskutov CLA 2019-03-06 11:29:46 EST
(In reply to Laurent CARON from comment #9)
> Well, when I worked on this feature I did not think about the "copy with
> middle click" behaviour :(

Sorry, I've missed to check the new feature completely.

> Solution a) is pretty easy to implement (with state mask) but in this case
> users can be puzzled when switching operating system (activation by clicking
> on the middle button on mac & windows and shift+middle button on Linux)
> 
> What do you think ?

I think the "delay" sounds interesting, but I personally also have no problems with extra keys. The question is if we can really prevent "paste" to happen then?
Comment 11 Laurent CARON CLA 2019-03-06 11:39:37 EST
Thanks to the state mask, we can "cancel" the paste event in StyledText if shift key if pressed.

Anyway, it can be weird for users because this functionality mimics the "mouse navigation" of Chrome and Firefox but users will have to press a key...

I'll work on the "delay" solution. Stay tuned !
Comment 12 Eclipse Genie CLA 2019-03-07 15:32:52 EST
New Gerrit change created: https://git.eclipse.org/r/138301
Comment 14 Eric Williams CLA 2019-04-05 09:30:06 EDT
(In reply to Eclipse Genie from comment #13)
> Gerrit change https://git.eclipse.org/r/138301 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=84153c9002a622b5a8568e5f5a4914d93cffa6ad

In master now, leaving this bug open for the Wayland portions that still need fixing.
Comment 15 Sravan Kumar Lakkimsetti CLA 2019-04-08 22:48:31 EDT
(In reply to Eric Williams from comment #14)
> (In reply to Eclipse Genie from comment #13)
> > Gerrit change https://git.eclipse.org/r/138301 was merged to [master].
> > Commit:
> > http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> > ?id=84153c9002a622b5a8568e5f5a4914d93cffa6ad
> 
> In master now, leaving this bug open for the Wayland portions that still
> need fixing.

Verified in I20190408-1800 on Suse Leap 15 with Java 12
Comment 16 Sravan Kumar Lakkimsetti CLA 2019-04-09 00:14:28 EDT
Verified in I20190408-1800 on Ubuntu 18.04 with Java 12
Comment 17 Laurent CARON CLA 2020-02-20 06:22:16 EST
We still have a problem on X11 (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=545041) => I close this bug and work on bug 545 041.

Please reopen if I did wrong.