Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panel: Use the wlroots backend with unknown Wayland compositors #2161

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Conan-Kudo
Copy link

The description of the LXQtPanelApplicationPrivate::loadBackend() method already states that if we cannot identify the correct backend for a Wayland session, we should fall back to the wlroots backend module. This is reasonable given how broadly the wlr protocols are implemented. However, this was not happening due to a small error where we checked for the wlroots string in XDG_CURRENT_DESKTOP, which is not a valid option.

This change fixes this by checking XDG_SESSION_TYPE for "wayland" instead. As this is fallback logic, this is safe as the preferred backend logic using XDG_CURRENT_DESKTOP still wins over this.

The description of the LXQtPanelApplicationPrivate::loadBackend()
method already states that if we cannot identify the correct backend
for a Wayland session, we should fall back to the wlroots backend
module. This is reasonable given how broadly the wlr protocols are
implemented. However, this was not happening due to a small error
where we checked for the wlroots string in XDG_CURRENT_DESKTOP, which
is not a valid option.

This change fixes this by checking XDG_SESSION_TYPE for "wayland"
instead. As this is fallback logic, this is safe as the preferred
backend logic using XDG_CURRENT_DESKTOP still wins over this.
@@ -263,7 +263,7 @@ void LXQtPanelApplicationPrivate::loadBackend()
}
}

if ( preferredBackend.isEmpty() && xdgCurrentDesktops.contains( QStringLiteral("wlroots") ) )
if ( preferredBackend.isEmpty() && xdgSessionType == QStringLiteral("wayland") ) )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wlroots backend should be used only if wlroots is included. That inclusion means, "we know that it works with this Wayland compositor." The dummy backed should be used with unsupported compositors.

@tsujan
Copy link
Member

tsujan commented Nov 3, 2024

As this is fallback logic

Only for compositors that are compatible with wlroots, as far as lxqt-panel is concerned. Otherwise:

// If no backend can be found fall back to dummy backend
loader.unload();
mWMBackend = new LXQtDummyWMBackend;
qWarning() << "\n"
<< "ERROR: Could not create a backend for window managment operations.\n"
<< "Falling back to dummy backend. Some functions will not be available.\n"
<< "\n";

@Conan-Kudo
Copy link
Author

That's not what the method description says:

/**
* 1. Get the XDG_CURRENT_DESKTOP. It's a colon separate list.
* 2. Get the preferredBackend. It's a comma separated list.
* 3. First attempt to match some value in XDG_CURRENT_DESKTOP with any value in preferredBackend.
* 4. If it matches, end of story. Else, we attempt to deduce the backend based on XDG_CURRENT_DESKTOP:
* a. X11 -> xcb
* b. kwin_wayland -> plasma
* c. wayfire -> wayfire
* d. wayland -> wlroots
* e. other -> dummy
*/

@tsujan
Copy link
Member

tsujan commented Nov 3, 2024

It's a code comment :) What exists other than X11 and Wayland?

The code isn't final of course — more generic backends might be added in future — but for now, several good compositors are compatible with wlroots (except for kwin_wayland, which has its own backend; I like it very much).

@Conan-Kudo
Copy link
Author

Yeah. I like KWin too. 😄

But yeah, I think it's reasonable to use the wlroots backend as a wayland fallback because outside of KWin; Mutter; and Weston, pretty much all compositors offer the wlr protocols that the backend depends on.

And we already have a KWin backend, if someone actually wants to use Mutter or Weston, then backends can be made for them. 😂

@tsujan
Copy link
Member

tsujan commented Nov 3, 2024

it's reasonable to use the wlroots backend as a wayland fallback

Until the current disarray comes to an end in the Wayland world, we should thread carefully, IMO.

Two years ago we didn't imagine that we could support 7 well-known Wayland compositors so soon. Yes, the situation of Wayland has got better but not completely.

Also see how "wlroots" is handled in another part of the code:

int LXQtWMBackendWlrootsLibrary::getBackendScore(const QString& key) const
{
if (key == QStringLiteral("wlroots"))
{
return 50;
}
else if (key == QStringLiteral("wayfire"))
{
return 30;
}
else if (key == QStringLiteral("sway"))
{
return 30;
}
else if (key == QStringLiteral("hyprland"))
{
return 30;
}
else if (key == QStringLiteral("labwc"))
{
return 30;
}
else if (key == QStringLiteral("river"))
{
return 30;
}
// Unsupported
return 0;
}

@Conan-Kudo
Copy link
Author

Why does this method exist? We already select to load it from the panel frontend side?

@tsujan
Copy link
Member

tsujan commented Nov 3, 2024

The backend is chosen in two ways: by checking the key preferred_backend in panel's config file (its value is a string list), or if it doesn't exist, by checking the scores of what is included in XDG_CURRENT_DESKTOP. This logic will work fine if more backends are added.

BTW, we need to add a dedicated backend for labwc because it supports cosmic-workspace-unstable-v1 now.

@Conan-Kudo
Copy link
Author

Conan-Kudo commented Nov 3, 2024

Sure, but does that mean that the wlroots backend isn't going to let itself be used as the least-common-denominator panel backend?

@tsujan
Copy link
Member

tsujan commented Nov 3, 2024

As the lowest common denominator for the compositors that are announced to be compatible with wlroots by lxqt-wayland-session — without raising false hopes.

@Conan-Kudo
Copy link
Author

Then we should use a separate variable for this, because XDG_CURRENT_DESKTOP isn't the right place for it.

@tsujan
Copy link
Member

tsujan commented Nov 3, 2024

This logic was a result of our developers' hard works and long discussions. It's proven to work fine and flexibly.

That being said, it isn't written in stone. If another method is shown to be better in practice, it could be replaced.

Anyway, LXQt 2.1.0 will be released with it the day after tomorrow.

@stefonarch
Copy link
Member

Then we should use a separate variable for this, because XDG_CURRENT_DESKTOP isn't the right place for it.

We could just read the compositor in use as in startlxqtwayland.

@tsujan
Copy link
Member

tsujan commented Nov 4, 2024

We could just read the compositor in use as in startlxqtwayland.

No, it's not that simple. We've used XDG_CURRENT_DESKTOP in other parts of the code because we agreed on it. For example:

#if (QT_VERSION >= QT_VERSION_CHECK(6,8,0))
// WARNING: Only the following desktops are known to give the focus to child popups
// when the panel does not accept focus.
const QRegularExpression desktops(QStringLiteral("(?i)(kde|kwin|wayfire|hyprland)"));
if (desktops.match(qEnvironmentVariable("XDG_CURRENT_DESKTOP")).hasMatch())
mLayerWindow->setKeyboardInteractivity(LayerShellQt::Window::KeyboardInteractivityNone);
else
#endif

@tsujan
Copy link
Member

tsujan commented Nov 4, 2024

Using XDG_CURRENT_DESKTOP is necessary because it isn't limited to compositors. For example, one may use LXQt panel inside Plasma Wayland. See

if(key == QLatin1String("KDE") || key == QLatin1String("KWIN"))
{
return 100;
}

Moreover, a Wayland compositor is a DE too.

EDIT:
Please remind me to remove the case-sensitivity after 2.1.0 if I forget it, although it isn't a problem for us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants