Просмотр исходного кода

--zorder191test @150: clicks only where the target is visible; a covered window button uses its own action

The Windows @150 run of 9fdfc902d showed what 190nr item 4 suspected wrongly: no scale factor reaches the Playlist's
title bar or the Device View's window button once the docked Surge XT editor is open, because that editor nearly
fills the 1240 x 648 logical window (the 1280 x 688 work area of a 1920 x 1080 screen at 150 %) and JUCE finds no
component under the mouse where another native window is on top. The click helper now logs the window on screen at
the point, tries the rest of the title bar's row (a user clicks the part of the Playlist they can see) and reports a
covered target; a covered window button is pressed through DetailView::pressWindowButtonForCheck (logged).
Ka1-S 2 недель назад
Родитель
Сommit
92c974469c
3 измененных файлов с 71 добавлено и 30 удалено
  1. 9 0
      src/ui/DetailView.cpp
  2. 1 0
      src/ui/DetailView.h
  3. 61 30
      src/ui/ZOrder191Test.cpp

+ 9 - 0
src/ui/DetailView.cpp

@@ -266,6 +266,14 @@ public:
         return windowBounds (cards[(std::size_t) i]);
     }
     bool isCardFolded (int i) const { return i >= 0 && i < (int) cards.size() && cards[(std::size_t) i].folded; }
+    // (--zorder191test, rollup 0.1.31 step 2: the card's window button pressed when a plugin editor covers it on screen)
+    bool pressWindowButtonForCheck (int i)
+    {
+        if (i < 0 || i >= (int) cards.size())
+            return false;
+        toggleWindow (cards[(std::size_t) i]);
+        return true;
+    }
     void toggleCardFold (int i)
     {
         if (i >= 0 && i < (int) cards.size() && cards[(std::size_t) i].kind != Card::add)
@@ -4178,6 +4186,7 @@ juce::Rectangle<int> DetailView::windowButtonForCheck (int card) const
     const auto r = chain->windowButtonOf (card);
     return r.isEmpty() ? r : getLocalArea (chain.get(), r);
 }
+bool DetailView::pressWindowButtonForCheck (int card) { return chain->pressWindowButtonForCheck (card); }
 int DetailView::chainInsertForCheck() const { return chain->insertShown(); }
 int DetailView::chainChannelForCheck() const { return chain->channelShown(); }
 bool DetailView::isFoldedForCheck (int card) const { return chain->isCardFolded (card); }

+ 1 - 0
src/ui/DetailView.h

@@ -131,6 +131,7 @@ public:
     juce::PopupMenu cardMenuForSnapshot (int card); // an effect card's right-click menu
     int cardCountForCheck() const;
     juce::Rectangle<int> windowButtonForCheck (int card) const; // (issue #191: in this component's coordinates)
+    bool pressWindowButtonForCheck (int card); // (--zorder191test: the button's action when an editor covers it on screen)
     int chainInsertForCheck() const;
     int chainChannelForCheck() const;
     bool isFoldedForCheck (int card) const;

+ 61 - 30
src/ui/ZOrder191Test.cpp

@@ -68,42 +68,67 @@ struct ZOrderTest final : juce::Timer
     DetailView* detail() const { return ui != nullptr ? ui->getDetailViewForSnapshot() : nullptr; }
     juce::Component& playlistFrame() const { return ui->workspaceForTest().getFrame (workspace::Panel::playlist); }
 
