luisbocanegra / plasma-panel-colorizer

Latte-Dock and WM status bar customization features for the default KDE Plasma panel
https://store.kde.org/p/2130967
GNU General Public License v3.0
236 stars 3 forks source link

Popup/dialogs spawn at incorrect position if 'Native panel background' is disabled in Plasma 6.2 Beta #80

Open luisbocanegra opened 1 month ago

luisbocanegra commented 1 month ago

image

luisbocanegra commented 1 month ago

Well turns out popups now align with the panel mask https://invent.kde.org/plasma/libplasma/-/merge_requests/1148.

Setting PlasmaCore.Types.NoBackground to the panel containmentItem https://github.com/luisbocanegra/plasma-panel-colorizer/blob/b284edbb89a335476418cf631d1a72d408c07c19/package/contents/ui/code/utils.js#L84C1-L88C2

function toggleTransparency(containmentItem, nativePanelBackgroundEnabled) {
  containmentItem.Plasmoid.backgroundHints = !nativePanelBackgroundEnabled
    ? PlasmaCore.Types.NoBackground
    : PlasmaCore.Types.DefaultBackground
}

results in the panel creating an empty mask https://github.com/KDE/plasma-workspace/blob/c809de7c72dcc7e94eeed5a0b09cb81f5512c2e0/shell/panelview.cpp#L1363C1-L1366C28

void PanelView::updateMask()
{
...
    if (m_backgroundHints == Plasma::Types::NoBackground) {
        KWindowEffects::enableBlurBehind(this, false);
        KWindowEffects::enableBackgroundContrast(this, false);
        setMask(QRegion()); // <- this line

Which successfully removes the blur and contrast (allowing the panel to be fully transparent) but breaks the positioning of popups.

If I don't set PlasmaCore.Types.NoBackground and instead try to create an empty mask from my PanelColorizer::updatePanelMask, the panel detects it's empty and creates its own from the panel QRect instead:

    } else {
        QRegion mask;
        QQuickItem *rootObject = this->rootObject();
        QRect screenPanelRect = geometry();
        screenPanelRect.moveTo(mapFromGlobal(screenPanelRect.topLeft()));
        if (rootObject) {
            QVariant maskProperty = rootObject->property("panelMask");
            if (static_cast<QMetaType::Type>(maskProperty.typeId()) == QMetaType::QRegion) {
                mask = get<QRegion>(std::move(maskProperty));
                const QPoint floatingTranslucentItemOffset = rootObject->property("floatingTranslucentItemOffset").toPoint();
                mask.translate(floatingTranslucentItemOffset);
            }
        }
        if (mask.isEmpty()) {
            mask = QRegion(QRect(screenPanelRect));
        }

Creating a 1x1 mask and setting the correct position fixes the popups but now there is a bright dot on the screen and it will require compiling the C++ plugin.

region = QRegion();
translateX = abs(offset.x());
translateY = abs(offset.y() + rect.height() - 1);

Screencast_20241004_223204.webm

luisbocanegra commented 1 month ago

Upstream Bugreport https://bugs.kde.org/show_bug.cgi?id=494193 Submitted a fix at https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/4797 waiting for it to be reviewed

luisbocanegra commented 1 month ago

Fix has been merged 🎉 Will be available in Plasma 6.2.2 (Tue 2024-10-22)

nikoraasu commented 1 week ago

Has this actually been fixed? I still face this issue with the dialogs being offset. I can temporarily fix it by enabling native panel background and disabling it, but this resets when I restart my system. image

Using Plasma 6.2.3 Running widget version 1.2.0-1 from Aur

mill413 commented 5 days ago

Has this actually been fixed? I still face this issue with the dialogs being offset. I can temporarily fix it by enabling native panel background and disabling it, but this resets when I restart my system. image

Using Plasma 6.2.3 Running widget version 1.2.0-1 from Aur

Same. Plasma 6.2.3(Wayland), widget version 1.2.0-1 from AUR

luisbocanegra commented 4 days ago

With Blur custom background disabled on the panel, popups are spawned at the edge of the original blur mask (provided by the Plasma style SVG) and without Native panel background popups spawn at the edge of the panel "window" which seems to be bigger than the panel probably to reserve space for the SVG shadows and dodge windows features

That is why by enabling Blur custom background "fixes" the problem.

Also might be related to https://github.com/luisbocanegra/plasma-panel-colorizer/issues/100, the fix workaround for that was turn the mask on and off again when the panel size changes, just like what @nikoraasu describes.

Something needs to be done to ensure the the mask is always the correct one, most likely requires another upstream patch.