Ver Fonte

Merge branch 'feature/rcfix190fc'

Ka1-S há 2 semanas atrás
pai
commit
b0cb90aec

+ 457 - 3
src/Main.cpp

@@ -1377,6 +1377,16 @@ public:
             return;
             return;
         }
         }
 
 
+        if (args.contains ("--simplekeytest"))
+        {
+            // LYNX --simplekeytest report.txt (round 190fc, 0.1.27 RC H2): the main window in the Simple layout; after a
+            // demo opened from Welcome › Start from and after clicks in the dock, its tabs, the Lyrics button, a track
+            // header and the grid, Space must start playback (a text field clicked into keeps its typing keys). Shows a
+            // window (takes the foreground on Windows: GUI lock); exit code 0 = OK.
+            runSimpleKeyTest (args[args.indexOf ("--simplekeytest") + 1].unquoted());
+            return;
+        }
+
         if (args.contains ("--pluginstyle")) // round 126: force one style for this run (glow, neon, hardware, vivid; auto = per plugin)
         if (args.contains ("--pluginstyle")) // round 126: force one style for this run (glow, neon, hardware, vivid; auto = per plugin)
         {
         {
             const auto i = args.indexOf ("--pluginstyle");
             const auto i = args.indexOf ("--pluginstyle");
@@ -1968,6 +1978,17 @@ public:
             return;
             return;
         }
         }
 
 
+        if (args.contains ("--simpleclosetest"))
+        {
+            // LYNX --simpleclosetest <report.txt>: round 190fc off-screen (no window) — the main window in the Simple
+            // layout with Welcome, the tour, Start from, a demo, the dock's tabs, Finish and Lyrics open, then closed as at
+            // shutdown (the 0.1.27 RC crashed on every such close); exit code 0 = OK
+            const auto i = args.indexOf ("--simpleclosetest");
+            setApplicationReturnValue (runSimpleCloseTest (args[i + 1].unquoted()) ? 0 : 1);
+            quit();
+            return;
+        }
+
         if (args.contains ("--patterns190ea"))
         if (args.contains ("--patterns190ea"))
         {
         {
             // LYNX --patterns190ea <report.txt>: round 190ea off-screen (no window) — a song with no pattern at all
             // LYNX --patterns190ea <report.txt>: round 190ea off-screen (no window) — a song with no pattern at all
@@ -6177,8 +6198,24 @@ private:
                         expect ("editor_above_rack_when_opened", h != nullptr && lynx::nativechild::isAbove (h, rack));
                         expect ("editor_above_rack_when_opened", h != nullptr && lynx::nativechild::isAbove (h, rack));
                         workspace->activate (Panel::channelRack); // a click on the rack
                         workspace->activate (Panel::channelRack); // a click on the rack
                         expect ("rack_above_editor_after_its_click", h != nullptr && lynx::nativechild::isAbove (rack, h));
                         expect ("rack_above_editor_after_its_click", h != nullptr && lynx::nativechild::isAbove (rack, h));
-                        if (h != nullptr) // a real click (a message to the editor's own window) on its title bar
-                            lynx::nativechild::postClickForTest (h, { 60, 8 });
+                        // a real click (a message to the editor's own window) on its title bar, at a point where the editor
+                        // can be seen. Round 190fc (0.1.27 RC M1): JUCE takes a button-down only where the system says its
+                        // window is the one under the point (HWNDComponentPeer::contains asks WindowFromPoint), so the old
+                        // fixed point (60, 8) was dropped whenever the rack, raised just above, covered it there: the
+                        // check read 0 while real clicks (on what can be seen) raise the editor.
+                        if (h != nullptr && ed != nullptr)
+                        {
+                            juce::Point<int> at (-1, -1);
+                            for (int x = 30; x < ed->getWidth() - 40 && at.x < 0; x += 12)
+                                if (lynx::nativechild::windowAt (*ed, { x, 8 }) == h)
+                                    at = { x, 8 };
+                            step (juce::String ("editor_title_visible_at=") + juce::String (at.x));
+                            if (at.x >= 0)
+                            {
+                                const auto scale = ed->getPeer() != nullptr ? ed->getPeer()->getPlatformScaleFactor() * (double) ed->getDesktopScaleFactor() : 1.0;
+                                lynx::nativechild::postClickForTest (h, (at.toDouble() * scale).roundToInt());
+                            }
+                        }
                     }
                     }
                     else if (at == 22)
                     else if (at == 22)
                     {
                     {
@@ -6872,6 +6909,315 @@ private:
 
 
         auto* test = new FocusTest();
         auto* test = new FocusTest();
         test->reportPath = reportPath;
         test->reportPath = reportPath;
+        startFocusTestWindow (*test);
+        test->startTimer (600);
+    }
+
+    // --simplekeytest (round 190fc, 0.1.27 RC H2): in the Simple layout Space often did nothing after a click in the
+    // window (the dock, a track header, the grid, the Lyrics button) or after a demo opened from Welcome › Start from. The
+    // main window in the Simple layout; each step clicks as the system would (through the native window under the point)
+    // and presses Space where the system sends it (the native window of the component with the focus): playback must
+    // start, except while a text field the user clicked into has the keys (it types). Shows a window (Windows: GUI lock).
+    void runSimpleKeyTest (const juce::String& reportPath)
+    {
+        juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
+
+        struct KeyTest final : juce::Timer
+        {
+            juce::String reportPath, report;
+            bool ok = true;
+            int stepIndex = 0, instrumentTrack = 0;
+            std::unique_ptr<lynx::AudioEngine> engine;
+            lynx::MainComponent* ui = nullptr;
+            std::unique_ptr<juce::DocumentWindow> main;
+            std::function<void()> done;
+
+            void line (const juce::String& text)
+            {
+                report << text << "\n";
+                juce::File (reportPath).replaceWithText (report);
+            }
+            void check (const juce::String& what, bool passed)
+            {
+                line ((passed ? "ok   " : "FAIL ") + what);
+                ok = ok && passed;
+            }
+            static juce::String describe (juce::Component* c)
+            {
+                if (c == nullptr)
+                    return "nothing";
+                juce::String path;
+                for (auto* p = c; p != nullptr && path.length() < 160; p = p->getParentComponent())
+                {
+                    auto name = p->getComponentID().isNotEmpty() ? p->getComponentID() : p->getName();
+                    if (name.isEmpty())
+                        name = juce::String (typeid (*p).name()).fromLastOccurrenceOf ("::", false, false).substring (0, 28);
+                    path << (path.isEmpty() ? "" : " < ") << name;
+                }
+                return path;
+            }
+            // the first showing component with this ID in the main window or a native child window of it
+            juce::Component* find (const juce::String& id)
+            {
+                std::function<juce::Component* (juce::Component&)> in = [&] (juce::Component& root) -> juce::Component* {
+                    if (root.getComponentID() == id && root.isShowing())
+                        return &root;
+                    for (auto* c : root.getChildren())
+                        if (auto* f = in (*c))
+                            return f;
+                    return nullptr;
+                };
+                if (auto* f = in (*main))
+                    return f;
+                if (auto* peer = main->getPeer())
+                    for (auto* attached : lynx::nativechild::attachedChildren (peer->getNativeHandle()))
+                        if (auto* f = in (*attached))
+                            return f;
+                return nullptr;
+            }
+            // a click (press and release) at `local` in `c`, through the native window it is in
+            juce::String lastHit;
+            void click (juce::Component& c, juce::Point<int> local)
+            {
+                auto* peer = c.getPeer();
+                if (peer == nullptr)
+                    return;
+                const auto at = peer->getComponent().getLocalPoint (&c, local.toFloat());
+                lastHit = describe (peer->getComponent().getComponentAt (at.roundToInt()));
+                line ("  click at " + local.toString() + " in " + describe (&c).upToFirstOccurrenceOf (" < ", false, false) + " -> " + lastHit);
+                const auto now = juce::Time::currentTimeMillis();
+                peer->handleMouseEvent (juce::MouseInputSource::InputSourceType::mouse, at, juce::ModifierKeys (juce::ModifierKeys::leftButtonModifier), 1.0f, 0.0f, now);
+                peer->handleMouseEvent (juce::MouseInputSource::InputSourceType::mouse, at, juce::ModifierKeys(), 1.0f, 0.0f, now + 40);
+            }
+            void click (juce::Component& c) { click (c, c.getLocalBounds().getCentre()); }
+            // Space where the system sends it: the native window of the focused component (else the main one)
+            bool space()
+            {
+                // Windows: posted to the window with the system's focus, as a real key goes (the system's own routing)
+                if (lynx::nativechild::pressSpaceForTest (main->getWindowHandle()))
+                    return true;
+                auto* focused = juce::Component::getCurrentlyFocusedComponent();
+                auto* peer = focused != nullptr && focused->getPeer() != nullptr ? focused->getPeer() : main->getPeer();
+                return peer != nullptr && peer->handleKeyPress (juce::KeyPress (juce::KeyPress::spaceKey, juce::ModifierKeys(), ' '));
+            }
+            void spacePlays (const juce::String& after)
+            {
+                line ("  keys at: " + describe (juce::Component::getCurrentlyFocusedComponent()));
+                auto& transport = engine->getTransport();
+                if (transport.playing.load())
+                    engine->stop();
+                space();
+                check ("Space plays after " + after, transport.playing.load());
+                engine->stop();
+            }
+
+            void timerCallback() override
+            {
+                auto* simple = ui->getSimpleWorkflowForSnapshot();
+                auto& playlist = ui->getPlaylistForSnapshot();
+                switch (stepIndex++)
+                {
+                    case 0:
+                        ui->setLayoutStyle (lynx::layoutstyle::Style::simple);
+                        ui->grabKeyboardFocus();
+                        break;
+                    case 1:
+                        check ("the Simple workflow is up", simple != nullptr);
+                        if (simple == nullptr)
+                            return finish();
+                        spacePlays ("the layout came up");
+                        simple->showWelcome();
+                        break;
+                    case 2:
+                        if (auto* demo = find ("tour.welcome.demo"))
+                            click (*demo); // Welcome › Open a demo song: the Start from list
+                        else
+                            check ("Welcome > Open a demo song found", false);
+                        break;
+                    case 3:
+                    {
+                        if (! simple->isStartFromShowing()) // (X11: a child window just mapped may miss the first click)
+                            if (auto* demo = find ("tour.welcome.demo"))
+                            {
+                                line ("  the first click was not taken: once more");
+                                click (*demo);
+                            }
+                        check ("Start from is up", simple->isStartFromShowing());
+                        if (auto* start = dynamic_cast<lynx::StartFromPanel*> (simple->startFromForSnapshot()))
+                            check ("a demo song opens from it", start->openForSnapshot (1));
+                        break;
+                    }
+                    case 4:
+                        check ("Start from closed with the demo open", ! simple->isStartFromShowing() && ! engine->getSong().playlist.empty());
+                        spacePlays ("a demo opened from Welcome > Start from");
+                        instrumentTrack = [] (const lynx::Song& song) { // the first Instrument track (the dock's Keyboard and Editor tabs are for it)
+                            for (int t = 0; t < (int) song.playlistTracks.size(); ++t)
+                                if (lynx::simpletracks::kindOf (song, t) == lynx::simpletracks::Kind::instrument)
+                                    return t;
+                            return 0;
+                        } (engine->getSong());
+                        line ("instrument track: " + juce::String (instrumentTrack));
+                        playlist.selectTrack (instrumentTrack);
+                        simple->trackSelected (instrumentTrack);
+                        break;
+                    case 5:
+                        if (auto* dock = simple->dockForSnapshot(); dock != nullptr && dock->isShowing())
+                        {
+                            click (*dock, { dock->getWidth() - 6, dock->getHeight() - 6 }); // (its empty corner)
+                            spacePlays ("a click in the dock");
+                        }
+                        else
+                            check ("the dock shows", false);
+                        break;
+                    case 6:
+                        if (auto* tab = find ("simple.dock.keyboard"))
+                        {
+                            click (*tab);
+                            spacePlays ("a click on a dock tab (Keyboard)");
+                        }
+                        if (auto* tab = find ("simple.dock.editor"))
+                        {
+                            click (*tab);
+                            spacePlays ("a click on a dock tab (Editor)");
+                        }
+                        break;
+                    case 7:
+                        if (auto* lyrics = find ("simple.lyrics"))
+                        {
+                            click (*lyrics);
+                            spacePlays ("a click on the Lyrics button");
+                        }
+                        else
+                            check ("the Lyrics button found", false);
+                        break;
+                    case 8:
+                    {
+                        const auto lane = playlist.trackRowForSnapshot (instrumentTrack).withTrimmedLeft (playlist.headerWidth);
+                        click (playlist, { juce::jmax (4, playlist.headerWidth / 2), lane.getCentreY() });
+                        spacePlays ("a click on a track header");
+                        click (playlist, lane.getCentre() + juce::Point<int> (40, 0));
+                        spacePlays ("a click in the Playlist grid");
+                        break;
+                    }
+                    case 9:
+                    {
+                        // a text field the user clicks into keeps its typing keys; a click outside gives Space back
+                        // a dock knob clicked keeps the arrow keys, and Space still plays from it
+                        for (auto tab : { lynx::SimpleDock::Tab::effects, lynx::SimpleDock::Tab::instrument })
+                        {
+                            juce::Component* knob = nullptr;
+                            std::function<void (juce::Component&)> seek = [&] (juce::Component& c) {
+                                if (knob == nullptr && c.isShowing() && (bool) c.getProperties().getWithDefault ("lynxClickKeepsKeys", false))
+                                    knob = &c;
+                                for (auto* child : c.getChildren())
+                                    seek (*child);
+                            };
+                            if (auto* dock = simple->dockForSnapshot())
+                            {
+                                dock->setTab (tab);
+                                seek (*dock);
+                            }
+                            if (knob != nullptr)
+                            {
+                                click (*knob);
+                                spacePlays ("a click on a dock knob");
+                                break;
+                            }
+                        }
+                        if (auto* dock = simple->dockForSnapshot())
+                            dock->setTab (lynx::SimpleDock::Tab::instrument);
+                        juce::TextEditor* field = nullptr;
+                        std::function<void (juce::Component&)> look = [&] (juce::Component& c) {
+                            if (auto* t = dynamic_cast<juce::TextEditor*> (&c); t != nullptr && t->isShowing() && field == nullptr)
+                                field = t;
+                            for (auto* child : c.getChildren())
+                                look (*child);
+                        };
+                        if (auto* dock = simple->dockForSnapshot())
+                            look (*dock);
+                        line ("text field in the dock found=" + juce::String ((int) (field != nullptr)));
+                        if (field != nullptr)
+                        {
+                            click (*field);
+                            const auto before = field->getText();
+                            space();
+                            check ("Space types into the text field the user clicked", field->getText() != before && ! engine->getTransport().playing.load());
+                            engine->stop();
+                            field->clear();
+                            const auto lane = playlist.trackRowForSnapshot (instrumentTrack).withTrimmedLeft (playlist.headerWidth);
+                            click (playlist, lane.getCentre() + juce::Point<int> (60, 0));
+                            spacePlays ("a click in the grid after typing");
+                        }
+                        // H1: the first-song tour's card in front of the native panels, taking no keys (started on the demo
+                        // as it is: Help's question about a new project is a dialog)
+                        if (auto* tour = simple->tourForSnapshot())
+                            tour->start();
+                        break;
+                    }
+                    case 10:
+                    {
+                        auto* tour = simple->tourForSnapshot();
+                        auto* card = tour != nullptr ? tour->cardForSnapshot() : nullptr;
+                        check ("the tour runs", tour != nullptr && tour->isRunning() && card != nullptr && card->isVisible());
+                        if (card == nullptr)
+                            return finish();
+                        auto& frame = ui->workspaceForTest().getFrame (lynx::workspace::Panel::playlist);
+                        const auto native = lynx::nativechild::dockingEnabled() && lynx::nativechild::isAttached (frame);
+                        line ("playlist native child window=" + juce::String ((int) native) + ", tour card native child window="
+                              + juce::String ((int) lynx::nativechild::isAttached (*card)));
+                        if (native)
+                        {
+                            check ("the tour card is a native child window of the main window (not under the panels)", lynx::nativechild::isAttached (*card));
+                           #if JUCE_WINDOWS
+                            check ("the tour card is above the Playlist's native window", lynx::nativechild::isAbove (card->getWindowHandle(), frame.getWindowHandle()));
+                            juce::Component* layer = nullptr;
+                            for (auto* c : lynx::nativechild::attachedChildren (main->getPeer()->getNativeHandle()))
+                                if (c != nullptr && c->getComponentID() == "tour.layer")
+                                    layer = c;
+                            check ("the ring's layer is above the Playlist too", layer != nullptr && lynx::nativechild::isAbove (layer->getWindowHandle(), frame.getWindowHandle()));
+                            check ("the ring's layer lets clicks through to the Playlist",
+                                   layer != nullptr && lynx::nativechild::windowAt (*layer, layer->getLocalBounds().getCentre()) != layer->getWindowHandle());
+                           #endif
+                        }
+                        check ("the tour card took no keys", ! card->hasKeyboardFocus (true));
+                        spacePlays ("the tour came up");
+                        if (auto* next = card->findChildWithID ("tour.next"); next != nullptr && next->isShowing())
+                        {
+                            click (*next);
+                            check ("a click on the card took no keys", ! card->hasKeyboardFocus (true));
+                            spacePlays ("a click on the tour card");
+                        }
+                        finish();
+                        break;
+                    }
+                    default:
+                        break;
+                }
+            }
+
+            void finish()
+            {
+                line (ok ? "result=OK" : "result=FAILED");
+                stopTimer();
+                done();
+            }
+        };
+
+        auto* test = new KeyTest();
+        test->reportPath = reportPath;
+        startFocusTestWindow (*test);
+        // Windows: kept above other apps' windows for its few seconds (JUCE takes a button-down only where the system finds
+        // its window under the point, and the test clicks through LYNX's own peers, not the system's input)
+       #if JUCE_WINDOWS
+        test->main->setAlwaysOnTop (true); // (Linux: JUCE makes the X11 window again for it; the private X server has no other windows)
+       #endif
+        test->startTimer (700);
+    }
+
+    template <typename Test>
+    void startFocusTestWindow (Test& t)
+    {
+        auto* test = &t;
         test->engine = std::make_unique<lynx::AudioEngine> (false);
         test->engine = std::make_unique<lynx::AudioEngine> (false);
         test->main = std::make_unique<juce::DocumentWindow> ("LYNX focus test", lynx::theme::window, juce::DocumentWindow::allButtons);
         test->main = std::make_unique<juce::DocumentWindow> ("LYNX focus test", lynx::theme::window, juce::DocumentWindow::allButtons);
         test->main->setUsingNativeTitleBar (true);
         test->main->setUsingNativeTitleBar (true);
@@ -6890,7 +7236,6 @@ private:
                 quit();
                 quit();
             });
             });
         };
         };
-        test->startTimer (600);
     }
     }
 
 
     void runWindowTest (const juce::String& reportPath)
     void runWindowTest (const juce::String& reportPath)
@@ -17131,6 +17476,115 @@ private:
         juce::File (prefix + "-report.txt").replaceWithText (report);
         juce::File (prefix + "-report.txt").replaceWithText (report);
     }
     }
 
 
+    // --simpleclosetest (round 190fc, 0.1.27 RC blocker B1): every close in the Simple layout crashed (the Simple workflow
+    // was destroyed after the Workspace and its destructor called into it). Off-screen, no window: the main window in the
+    // Simple layout with everything of it open — Welcome, the first-song tour's card, Start from, a demo song, each dock
+    // tab (the Editor tab docks the Piano roll), Finish, Lyrics, the chooser — then destroyed as the app's shutdown does.
+    // A second main window goes Simple -> Pattern -> Simple and closes too. Checks: no Simple workflow outlives its main
+    // window's destructor body, none is left at all. (Under ASan on Linux the old order is a heap-use-after-free.)
+    bool runSimpleCloseTest (const juce::String& reportPath)
+    {
+        juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
+        juce::String report;
+        bool ok = true;
+        const auto line = [&report, &reportPath] (const juce::String& text) {
+            report << text << "\n";
+            juce::File (reportPath).replaceWithText (report); // (written as it goes: a crash still leaves the last step)
+        };
+        const auto check = [&line, &ok] (const juce::String& what, bool good) {
+            line ((good ? "ok   " : "FAIL ") + what);
+            ok = ok && good;
+        };
+        const auto aliveBefore = lynx::SimpleWorkflow::alive.load();
+        {
+            lynx::AudioEngine offline (false);
+            {
+                lynx::MainComponent ui (offline, false);
+                ui.setSize (1600, 900);
+                ui.setVisible (true); // (no window: the docked editor and the tour only need their parents visible)
+                const auto settle = [&] {
+                    for (int k = 0; k < 3; ++k)
+                        offline.dispatchPendingMessages();
+                };
+                ui.setLayoutStyle (lynx::layoutstyle::Style::simple);
+                settle();
+                auto* simple = ui.getSimpleWorkflowForSnapshot();
+                check ("the Simple workflow is up", simple != nullptr);
+                if (simple != nullptr)
+                {
+                    const auto empty = lynx::builtInTemplateIndex ("Empty");
+                    offline.setSong (empty >= 0 ? lynx::makeNewProject (empty) : lynx::makeNewProject());
+                    settle();
+                    simple->showWelcome();
+                    settle();
+                    auto* tour = simple->tourForSnapshot();
+                    check ("Welcome screen shown", tour != nullptr && tour->isWelcomeShowing());
+                    simple->startOrContinueTour();
+                    settle();
+                    simple->doTourStep (lynx::tour::beat);
+                    settle();
+                    check ("the tour runs with its card up", simple->tourRunning() && tour != nullptr && tour->cardForSnapshot() != nullptr);
+                    // a demo song from Start from (the panel stays up over the Playlist)
+                    if (auto* start = simple->startFromForSnapshot(); start != nullptr && lynx::demos::count > 1)
+                    {
+                        offline.setSong (lynx::demos::make (1));
+                        settle();
+                        check ("a demo song opened, Start from up", simple->isStartFromShowing() && ! offline.getSong().playlist.empty());
+                    }
+                    // the dock on a track, every tab (the Editor tab docks the Piano roll)
+                    if (auto* dock = simple->dockForSnapshot())
+                    {
+                        simple->trackSelected ([] (const lynx::Song& song) { // the first Instrument track (the dock's Keyboard and Editor tabs are for it)
+                        for (int t = 0; t < (int) song.playlistTracks.size(); ++t)
+                            if (lynx::simpletracks::kindOf (song, t) == lynx::simpletracks::Kind::instrument)
+                                return t;
+                        return 0;
+                    } (offline.getSong()));
+                        for (auto tab : { lynx::SimpleDock::Tab::instrument, lynx::SimpleDock::Tab::keyboard, lynx::SimpleDock::Tab::editor,
+                                          lynx::SimpleDock::Tab::effects, lynx::SimpleDock::Tab::editor })
+                        {
+                            dock->setTab (tab);
+                            settle();
+                        }
+                        check ("the dock shows", simple->isDockShowing());
+                        line ("dock tab at the close: " + juce::String ((int) dock->getTab()) + " (2 = Editor, the docked Piano roll)");
+                    }
+                    ui.toggleLyrics(); // (Lyrics, then Finish: they share the dock on the right)
+                    settle();
+                    simple->showFinish();
+                    settle();
+                    check ("Finish open", simple->isFinishShowing());
+                    simple->showChooser();
+                    settle();
+                    line ("Simple workflow objects alive before the close: " + juce::String (lynx::SimpleWorkflow::alive.load() - aliveBefore));
+                }
+            } // (the main window goes as at shutdown)
+            check ("no Simple workflow outlived its main window's destructor body (it reaches the Workspace)",
+                   lynx::MainComponent::simpleWorkflowAliveAfterTeardown == aliveBefore);
+            check ("none left after the close", lynx::SimpleWorkflow::alive.load() == aliveBefore);
+
+            // Simple, then Pattern, then Simple again, and closed
+            {
+                lynx::MainComponent ui (offline, false);
+                ui.setSize (1600, 900);
+                ui.setVisible (true);
+                ui.setLayoutStyle (lynx::layoutstyle::Style::simple);
+                offline.dispatchPendingMessages();
+                ui.setLayoutStyle (lynx::layoutstyle::Style::pattern);
+                offline.dispatchPendingMessages();
+                ui.setLayoutStyle (lynx::layoutstyle::Style::simple);
+                offline.dispatchPendingMessages();
+                if (auto* simple = ui.getSimpleWorkflowForSnapshot())
+                    simple->showWelcome();
+                offline.dispatchPendingMessages();
+            }
+            check ("Simple -> Pattern -> Simple, closed: none outlived the destructor body", lynx::MainComponent::simpleWorkflowAliveAfterTeardown == aliveBefore
+                                                                                              && lynx::SimpleWorkflow::alive.load() == aliveBefore);
+        }
+        line (ok ? "result=OK" : "result=FAILED");
+        return ok;
+    }
+
     void runTour190dvShot (const juce::String& prefix)
     void runTour190dvShot (const juce::String& prefix)
     {
     {
         juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
         juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);

+ 10 - 1
src/ui/AudioEditor.cpp

@@ -41,6 +41,8 @@
 #include "ui/Icons.h"
 #include "ui/Icons.h"
 #include "ui/Theme.h"
 #include "ui/Theme.h"
 #include "ui/ToolWindow.h"
 #include "ui/ToolWindow.h"
+#include "ui/NativeChild.h"
+#include "ui/WindowOwner.h"
 
 
 namespace lynx
 namespace lynx
 {
 {
@@ -5304,6 +5306,11 @@ AudioEditor* openWindow (AudioEngine& engine, Source source)
     {
     {
         window->setResizable (true, false);
         window->setResizable (true, false);
         window->setResizeLimits (720, 380, 4000, 3000);
         window->setResizeLimits (720, 380, 4000, 3000);
+        // Edison in a mixer slot is one of the insert's plugin windows: docked in the workspace as FL's are (round 190fc,
+        // 0.1.27 RC M2; the other LYNX editors since round 190ev), so a click on the Playlist or any panel brings that panel
+        // in front of it. FL's "Detach all new plugins" or LYNX_DOCKED_PLUGINS=0 keep it a floating window.
+        if (source.kind == Source::Kind::slot)
+            dockOrKeepAbove (*window);
     }
     }
     return raw;
     return raw;
 }
 }
@@ -5405,7 +5412,9 @@ void openEdisonSlot (AudioEngine& engine, int track, int slot, bool record)
     AudioEditor* editor = nullptr;
     AudioEditor* editor = nullptr;
     if (auto* open = findToolWindow (windowKey (*source)))
     if (auto* open = findToolWindow (windowKey (*source)))
     {
     {
-        open->toFront (true);
+        open->toFront (! nativechild::isAttached (*open)); // (a docked one comes in front without taking the activation)
+        if (nativechild::isAttached (*open))
+            nativechild::raiseOverlays();
         editor = dynamic_cast<AudioEditor*> (open->getContentComponent());
         editor = dynamic_cast<AudioEditor*> (open->getContentComponent());
     }
     }
     else
     else

+ 130 - 16
src/ui/FirstSongTour.cpp

@@ -3,6 +3,7 @@
 #include "engine/AudioEngine.h"
 #include "engine/AudioEngine.h"
 #include "platform/Paths.h"
 #include "platform/Paths.h"
 #include "ui/I18n.h"
 #include "ui/I18n.h"
+#include "ui/NativeChild.h"
 #include "ui/Theme.h"
 #include "ui/Theme.h"
 
 
 namespace lynx
 namespace lynx
@@ -13,7 +14,7 @@ constexpr const char* layerId = "tour.layer";
 constexpr const char* cardId = "tour.card";
 constexpr const char* cardId = "tour.card";
 
 
 // The first component with this ID that is on screen inside `root` (the tour's own parts left out)
 // The first component with this ID that is on screen inside `root` (the tour's own parts left out)
-juce::Component* findShowing (juce::Component& root, const juce::String& id)
+juce::Component* findShowingIn (juce::Component& root, const juce::String& id)
 {
 {
     for (auto* c : root.getChildren())
     for (auto* c : root.getChildren())
     {
     {
@@ -21,12 +22,45 @@ juce::Component* findShowing (juce::Component& root, const juce::String& id)
             continue;
             continue;
         if (c->getComponentID() == id && ! c->getLocalBounds().isEmpty()) // (its parents up to the window are visible: checked on the way down)
         if (c->getComponentID() == id && ! c->getLocalBounds().isEmpty()) // (its parents up to the window are visible: checked on the way down)
             return c;
             return c;
-        if (auto* inner = findShowing (*c, id))
+        if (auto* inner = findShowingIn (*c, id))
             return inner;
             return inner;
     }
     }
     return nullptr;
     return nullptr;
 }
 }
 
 
+// The same in the window and in the panels that are native child windows of it (issue #116: the Playlist, Channel rack,
+// Piano roll and Mixer frames are not its child components then; round 190fc)
+juce::Component* findShowing (juce::Component& window, const juce::String& id)
+{
+    if (auto* c = findShowingIn (window, id))
+        return c;
+    if (auto* peer = window.getPeer())
+        for (auto* attached : nativechild::attachedChildren (peer->getNativeHandle()))
+            if (attached != nullptr && attached->isVisible() && attached->getComponentID() != layerId && attached->getComponentID() != cardId)
+                if (auto* c = attached->getComponentID() == id ? attached : findShowingIn (*attached, id))
+                    return c;
+    return nullptr;
+}
+
+// `c`'s bounds in `window`'s coordinates, also for a component inside an attached native child window (whose bounds
+// are kept in the main window's client coordinates, ui/NativeChild.h)
+juce::Rectangle<int> areaIn (juce::Component& window, juce::Component& c)
+{
+    auto* top = c.getTopLevelComponent();
+    auto* main = window.getTopLevelComponent();
+    if (top == nullptr || main == nullptr || top == main || ! nativechild::isAttached (*top))
+        return window.getLocalArea (&c, c.getLocalBounds());
+    return window.getLocalArea (main, top->getLocalArea (&c, c.getLocalBounds()) + top->getPosition());
+}
+
+// Issue #116 / round 190fc (0.1.27 RC H1): the panels are native child windows, always drawn above the main window's
+// own components, so the tour's card and ring go in front of them as floaters (ui/NativeChild.h): layered child windows
+// that take no focus. Without a native main window (--snapshot routes, tests) they stay plain children of the window.
+bool tourAsNativeWindows (const juce::Component& window)
+{
+    return nativechild::dockingEnabled() && window.getPeer() != nullptr;
+}
+
 void styleButton (juce::TextButton& b, bool primary)
 void styleButton (juce::TextButton& b, bool primary)
 {
 {
     b.setColour (juce::TextButton::buttonColourId, primary ? theme::colour::accent : theme::colour::bg4);
     b.setColour (juce::TextButton::buttonColourId, primary ? theme::colour::accent : theme::colour::bg4);
@@ -110,6 +144,9 @@ public:
             addChildComponent (*b);
             addChildComponent (*b);
         }
         }
         close.setVisible (true);
         close.setVisible (true);
+        for (auto [b, id] : { std::pair<juce::Component*, const char*> { &close, "tour.close" }, { &skipButton, "tour.skip" }, { &backButton, "tour.back" },
+                              { &doButton, "tour.do" }, { &nextButton, "tour.next" } })
+            b->setComponentID (id); // (round 190fc: --simplekeytest clicks them)
         close.onClick = [this] { owner.clicked ("close"); };
         close.onClick = [this] { owner.clicked ("close"); };
         skipButton.onClick = [this] { owner.clicked ("skip"); };
         skipButton.onClick = [this] { owner.clicked ("skip"); };
         backButton.onClick = [this] { owner.clicked ("back"); };
         backButton.onClick = [this] { owner.clicked ("back"); };
@@ -157,8 +194,12 @@ public:
         return nullptr;
         return nullptr;
     }
     }
 
 
+    bool solidBackdrop = false; // an attached child window without per-pixel transparency (Linux): its corners are filled
+
     void paint (juce::Graphics& g) override
     void paint (juce::Graphics& g) override
     {
     {
+        if (solidBackdrop)
+            g.fillAll (theme::colour::bg1);
         auto r = getLocalBounds().toFloat().reduced (2.0f);
         auto r = getLocalBounds().toFloat().reduced (2.0f);
         g.setColour (juce::Colours::black.withAlpha (0.4f));
         g.setColour (juce::Colours::black.withAlpha (0.4f));
         g.fillRoundedRectangle (r.translated (0.0f, 3.0f), theme::radius::lg + 1.0f);
         g.fillRoundedRectangle (r.translated (0.0f, 3.0f), theme::radius::lg + 1.0f);
@@ -297,6 +338,7 @@ public:
     {
     {
         setComponentID ("tour.welcome");
         setComponentID ("tour.welcome");
         setWantsKeyboardFocus (true);
         setWantsKeyboardFocus (true);
+        getProperties().set ("lynxKeepsKeys", true); // (round 190fc: Esc and its options' keys while it is up)
         title.setText (tr ("Welcome to LYNX"), juce::dontSendNotification);
         title.setText (tr ("Welcome to LYNX"), juce::dontSendNotification);
         title.setFont (theme::font (theme::type::display, true));
         title.setFont (theme::font (theme::type::display, true));
         title.setJustificationType (juce::Justification::centred);
         title.setJustificationType (juce::Justification::centred);
@@ -312,6 +354,8 @@ public:
         close.setTooltip (tr ("Close"));
         close.setTooltip (tr ("Close"));
         styleButton (close, false);
         styleButton (close, false);
         tourOption.setComponentID ("tour.welcome.start");
         tourOption.setComponentID ("tour.welcome.start");
+        demoOption.setComponentID ("tour.welcome.demo");
+        emptyOption.setComponentID ("tour.welcome.empty");
         tourOption.onClick = [this] { owner.clicked ("welcome.tour"); };
         tourOption.onClick = [this] { owner.clicked ("welcome.tour"); };
         demoOption.onClick = [this] { owner.clicked ("welcome.demo"); };
         demoOption.onClick = [this] { owner.clicked ("welcome.demo"); };
         emptyOption.onClick = [this] { owner.clicked ("welcome.empty"); };
         emptyOption.onClick = [this] { owner.clicked ("welcome.empty"); };
@@ -389,6 +433,10 @@ FirstSongTour::~FirstSongTour()
 {
 {
     hideCard();
     hideCard();
     hideWelcome();
     hideWelcome();
+    if (card != nullptr)
+        nativechild::removeFloater (*card);
+    if (layer != nullptr)
+        nativechild::removeFloater (*layer);
 }
 }
 
 
 juce::File FirstSongTour::stateFile() { return platform::settingsFile ("simple-tour.txt"); }
 juce::File FirstSongTour::stateFile() { return platform::settingsFile ("simple-tour.txt"); }
@@ -497,17 +545,72 @@ void FirstSongTour::showCard()
         layer = std::make_unique<Layer>();
         layer = std::make_unique<Layer>();
         card->follow = [this] { update(); };
         card->follow = [this] { update(); };
     }
     }
-    if (layer->getParentComponent() != window)
-        window->addAndMakeVisible (*layer);
-    if (card->getParentComponent() != window)
-        window->addAndMakeVisible (*card);
-    layer->setBounds (window->getLocalBounds());
+    shownIn = window;
+    if (tourAsNativeWindows (*window))
+    {
+        // in front of the native panels and docked plugin windows (round 190fc): the card always; the dimmed layer with
+        // the ring where child windows blend (Windows, macOS), passing every click and drop through to what is under it
+        const auto attach = [window] (juce::Component& c, juce::Rectangle<int> bounds, bool passThrough) {
+            if (auto* p = c.getParentComponent())
+                p->removeChildComponent (&c);
+            if (! nativechild::isAttached (c))
+            {
+                c.setAlwaysOnTop (false); // (a flag for siblings in one window; it would make a child window "topmost")
+                c.setBounds (bounds);
+                const auto flags = passThrough ? (int) juce::ComponentPeer::windowIgnoresMouseClicks : 0;
+                if (! nativechild::attach (c, *window, flags))
+                    return false;
+                if (passThrough)
+                    nativechild::passInputThrough (c);
+                nativechild::addFloater (c);
+            }
+            else
+                nativechild::reattachIfNeeded (c, *window);
+            c.setVisible (true);
+            return true;
+        };
+        const auto blends = nativechild::supportsFloaters();
+        if (! (blends && attach (*layer, window->getLocalBounds(), true)) && layer->getParentComponent() != window)
+            window->addAndMakeVisible (*layer); // (Linux: dims the window's own parts; the card stays readable above the panels)
+        card->solidBackdrop = ! blends;
+        auto cardBounds = nativechild::boundsIn (*card, *window);
+        if (cardBounds.isEmpty())
+            cardBounds = { 0, 0, Card::width, Card::height }; // (update() puts it in its corner)
+        if (! attach (*card, cardBounds, false) && card->getParentComponent() != window)
+        {
+            card->solidBackdrop = false;
+            window->addAndMakeVisible (*card);
+        }
+        nativechild::raiseOverlays(); // (the layer first, then the card: their order in the floaters list)
+    }
+    else
+    {
+        for (auto* c : { (juce::Component*) card.get(), (juce::Component*) layer.get() })
+            if (nativechild::isAttached (*c)) // (the main window lost its native window meanwhile)
+            {
+                nativechild::removeFloater (*c);
+                nativechild::detach (*c);
+            }
+        card->solidBackdrop = false;
+        if (layer->getParentComponent() != window)
+            window->addAndMakeVisible (*layer);
+        if (card->getParentComponent() != window)
+            window->addAndMakeVisible (*card);
+        layer->setBounds (window->getLocalBounds());
+    }
     layer->toFront (false);
     layer->toFront (false);
     card->toFront (false);
     card->toFront (false);
+    nativechild::keepFloatersInFront();
     card->startFollowing();
     card->startFollowing();
     update();
     update();
 }
 }
 
 
+bool FirstSongTour::cardShowing() const noexcept
+{
+    return card != nullptr && shownIn != nullptr
+           && (card->getParentComponent() != nullptr || (nativechild::isAttached (*card) && card->isVisible()));
+}
+
 void FirstSongTour::hideCard()
 void FirstSongTour::hideCard()
 {
 {
     if (card != nullptr)
     if (card != nullptr)
@@ -519,13 +622,23 @@ void FirstSongTour::hideCard()
     if (layer != nullptr)
     if (layer != nullptr)
         if (auto* p = layer->getParentComponent())
         if (auto* p = layer->getParentComponent())
             p->removeChildComponent (layer.get());
             p->removeChildComponent (layer.get());
+    for (auto* c : { (juce::Component*) card.get(), (juce::Component*) layer.get() })
+        if (c != nullptr && nativechild::isAttached (*c))
+        {
+            nativechild::removeFloater (*c);
+            nativechild::detach (*c);
+            c->setVisible (false);
+        }
+    shownIn = nullptr;
 }
 }
 
 
 void FirstSongTour::update()
 void FirstSongTour::update()
 {
 {
-    if (card == nullptr || card->getParentComponent() == nullptr)
+    if (! cardShowing())
         return;
         return;
-    auto* window = card->getParentComponent();
+    auto* window = shownIn.getComponent();
+    for (auto* c : { (juce::Component*) card.get(), (juce::Component*) layer.get() })
+        nativechild::reattachIfNeeded (*c, *window); // (the main window's native window was made again)
     const auto step = machine.step();
     const auto step = machine.step();
     card->show (step, machine.shownDone (engine.getSong()));
     card->show (step, machine.shownDone (engine.getSong()));
 
 
@@ -534,10 +647,11 @@ void FirstSongTour::update()
     for (const auto& id : tour::targets (step))
     for (const auto& id : tour::targets (step))
         if (auto* c = findShowing (*window, id))
         if (auto* c = findShowing (*window, id))
         {
         {
-            ring = window->getLocalArea (c, c->getLocalBounds());
+            ring = areaIn (*window, *c);
             break;
             break;
         }
         }
-    layer->setBounds (window->getLocalBounds());
+    if (nativechild::boundsIn (*layer, *window) != window->getLocalBounds())
+        nativechild::place (*layer, *window, window->getLocalBounds());
     layer->setRing (ring);
     layer->setRing (ring);
 
 
     // the card: in a corner the ring is not in (top right first, under the toolbar)
     // the card: in a corner the ring is not in (top right first, under the toolbar)
@@ -551,7 +665,7 @@ void FirstSongTour::update()
     // (and not over the Finish dock while it is open: the end card would hide its looks)
     // (and not over the Finish dock while it is open: the end card would hide its looks)
     juce::Rectangle<int> keepClear;
     juce::Rectangle<int> keepClear;
     if (auto* finishDock = findShowing (*window, "simple.finishDock"))
     if (auto* finishDock = findShowing (*window, "simple.finishDock"))
-        keepClear = window->getLocalArea (finishDock, finishDock->getLocalBounds());
+        keepClear = areaIn (*window, *finishDock);
     auto place = spots[0];
     auto place = spots[0];
     for (const auto& s : spots)
     for (const auto& s : spots)
         if ((ring.isEmpty() || ! s.intersects (ring.expanded (24))) && ! s.intersects (keepClear))
         if ((ring.isEmpty() || ! s.intersects (ring.expanded (24))) && ! s.intersects (keepClear))
@@ -559,8 +673,8 @@ void FirstSongTour::update()
             place = s;
             place = s;
             break;
             break;
         }
         }
-    if (card->getBounds() != place)
-        card->setBounds (place);
+    if (nativechild::boundsIn (*card, *window) != place)
+        nativechild::place (*card, *window, place);
 }
 }
 
 
 void FirstSongTour::clicked (const juce::String& what)
 void FirstSongTour::clicked (const juce::String& what)
@@ -642,10 +756,10 @@ juce::Rectangle<int> FirstSongTour::ringForSnapshot()
 
 
 juce::String FirstSongTour::targetIdForSnapshot() const
 juce::String FirstSongTour::targetIdForSnapshot() const
 {
 {
-    if (card == nullptr || card->getParentComponent() == nullptr)
+    if (! cardShowing())
         return {};
         return {};
     for (const auto& id : tour::targets (machine.step()))
     for (const auto& id : tour::targets (machine.step()))
-        if (findShowing (*card->getParentComponent(), id) != nullptr)
+        if (findShowing (*shownIn.getComponent(), id) != nullptr)
             return id;
             return id;
     return {};
     return {};
 }
 }

+ 2 - 0
src/ui/FirstSongTour.h

@@ -82,6 +82,7 @@ private:
     void showCard();
     void showCard();
     void hideCard();
     void hideCard();
     void update();             // the card's text and the ring's target
     void update();             // the card's text and the ring's target
+    bool cardShowing() const noexcept; // in its window (as a child component or a native child window, round 190fc)
     void save();
     void save();
     void clicked (const juce::String& what);
     void clicked (const juce::String& what);
 
 
@@ -92,5 +93,6 @@ private:
     std::unique_ptr<Card> card;
     std::unique_ptr<Card> card;
     std::unique_ptr<Layer> layer;
     std::unique_ptr<Layer> layer;
     std::unique_ptr<Welcome> welcome;
     std::unique_ptr<Welcome> welcome;
+    juce::Component::SafePointer<juce::Component> shownIn; // the window the card and the ring are in (while shown)
 };
 };
 } // namespace lynx
 } // namespace lynx

+ 80 - 1
src/ui/MainComponent.cpp

@@ -903,6 +903,7 @@ MainComponent::MainComponent (AudioEngine& e, bool restoreUserSettings)
         if (insert >= 0 && insert < (int) song.mixer.size())
         if (insert >= 0 && insert < (int) song.mixer.size())
             safe->mixer.selectTrack (insert);
             safe->mixer.selectTrack (insert);
     });
     });
+    simpleClickKeys.up = [this] (juce::Component* clicked) { simpleClickEnded (clicked); };
     setSecondaryWindowKeyHandler ([safe = juce::Component::SafePointer<MainComponent> (this)] (const juce::KeyPress& key) {
     setSecondaryWindowKeyHandler ([safe = juce::Component::SafePointer<MainComponent> (this)] (const juce::KeyPress& key) {
         return safe != nullptr && safe->keyFromSecondaryWindow (key);
         return safe != nullptr && safe->keyFromSecondaryWindow (key);
     });
     });
@@ -932,6 +933,7 @@ MainComponent::~MainComponent()
     setKeyboardSettingsListener (nullptr);
     setKeyboardSettingsListener (nullptr);
     setTypingKeyLetters (nullptr);
     setTypingKeyLetters (nullptr);
     juce::Desktop::getInstance().removeGlobalMouseListener (&dockClickWatcher);
     juce::Desktop::getInstance().removeGlobalMouseListener (&dockClickWatcher);
+    juce::Desktop::getInstance().removeGlobalMouseListener (&simpleClickKeys);
     workspace.onWillShow = nullptr;
     workspace.onWillShow = nullptr;
     engine.onSessionUndoSkipped = nullptr;
     engine.onSessionUndoSkipped = nullptr;
     PianoRollComponent::onSelectedKeys = nullptr;
     PianoRollComponent::onSelectedKeys = nullptr;
@@ -954,6 +956,18 @@ MainComponent::~MainComponent()
     PlaylistComponent::shortcutText = nullptr;
     PlaylistComponent::shortcutText = nullptr;
     saveUiSettings();
     saveUiSettings();
     workspace.saveState();
     workspace.saveState();
+    // Round 190fc (0.1.27 RC blocker B1): the Simple workflow goes while everything its Host reaches still exists. As a
+    // member it was destroyed after `workspace` (declared later, destroyed first), and its destructor leaves the style
+    // (SimpleWorkflow::left): Host::setTitleAccessory then reached the destroyed Workspace's panel frames — an access
+    // violation in PanelFrame::setAccessory on every close (and the setup wizard's "Restart now") in the Simple layout.
+    if (simpleWorkflow != nullptr)
+    {
+        playlist.onTrackEffects = nullptr;
+        playlist.onSimpleTrackSelected = nullptr;
+        playlist.onSimpleFilesDropped = nullptr;
+        simpleWorkflow.reset();
+    }
+    simpleWorkflowAliveAfterTeardown = SimpleWorkflow::alive.load();
     ui::uninstallSliderContract();
     ui::uninstallSliderContract();
     ui::onTweak = nullptr;
     ui::onTweak = nullptr;
     themeui::previewStartupSound = nullptr;
     themeui::previewStartupSound = nullptr;
@@ -3292,7 +3306,16 @@ void MainComponent::setLayoutStyle (layoutstyle::Style style, bool swapLayout)
     if (style == Style::simple && simpleWorkflow == nullptr)
     if (style == Style::simple && simpleWorkflow == nullptr)
     {
     {
         SimpleWorkflow::Host host;
         SimpleWorkflow::Host host;
-        host.setOverlay = [this] (juce::Component* c) { playlistArea.setOverlay (c); };
+        host.setOverlay = [this] (juce::Component* c) {
+            // round 190fc (0.1.27 RC H2): an overlay that had the keys (Welcome, Start from, the chooser) gives them back
+            // to the main window when it goes; JUCE would hand them to the first child that takes keys (the dock's
+            // search box, the Lyrics text...), where Space typed instead of playing
+            auto* old = playlistArea.getOverlay();
+            const auto hadKeys = old != nullptr && old != c && old->hasKeyboardFocus (true);
+            playlistArea.setOverlay (c);
+            if (hadKeys && c == nullptr && isShowing())
+                grabKeyboardFocus();
+        };
         host.showKeys = [this] {
         host.showKeys = [this] {
             if (! isTouchKeyboardOpen()) // (round 190p: a new instrument can be played at once, with the mouse too)
             if (! isTouchKeyboardOpen()) // (round 190p: a new instrument can be played at once, with the mouse too)
                 toggleTouchKeyboard (engine);
                 toggleTouchKeyboard (engine);
@@ -3370,6 +3393,11 @@ void MainComponent::setLayoutStyle (layoutstyle::Style style, bool swapLayout)
     }
     }
     if (from == Style::simple && style != Style::simple && simpleWorkflow != nullptr)
     if (from == Style::simple && style != Style::simple && simpleWorkflow != nullptr)
         simpleWorkflow->left();
         simpleWorkflow->left();
+    // round 190fc (H2): every click in the Simple window leaves the keys with the main window (text fields excepted)
+    if (style == Style::simple)
+        juce::Desktop::getInstance().addGlobalMouseListener (&simpleClickKeys);
+    else
+        juce::Desktop::getInstance().removeGlobalMouseListener (&simpleClickKeys);
 
 
     // the workspace layout is kept per style, so going back restores the Pattern layout exactly
     // the workspace layout is kept per style, so going back restores the Pattern layout exactly
     const auto layoutFile = [] (Style s) { return platform::settingsFile (layoutstyle::workspaceFile (s)); };
     const auto layoutFile = [] (Style s) { return platform::settingsFile (layoutstyle::workspaceFile (s)); };
@@ -3584,6 +3612,57 @@ void MainComponent::toggleHotSwap (const hotswap::Target& target)
     browser.beginHotSwap (target);
     browser.beginHotSwap (target);
 }
 }
 
 
+// Round 190fc (0.1.27 RC H2, the #161 family inside the app): in the Simple layout Space often did nothing after a click
+// in the window. Its own controls (the dock's tabs and cards, the Lyrics and Finish buttons, the looks) take the keyboard
+// focus on a click, unlike the Pattern layout's panels, and JUCE then hands the keys to whatever child takes them — the
+// dock's sound search box or the Lyrics text, where Space typed a space; the Finish looks and the chooser's tiles also
+// take Space as a click. FL's rule (issue #9): a click anywhere but in a text field leaves the keys with the main window,
+// so Space plays. So after each click in the main window or one of its panels: unless the click was in a text field, or
+// in a part that keeps its own keys (the overlays with their list and tile keys: property "lynxKeepsKeys"; a dock knob
+// just clicked, for its arrow keys: "lynxClickKeepsKeys"), the main window takes the keys back from a text field, from a
+// panel's control, or from nobody.
+// Plugin windows, dialogs and menus are left alone.
+void MainComponent::simpleClickEnded (juce::Component* clicked)
+{
+    if (layoutStyle != layoutstyle::Style::simple || clicked == nullptr || ! isShowing())
+        return;
+    auto inside = clicked == this || isParentOf (clicked);
+    for (int i = 0; ! inside && i < workspace::panelCount; ++i)
+    {
+        auto& frame = workspace.getFrame ((Panel) i);
+        inside = &frame == clicked || frame.isParentOf (clicked);
+    }
+    if (! inside)
+        return;
+    const auto keepsKeys = [] (juce::Component* c) {
+        for (; c != nullptr; c = c->getParentComponent())
+            if ((bool) c->getProperties().getWithDefault ("lynxKeepsKeys", false))
+                return true;
+        return false;
+    };
+    const auto inTextField = [] (juce::Component* c) {
+        for (; c != nullptr; c = c->getParentComponent())
+            if (dynamic_cast<juce::TextEditor*> (c) != nullptr)
+                return true;
+        return false;
+    };
+    if (inTextField (clicked) || keepsKeys (clicked) || (bool) clicked->getProperties().getWithDefault ("lynxClickKeepsKeys", false))
+        return; // (a knob clicked keeps the arrow keys until the next click elsewhere)
+    // now (the clicked control has acted: this listener runs after its own mouseUp, where a button's click and the Lyrics
+    // panel's text focus happen), and once more after what the click posted has run
+    const auto takeKeys = [keepsKeys, inTextField] (MainComponent* self) {
+        if (self == nullptr || self->layoutStyle != layoutstyle::Style::simple || ! self->isShowing()
+            || juce::Component::getCurrentlyModalComponent() != nullptr) // (a menu or a dialog the click opened)
+            return;
+        auto* focused = juce::Component::getCurrentlyFocusedComponent();
+        if (focused != nullptr && ! inTextField (focused) && (focused == self || self->isParentOf (focused) || keepsKeys (focused)))
+            return; // (the main window, or a part with its own keys, has them)
+        self->grabKeyboardFocus();
+    };
+    takeKeys (this);
+    juce::MessageManager::callAsync ([safe = juce::Component::SafePointer<MainComponent> (this), takeKeys] { takeKeys (safe.getComponent()); });
+}
+
 bool MainComponent::pianoRollKeysHere() const
 bool MainComponent::pianoRollKeysHere() const
 {
 {
     return pianoRollDocked && pianoRollDockActive && pianoRoll.isShowing();
     return pianoRollDocked && pianoRollDockActive && pianoRoll.isShowing();

+ 15 - 0
src/ui/MainComponent.h

@@ -120,6 +120,9 @@ public:
     void setLayoutStyle (layoutstyle::Style style, bool swapLayout = true);
     void setLayoutStyle (layoutstyle::Style style, bool swapLayout = true);
     layoutstyle::Style getLayoutStyle() const noexcept { return layoutStyle; }
     layoutstyle::Style getLayoutStyle() const noexcept { return layoutStyle; }
     SimpleWorkflow* getSimpleWorkflowForSnapshot() noexcept { return simpleWorkflow.get(); } // --simpleshot
     SimpleWorkflow* getSimpleWorkflowForSnapshot() noexcept { return simpleWorkflow.get(); } // --simpleshot
+    // round 190fc (B1): how many Simple workflow objects were still alive when the last MainComponent's destructor body
+    // ended (must be 0: what is left is destroyed after the Workspace, which its Host still reaches); -1: none ended yet
+    static inline int simpleWorkflowAliveAfterTeardown = -1;
     // The Clip-launch workflow's detail view (round 183a), made with the grid; nullptr until then.
     // The Clip-launch workflow's detail view (round 183a), made with the grid; nullptr until then.
     DetailView* getDetailViewForSnapshot() const noexcept { return detailView.get(); }
     DetailView* getDetailViewForSnapshot() const noexcept { return detailView.get(); }
     juce::Component* getClipGridForSnapshot() const noexcept { return clipGridView.get(); } // --gridshot (round 190bv)
     juce::Component* getClipGridForSnapshot() const noexcept { return clipGridView.get(); } // --gridshot (round 190bv)
@@ -714,6 +717,18 @@ private:
         }
         }
     };
     };
     DockClickWatcher dockClickWatcher; // a global listener only while the Piano roll is docked
     DockClickWatcher dockClickWatcher; // a global listener only while the Piano roll is docked
+    // round 190fc (H2): after a click in the Simple window the main window keeps the keys (MainComponent.cpp)
+    struct SimpleClickKeys final : juce::MouseListener
+    {
+        std::function<void (juce::Component*)> up;
+        void mouseUp (const juce::MouseEvent& e) override
+        {
+            if (up != nullptr)
+                up (e.eventComponent);
+        }
+    };
+    SimpleClickKeys simpleClickKeys; // (its `up` is set in the constructor)
+    void simpleClickEnded (juce::Component* clicked);
     bool pianoRollDockActive = false;
     bool pianoRollDockActive = false;
     bool runDetailAction (const std::string& id);
     bool runDetailAction (const std::string& id);
     void openGridClip (int track, int scene);
     void openGridClip (int track, int scene);

+ 58 - 0
src/ui/NativeChild.cpp

@@ -443,6 +443,22 @@ void installClickHook()
 struct KeyForwarder final : juce::KeyListener
 struct KeyForwarder final : juce::KeyListener
 {
 {
     bool keyPressed (const juce::KeyPress& key, juce::Component*) override { return runSecondaryWindowKey (key); }
     bool keyPressed (const juce::KeyPress& key, juce::Component*) override { return runSecondaryWindowKey (key); }
+
+    // Round 190fc (0.1.27 RC H2): a key-down that nothing in an attached window used is posted on to the parent window by
+    // JUCE (HWNDComponentPeer: WM_KEYDOWN -> doKeyDown false -> forwardMessageToParent). The main window's peer then
+    // finds no WM_CHAR of its own and makes a key press of it for the focused component, which is still the one in this
+    // window: its keys reached the shortcuts twice, so Space played and stopped at once ("Space does nothing" after a
+    // click on a control of the Simple dock or title bar). The key press itself still comes here (the WM_CHAR, or
+    // JUCE's own for keys without a character) and keyPressed forwards it once, so the key-down is taken as used.
+    bool keyStateChanged (bool isKeyDown, juce::Component* origin) override
+    {
+       #if JUCE_WINDOWS
+        return isKeyDown && origin != nullptr && isAttached (*origin);
+       #else
+        juce::ignoreUnused (isKeyDown, origin);
+        return false;
+       #endif
+    }
 };
 };
 
 
 KeyForwarder& keyForwarder()
 KeyForwarder& keyForwarder()
@@ -672,6 +688,16 @@ void removeFloater (juce::Component& c)
     dropDeleted (floaters(), &c);
     dropDeleted (floaters(), &c);
 }
 }
 
 
+void passInputThrough (juce::Component& c)
+{
+   #if JUCE_WINDOWS
+    if (auto* hwnd = static_cast<HWND> (c.getWindowHandle()); hwnd != nullptr && isAttached (c))
+        SetWindowLongPtr (hwnd, GWL_EXSTYLE, GetWindowLongPtr (hwnd, GWL_EXSTYLE) | WS_EX_TRANSPARENT);
+   #else
+    juce::ignoreUnused (c);
+   #endif
+}
+
 void keepFloatersInFront()
 void keepFloatersInFront()
 {
 {
    #if JUCE_WINDOWS
    #if JUCE_WINDOWS
@@ -929,6 +955,38 @@ void postClickForTest (void* window, juce::Point<int> clientPoint)
    #endif
    #endif
 }
 }
 
 
+bool pressSpaceForTest (void* fallback)
+{
+   #if JUCE_WINDOWS
+    auto to = GetFocus();
+    DWORD pid = 0;
+    if (to != nullptr)
+        GetWindowThreadProcessId (to, &pid);
+    if (to == nullptr || pid != GetCurrentProcessId())
+        to = static_cast<HWND> (fallback);
+    if (to == nullptr)
+        return false;
+    const auto scan = MapVirtualKeyW (VK_SPACE, MAPVK_VK_TO_VSC);
+    PostMessageW (to, WM_KEYDOWN, VK_SPACE, (LPARAM) (1u | (scan << 16)));
+    PostMessageW (to, WM_KEYUP, VK_SPACE, (LPARAM) (1u | (scan << 16) | (1u << 30) | (1u << 31)));
+    const auto until = GetTickCount64() + 120;
+    MSG m;
+    while (GetTickCount64() < until)
+    {
+        while (PeekMessageW (&m, nullptr, 0, 0, PM_REMOVE))
+        {
+            TranslateMessage (&m);
+            DispatchMessageW (&m);
+        }
+        Sleep (5);
+    }
+    return true;
+   #else
+    juce::ignoreUnused (fallback);
+    return false;
+   #endif
+}
+
 bool isLayered (void* window)
 bool isLayered (void* window)
 {
 {
    #if JUCE_WINDOWS
    #if JUCE_WINDOWS

+ 8 - 0
src/ui/NativeChild.h

@@ -72,6 +72,10 @@ void raiseOverlays();
 // drawing in the main window's components.
 // drawing in the main window's components.
 bool supportsFloaters();
 bool supportsFloaters();
 void addFloater (juce::Component& c);
 void addFloater (juce::Component& c);
+// An attached floater that never takes the mouse or a drop (round 190fc: the first-song tour's dimmed layer): the system
+// passes every click, wheel and file drop through it to the window under it (Windows: WS_EX_TRANSPARENT on its layered
+// window; elsewhere nothing more than the windowIgnoresMouseClicks flag it was attached with).
+void passInputThrough (juce::Component& c);
 void removeFloater (juce::Component& c);
 void removeFloater (juce::Component& c);
 // A floater or an overlay with an attached sibling above it that is neither: raiseOverlays (Windows; a cheap walk of
 // A floater or an overlay with an attached sibling above it that is neither: raiseOverlays (Windows; a cheap walk of
 // the siblings above each one). Elsewhere: nothing (raiseOverlays already runs on every stacking change).
 // the siblings above each one). Elsewhere: nothing (raiseOverlays already runs on every stacking change).
@@ -130,6 +134,10 @@ bool isLayered (void* window);
 // of its client area, in physical pixels (a message to that window only: nothing goes through the system's input).
 // of its client area, in physical pixels (a message to that window only: nothing goes through the system's input).
 void* innermostChild (void* window);
 void* innermostChild (void* window);
 void postClickForTest (void* window, juce::Point<int> clientPoint);
 void postClickForTest (void* window, juce::Point<int> clientPoint);
+// Tests (Windows; elsewhere false), round 190fc: Space pressed as the system delivers it — key-down and key-up posted to the
+// window that has the system's keyboard focus (when it is one of LYNX's own; else `fallback`), then the thread's
+// messages pumped for a moment (TranslateMessage makes the character, as for a real key). True when it was posted.
+bool pressSpaceForTest (void* fallback);
 // Tests (Windows; elsewhere 0): the system's hit test of the component's own native window at its local point: 1
 // Tests (Windows; elsewhere 0): the system's hit test of the component's own native window at its local point: 1
 // (HTCLIENT) = the window takes the mouse there, -1 (HTTRANSPARENT) = the click goes to the window under it. (Round
 // (HTCLIENT) = the window takes the mouse there, -1 (HTTRANSPARENT) = the click goes to the window under it. (Round
 // 190cj: an attached component that is not opaque answers "transparent" wherever its hitTest says no.)
 // 190cj: an attached component that is not opaque answers "transparent" wherever its hitTest says no.)

+ 2 - 0
src/ui/PlaylistComponent.h

@@ -181,6 +181,7 @@ public:
     void setScrollTickForSnapshot (double tick) { scrollTicks = tick; repaint(); }
     void setScrollTickForSnapshot (double tick) { scrollTicks = tick; repaint(); }
     // round 190ef (--drawshot190ef): where a lane's curve is drawn, and the x of a tick
     // round 190ef (--drawshot190ef): where a lane's curve is drawn, and the x of a tick
     juce::Rectangle<float> laneBodyForSnapshot (int track, int lane) const { return laneBody (track, lane); }
     juce::Rectangle<float> laneBodyForSnapshot (int track, int lane) const { return laneBody (track, lane); }
+    juce::Rectangle<int> trackRowForSnapshot (int track) const { return { 0, trackToY (track), getWidth(), heightOf (track) }; } // (round 190fc)
     double xOfTickForSnapshot (double tick) const { return tickToX (tick); }
     double xOfTickForSnapshot (double tick) const { return tickToX (tick); }
     juce::PopupMenu getClipMenuForSnapshot (int index); // --snapshot: the clip menu of that clip
     juce::PopupMenu getClipMenuForSnapshot (int index); // --snapshot: the clip menu of that clip
     juce::PopupMenu getAutomationPointMenuForSnapshot (int clip, int point); // FL's point menu of an automation clip's point (round 190bw)
     juce::PopupMenu getAutomationPointMenuForSnapshot (int clip, int point); // FL's point menu of an automation clip's point (round 190bw)
@@ -789,6 +790,7 @@ public:
 
 
     // A component over everything under the toolbar band (round 184a: the Simple workflow's New track chooser); not
     // A component over everything under the toolbar band (round 184a: the Simple workflow's New track chooser); not
     // owned, nullptr = none.
     // owned, nullptr = none.
+    juce::Component* getOverlay() const noexcept { return overlay; }
     void setOverlay (juce::Component* c)
     void setOverlay (juce::Component* c)
     {
     {
         if (overlay != nullptr && overlay != c)
         if (overlay != nullptr && overlay != c)

+ 1 - 0
src/ui/SimpleDock.cpp

@@ -77,6 +77,7 @@ public:
     DockKnob()
     DockKnob()
     {
     {
         setWantsKeyboardFocus (true);
         setWantsKeyboardFocus (true);
+        getProperties().set ("lynxClickKeepsKeys", true); // (round 190fc: clicked, the arrow keys turn it; Space still plays)
         setMouseCursor (juce::MouseCursor::UpDownResizeCursor);
         setMouseCursor (juce::MouseCursor::UpDownResizeCursor);
     }
     }
 
 

+ 4 - 0
src/ui/SimpleWorkflow.cpp

@@ -213,6 +213,7 @@ public:
           loops (Glyph::loops, kindColour (Kind::audio), tr ("Loops"), tr ("Browse loops and drag them onto the timeline."))
           loops (Glyph::loops, kindColour (Kind::audio), tr ("Loops"), tr ("Browse loops and drag them onto the timeline."))
     {
     {
         setWantsKeyboardFocus (true);
         setWantsKeyboardFocus (true);
+        getProperties().set ("lynxKeepsKeys", true); // (round 190fc: its tiles' keys while it is up)
         title.setText (tr ("New track"), juce::dontSendNotification);
         title.setText (tr ("New track"), juce::dontSendNotification);
         title.setFont (theme::font (theme::type::display, true));
         title.setFont (theme::font (theme::type::display, true));
         title.setJustificationType (juce::Justification::centred);
         title.setJustificationType (juce::Justification::centred);
@@ -507,6 +508,7 @@ private:
 SimpleWorkflow::SimpleWorkflow (AudioEngine& e, Host h) : engine (e), host (std::move (h))
 SimpleWorkflow::SimpleWorkflow (AudioEngine& e, Host h) : engine (e), host (std::move (h))
 {
 {
     instances.fetch_add (1, std::memory_order_relaxed);
     instances.fetch_add (1, std::memory_order_relaxed);
+    alive.fetch_add (1, std::memory_order_relaxed);
     auto button = std::make_unique<AddTrackButton>();
     auto button = std::make_unique<AddTrackButton>();
     button->onClick = [this] { showChooser(); };
     button->onClick = [this] { showChooser(); };
     addButton = std::move (button);
     addButton = std::move (button);
@@ -524,6 +526,7 @@ SimpleWorkflow::SimpleWorkflow (AudioEngine& e, Host h) : engine (e), host (std:
     // round 190ch: the project's Lyrics / Notes panel, docked beside the timeline
     // round 190ch: the project's Lyrics / Notes panel, docked beside the timeline
     auto lyrics = std::make_unique<juce::TextButton> (tr ("Lyrics"));
     auto lyrics = std::make_unique<juce::TextButton> (tr ("Lyrics"));
     lyrics->setTooltip (tr ("Lyrics and notes of this project"));
     lyrics->setTooltip (tr ("Lyrics and notes of this project"));
+    lyrics->setComponentID ("simple.lyrics");
     lyrics->onClick = [this] {
     lyrics->onClick = [this] {
         if (host.toggleLyrics)
         if (host.toggleLyrics)
             host.toggleLyrics();
             host.toggleLyrics();
@@ -622,6 +625,7 @@ SimpleWorkflow::~SimpleWorkflow()
     if (active)
     if (active)
         left();
         left();
     tour.reset(); // (before the chooser and the docks it may point at)
     tour.reset(); // (before the chooser and the docks it may point at)
+    alive.fetch_sub (1, std::memory_order_relaxed);
 }
 }
 
 
 // --- the Welcome screen and the first-song tour (round 190dv) ------------------------------------------------------------
 // --- the Welcome screen and the first-song tour (round 190dv) ------------------------------------------------------------

+ 2 - 0
src/ui/SimpleWorkflow.h

@@ -128,6 +128,8 @@ public:
 
 
     // how many were ever made in this process (the "nothing exists in Pattern workflow" check)
     // how many were ever made in this process (the "nothing exists in Pattern workflow" check)
     static inline std::atomic<int> instances { 0 };
     static inline std::atomic<int> instances { 0 };
+    // how many exist now (round 190fc: none may outlive its MainComponent's destructor body)
+    static inline std::atomic<int> alive { 0 };
 
 
 private:
 private:
     class Chooser;
     class Chooser;

+ 1 - 0
src/ui/StartFromPanel.cpp

@@ -161,6 +161,7 @@ private:
 StartFromPanel::StartFromPanel (AudioEngine& e, Hooks h) : engine (e), hooks (std::move (h)), shared (std::make_shared<Shared>())
 StartFromPanel::StartFromPanel (AudioEngine& e, Hooks h) : engine (e), hooks (std::move (h)), shared (std::make_shared<Shared>())
 {
 {
     setWantsKeyboardFocus (true);
     setWantsKeyboardFocus (true);
+    getProperties().set ("lynxKeepsKeys", true); // (round 190fc: its list keys while it is up; MainComponent::simpleClickEnded)
     setTitle (tr ("Start from"));
     setTitle (tr ("Start from"));
     title.setText (tr ("Start from"), juce::dontSendNotification);
     title.setText (tr ("Start from"), juce::dontSendNotification);
     title.setFont (theme::font (theme::type::display, true));
     title.setFont (theme::font (theme::type::display, true));

+ 102 - 0
tests/Rcfix190fcTests.inc

@@ -0,0 +1,102 @@
+// Round 190fc: the 0.1.27 release candidate's blocker and the two HIGH bugs of its interactive QA (round 190fb).
+// (B1) Every close in the Simple layout crashed (access violation in PanelFrame::setAccessory): MainComponent's
+//      `simpleWorkflow` member is declared before `workspace`, so it was destroyed after it, and ~SimpleWorkflow leaves
+//      the style through its Host (setTitleAccessory -> the destroyed Workspace's frames). The destructor body now
+//      destroys it while everything exists. The app route --simpleclosetest closes the main window with everything of
+//      the Simple layout open (run under ASan on Linux and on Windows).
+// (H1) The first-song tour's card and ring were children of the main window, under the panels' native child windows:
+//      they are floaters now (ui/NativeChild.h), the ring passing every click and drop through.
+// (H2) Space did nothing after clicks in the Simple window (the keys went to the dock's search box, a button, nobody):
+//      MainComponent::simpleClickEnded gives them back to the main window (text fields excepted), and an overlay that
+//      had the keys returns them when it goes. The app route --simplekeytest clicks and presses Space as the system does.
+// These are the source guards; the behaviour is checked by the two app routes.
+
+namespace rcfix190fc
+{
+inline std::size_t after (const std::string& text, const std::string& what, std::size_t from = 0)
+{
+    const auto at = text.find (what, from);
+    return at == std::string::npos ? std::string::npos : at + what.size();
+}
+} // namespace rcfix190fc
+
+TEST (rcfix190fc_simple_workflow_goes_before_the_workspace)
+{
+    using namespace i18ntest;
+    const auto header = readFile ("src/ui/MainComponent.h");
+    const auto member = header.find ("std::unique_ptr<SimpleWorkflow> simpleWorkflow;");
+    const auto workspace = header.find ("Workspace workspace;");
+    CHECK (member != std::string::npos && workspace != std::string::npos);
+    const auto source = readFile ("src/ui/MainComponent.cpp");
+    const auto dtor = source.find ("MainComponent::~MainComponent()");
+    const auto end = source.find ("\nvoid MainComponent::paint", dtor);
+    const auto reset = source.find ("simpleWorkflow.reset();", dtor);
+    CHECK (dtor != std::string::npos && end != std::string::npos);
+    // declared before the Workspace (so a plain member would outlive it): the destructor body must destroy it
+    if (member < workspace)
+        CHECK (reset != std::string::npos && reset < end);
+    CHECK (source.find ("simpleWorkflowAliveAfterTeardown = SimpleWorkflow::alive.load();", dtor) < end);
+    // ~SimpleWorkflow still leaves the style through the Host: only safe while the owner's members exist
+    const auto simple = readFile ("src/ui/SimpleWorkflow.cpp");
+    CHECK (simple.find ("alive.fetch_sub (1, std::memory_order_relaxed);") != std::string::npos);
+    // the route exists and is wired
+    const auto main = readFile ("src/Main.cpp");
+    CHECK (main.find ("args.contains (\"--simpleclosetest\")") != std::string::npos);
+    CHECK (main.find ("bool runSimpleCloseTest (const juce::String& reportPath)") != std::string::npos);
+}
+
+TEST (rcfix190fc_tour_card_floats_above_the_native_panels)
+{
+    using namespace i18ntest;
+    const auto tour = readFile ("src/ui/FirstSongTour.cpp");
+    const auto show = tour.find ("void FirstSongTour::showCard()");
+    CHECK (show != std::string::npos);
+    CHECK (tour.find ("nativechild::addFloater (c);", show) != std::string::npos);
+    CHECK (tour.find ("nativechild::passInputThrough (c);", show) != std::string::npos);
+    CHECK (tour.find ("juce::ComponentPeer::windowIgnoresMouseClicks", show) != std::string::npos);
+    // the ring finds its targets inside the panels' native windows too
+    CHECK (tour.find ("nativechild::attachedChildren (peer->getNativeHandle())") != std::string::npos);
+    // the card takes no focus
+    const auto card = tour.find ("class FirstSongTour::Card final");
+    CHECK (tour.find ("setWantsKeyboardFocus (false);", card) < tour.find ("void show (int stepIndex, bool done)", card));
+    CHECK (tour.find ("setMouseClickGrabsKeyboardFocus (false);", card) < tour.find ("void show (int stepIndex, bool done)", card));
+}
+
+TEST (rcfix190fc_simple_clicks_leave_the_keys_with_the_main_window)
+{
+    using namespace i18ntest;
+    const auto source = readFile ("src/ui/MainComponent.cpp");
+    const auto handler = source.find ("void MainComponent::simpleClickEnded (juce::Component* clicked)");
+    CHECK (handler != std::string::npos);
+    // text fields keep their keys; the overlays and knobs that keep theirs say so
+    CHECK (source.find ("dynamic_cast<juce::TextEditor*> (c) != nullptr", handler) != std::string::npos);
+    CHECK (source.find ("\"lynxKeepsKeys\"", handler) != std::string::npos);
+    CHECK (source.find ("juce::Component::getCurrentlyModalComponent() != nullptr", handler) != std::string::npos);
+    CHECK (source.find ("addGlobalMouseListener (&simpleClickKeys)") != std::string::npos);
+    CHECK (source.find ("removeGlobalMouseListener (&simpleClickKeys)") != std::string::npos);
+    // an overlay that had the keys gives them back when it goes
+    CHECK (source.find ("const auto hadKeys = old != nullptr && old != c && old->hasKeyboardFocus (true);") != std::string::npos);
+    CHECK (readFile ("src/ui/SimpleDock.cpp").find ("getProperties().set (\"lynxClickKeepsKeys\", true);") != std::string::npos);
+    for (const char* file : { "src/ui/StartFromPanel.cpp", "src/ui/FirstSongTour.cpp", "src/ui/SimpleWorkflow.cpp" })
+        CHECK (readFile (file).find ("getProperties().set (\"lynxKeepsKeys\", true);") != std::string::npos);
+    const auto main = readFile ("src/Main.cpp");
+    CHECK (main.find ("args.contains (\"--simplekeytest\")") != std::string::npos);
+    // Windows: a key-down unused in an attached window is not also posted to the main window (it ran every shortcut twice)
+    const auto native = readFile ("src/ui/NativeChild.cpp");
+    const auto forwarder = native.find ("struct KeyForwarder final : juce::KeyListener");
+    CHECK (forwarder != std::string::npos);
+    CHECK (native.find ("bool keyStateChanged (bool isKeyDown, juce::Component* origin) override", forwarder) < native.find ("KeyForwarder& keyForwarder()"));
+}
+
+TEST (rcfix190fc_edison_slot_window_docks)
+{
+    using namespace i18ntest;
+    const auto editor = readFile ("src/ui/AudioEditor.cpp");
+    const auto open = editor.find ("AudioEditor* openWindow (AudioEngine& engine, Source source)");
+    CHECK (open != std::string::npos);
+    CHECK (rcfix190fc::after (editor, "if (source.kind == Source::Kind::slot)\n            dockOrKeepAbove (*window);", open) != std::string::npos);
+    // --plugwintest clicks the docked editor where it can be seen (JUCE drops a button-down on a covered point)
+    const auto main = readFile ("src/Main.cpp");
+    CHECK (main.find ("editor_title_visible_at=") != std::string::npos);
+    CHECK (main.find ("lynx::nativechild::postClickForTest (h, { 60, 8 });") == std::string::npos);
+}

+ 1 - 0
tests/tests.cpp

@@ -17565,3 +17565,4 @@ TEST (fl_low_lifter_matches_fl_engine)
 #include "Iss158Tests.inc"
 #include "Iss158Tests.inc"
 #include "Voices190ejTests.inc"
 #include "Voices190ejTests.inc"
 #include "Flfix190ezTests.inc"
 #include "Flfix190ezTests.inc"
+#include "Rcfix190fcTests.inc"