Package launch_vimix script in flatpak and snap for wayland support

under wayland window manager, there are opengl driver issues (specifically for nvidia) so vimix shall be launched with specific settings using a launcher script
This commit is contained in:
Bruno Herbelin
2025-01-09 18:58:46 +01:00
parent ab7a84c40f
commit 8a336b3a6e
8 changed files with 100 additions and 43 deletions

View File

@@ -42,7 +42,35 @@ Mac OSX specificities
Instructions to reset in finder, do "Go to folder" (shift+command+G),
enter "/Users/[username]/Library/Application Support/vimix" and delete the folder 'vimix'
-
- POST INSTALL DMG SIGNING AND NOTARIZATION
1. SIGN DMG
codesign --force --sign "Developer ID Application: <identityIdentifier>" <pathToDMG>
verify with:
codesign --verify --verbose=2 <pathToDMG>
2. SUBMIT TO NOTARIZATION
xcrun notarytool submit <pathToDMG> --keychain-profile "vimix" --wait
verify with:
xcrun notarytool log xxxx-xxxx-xxx --keychain-profile "vimix"
NB: "vimix" is the name of the app-specific password in keychain generated online: https://support.apple.com/en-us/102654
3. STAPLE THE TICKET TO THE DISK IMAGE
xcrun stapler staple <pathToDMG>
4. VERIFY NOTARIZATION
spctl -a -vv -t install <pathToDMG>
NB: more info at https://wiki.lazarus.freepascal.org/Notarization_for_macOS_10.14.5%2B
Testing performance

View File

