codecentric / NSMenuFX

Other
127 stars 26 forks source link

Global menubar reset on any window change #33

Closed jkaving closed 4 years ago

jkaving commented 4 years ago

The code in StageUtils.updateStages() currently has the effect that a global menubar will be reset on all stages on any window change. The call to setAll(newStages) here will trigger stage listeners even if there has been only changes no non-stage windows and no changes to any stage:

private static void updateStages() {
    List<Stage> newStages = new LinkedList<>();
    for (Window w : windows) {
        if (w instanceof Stage) {
            newStages.add((Stage)w);
        }
    }
    stages.setAll(newStages);       
}

If a global menu bar has been set this will trigger this code in MenuBarSyncListener.

stageChanges.getAddedSubList().forEach(stage -> MenuBarUtils.setMenuBar(stage, MENU_BAR));

If popup windows are used when hovering over elements in a scene the effect will be that the system menubar on MacOS flickers when popup windows are shown or hidden.