Răsfoiți Sursa

Round 190rv checks: --bugs190rvtest [shot prefix] and --selftest bugs190rv (#317, #319)

- #317: every native effect editor with the header LED (112: FL layouts, LYNX layouts, display-first editors, Facet EQ)
  finds the LED by its hint, a click turns the effect off and on, Ctrl+click solos it.
- #319 (Linux): a window with a child X window (a plugin editor's stand-in) pinned and unpinned keeps its peer, its X
  window and the child window.
- Shots: the Fruity Limiter / Facet EQ headers on and off at 100 % and 150 %.
- --plugwintest opens an effect's window with its insert / slot, as the Mixer does (the side-chain picker and #321's
  ON / MIX LEVEL show there now).
Ka1-S 1 săptămână în urmă
părinte
comite
fb4efbf4cf
2 a modificat fișierele cu 198 adăugiri și 2 ștergeri
  1. 178 0
      src/Bugs190rvCheck.inc
  2. 20 2
      src/Main.cpp

+ 178 - 0
src/Bugs190rvCheck.inc

@@ -0,0 +1,178 @@
+    // Round 190rv (0.1.32 open bug issues). Included in the app class of Main.cpp; --bugs190rvtest <report> and --selftest
+    // "bugs190rv".
+    //  #317 the power LED in the header of LYNX's own effect windows (the generic panels with FL's or LYNX's layout, the
+    //       display-first editors, Facet EQ) was only drawn: a click did nothing, while the Mixer slot's LED worked. For
+    //       every such editor: the LED's hint, a click turns the effect off and on again, Ctrl+click solos it (the Mixer
+    //       LED's edits).
+    //  #319 Linux: the pin of a plugin window ("Always on top") made JUCE destroy the window and make a new one, and the
+    //       X11-embedded plugin editor in the old one went with it (a blank editor). The window and a child window in it
+    //       stay the same through pin on / off now (JUCE fix 190rv).
+    juce::String bugs190rvCheck (juce::String& log, const juce::String& shots = {})
+    {
+        using namespace lynx;
+        juce::String result = "OK";
+        const auto check = [&] (const juce::String& what, bool ok, const juce::String& detail = {}) {
+            log << (ok ? "ok   " : "FAIL ") << what << (detail.isNotEmpty() ? "  [" + detail + "]" : juce::String()) << "\n";
+            if (! ok && result == "OK")
+                result = "ERROR " + what + " " + detail;
+        };
+        const auto mouseOn = [] (juce::Component& target, juce::Point<float> p, juce::ModifierKeys mods) {
+            auto source = juce::Desktop::getInstance().getMainMouseSource();
+            const auto now = juce::Time::getCurrentTime();
+            return juce::MouseEvent (source, p, mods, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, &target, &target, now, p, now, 1, false);
+        };
+
+        // ---- #317 --------------------------------------------------------------------------------------------------
+        {
+            AudioEngine offline (false);
+            offline.setSong (Song::makeDefault());
+            offline.dispatchPendingMessages();
+            std::vector<EffectKind> kinds = plugui::flLayoutKinds();
+            for (const auto k : plugui::ownLayoutKinds())
+                kinds.push_back (k);
+            for (int k = 0; k <= (int) EffectKind::harmonia; ++k)
+                if (ProEditorWindows::handles ((EffectKind) k))
+                    kinds.push_back ((EffectKind) k);
+            kinds.push_back (EffectKind::facetEq);
+            std::sort (kinds.begin(), kinds.end());
+            kinds.erase (std::unique (kinds.begin(), kinds.end()), kinds.end());
+
+            int withLed = 0, toggled = 0;
+            juce::StringArray noLed, failed;
+            const auto enabledOf = [&offline] (int slot) {
+                const auto& fx = offline.getSong().mixer[1].effects;
+                return slot < (int) fx.size() && fx[(std::size_t) slot].enabled;
+            };
+            for (const auto kind : kinds)
+            {
+                // the effect in slot 1 of insert 1, another effect in slot 2 (for the solo)
+                offline.editSong ([kind] (Song& s) { s.mixer[1].effects = { makeEffectSlot (EffectKind::eq), makeEffectSlot (kind) }; });
+                offline.dispatchPendingMessages();
+                const auto name = juce::String (effectInfo (kind).name);
+                std::unique_ptr<juce::Component> editor;
+                if (kind == EffectKind::facetEq)
+                    editor = makeFacetEqEditor (offline, 1, 1);
+                else if (ProEditorWindows::handles (kind))
+                    editor = makeProEditor (offline, 1, 1);
+                else
+                    editor = makeNativeEffectEditor (offline, 1, 1);
+                if (editor == nullptr || editor->getWidth() <= 0)
+                    continue;
+                auto* hints = dynamic_cast<ui::HintSource*> (editor.get());
+                if (hints == nullptr)
+                {
+                    noLed.add (name + " (no hint source)");
+                    continue;
+                }
+                // the LED: where the header's slot grid puts it (compact below 520 px), found through its hint
+                std::optional<juce::Point<float>> led;
+                const auto ledX = editor->getWidth() < (int) pluginheader::compactBelow ? 28 : 48;
+                for (int y = 2; y < 40 && ! led; ++y)
+                    if (hints->hintAt ({ ledX, y }).text == pluginheader::ledHint())
+                        led = juce::Point<float> ((float) ledX, (float) y + 2.0f);
+                if (! led)
+                {
+                    noLed.add (name);
+                    continue;
+                }
+                ++withLed;
+                const auto click = [&] (juce::ModifierKeys mods) {
+                    editor->mouseDown (mouseOn (*editor, *led, mods.withFlags (juce::ModifierKeys::leftButtonModifier)));
+                    editor->mouseUp (mouseOn (*editor, *led, mods));
+                    offline.dispatchPendingMessages();
+                };
+                // (shots: the header of Fruity Limiter's and Facet EQ's windows, the effect on and off, 100 % and 150 %)
+                const auto shoot = [&] (const juce::String& state) {
+                    if (shots.isEmpty() || (kind != EffectKind::fruityLimiter && kind != EffectKind::facetEq))
+                        return;
+                    const auto top = juce::Rectangle<int> (0, 0, editor->getWidth(), juce::jmin (editor->getHeight(), 80));
+                    for (const auto scale : { 1.0f, 1.5f })
+                    {
+                        juce::PNGImageFormat png;
+                        const juce::File f (shots + "-317-" + (kind == EffectKind::facetEq ? "facet" : "limiter") + "-" + state + (scale > 1.0f ? "@150" : "") + ".png");
+                        f.deleteFile();
+                        if (auto out = f.createOutputStream())
+                            png.writeImageToStream (editor->createComponentSnapshot (top, true, scale), *out);
+                    }
+                };
+                const auto before = enabledOf (1);
+                shoot ("on");
+                click ({});
+                shoot ("off");
+                const auto off = enabledOf (1);
+                click ({});
+                const auto on = enabledOf (1);
+                click (juce::ModifierKeys (juce::ModifierKeys::ctrlModifier)); // solo: only this effect of the insert on
+                const auto soloed = enabledOf (1) && ! enabledOf (0);
+                if (before && ! off && on && soloed)
+                    ++toggled;
+                else
+                    failed.add (name + " (" + juce::String ((int) before) + juce::String ((int) off) + juce::String ((int) on) + juce::String ((int) soloed) + ")");
+            }
+            log << "     #317 editors without a header LED: " << (noLed.isEmpty() ? juce::String ("none") : noLed.joinIntoString (", ")) << "\n";
+            check ("#317: a click on the header's LED of " + juce::String (withLed) + " native effect editors turns the effect off and on, Ctrl+click solos it",
+                   withLed > 40 && toggled == withLed, failed.joinIntoString (", "));
+        }
+
+        // ---- #319 --------------------------------------------------------------------------------------------------
+       #if JUCE_LINUX
+        if (juce::Desktop::getInstance().getDisplays().getPrimaryDisplay() != nullptr)
+        {
+            auto* x11 = dlopen ("libX11.so.6", RTLD_NOW | RTLD_NOLOAD);
+            using CreateWindow = unsigned long (*) (void*, unsigned long, int, int, unsigned, unsigned, unsigned, unsigned long, unsigned long);
+            using QueryTree = int (*) (void*, unsigned long, unsigned long*, unsigned long*, unsigned long**, unsigned*);
+            using MapWindow = int (*) (void*, unsigned long);
+            using Sync = int (*) (void*, int);
+            using Free = int (*) (void*);
+            using Destroy = int (*) (void*, unsigned long);
+            auto* createWindow = x11 != nullptr ? (CreateWindow) dlsym (x11, "XCreateSimpleWindow") : nullptr;
+            auto* queryTree = x11 != nullptr ? (QueryTree) dlsym (x11, "XQueryTree") : nullptr;
+            auto* mapWindow = x11 != nullptr ? (MapWindow) dlsym (x11, "XMapWindow") : nullptr;
+            auto* sync = x11 != nullptr ? (Sync) dlsym (x11, "XSync") : nullptr;
+            auto* xfree = x11 != nullptr ? (Free) dlsym (x11, "XFree") : nullptr;
+            auto* destroy = x11 != nullptr ? (Destroy) dlsym (x11, "XDestroyWindow") : nullptr;
+            auto* display = juce::lynxX11Display();
+            if (createWindow != nullptr && queryTree != nullptr && mapWindow != nullptr && sync != nullptr && xfree != nullptr && destroy != nullptr
+                && display != nullptr)
+            {
+                juce::DocumentWindow window ("bugs190rv pin", juce::Colours::black, juce::DocumentWindow::closeButton);
+                window.setUsingNativeTitleBar (true);
+                window.setSize (300, 200);
+                window.setVisible (true);
+                auto* peerBefore = window.getPeer();
+                const auto handle = peerBefore != nullptr ? (unsigned long) (juce::pointer_sized_uint) peerBefore->getNativeHandle() : 0ul;
+                // a stand-in for a plugin's own editor window, embedded in the plugin window as a VST3 / CLAP / LV2 editor is
+                const auto child = handle != 0 ? createWindow (display, handle, 0, 0, 100, 100, 0, 0, 0) : 0ul;
+                if (child != 0)
+                    mapWindow (display, child);
+                sync (display, 0);
+                const auto childOf = [&] (unsigned long parent) {
+                    unsigned long root = 0, up = 0, *children = nullptr;
+                    unsigned n = 0;
+                    if (queryTree (display, child, &root, &up, &children, &n) == 0)
+                        return false; // the child window is gone (BadWindow is ignored by JUCE's error handler)
+                    if (children != nullptr)
+                        xfree (children);
+                    return up == parent;
+                };
+                window.setAlwaysOnTop (true);
+                sync (display, 0);
+                const auto samePinned = window.getPeer() == peerBefore && window.getPeer() != nullptr
+                                        && (unsigned long) (juce::pointer_sized_uint) window.getPeer()->getNativeHandle() == handle;
+                const auto childPinned = child != 0 && childOf (handle);
+                window.setAlwaysOnTop (false);
+                sync (display, 0);
+                const auto sameUnpinned = window.getPeer() == peerBefore && child != 0 && childOf (handle);
+                check ("#319: pinning a window (always on top) keeps its X window and the editor window inside it, also when unpinned",
+                       samePinned && childPinned && sameUnpinned && window.isAlwaysOnTop() == false,
+                       juce::String ((int) samePinned) + juce::String ((int) childPinned) + juce::String ((int) sameUnpinned));
+                if (child != 0 && childOf (handle))
+                    destroy (display, child);
+                sync (display, 0);
+            }
+            else
+                log << "     #319 skipped: no X11 display\n";
+        }
+       #endif
+        return result;
+    }

