Merge pull request #3842 from jgilje/set-wmclass-instance-from-vmname
update WM_CLASS instance name from vm_name
This commit is contained in:
@@ -371,6 +371,8 @@ if (APPLE AND CMAKE_MACOSX_BUNDLE)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (UNIX AND NOT APPLE AND NOT HAIKU)
|
if (UNIX AND NOT APPLE AND NOT HAIKU)
|
||||||
|
target_sources(ui PRIVATE x11_util.c)
|
||||||
|
|
||||||
find_package(X11 REQUIRED)
|
find_package(X11 REQUIRED)
|
||||||
target_link_libraries(ui PRIVATE X11::X11 X11::Xi)
|
target_link_libraries(ui PRIVATE X11::X11 X11::Xi)
|
||||||
target_sources(ui PRIVATE evdev_keyboard.cpp xinput2_mouse.cpp)
|
target_sources(ui PRIVATE evdev_keyboard.cpp xinput2_mouse.cpp)
|
||||||
|
@@ -117,6 +117,11 @@ extern int qt_nvr_save(void);
|
|||||||
# undef KeyRelease
|
# undef KeyRelease
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined Q_OS_UNIX && !defined Q_OS_HAIKU && !defined Q_OS_MACOS
|
||||||
|
#include <qpa/qplatformwindow.h>
|
||||||
|
#include "x11_util.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
# include "cocoa_keyboard.hpp"
|
# include "cocoa_keyboard.hpp"
|
||||||
// The namespace is required to avoid clashing typedefs; we only use this
|
// The namespace is required to avoid clashing typedefs; we only use this
|
||||||
@@ -712,6 +717,20 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
# endif
|
# endif
|
||||||
{}
|
{}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined Q_OS_UNIX && !defined Q_OS_MACOS && !defined Q_OS_HAIKU
|
||||||
|
if (QApplication::platformName().contains("xcb")) {
|
||||||
|
QTimer::singleShot(0, this, [this] {
|
||||||
|
auto whandle = windowHandle();
|
||||||
|
if (! whandle) {
|
||||||
|
qWarning() << "No window handle";
|
||||||
|
} else {
|
||||||
|
QPlatformWindow *window = whandle->handle();
|
||||||
|
set_wm_class(window->winId(), vm_name);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
22
src/qt/x11_util.c
Normal file
22
src/qt/x11_util.c
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/Xutil.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "x11_util.h"
|
||||||
|
|
||||||
|
void set_wm_class(unsigned long window, char *res_name) {
|
||||||
|
Display* display = XOpenDisplay(NULL);
|
||||||
|
if (display == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
XClassHint hint;
|
||||||
|
XGetClassHint(display, window, &hint);
|
||||||
|
|
||||||
|
hint.res_name = res_name;
|
||||||
|
XSetClassHint(display, window, &hint);
|
||||||
|
|
||||||
|
// During testing, I've had to issue XGetClassHint after XSetClassHint
|
||||||
|
// to get the window manager to recognize the change.
|
||||||
|
XGetClassHint(display, window, &hint);
|
||||||
|
}
|
9
src/qt/x11_util.h
Normal file
9
src/qt/x11_util.h
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void set_wm_class(unsigned long window, char *res_name);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
Reference in New Issue
Block a user