-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: falkTX <[email protected]>
- Loading branch information
Showing
13 changed files
with
271 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// SPDX-FileCopyrightText: 2023-2024 MOD Audio UG | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
#include "DistrhoUtils.hpp" | ||
|
||
START_NAMESPACE_DISTRHO | ||
|
||
// ----------------------------------------------------------------------------------------------------------- | ||
|
||
void* addWebView(uintptr_t viewptr); | ||
void destroyWebView(void* webview); | ||
void reloadWebView(void* webview); | ||
void resizeWebView(void* webview, uint offset, uint width, uint height); | ||
|
||
// ----------------------------------------------------------------------------------------------------------- | ||
|
||
END_NAMESPACE_DISTRHO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// SPDX-FileCopyrightText: 2023-2024 MOD Audio UG | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
#include "DistrhoPluginInfo.h" | ||
|
||
#include "../systray/qrc_mod-desktop.hpp" | ||
|
||
// TODO split build | ||
#include "../systray/utils.cpp" | ||
|
||
#include <QtGui/QWindow> | ||
#include <QtWidgets/QApplication> | ||
#include <QtWidgets/QMainWindow> | ||
#include <QtWebEngineWidgets/QWebEngineView> | ||
|
||
// ----------------------------------------------------------------------------------------------------------- | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
QApplication::setAttribute(Qt::AA_X11InitThreads); | ||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); | ||
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); | ||
|
||
setupControlCloseSignal(); | ||
|
||
// TODO set up all branding here | ||
QApplication app(argc, argv); | ||
app.setApplicationName("MOD Desktop"); | ||
app.setOrganizationName("MOD Audio"); | ||
app.setWindowIcon(QIcon(":/res/mod-logo.svg")); | ||
|
||
const bool darkMode = shouldUseDarkMode(); | ||
|
||
if (darkMode) | ||
setupDarkModePalette(app); | ||
|
||
printf("'%s' '%s'\n", argv[1], argv[2]); | ||
|
||
if (argc == 3 && std::strcmp(argv[1], "-xembed") == 0) | ||
{ | ||
const uintptr_t parentId = std::atoll(argv[2]); | ||
QWindow* const parentWindow = QWindow::fromWinId(parentId); | ||
|
||
QWebEngineView webview; | ||
webview.move(0, kVerticalOffset); | ||
webview.setFixedSize(DISTRHO_UI_DEFAULT_WIDTH, DISTRHO_UI_DEFAULT_HEIGHT - kVerticalOffset); | ||
webview.winId(); | ||
webview.windowHandle()->setParent(parentWindow); | ||
webview.setUrl(QUrl("http://127.0.0.1:18181/")); | ||
webview.show(); | ||
return app.exec(); | ||
} | ||
else | ||
{ | ||
QMainWindow window; | ||
window.setWindowTitle("Web View"); | ||
|
||
QWebEngineView webview(&window); | ||
webview.setUrl(QUrl("http://127.0.0.1:18181/")); | ||
|
||
window.setCentralWidget(&webview); | ||
window.resize(DISTRHO_UI_DEFAULT_WIDTH, DISTRHO_UI_DEFAULT_HEIGHT - kVerticalOffset); | ||
|
||
if (darkMode) | ||
setupDarkModeWindow(window); | ||
|
||
window.show(); | ||
return app.exec(); | ||
} | ||
} | ||
|
||
// ----------------------------------------------------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
// SPDX-FileCopyrightText: 2023-2024 MOD Audio UG | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
#include "WebView.hpp" | ||
|
||
#include "ChildProcess.hpp" | ||
#include "extra/String.hpp" | ||
|
||
#include <dlfcn.h> | ||
#include <linux/limits.h> | ||
#include <X11/Xlib.h> | ||
// #include <X11/Xutil.h> | ||
|
||
START_NAMESPACE_DISTRHO | ||
|
||
// ----------------------------------------------------------------------------------------------------------- | ||
|
||
struct WebViewIPC { | ||
ChildProcess p; | ||
::Display* display; | ||
::Window childWindow; | ||
::Window ourWindow; | ||
}; | ||
|
||
// ----------------------------------------------------------------------------------------------------------- | ||
|
||
void* addWebView(uintptr_t viewptr) | ||
{ | ||
::Display* const display = XOpenDisplay(nullptr); | ||
DISTRHO_SAFE_ASSERT_RETURN(display != nullptr, nullptr); | ||
|
||
WebViewIPC* const ipc = new WebViewIPC(); | ||
ipc->display = display; | ||
ipc->childWindow = 0; | ||
ipc->ourWindow = viewptr; | ||
|
||
char webviewTool[PATH_MAX] = {}; | ||
|
||
{ | ||
Dl_info info = {}; | ||
dladdr((void*)addWebView, &info); | ||
|
||
if (info.dli_fname[0] == '.') | ||
{ | ||
getcwd(webviewTool, PATH_MAX - 1); | ||
std::strncat(webviewTool, info.dli_fname + 1, PATH_MAX - 1); | ||
} | ||
else if (info.dli_fname[0] != '/') | ||
{ | ||
getcwd(webviewTool, PATH_MAX - 1); | ||
std::strncat(webviewTool, "/", PATH_MAX - 1); | ||
std::strncat(webviewTool, info.dli_fname, PATH_MAX - 1); | ||
} | ||
else | ||
{ | ||
std::strncpy(webviewTool, info.dli_fname, PATH_MAX - 1); | ||
} | ||
} | ||
|
||
if (char* const c = std::strrchr(webviewTool, '/')) | ||
*c = 0; | ||
|
||
std::strncat(webviewTool, "/MOD-Desktop-WebView", PATH_MAX - 1); | ||
|
||
const String viewStr(viewptr); | ||
const char* const args[] = { webviewTool, "-platform", "xcb", "-xembed", viewStr.buffer(), nullptr }; | ||
ipc->p.start2(args); | ||
|
||
return ipc; | ||
} | ||
|
||
void destroyWebView(void* const webviewptr) | ||
{ | ||
WebViewIPC* const ipc = static_cast<WebViewIPC*>(webviewptr); | ||
|
||
XCloseDisplay(ipc->display); | ||
delete ipc; | ||
} | ||
|
||
void reloadWebView(void* const webviewptr) | ||
{ | ||
} | ||
|
||
void resizeWebView(void* const webviewptr, const uint offset, const uint width, const uint height) | ||
{ | ||
WebViewIPC* const ipc = static_cast<WebViewIPC*>(webviewptr); | ||
|
||
if (ipc->childWindow == 0) | ||
{ | ||
::Window rootWindow, parentWindow; | ||
::Window* childWindows = nullptr; | ||
uint numChildren = 0; | ||
|
||
XFlush(ipc->display); | ||
XQueryTree(ipc->display, ipc->ourWindow, &rootWindow, &parentWindow, &childWindows, &numChildren); | ||
|
||
if (numChildren == 0 || childWindows == nullptr) | ||
return; | ||
|
||
ipc->childWindow = childWindows[0]; | ||
XFree(childWindows); | ||
} | ||
|
||
XMoveResizeWindow(ipc->display, ipc->childWindow, 0, offset, width, height); | ||
XFlush(ipc->display); | ||
} | ||
|
||
// ----------------------------------------------------------------------------------------------------------- | ||
|
||
END_NAMESPACE_DISTRHO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.