microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.38k stars 28.94k forks source link

Middleclick in Ubuntu Unity Launcher does not open a new window #17669

Closed jacob3141 closed 7 years ago

jacob3141 commented 7 years ago

Steps to Reproduce:

  1. Middle-click on the Unity Launcher Icon.
  2. The load mouse indicator appears and disappears again. Then nothing happens.

This is breaking Ubuntus default behaviour of opening a new instance of the application upon a middle click. A left click brings the running app instance to the front or launches a new one (works) and a right click opens the context menu (works).

As a workaround I have to spawn a new window from the file menu each time I need a new instance, which feels really broken.

Tyriar commented 7 years ago

Duplicate https://github.com/Microsoft/vscode/issues/48

jacob3141 commented 7 years ago

@Tyriar Are you familiar with the Unity desktop and sure this is a duplicate? The other issue is about calling vscode from the command line, this one is about invoking from the Unity launcher (the default desktop launcher in Ubuntu). From reading in the post, there should just be a link to define that "code -n" is being called upon a middle click, which is not the case yet.

I was able to solve it myself. I looked into the .desktop files and notieced that Ubuntu manages the instances itself, so by default every application should assume that the default command for the launcher icon is opening a new window. I have removed the "new-window" section and added the --new-window flag as the default command. Now it behaves just like every other app. Also left-clicking the icon brings up the currently running instance to the front, just as expected.

Here is my working code.desktop:

[Desktop Entry]
Name=Visual Studio Code
Comment=Code Editing. Redefined.
GenericName=Text Editor
Exec=/usr/share/code/code --new-window %U
Icon=code
Type=Application
StartupNotify=true
StartupWMClass=Code
Categories=Utility;TextEditor;Development;IDE;
MimeType=text/plain;inode/directory;
Actions=new-window;
Keywords=vscode;

X-Desktop-File-Install-Version=0.23

Icon=code
jacob3141 commented 7 years ago

Fixed it here: https://github.com/Microsoft/vscode/pull/17699

Tyriar commented 7 years ago

Yeah I suggested something similar in https://github.com/Microsoft/vscode/issues/48#issuecomment-268616502, let's go forward with this and then try get a similar fix for Windows (which also uses middle click/shift+click) or for the CLI generally pending the discussion in #48 :+1: