mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-20 14:54:31 +01:00
Fix always-on-top notification popup
This commit is contained in:
parent
219e540573
commit
1a7eaaf8b2
@ -36,10 +36,14 @@ import cc.arduino.contributions.packages.filters.UpdatablePlatformPredicate;
|
||||
import cc.arduino.view.NotificationPopup;
|
||||
import processing.app.Base;
|
||||
import processing.app.BaseNoGui;
|
||||
import processing.app.Editor;
|
||||
import processing.app.I18n;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.HyperlinkListener;
|
||||
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.event.WindowFocusListener;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import static processing.app.I18n.tr;
|
||||
@ -95,8 +99,30 @@ public class ContributionsSelfCheck extends TimerTask {
|
||||
}
|
||||
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
notificationPopup = new NotificationPopup(base.getActiveEditor(), hyperlinkListener, text);
|
||||
notificationPopup.setVisible(true);
|
||||
Editor ed = base.getActiveEditor();
|
||||
notificationPopup = new NotificationPopup(ed, hyperlinkListener, text);
|
||||
if (ed.isFocused()) {
|
||||
notificationPopup.setVisible(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// If the IDE is not focused wait until it is focused again to
|
||||
// display the notification, this avoids the annoying side effect
|
||||
// to "steal" the focus from another application.
|
||||
WindowFocusListener wfl = new WindowFocusListener() {
|
||||
@Override
|
||||
public void windowLostFocus(WindowEvent evt) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowGainedFocus(WindowEvent evt) {
|
||||
notificationPopup.setVisible(true);
|
||||
for (Editor e : base.getEditors())
|
||||
e.removeWindowFocusListener(this);
|
||||
}
|
||||
};
|
||||
for (Editor e : base.getEditors())
|
||||
e.addWindowFocusListener(wfl);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,6 @@ public class NotificationPopup extends JDialog {
|
||||
super(parent, false);
|
||||
setLayout(new FlowLayout());
|
||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||
setAlwaysOnTop(true);
|
||||
setUndecorated(true);
|
||||
setResizable(false);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user