mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-22 02:32:29 +01:00
Refactor linux X11 support
Rename LinuxWindow to LinuxX11Window, for kde we use a desktop wallpaper plugin and for Wayland we need something else entirely.
This commit is contained in:
parent
4dab506b41
commit
37db908db1
@ -20,6 +20,8 @@
|
|||||||
1. Install dependencies for Debian/Ubuntu:
|
1. Install dependencies for Debian/Ubuntu:
|
||||||
``` bash
|
``` bash
|
||||||
sudo apt install build-essential git gpg ffmpeg mesa-common-dev libxkbcommon-* libfontconfig curl zip unzip tar cmake pkg-config apt-transport-https ca-certificates gnupg software-properties-common wget software-properties-common python3 python3-pip libgl1-mesa-dev lld ninja-build qml-module-qt-websockets qtwebengine5-* -y
|
sudo apt install build-essential git gpg ffmpeg mesa-common-dev libxkbcommon-* libfontconfig curl zip unzip tar cmake pkg-config apt-transport-https ca-certificates gnupg software-properties-common wget software-properties-common python3 python3-pip libgl1-mesa-dev lld ninja-build qml-module-qt-websockets qtwebengine5-* -y
|
||||||
|
# Only needed if we want x11 support
|
||||||
|
sudo apt-get install libx11-dev xserver-xorg-dev xorg-dev
|
||||||
```
|
```
|
||||||
|
|
||||||
## MacOS
|
## MacOS
|
||||||
|
@ -17,7 +17,11 @@ Q_IMPORT_QML_PLUGIN(ScreenPlayWorkshopPlugin)
|
|||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#if !defined(Q_OS_LINUX)
|
||||||
qputenv("QT_MEDIA_BACKEND","ffmpeg");
|
qputenv("QT_MEDIA_BACKEND","ffmpeg");
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
// https://bugreports.qt.io/browse/QTBUG-72028
|
// https://bugreports.qt.io/browse/QTBUG-72028
|
||||||
qputenv("QT_QPA_PLATFORM", "windows:darkmode=2");
|
qputenv("QT_QPA_PLATFORM", "windows:darkmode=2");
|
||||||
|
@ -30,8 +30,8 @@ elseif(APPLE)
|
|||||||
src/macintegration.h
|
src/macintegration.h
|
||||||
src/macwindow.h)
|
src/macwindow.h)
|
||||||
elseif(UNIX)
|
elseif(UNIX)
|
||||||
set(SOURCES src/linuxwindow.cpp)
|
set(SOURCES src/linuxx11window.cpp)
|
||||||
set(HEADER src/linuxwindow.h)
|
set(HEADER src/linuxx11window.h)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(SOURCES ${SOURCES} main.cpp src/basewindow.cpp)
|
set(SOURCES ${SOURCES} main.cpp src/basewindow.cpp)
|
||||||
@ -81,6 +81,8 @@ target_link_libraries(
|
|||||||
Qt6::WebEngineQuick)
|
Qt6::WebEngineQuick)
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
target_link_libraries(${PROJECT_NAME} PRIVATE ScreenPlaySysInfoplugin)
|
target_link_libraries(${PROJECT_NAME} PRIVATE ScreenPlaySysInfoplugin)
|
||||||
|
elseif(UNIX)
|
||||||
|
target_link_libraries( ${PROJECT_NAME} PRIVATE X11)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(UNIX AND NOT APPLE)
|
if(UNIX AND NOT APPLE)
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#include "src/winwindow.h"
|
#include "src/winwindow.h"
|
||||||
Q_IMPORT_QML_PLUGIN(ScreenPlaySysInfoPlugin)
|
Q_IMPORT_QML_PLUGIN(ScreenPlaySysInfoPlugin)
|
||||||
#elif defined(Q_OS_LINUX)
|
#elif defined(Q_OS_LINUX)
|
||||||
#include "src/linuxwindow.h"
|
#include "src/linuxx11window.h"
|
||||||
#elif defined(Q_OS_OSX)
|
#elif defined(Q_OS_OSX)
|
||||||
#include "src/macwindow.h"
|
#include "src/macwindow.h"
|
||||||
#endif
|
#endif
|
||||||
@ -21,7 +21,11 @@ Q_IMPORT_QML_PLUGIN(ScreenPlayWeatherPlugin)
|
|||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#if !defined(Q_OS_LINUX)
|
||||||
qputenv("QT_MEDIA_BACKEND","ffmpeg");
|
qputenv("QT_MEDIA_BACKEND","ffmpeg");
|
||||||
|
#endif
|
||||||
|
|
||||||
QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
|
QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
|
||||||
QtWebEngineQuick::initialize();
|
QtWebEngineQuick::initialize();
|
||||||
|
|
||||||
@ -30,7 +34,7 @@ int main(int argc, char* argv[])
|
|||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
WinWindow window;
|
WinWindow window;
|
||||||
#elif defined(Q_OS_LINUX)
|
#elif defined(Q_OS_LINUX)
|
||||||
LinuxWindow window;
|
LinuxX11Window window;
|
||||||
#elif defined(Q_OS_OSX)
|
#elif defined(Q_OS_OSX)
|
||||||
MacWindow window;
|
MacWindow window;
|
||||||
#endif
|
#endif
|
||||||
@ -42,8 +46,8 @@ int main(int argc, char* argv[])
|
|||||||
// For testing purposes when starting the ScreenPlayWallpaper directly.
|
// For testing purposes when starting the ScreenPlayWallpaper directly.
|
||||||
if (argumentList.length() == 1) {
|
if (argumentList.length() == 1) {
|
||||||
window.setActiveScreensList({ 0 });
|
window.setActiveScreensList({ 0 });
|
||||||
// window.setProjectPath("test");
|
window.setProjectPath("test");
|
||||||
window.setProjectPath("C:/Program Files (x86)/Steam/steamapps/workshop/content/672870/19112022140605-Horde 1980");
|
//window.setProjectPath("C:/Program Files (x86)/Steam/steamapps/workshop/content/672870/19112022140605-Horde 1980");
|
||||||
window.setAppID("test");
|
window.setAppID("test");
|
||||||
window.setVolume(1);
|
window.setVolume(1);
|
||||||
window.setFillMode("fill");
|
window.setFillMode("fill");
|
||||||
|
@ -1,45 +0,0 @@
|
|||||||
// SPDX-License-Identifier: LicenseRef-EliasSteurerTachiom OR AGPL-3.0-only
|
|
||||||
#include "linuxwindow.h"
|
|
||||||
|
|
||||||
|
|
||||||
ScreenPlay::WallpaperExitCode LinuxWindow::start()
|
|
||||||
{
|
|
||||||
|
|
||||||
if(!debugMode()){
|
|
||||||
connect(m_sdk.get(), &ScreenPlaySDK::sdkDisconnected, this, &LinuxWindow::destroyThis);
|
|
||||||
}
|
|
||||||
|
|
||||||
Qt::WindowFlags flags = m_window.flags();
|
|
||||||
m_window.setFlags(flags | Qt::FramelessWindowHint | Qt::Desktop);
|
|
||||||
auto* screen = QGuiApplication::screens().at(activeScreensList().at(0));
|
|
||||||
m_window.setGeometry(screen->geometry());
|
|
||||||
m_window.show();
|
|
||||||
|
|
||||||
m_window.setResizeMode(QQuickView::ResizeMode::SizeRootObjectToView);
|
|
||||||
qmlRegisterSingletonInstance<LinuxWindow>("ScreenPlayWallpaper", 1, 0, "Wallpaper", this);
|
|
||||||
m_window.setTextRenderType(QQuickWindow::TextRenderType::NativeTextRendering);
|
|
||||||
m_window.setSource(QUrl("qrc:/ScreenPlayWallpaper/qml/Wallpaper.qml"));
|
|
||||||
return ScreenPlay::WallpaperExitCode::Ok;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LinuxWindow::setupWallpaperForOneScreen(int activeScreen)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void LinuxWindow::setupWallpaperForAllScreens()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void LinuxWindow::setupWallpaperForMultipleScreens(const QVector<int>& activeScreensList)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void LinuxWindow::setVisible(bool show)
|
|
||||||
{
|
|
||||||
m_window.setVisible(show);
|
|
||||||
}
|
|
||||||
|
|
||||||
void LinuxWindow::destroyThis()
|
|
||||||
{
|
|
||||||
QCoreApplication::quit();
|
|
||||||
}
|
|
136
ScreenPlayWallpaper/src/linuxx11window.cpp
Normal file
136
ScreenPlayWallpaper/src/linuxx11window.cpp
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
// SPDX-License-Identifier: LicenseRef-EliasSteurerTachiom OR AGPL-3.0-only
|
||||||
|
#include "linuxx11window.h"
|
||||||
|
#include <X11/Xatom.h>
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/Xproto.h>
|
||||||
|
#include <X11/Xutil.h>
|
||||||
|
#include <X11/extensions/shape.h>
|
||||||
|
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#define WIDTH 512
|
||||||
|
#define HEIGHT 384
|
||||||
|
#define OPAQUE 0xffffffff
|
||||||
|
#define NAME "xwinwrap"
|
||||||
|
#define ATOM(a) XInternAtom(display, #a, False)
|
||||||
|
|
||||||
|
ScreenPlay::WallpaperExitCode LinuxX11Window::start()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!debugMode()) {
|
||||||
|
connect(m_sdk.get(), &ScreenPlaySDK::sdkDisconnected, this, &LinuxX11Window::destroyThis);
|
||||||
|
}
|
||||||
|
|
||||||
|
qmlRegisterSingletonInstance<LinuxX11Window>("ScreenPlayWallpaper", 1, 0, "Wallpaper", this);
|
||||||
|
|
||||||
|
auto* screen = QGuiApplication::screens().at(0);
|
||||||
|
m_window.setGeometry(screen->geometry());
|
||||||
|
Window window = m_window.winId();
|
||||||
|
|
||||||
|
Display* display = XOpenDisplay("");
|
||||||
|
|
||||||
|
XSetWindowAttributes attrs = { ParentRelative, 0L, 0, 0L, 0, 0,
|
||||||
|
Always, 0L, 0L, False, StructureNotifyMask | ExposureMask | ButtonPressMask | ButtonReleaseMask, 0L, False, 0, 0 };
|
||||||
|
|
||||||
|
XWMHints wmHint;
|
||||||
|
Atom xa;
|
||||||
|
int flags;
|
||||||
|
flags |= CWBorderPixel | CWColormap;
|
||||||
|
|
||||||
|
XChangeWindowAttributes(display, window, flags, &attrs);
|
||||||
|
|
||||||
|
wmHint.flags = InputHint | StateHint;
|
||||||
|
wmHint.input = true;
|
||||||
|
wmHint.initial_state = WithdrawnState;
|
||||||
|
|
||||||
|
XSetWMProperties(display, window, NULL, NULL, NULL,
|
||||||
|
0, NULL, &wmHint, NULL);
|
||||||
|
|
||||||
|
xa = ATOM(_NET_WM_WINDOW_TYPE);
|
||||||
|
|
||||||
|
Atom prop;
|
||||||
|
xa = ATOM(_MOTIF_WM_HINTS);
|
||||||
|
if (xa != None) {
|
||||||
|
long prop[5] = { 2, 0, 0, 0, 0 };
|
||||||
|
XChangeProperty(display, window, xa, xa, 32,
|
||||||
|
PropModeReplace, (unsigned char*)prop, 5);
|
||||||
|
}
|
||||||
|
xa = ATOM(_NET_WM_STATE);
|
||||||
|
if (xa != None) {
|
||||||
|
Atom xa_prop = ATOM(_NET_WM_STATE_BELOW);
|
||||||
|
|
||||||
|
XChangeProperty(display, window, xa, XA_ATOM, 32,
|
||||||
|
PropModeAppend, (unsigned char*)&xa_prop, 1);
|
||||||
|
}
|
||||||
|
xa = ATOM(_NET_WM_DESKTOP);
|
||||||
|
if (xa != None) {
|
||||||
|
CARD32 xa_prop = 0xFFFFFFFF;
|
||||||
|
|
||||||
|
XChangeProperty(display, window, xa, XA_CARDINAL, 32,
|
||||||
|
PropModeAppend, (unsigned char*)&xa_prop, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
xa = ATOM(_NET_WM_STATE);
|
||||||
|
if (xa != None) {
|
||||||
|
Atom xa_prop = ATOM(_NET_WM_STATE_STICKY);
|
||||||
|
|
||||||
|
XChangeProperty(display, window, xa, XA_ATOM, 32,
|
||||||
|
PropModeAppend, (unsigned char*)&xa_prop, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
xa = ATOM(_NET_WM_STATE);
|
||||||
|
if (xa != None) {
|
||||||
|
Atom xa_prop = ATOM(_NET_WM_STATE_SKIP_TASKBAR);
|
||||||
|
|
||||||
|
XChangeProperty(display, window, xa, XA_ATOM, 32,
|
||||||
|
PropModeAppend, (unsigned char*)&xa_prop, 1);
|
||||||
|
}
|
||||||
|
xa = ATOM(_NET_WM_STATE);
|
||||||
|
if (xa != None) {
|
||||||
|
Atom xa_prop = ATOM(_NET_WM_STATE_SKIP_PAGER);
|
||||||
|
|
||||||
|
XChangeProperty(display, window, xa, XA_ATOM, 32,
|
||||||
|
PropModeAppend, (unsigned char*)&xa_prop, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
XMapWindow(display, window);
|
||||||
|
|
||||||
|
XSync(display, window);
|
||||||
|
QDir workingDir(QGuiApplication::instance()->applicationDirPath());
|
||||||
|
m_window.engine()->addImportPath(workingDir.path() + "/qml");
|
||||||
|
m_window.setResizeMode(QQuickView::ResizeMode::SizeRootObjectToView);
|
||||||
|
m_window.setTextRenderType(QQuickWindow::TextRenderType::NativeTextRendering);
|
||||||
|
m_window.setSource(QUrl("qrc:/qml/ScreenPlayWallpaper/qml/Wallpaper.qml"));
|
||||||
|
m_window.show();
|
||||||
|
return ScreenPlay::WallpaperExitCode::Ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LinuxX11Window::setupWallpaperForOneScreen(int activeScreen)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void LinuxX11Window::setupWallpaperForAllScreens()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void LinuxX11Window::setupWallpaperForMultipleScreens(const QVector<int>& activeScreensList)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void LinuxX11Window::setVisible(bool show)
|
||||||
|
{
|
||||||
|
m_window.setVisible(show);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LinuxX11Window::destroyThis()
|
||||||
|
{
|
||||||
|
QCoreApplication::quit();
|
||||||
|
}
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
#include "basewindow.h"
|
#include "basewindow.h"
|
||||||
|
|
||||||
class LinuxWindow : public BaseWindow {
|
class LinuxX11Window : public BaseWindow {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
@ -14,7 +14,11 @@ Q_IMPORT_QML_PLUGIN(ScreenPlayWeatherPlugin)
|
|||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#if !defined(Q_OS_LINUX)
|
||||||
qputenv("QT_MEDIA_BACKEND","ffmpeg");
|
qputenv("QT_MEDIA_BACKEND","ffmpeg");
|
||||||
|
#endif
|
||||||
|
|
||||||
QtWebEngineQuick::initialize();
|
QtWebEngineQuick::initialize();
|
||||||
QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
|
QApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user