Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 335021 - [terminal] Middle mouse button copy/paste does not work with the terminal
Summary: [terminal] Middle mouse button copy/paste does not work with the terminal
Status: RESOLVED FIXED
Alias: None
Product: Target Management
Classification: Tools
Component: Terminal (show other bugs)
Version: 3.2   Edit
Hardware: All Unix All
: P3 normal (vote)
Target Milestone: 3.3 M5   Edit
Assignee: Martin Oberhuber CLA
QA Contact: Martin Oberhuber CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 300809 335408
  Show dependency tree
 
Reported: 2011-01-21 09:33 EST by Anton Leherbauer CLA
Modified: 2012-01-18 09:56 EST (History)
1 user (show)

See Also:


Attachments
Suggested fix (6.28 KB, patch)
2011-01-24 09:16 EST, Anton Leherbauer CLA
mober.at+eclipse: review-
Details | Diff
Backport fix (6.88 KB, patch)
2011-01-25 05:17 EST, Anton Leherbauer CLA
no flags Details | Diff
Backport fix (2) (6.92 KB, patch)
2011-01-25 06:57 EST, Anton Leherbauer CLA
mober.at+eclipse: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Anton Leherbauer CLA 2011-01-21 09:33:22 EST
It is not possible to paste text using the middle mouse button from the terminal somewhere outside the terminal itself.
Comment 1 Anton Leherbauer CLA 2011-01-24 09:16:51 EST
Created attachment 187421 [details]
Suggested fix

This patch adds support for the clipboard type DND.SELECTION_CLIPBOARD which is used to handle the middle mouse button copy/paste feature.
Comment 2 Martin Oberhuber CLA 2011-01-24 12:48:52 EST
Comment on attachment 187421 [details]
Suggested fix

CQ:WIND00250102 

With the change, the "paste on middle mouse button" doesn't work for me on Windows any more.

I also have a couple other concerns especially wrt backporting this to 3.2.2: 
a) In the backport, we need to live with the possibility that only tm.terminal
   gets updated but tm.terminal.view might remain the old version. That way, it
   can happen that a MouseAdapter is registered twice for the Terminal widget.
b) In the backport, some container might have expected to be able and register
   its own MouseAdapter on the Terminal Widget for handling middle click 
   differently than doing a Paste (unlikely but possible).

Can we live with this situation? Or could you come up with a different patch for the backport, perhaps at the expense of supporting the "middle button paste" only after a right-click > copy operation?

Retaining the middle button "paste" support on Windows is a must-have I think since I believe that users got used to it already. Could we, perhaps, copy into BOTH the DND.CLIPBOARD and the DND.SELECTION_CLIPBOARD style buffers ?

I believe that the other version clash possibility (of tm.terminal.view getting updated but the tm.terminal widget not getting updated) can be prohibited by forcing a narrow lower bounds on the "require-bundle" version range of terminal.view.
Comment 3 Anton Leherbauer CLA 2011-01-25 05:17:56 EST
Created attachment 187504 [details]
Backport fix

This is a backwards compatible fix which also restores the middle mouse button support on Windows.
Comment 4 Martin Oberhuber CLA 2011-01-25 05:39:48 EST
The new patch looks mostly OK, I'm only concerned about introducing the Platform-specific code. We won't be able to test on all Platforms (eg Mac) so there is a small risk of introducing a regression.

In TerminalViewConnection, could you try 

  getContents(textTransfer, DND.CLIPBOARD | DND.SELECTION_CLIPBOARD)

since bitwise OR'ing the constants is allowed as per the Clipboard#getContents Javadocs. If this does what we want on both Windows and Linux, we should be good on all Platforms.
Comment 5 Anton Leherbauer CLA 2011-01-25 06:57:30 EST
Created attachment 187511 [details]
Backport fix (2)

(In reply to comment #4)
>   getContents(textTransfer, DND.CLIPBOARD | DND.SELECTION_CLIPBOARD)

This works on Windows, but under Linux/GTK the DND.CLIPBOARD is preferred over DND.SELECTION_CLIPBOARD, ie. the content from the last copy operation is used instead of the last selection event.

Attached patch now uses Clipboard.getAvailableTypes(int) to determine whether the selection clipboard is available or not.  This should work on all platforms.
Comment 6 Martin Oberhuber CLA 2011-01-25 12:13:45 EST
Patch applied - thanks!