diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2022-10-16 23:23:04 +0200 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2022-10-16 23:23:04 +0200 |
| commit | 723d8caa9d2a5acd423a354332f652ddfefb7d6e (patch) | |
| tree | d33fc9395002c81968b64fb1ccec9cba14a2437a /src/drivers/X11 | |
| parent | 260a446609b7638669fa97afb393f3993106b6ac (diff) | |
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.
Diffstat (limited to 'src/drivers/X11')
| -rw-r--r-- | src/drivers/X11/Fl_X11_Window_Driver.cxx | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/drivers/X11/Fl_X11_Window_Driver.cxx b/src/drivers/X11/Fl_X11_Window_Driver.cxx index 3fb10cb74..5b44bedec 100644 --- a/src/drivers/X11/Fl_X11_Window_Driver.cxx +++ b/src/drivers/X11/Fl_X11_Window_Driver.cxx @@ -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(); + } } |
