Wayland: Set app_id for icon in kde (#718)

This commit is contained in:
Colin Kinloch 2023-03-29 15:28:17 +01:00 committed by GitHub
parent 715d2247a9
commit be1e77186e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 51 additions and 3 deletions

View File

@ -69,6 +69,8 @@ add_library(CemuGui
helpers/wxHelpers.cpp
helpers/wxHelpers.h
helpers/wxLogEvent.h
helpers/wxWayland.cpp
helpers/wxWayland.h
input/InputAPIAddWindow.cpp
input/InputAPIAddWindow.h
input/InputSettings2.cpp

View File

@ -12,6 +12,10 @@
#include "gui/helpers/wxHelpers.h"
#include "Cemu/ncrypto/ncrypto.h"
#if BOOST_OS_LINUX && HAS_WAYLAND
#include "gui/helpers/wxWayland.h"
#endif
#include <wx/image.h>
#include <wx/filename.h>
#include <wx/stdpaths.h>
@ -176,6 +180,11 @@ bool CemuApp::OnInit()
SetTopWindow(m_mainFrame);
m_mainFrame->Show();
#if BOOST_OS_LINUX && HAS_WAYLAND
if (wxWlIsWaylandWindow(m_mainFrame))
wxWlSetAppId(m_mainFrame, "info.cemu.Cemu");
#endif
// show warning on macOS about state of builds
#if BOOST_OS_MACOS
if (!GetConfig().did_show_macos_disclaimer)

View File

@ -57,6 +57,10 @@
#include "resource/embedded/resources.h"
#endif
#if BOOST_OS_LINUX && HAS_WAYLAND
#include "gui/helpers/wxWayland.h"
#endif
#include "Cafe/TitleList/TitleInfo.h"
#include "Cafe/TitleList/TitleList.h"
#include "wxHelper.h"
@ -753,6 +757,12 @@ void MainWindow::TogglePadView()
m_padView->Bind(wxEVT_CLOSE_WINDOW, &MainWindow::OnPadClose, this);
m_padView->Show(true);
#if BOOST_OS_LINUX && HAS_WAYLAND
if (wxWlIsWaylandWindow(m_padView))
wxWlSetAppId(m_padView, "info.cemu.Cemu");
#endif
m_padView->Initialize();
if (m_game_launched)
m_padView->InitializeRenderCanvas();

View File

@ -0,0 +1,24 @@
#include "gui/helpers/wxWayland.h"
#if BOOST_OS_LINUX && HAS_WAYLAND
#include <dlfcn.h>
bool wxWlIsWaylandWindow(wxWindow* window)
{
GtkWidget* gtkWindow = static_cast<GtkWidget*>(window->GetHandle());
GdkWindow* gdkWindow = gtk_widget_get_window(gtkWindow);
return GDK_IS_WAYLAND_WINDOW(gdkWindow);
}
void wxWlSetAppId(wxFrame* frame, const char* applicationId)
{
GtkWidget* gtkWindow = static_cast<GtkWidget*>(frame->GetHandle());
gtk_widget_realize(gtkWindow);
GdkWindow* gdkWindow = gtk_widget_get_window(gtkWindow);
static auto gdk_wl_set_app_id = reinterpret_cast<void (*) (GdkWindow*, const char*)>(dlsym(nullptr, "gdk_wayland_window_set_application_id"));
if (gdk_wl_set_app_id)
gdk_wl_set_app_id(gdkWindow, applicationId);
}
#endif // BOOST_OS_LINUX && HAS_WAYLAND

View File

@ -1,6 +1,6 @@
#pragma once
#if BOOST_OS_LINUX
#if BOOST_OS_LINUX && HAS_WAYLAND
#include <gdk/gdk.h>
#include <gdk/gdkwayland.h>
@ -72,4 +72,7 @@ class wxWlSubsurface
}
};
#endif // BOOST_OS_LINUX
bool wxWlIsWaylandWindow(wxWindow* window);
void wxWlSetAppId(wxFrame* frame, const char* application_id);
#endif // BOOST_OS_LINUX && HAS_WAYLAND