das-developers / das2java

The original das2 library. Provides interactive publication-ready 2-D plotting
https://das2.org
GNU Lesser General Public License v3.0
4 stars 0 forks source link

When using multiple displays, vertical and horizontal slices of a spectrogram snap back to their original display #96

Closed DiamondJim87 closed 5 months ago

DiamondJim87 commented 5 months ago

A user has pointed out a very user un-friendly aspect of the horizontal and vertical slice tools Das provides on spectrograms if one is using multiple monitors. Suppose you have a DasCanvas with a spectrogram, and you right-click and create a horizontal slice. Then you move that slice window to a different monitor, and position it lovingly just where you want it. Now you return to the spectrogram to fine-tune which slice you are seeing. As soon as you click anywhere on the spectrogram, the whole horizontal slice window jumps back to the primary display.

I found that if I comment out the following line in HorizontalSpectrogramSlicer.showSlice( QDataSet tds, Datum xValue, Datum yValue ) (around line 488):

     popupWindow.setLocation( r.x, r.y );

this behavior stops and there seem to be no ill effects from not resetting the location. If the intention here is to ensure that the slice window jumps to the top if it somehow was covered up, I would expect popupWindow.toFront() to accomplish that without changing its position.

Would this be an acceptable change? (Replacing the setLocation call with toFront()?)

A related behavior that is not so critical to change is that when the slice window first appears, it shows up on the primary display even if the spectrogram window is on some other display. If it is not difficult, it would be great if the slice would appear on whichever display the spectrogram window is shown on. But I don't know how to do that without digging a little further.

jbfaden commented 5 months ago

This sounds fine to me, especially if the behavior is inconsistent between slice types. There was a goal to have the initial position be close to the sliced plot, but I agree that additional events it receives should not move it from its current position. If there is a stack of three plots, slicing each should initially locate a slice window next to each of the plots.

DiamondJim87 commented 5 months ago

To clarify: both horizontal and vertical slices behave the same way. I understand and like the intent to have the slice close to the original plot -- in fact that desirable behavior doesn't work if the original plot is on a secondary display.

jbfaden commented 5 months ago

I think this is a problem with Java versions and window systems. There's a function "verifyVisible" which is misfiring in your case, I believe. It thinks the window is outsize of the screens, so it's fixing it for you.

jbfaden commented 5 months ago

See https://github.com/das-developers/das2java/blob/c71e3f3fa69fd268039d6474079975c55ff9ffce/dasCore/src/org/das2/components/ComponentsUtil.java#L94

DiamondJim87 commented 5 months ago

Jeremy and I did this one on a zoom. The problem occurred if the displays were oriented such that one had negative coordinates.