@@ -3,7 +3,7 @@
"runtime": "org.gnome.Platform",
"runtime-version": "47",
"sdk": "org.gnome.Sdk",
"command": "vimix",
"command": "launch_vimix.sh",
"rename-desktop-file": "vimix.desktop",
"rename-icon": "vimix",
"finish-args": [
@@ -18,9 +18,7 @@
"--filesystem=host",
"--filesystem=/tmp",
"--talk-name=org.gtk.vfs.*",
"--env=FREI0R_PATH=/app/lib/frei0r-1",
"--env=__NV_PRIME_RENDER_OFFLOAD=1",
"--env=__GLX_VENDOR_LIBRARY_NAME=nvidia"
"--env=FREI0R_PATH=/app/lib/frei0r-1"
],
"cleanup": [
"/include",

19
rsc/launch_vimix.sh Normal file
View File

@@ -0,0 +1,19 @@
#!/bin/bash
# Test if running under wayland
if [ -z "$WAYLAND_DISPLAY" ]; then
# not Wayland, nothing special
vimix "$@"
else
# Wayland: test if there is an nvidia GPU
gpu=$(lspci | grep -i '.* vga .* nvidia .*')
shopt -s nocasematch
if [[ $gpu == *' nvidia '* ]]; then
# with nvidia, request Wayland render offload
printf 'Nvidia GPU present: %s\n' "$gpu"
__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia vimix "$@"
else
# otherwise, nothing special
vimix "$@"
fi
fi

View File

@@ -5,6 +5,6 @@ GenericName=Video mixer
Comment=Video live mixer
Categories=AudioVideo;Video;Graphics;
Icon=vimix.svg
Exec=vimix
Exec=launch_vimix.sh
MimeType=application/x-vimix;text/xml
Terminal=false

View File

@@ -5,6 +5,6 @@ GenericName=Video mixer
Comment=Video live mixer
Categories=AudioVideo;Video;Graphics;
Icon=${SNAP}/meta/gui/vimix.svg
Exec=vimix
Exec=launch_vimix.sh
MimeType=application/x-vimix;text/xml
Terminal=false

View File

@@ -307,30 +307,14 @@ IF(APPLE)
)
endif()
## POST INSTALL DMG SIGNING AND NOTARIZATION
## 1. SIGN DMG
## codesign --force --sign "Developer ID Application: <identityIdentifier>" <pathToDMG>
## codesign --verify --verbose=2 ./_CPack_Packages/OSX_13_arm64/DragNDrop/vimix_0.8.2_OSX_13_arm64.dmg
##
## 2. SUBMIT TO NOTARIZATION
## xcrun notarytool submit ./_CPack_Packages/OSX_13_arm64/DragNDrop/vimix_0.8.2_OSX_13_arm64.dmg --keychain-profile "vimix" --wait
##
## verify with: xcrun notarytool log xxxx-xxxx-xxx --keychain-profile "vimix"
##
## NB: "vimix" is the name of the app-specific password in keychain
## generated online : https://support.apple.com/en-us/102654
##
## 3. STAPLE THE TICKET TO THE DISK IMAGE
## xcrun stapler staple ./_CPack_Packages/OSX_13_arm64/DragNDrop/vimix_0.8.2_OSX_13_arm64.dmg
##
## 4. VERIFY NOTARIZATION
## spctl -a -vv -t install ./_CPack_Packages/OSX_13_arm64/DragNDrop/vimix_0.8.2_OSX_13_arm64.dmg
##
## NB: more info at https://wiki.lazarus.freepascal.org/Notarization_for_macOS_10.14.5%2B
ELSE(APPLE)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/share DESTINATION ${CMAKE_INSTALL_PREFIX})
install(FILES "${CMAKE_SOURCE_DIR}/rsc/launch_vimix.sh"
DESTINATION bin
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
COMPONENT Runtime
)
install(TARGETS ${VMIX_BINARY}
CONFIGURATIONS Release RelWithDebInfo

View File

@@ -145,7 +145,7 @@ bool openGLExtensionAvailable(const char *extensionname)
static void glfw_error_callback(int error, const char* description)
{
g_printerr("Glfw Error %d: %s\n", error, description);
g_printerr("GLFW Error %d: %s\n", error, description);
}
static void WindowResizeCallback( GLFWwindow *w, int width, int height)
@@ -324,6 +324,7 @@ Rendering::Rendering()
{
// main_window_ = nullptr;
request_screenshot_ = false;
wayland_ = false;
}
bool Rendering::init()
@@ -337,6 +338,15 @@ bool Rendering::init()
return false;
}
int major, minor;
glfwGetVersion(&major, &minor, NULL);
if (major > 2 && minor > 3) {
wayland_ = glfwGetPlatform() == GLFW_PLATFORM_WAYLAND;
if (wayland_)
Log::Info("Warning: some features are not available with WAYLAND window manager and framerate might be slow. Vimix prefers X11 window manager.");
}
//
// Gstreamer setup
//
@@ -767,13 +777,15 @@ void RenderingWindow::setTitle(const std::string &title)
void RenderingWindow::setIcon(const std::string &resource)
{
#ifndef APPLE
size_t fpsize = 0;
const char *fp = Resource::getData(resource, &fpsize);
if (fp != nullptr && window_) {
GLFWimage icon;
icon.pixels = stbi_load_from_memory( (const stbi_uc*)fp, fpsize, &icon.width, &icon.height, nullptr, 4 );
glfwSetWindowIcon( window_, 1, &icon );
free( icon.pixels );
if (!Rendering::manager().wayland_) {
size_t fpsize = 0;
const char *fp = Resource::getData(resource, &fpsize);
if (fp != nullptr && window_) {
GLFWimage icon;
icon.pixels = stbi_load_from_memory( (const stbi_uc*)fp, fpsize, &icon.width, &icon.height, nullptr, 4 );
glfwSetWindowIcon( window_, 1, &icon );
free( icon.pixels );
}
}
#endif
}
@@ -784,7 +796,9 @@ GLFWmonitor *RenderingWindow::monitor()
int x = 0, y = 0, w = 2, h = 2;
if (window_) {
glfwGetWindowSize(window_, &w, &h);
glfwGetWindowPos(window_, &x, &y);
if (!Rendering::manager().wayland_)
glfwGetWindowPos(window_, &x, &y);
}
return Rendering::manager().monitorAt(x + w/2, y + h/2);
}
@@ -897,8 +911,17 @@ void RenderingWindow::setCoordinates(glm::ivec4 rect)
if (glfwGetWindowAttrib(window_, GLFW_MAXIMIZED))
glfwRestoreWindow(window_);
glfwSetWindowSize( window_, glm::max(50, rect.p), glm::max(50, rect.q));
glfwSetWindowPos( window_, rect.x, rect.y);
glfwSetWindowSize(window_, glm::max(50, rect.p), glm::max(50, rect.q));
if (!Rendering::manager().wayland_)
glfwSetWindowPos(window_, rect.x, rect.y);
else {
static bool once = false;
if (!once) {
Log::Warning("Set window coordilates is not possible under Wayland window manager");
once = true;
}
}
}
int RenderingWindow::width()
@@ -953,6 +976,7 @@ bool RenderingWindow::init(int index, GLFWwindow *share)
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // 3.2+ only
#if __APPLE__
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // Required on Mac
#endif
@@ -974,7 +998,7 @@ bool RenderingWindow::init(int index, GLFWwindow *share)
// create the window
window_ = glfwCreateWindow(winset.w, winset.h, winset.name.c_str(), NULL, master_);
if (window_ == NULL){
Log::Error("Failed to create GLFW Window %d", index_);
g_printerr("Failed to create GLFW Window %d", index_);
return false;
}
@@ -983,7 +1007,8 @@ bool RenderingWindow::init(int index, GLFWwindow *share)
previous_size = glm::vec2(winset.w, winset.h);
// set initial position
glfwSetWindowPos(window_, winset.x, winset.y);
if (!Rendering::manager().wayland_)
glfwSetWindowPos(window_, winset.x, winset.y);
// set icon
setIcon("images/vimix_256x256.png");
@@ -997,7 +1022,8 @@ bool RenderingWindow::init(int index, GLFWwindow *share)
//
// window position and resize callbacks
//
glfwSetWindowPosCallback( window_, WindowMoveCallback );
if (!Rendering::manager().wayland_)
glfwSetWindowPosCallback( window_, WindowMoveCallback );
glfwSetWindowSizeCallback( window_, WindowResizeCallback );
//
@@ -1027,7 +1053,7 @@ bool RenderingWindow::init(int index, GLFWwindow *share)
if ( !glad_initialized ) {
bool err = gladLoadGL((GLADloadfunc) glfwGetProcAddress) == 0;
if (err) {
Log::Error("Failed to initialize GLAD OpenGL loader.");
g_printerr("Failed to initialize GLAD OpenGL loader.");
return false;
}
glad_initialized = true;

View File

@@ -181,6 +181,8 @@ protected:
// file drop callback
static void FileDropped(GLFWwindow* main_window_, int path_count, const char* paths[]);
bool wayland_;
private:
// list of rendering attributes