diff --git a/src/skins-qt/plugin.cc b/src/skins-qt/plugin.cc index 16dfbd121..d9e491ff2 100644 --- a/src/skins-qt/plugin.cc +++ b/src/skins-qt/plugin.cc @@ -176,10 +176,11 @@ bool QtSkins::init () return false; } - if (QGuiApplication::platformName() == "wayland") + if (QGuiApplication::platformName () == "wayland" && + ! qEnvironmentVariableIsSet ("DISPLAY")) { - AUDERR ("The Winamp interface is not supported on Wayland. " - "Please run Audacious via XWayland.\n"); + AUDERR ("The Winamp interface is not supported on Wayland, and " + "Xwayland does not appear to be available on this system.\n"); audqt::cleanup (); return false; } diff --git a/src/skins-qt/view.cc b/src/skins-qt/view.cc index f06d71fa9..1968e4b7f 100644 --- a/src/skins-qt/view.cc +++ b/src/skins-qt/view.cc @@ -20,9 +20,15 @@ */ #include +#include #include #include +#include +#include +#include +#include +#include #include #include "plugin.h" @@ -38,8 +44,62 @@ #include "view.h" #include "window.h" +class QuitOnCloseMessageBox : public QMessageBox +{ +protected: + void closeEvent (QCloseEvent *) override + { + aud_quit (); + } +}; + void view_show_player (bool show) { + static QPointer dialog; + + if (show && QGuiApplication::platformName () == "wayland") + { + if (! dialog) + { + dialog = new QuitOnCloseMessageBox; + + auto restart = new QPushButton (audqt::translate_str (N_("Restart")), dialog); + auto quit = new QPushButton (audqt::translate_str (N_("Quit")), dialog); + + restart->setIcon (QIcon::fromTheme ("view-refresh")); + quit->setIcon (QIcon::fromTheme ("application-exit")); + + QObject::connect (restart, & QPushButton::clicked, [] () { + aud_set_bool ("use_xwayland", true); + aud_request_restart (); + }); + QObject::connect (quit, & QPushButton::clicked, [] () { + aud_set_bool ("use_xwayland", true); + aud_quit (); + }); + + dialog->setIcon (QMessageBox::Warning); + dialog->setWindowTitle (_("Compatibility Issue")); + dialog->setText( + _("The Winamp interface requires windowing system features not " + "supported by Wayland. Audacious will attempt to enable Xwayland " + "compatibility mode after restart.\n\n" + "With the GTK or Qt interface you may disable this setting " + "again in the “Advanced” category of the Audacious settings.")); + + dialog->addButton (restart, QMessageBox::AcceptRole); + dialog->addButton (quit, QMessageBox::RejectRole); + dialog->setDefaultButton (restart); + } + + dialog->show (); + show = false; // don't show main window + } + else if (dialog) + { + delete dialog.data (); + } + if (show) { mainwin->show (); diff --git a/src/skins/plugin.cc b/src/skins/plugin.cc index 31a0ad898..1638c487a 100644 --- a/src/skins/plugin.cc +++ b/src/skins/plugin.cc @@ -169,10 +169,11 @@ bool SkinnedUI::init () audgui_init (); #ifdef GDK_WINDOWING_WAYLAND - if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ())) + if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ()) && + ! g_getenv ("DISPLAY")) { - AUDERR ("The Winamp interface is not supported on Wayland. " - "Please run Audacious via XWayland.\n"); + AUDERR ("The Winamp interface is not supported on Wayland, and " + "Xwayland does not appear to be available on this system.\n"); audgui_cleanup (); return false; } diff --git a/src/skins/view.cc b/src/skins/view.cc index 890545614..1c10fda88 100644 --- a/src/skins/view.cc +++ b/src/skins/view.cc @@ -20,8 +20,14 @@ */ #include +#include #include #include +#include + +#ifdef GDK_WINDOWING_WAYLAND +#include +#endif #include "plugin.h" #include "plugin-window.h" @@ -38,6 +44,44 @@ void view_show_player (bool show) { +#ifdef GDK_WINDOWING_WAYLAND + static GtkWidget * dialog; + + if (show && GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ())) + { + if (! dialog) + { + auto restart = audgui_button_new (_("Restart"), "view-refresh", [] (void *) { + aud_set_bool ("use_xwayland", true); + aud_request_restart (); + }, nullptr); + + auto quit = audgui_button_new (_("Quit"), "application-exit", [] (void *) { + aud_set_bool ("use_xwayland", true); + aud_quit (); + }, nullptr); + + dialog = audgui_dialog_new (GTK_MESSAGE_WARNING, _("Compatibility Issue"), + _("The Winamp interface requires windowing system features not " + "supported by Wayland. Audacious will attempt to enable Xwayland " + "compatibility mode after restart.\n\n" + "With the GTK or Qt interface you may disable this setting " + "again in the “Advanced” category of the Audacious settings."), + restart, quit); + + g_signal_connect (dialog, "delete-event", (GCallback) aud_quit, nullptr); + g_signal_connect (dialog, "destroy", (GCallback) gtk_widget_destroyed, & dialog); + } + + gtk_widget_show_all (dialog); + show = false; // don't show main window + } + else if (dialog) + { + gtk_widget_destroy (dialog); + } +#endif + if (show) { // "Move" the window to the position it's already at. This seems