Bug #9529
Newly created window is shown in front of DIALOG-BOX
0%
History
#1 Updated by Șerban Bursuc over 1 year ago
It has been observed from findings in #9381 that despite the value of TOP-ONLY or ALWAYS-ON-TOP attribute of a window, a DIALOG-BOX window is always shown in front of a window.
The problem is that in FWD a newly created is put in front of the DIALOG-BOX, which is wrong.
Below is a testcase to demonstrate:
define variable diag as handle.
create dialog-box diag.
diag:visible = true.
diag:WIDTH-PIXELS = 300.
diag:HEIGHT-PIXELS = 300.
define variable btn_h as handle.
create button btn_h
assign frame = diag
visible = true
sensitive = true
label = "spawn window".
on choose of btn_h do:
define variable w as handle.
create window w.
w:visible = true.
w:WIDTH-PIXELS = 300.
w:HEIGHT-PIXELS = 300.
w:TOP-ONLY = yes.
end.
wait-for go of diag.
#9381 fixes the problem for the Web client but not for the Swing client.
Swing does not have a z index management like CSS does, it simply puts on top whatever widget was introduced last or that was set with toFront or setAlwaysOnTop. Therefore the likely fix is making sure an existing modal window stays on top. For example:
public void setAlwaysOnTop(int windowId, boolean topOnly, boolean alwaysOnTop)
{
boolean top = topOnly;
List<TitledWindow<?>> list = WindowManager.windowList();
for (TitledWindow<?> tw : list)
{
if (tw instanceof DialogBoxWindow && tw.getId().asInt() != windowId) // if there is a modal present and the current window is not a modal, it will not be always on top even if topOnly is true
{
top = false; // the modal will stay on top only if no other window uses setAlwaysOnTop(true), so set this to false if a modal is present
}
}
SwingEmulatedWindow sew = (SwingEmulatedWindow) direct.getWindowEmulator(windowId);
sew.setAlwaysOnTop(top, alwaysOnTop);
}
After preventing a non-modal window from being in front of a modal window, after the modal disappears the correct state needs to be restored for the rest of the windows.
#2 Updated by Hynek Cihlar over 1 year ago
- reviewer Hynek Cihlar added