-    // A press (and its release) at `local` in `c`, through the peer that holds `c`, as the system delivers a click
-    bool click (juce::Component& c, juce::Point<int> local)
+    // The native window on screen at `local` in `c` (Windows: WindowFromPoint), for the report
+    juce::String windowAt (juce::Component& c, juce::Point<int> local) const
+    {
+#if JUCE_WINDOWS
+        const auto screen = c.localPointToGlobal (local).toFloat() * juce::Desktop::getInstance().getGlobalScaleFactor();
+        auto* h = WindowFromPoint ({ (LONG) screen.x, (LONG) screen.y });
+        juce::String what = h == nullptr ? "none" : h == (HWND) window->getWindowHandle() ? "main" : h == (HWND) playlistHandle() ? "playlist" : "other";
+        if (h != nullptr && what == "other")
+        {
+            wchar_t name[64] {};
+            GetClassNameW (h, name, 63);
+            RECT r {};
+            GetWindowRect (h, &r);
+            what << "(" << juce::String (name) << " " << (int) r.left << "," << (int) r.top << "-" << (int) r.right << "," << (int) r.bottom << ")";
+        }
+        return what + "@" + juce::String ((int) screen.x) + "," + juce::String ((int) screen.y);
+#else
+        juce::ignoreUnused (c, local);
+        return "-";
+#endif
+    }
+
+    // A press (and its release) at `local` in `c`, through the peer that holds `c`, as the system delivers a click.
+    // Rollup 0.1.31 step 2 (190nr item 4): the press goes where JUCE finds `c` under the mouse. A peer's positions carry the
+    // Desktop's global scale (LYNX_ZTEST_SCALE runs); the first move that finds `c` (or a child) decides the factor. When a
+    // native window covers `local` on screen (at 150 % the docked Surge XT editor nearly fills the 1240 x 648 window),
+    // `scanRow` tries the rest of that row of `c`, as a user clicks the part they see. Returns whether `c` took the press.
+    bool click (juce::Component& c, juce::Point<int> local, bool scanRow = false)
     {
         auto* peer = c.getPeer();
         if (peer == nullptr)
             return false;
         using MIS = juce::MouseInputSource;
-        // (a top-level peer's positions are not divided by the Desktop's global scale: LYNX_ZTEST_SCALE runs.) Rollup 0.1.31
-        // step 2 (190nr item 4): a native child peer (the Playlist docked as its own child window, nativechild) does not
-        // take the factor on Windows, so the title-bar click at 150 % landed 1.5x too far right, on the docked editor. The
-        // factor is now found by a move: the first position whose component under the mouse is `c` (or inside it).
-        const auto base = peer->getComponent().getLocalPoint (&c, local).toFloat();
         const auto global = juce::Desktop::getInstance().getGlobalScaleFactor();
         const auto source = juce::Desktop::getInstance().getMainMouseSource();
-        auto at = base * global;
-        juce::String tried;
-        for (const auto factor : { global, 1.0f, peer->getComponent().getDesktopScaleFactor() })
-        {
-            const auto p = base * factor;
-            peer->handleMouseEvent (MIS::InputSourceType::mouse, p, juce::ModifierKeys(), MIS::defaultPressure, MIS::defaultOrientation, juce::Time::currentTimeMillis());
+        const auto name = c.getName().isNotEmpty() ? c.getName() : juce::String (typeid (c).name());
+        const auto hits = [&] (juce::Point<int> p, float factor) {
+            const auto at = peer->getComponent().getLocalPoint (&c, p).toFloat() * factor;
+            peer->handleMouseEvent (MIS::InputSourceType::mouse, at, juce::ModifierKeys(), MIS::defaultPressure, MIS::defaultOrientation, juce::Time::currentTimeMillis());
             auto* under = source.getComponentUnderMouse();
-            tried << juce::String (factor, 2) << ":" << (under == nullptr ? juce::String ("-") : under->getName().isNotEmpty() ? under->getName() : juce::String (typeid (*under).name()))
-                  << (under == &c || (under != nullptr && c.isParentOf (under)) ? "(hit) " : " ");
-            if (under == &c || (under != nullptr && c.isParentOf (under)))
-            {
-                at = p;
-                break;
-            }
-        }
-        line ("click_" + (c.getName().isNotEmpty() ? c.getName() : juce::String (typeid (c).name())) + "=" + tried.trim());
-        const auto now = juce::Time::currentTimeMillis();
-        peer->handleMouseEvent (MIS::InputSourceType::mouse, at, juce::ModifierKeys(), MIS::defaultPressure, MIS::defaultOrientation, now);
-        peer->handleMouseEvent (MIS::InputSourceType::mouse, at, juce::ModifierKeys (juce::ModifierKeys::leftButtonModifier), MIS::defaultPressure,
-                                MIS::defaultOrientation, now + 1);
-        peer->handleMouseEvent (MIS::InputSourceType::mouse, at, juce::ModifierKeys(), MIS::defaultPressure, MIS::defaultOrientation, now + 60);
-        return true;
+            return under == &c || (under != nullptr && c.isParentOf (under));
+        };
+        std::vector<juce::Point<int>> points { local };
+        if (scanRow)
+            for (int x = 8; x < c.getWidth() - 8; x += 16)
+                points.push_back ({ x, local.y });
+        line ("click_" + name + "_screen=" + windowAt (c, local));
+        for (const auto& p : points)
+            for (const auto factor : { global, 1.0f })
+                if (hits (p, factor))
+                {
+                    const auto at = peer->getComponent().getLocalPoint (&c, p).toFloat() * factor;
+                    line ("click_" + name + "=hit at " + p.toString() + " factor " + juce::String (factor, 2));
+                    const auto now = juce::Time::currentTimeMillis();
+                    peer->handleMouseEvent (MIS::InputSourceType::mouse, at, juce::ModifierKeys (juce::ModifierKeys::leftButtonModifier), MIS::defaultPressure,
+                                            MIS::defaultOrientation, now + 1);
+                    peer->handleMouseEvent (MIS::InputSourceType::mouse, at, juce::ModifierKeys(), MIS::defaultPressure, MIS::defaultOrientation, now + 60);
+                    return true;
+                }
+        line ("click_" + name + "=covered (no visible point)");
+        return false;
     }
 
     bool clickWindowButton (int card)
@@ -113,7 +138,13 @@ struct ZOrderTest final : juce::Timer
             return false;
         const auto r = dv->windowButtonForCheck (card);
         line ("window_button_" + juce::String (card) + "=" + r.toString());
-        return ! r.isEmpty() && click (*dv, r.getCentre());
+        if (r.isEmpty())
+            return false;
+        if (click (*dv, r.getCentre()))
+            return true;
+        // covered on screen by a plugin editor (a user would move it first): the button's own action, logged
+        line ("window_button_" + juce::String (card) + "_pressed_directly=1");
+        return dv->pressWindowButtonForCheck (card);
     }
 
     void snapshotDesktop()
@@ -279,7 +310,7 @@ struct ZOrderTest final : juce::Timer
                 startTimer (700);
                 // a click on the Playlist's title bar: the Playlist comes in front (FL's / issue #116's rule stays)
                 auto& frame = playlistFrame();
-                click (frame, { frame.getWidth() / 2, 8 });
+                expect ("playlist_title_bar_clicked_" + name, click (frame, { frame.getWidth() / 2, 8 }, true));
                 return 3;
             }
             case 3: