Fix "Fl::focus() changes Fl_Group::current() to null" (#515)

This issue is caused by setting `Fl_Group::current(0);` in
Fl_Window::show(), i.e. in Fl_X::make_xid(..) in an attempt to
fix a "very common user bug: forgot end()". As long as this is
done, this commit fixes the issue.

For details see GitHub issue #515.
This commit is contained in:
Albrecht Schlosser 2022-10-16 23:23:04 +02:00
parent 260a446609
commit 723d8caa9d

View File

@ -127,10 +127,18 @@ int Fl_X11_Window_Driver::decorated_w()
void Fl_X11_Window_Driver::take_focus()
{
Fl_X *i = Fl_X::i(pWindow);
if (!Fl_X11_Screen_Driver::ewmh_supported())
pWindow->show(); // Old WMs, XMapRaised
else if (i) // New WMs use the NETWM attribute:
if (!Fl_X11_Screen_Driver::ewmh_supported()) {
// Save and restore the current group because 'show()' sets it to NULL.
// See issue #515: Fl::focus() changes Fl_Group::current() to null.
Fl_Group *cg = Fl_Group::current(); // save current group
pWindow->show(); // old WMs, XMapRaised
Fl_Group::current(cg); // restore current group
}
else if (i) { // New WMs use the NETWM attribute:
activate_window();
}
}