peele / plantuml-preview

Atom package.
MIT License
23 stars 13 forks source link

Generating preview when Atom is fullscreen causes editor to lose focus #14

Closed michael-lawrence closed 7 years ago

michael-lawrence commented 8 years ago

I'm running Atom 1.5.4 on OS X 10.10.5 and when I have Atom in fullscreen mode and generate a diagram it causes the "Run" application to gain focus which causes the OS to switch desktops. Each time I save the file I have to CMD+tab back to Atom.

peele commented 8 years ago

I don't see this occurring with with OS X 10.11.6. Is this still an issue?

bopjiang commented 7 years ago

same issue, happens when plantuml file changed and need to compile when preview. OS X 10.11.6 Atom 1.10.2

peele commented 7 years ago

When atom is fullscreen with only one monitor, I'm seeing it switch back to the primary desktop. More then one monitor, don't see it happening.

See the java icon on the dock when saving. Never noticed that before. Generally keep the dock hidden.

I'm not sure what do look into for this but I'll do some research and experiment. Wonder if it happens when any command if called through BufferedProcess.

peele commented 7 years ago

Also happens if you run plantuml jar from fullscreen terminal with a single monitor.

eduncan911 commented 7 years ago

This is because of the freakin "splash" screen that is part of the MANIFEST of the plantuml.jar file that was added sometime in 2015 or 2016 by the PlantUML authors.

http://plantuml.sourceforge.net/qa/?qa=5403/popup-icon-disrupts-gui-use-grabbing-keyboard-window-focus&show=5404#a5404

As you can see in my reply, I've asked if they will just remove the splash image from the Manifest and publish that jar for CLI devs, like us.

And it is soooo annoying for scripting/automation tooling too.

Per the authors of PlantUML, one could pass the -splash:no option on command line.

Within this PlantUML plugin, we can add to the "Additional Java Arguments" settings: -splash:no. This gets rid of the splash screen; but, Java will still get focus itself because the -splash image actually tries to load an image named "no"!

A trick around that is to pass the -version option at the end of the cmd that executes.

The problem with that is when adding the -version flag, which forces a stdout output and disables the GUI I think, this causes Atom to display a blue info box - instead of running the command!

--

UPDATE: I removed it from the MANIFEST and it still forces the GUI focus on the next screen.

We need a way to set the -version flag and not cause Atom to display the notification box, and to execute the command.

It looks like this logic is in:

lib/plantuml-preview-view.coffee

All the way to the bottom. I don't know enough coffee script to understand why it isn't running the executable/re-rendering the file with the -version flag set.

This means this Issue can now be considered a bug/fix.

--

UPDATE 2:

Ok, the Notification dialog is still annoying and should be removed from this plugin when using -version flag, because this seems to be the only way to get rid of the GUI focus issue.

So the issue in the first UPDATE above may have the correct logic and attempt to execute the file ok, and may display the results. (we just don't know yet)

But... PlantUML doesn't seem to be generating the file itself when passing in the -version flag. Not sure if it is a bug in that, or with their -output setting with -version or what...

I've opened some forum discussions on it. Will update again.

eduncan911 commented 7 years ago

FIXED!!!!!!!!

The solution is to add this to the "Additional Java Arguments" setting with this plugin:

-Djava.awt.headless=true

So that the entire command line that gets executed looks like this:

$ /usr/bin/java -Djava.awt.headless=true -jar /usr/local/share/plantuml.jar -charset utf8 -tsvg -nbthread auto -graphvizdot /usr/local/bin/dot -output . test.pu

Confirmed with Atom 1.14.3 and Plugin version 0.12.4.

--

To the Plugin Author:

1) Could we have a Settings option called "Disabled PlantUML Splash Image"? The sub-text would be: "Should prevent the lost of focus when generating graphs."

2) Or, could you just go ahead and force this option on your command line execution?

For either option above, the functionality would be to add -Djava.awt.headless=true to the Java Additional Options.

I vote for #2 - there is NO REASON why Java should ever grab focus from our Atom development environment for generating a Preview of PlantUML.

peele commented 7 years ago

Thanks for the investigation and feedback. I'll put out an update to always add -Djava.awt.headless=true to the java arguments.

I did a quick test and did not see an issue with the argument included more than once, if someone happened to add it to the "Additional Java Arguments" field.

eduncan911 commented 7 years ago

confirmed the latest release works with and without -Djava.awt.headless=true!

thank you!