+ 20 - 2
src/Main.cpp

@@ -152,6 +152,7 @@
 #include "ui/TiltViewport.h"
 #if JUCE_LINUX
  #include <dlfcn.h> // (round 190ou: --hwheel254test presses X11 buttons through XTest)
+namespace juce { void* lynxX11Display(); } // (JUCE fix 41's accessor of its X11 display; round 190rv's #319 check)
  #include <sys/prctl.h> // (round 190ou: --multieditor255test LYNX_ME_PTRACE=1)
  #include <sys/socket.h> // (round 190rf: --qa190rfchild display)
  #include <unistd.h>
@@ -2237,6 +2238,18 @@ public:
            #endif
             std::_Exit (2); // (not reached when the display part ran)
         }
+        if (args.contains ("--bugs190rvtest"))
+        {
+            // LYNX --bugs190rvtest report.txt [shot prefix] (round 190rv, the 0.1.32 open bug issues; also in --selftest): src/Bugs190rvCheck.inc
+            juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
+            juce::String log;
+            const auto i = args.indexOf ("--bugs190rvtest");
+            const auto result = bugs190rvCheck (log, i + 2 < args.size() ? args[i + 2].unquoted() : juce::String());
+            juce::File (args[i + 1].unquoted()).replaceWithText (log + "bugs190rv=" + result + "\n");
+            setApplicationReturnValue (result == "OK" ? 0 : 1);
+            quit();
+            return;
+        }
         if (args.contains ("--community190ritest"))
         {
             // LYNX --community190ritest report.txt [shot prefix] (round 190ri, the community batch of 0.1.32; also in --selftest):
@@ -10380,6 +10393,9 @@ private:
         // UI monkey test (src/Qa190rbCheck.inc)
         juce::String qa190rbLog;
         const auto qa190rbResult = qa190rbCheck (qa190rbLog);
+        // round 190rv (0.1.32 open bug issues): #317 the native editors' header LED, #319 the pin keeps the window (src/Bugs190rvCheck.inc)
+        juce::String bugs190rvLog;
+        const auto bugs190rvResult = bugs190rvCheck (bugs190rvLog);
 
         // round 190qh (research190qa R5, Mixer QoL): FL's rule for a switched-off slot through the app's own publish
         // (D2-MX9, REA 190qc: its latency leaves the plan at once, a muted insert keeps it), the theme's own meter
@@ -11801,7 +11817,7 @@ private:
                         && sidechainResult == "OK" && lanesResult == "OK" && arrange190cgResult == "OK" && livescr190drResult == "OK" && livewf190efResult == "OK" && livewf190emResult == "OK" && trackclips190neResult == "OK" && tracker190nwResult == "OK" && tracker190obResult == "OK" && rackauto190ooResult == "OK" && tracker190omResult == "OK" && rackauto190owResult == "OK" && versionsResult == "OK" && pluginsOffResult == "OK" && missingFilesResult == "OK"
                         && midigen190fmResult == "OK" && clipenv190giResult == "OK" && beatslaw190gxResult == "OK" && warplaw190ikResult == "OK" && editorScale190heResult == "OK" && sfModBase190heResult == "OK" && trackauto190gzResult == "OK" && community190hqResult == "OK" && rollup030Result == "OK" && rollup031Result == "OK" && rollup031s2Result == "OK"
                         && keys190nuResult == "OK" && rollup031s3Result == "OK"
-                        && helix4khs190ocResult == "OK" && rollup031s4Result == "OK" && sections190olResult == "OK" && rollup031s5Result == "OK" && simpleDuck190otResult == "OK" && tracks190peResult == "OK" && issue258Result == "OK" && issues190qrResult == "OK" && backlog190rcResult == "OK" && community190riResult == "OK" && iox190rmResult == "OK" && perf190rnResult == "OK" && qa190rbResult == "OK" && repeats190pmResult == "OK" && mixerqol190qhResult == "OK" && autolive190qpResult == "OK" && issue282Result == "OK" && feel190qeResult == "OK" && toolbar190qgResult == "OK" && extras190qkResult == "OK" && extras190roResult == "OK" && discord190quResult == "OK" && trialmark190qtResult == "OK" && optionsux190qxResult == "OK" && chordlane190pfResult == "OK" && autolinks190ovResult == "OK"
+                        && helix4khs190ocResult == "OK" && rollup031s4Result == "OK" && sections190olResult == "OK" && rollup031s5Result == "OK" && simpleDuck190otResult == "OK" && tracks190peResult == "OK" && issue258Result == "OK" && issues190qrResult == "OK" && backlog190rcResult == "OK" && community190riResult == "OK" && iox190rmResult == "OK" && perf190rnResult == "OK" && qa190rbResult == "OK" && bugs190rvResult == "OK" && repeats190pmResult == "OK" && mixerqol190qhResult == "OK" && autolive190qpResult == "OK" && issue282Result == "OK" && feel190qeResult == "OK" && toolbar190qgResult == "OK" && extras190qkResult == "OK" && extras190roResult == "OK" && discord190quResult == "OK" && trialmark190qtResult == "OK" && optionsux190qxResult == "OK" && chordlane190pfResult == "OK" && autolinks190ovResult == "OK"
                         && trackstates190opResult == "OK" && rollup031s6Result == "OK" // (round 190op's item, reported but not counted in its branch: rollup 0.1.31 step 6)
                         && rollup031s7Result == "OK" && rollup031s8Result == "OK" && rollup032Result == "OK" && headerGearResult == "OK" && perTab259Result == "OK" && slots260Result == "OK" && hotfixPlacesResult == "OK" && startPageScrollResult.startsWith ("OK") // (round 190qf: slots260) (rollup 0.1.31 step 7, round 190pw; and the three rounds' items its branches reported but did not count:)
                         && slides190piResult == "OK" && automodes190paResult == "OK" && heldSteps190ozResult == "OK"
@@ -11931,6 +11947,7 @@ private:
                << "iox190rm=" << iox190rmResult << "\n"
                << "perf190rn=" << perf190rnResult << "\n"
                << "qa190rb=" << qa190rbResult << "\n"
+               << "bugs190rv=" << bugs190rvResult << (bugs190rvResult == "OK" ? juce::String() : " | " + bugs190rvLog.replace ("\n", "; ")) << "\n"
                << "repeats190pm=" << repeats190pmResult << "\n"
                << "mixerqol190qh=" << mixerqol190qhResult << "\n"
                << "hotfixplaces190qp=" << hotfixPlacesResult << "\n"
@@ -13675,7 +13692,7 @@ private:
                                                         return channelIndex < 0 || channelIndex >= (int) song.channels.size()
                                                                    ? nullptr : &song.channels[(size_t) channelIndex].plugin;
                                                     return song.mixer.size() < 2 || song.mixer[1].effects.empty() ? nullptr : &song.mixer[1].effects[0].plugin;
-                                                }, instrument });
+                                                }, instrument, instrument ? -1 : 1, instrument ? -1 : 0 }); // (round 190rv: an effect's insert / slot, as the Mixer opens it)
                     owner.reset();
                     step ("window_open=" + juce::String ((int) lynx::PluginWindows::isOpen (*instance)));
                     phase = 1;
@@ -22069,6 +22086,7 @@ private:
 #include "Community190riCheck.inc" // round 190ri: the 0.1.32 community batch
 #include "Perf190rnCheck.inc" // round 190rn: the undo history's memory cap
 #include "Backlog190rcCheck.inc" // round 190rc: #288 native presets, #287 MIDI drop, #283 #285 #286, PR #284, Discord 11-24
+#include "Bugs190rvCheck.inc" // round 190rv: 0.1.32 open bug issues (#317 header LED, #319 pin)
 #include "Qa190rbCheck.inc" // round 190rb: the 0.1.32 quality round's crash / memory fixes, checked
 #include "Iox190rmCheck.inc" // round 190rm: the 0.1.32 import / export sweep (--convert190rm)
 #include "DetailsShot190mr.inc" // round 190mr