Fixed oversight on Video backgrounds not working on X11

Added unistd.h to fix compilation error on ubuntu

Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
Alexis Maiquez 2023-04-22 12:55:37 +02:00
parent f21a6e64a7
commit f047bdd2d6
6 changed files with 22 additions and 11 deletions

View File

@ -6,18 +6,11 @@
using namespace WallpaperEngine; using namespace WallpaperEngine;
using namespace WallpaperEngine::Render; using namespace WallpaperEngine::Render;
void* get_proc_address_glfw (void* ctx, const char* name) void* get_proc_address (void* ctx, const char* name)
{ {
return reinterpret_cast <void*> (glfwGetProcAddress (name)); return static_cast<CVideo*> (ctx)->getContext ().getDriver ().getProcAddress (name);
} }
#ifdef ENABLE_WAYLAND
#include <EGL/egl.h>
void* get_proc_address_wayland(void* ctx, const char* name) {
return reinterpret_cast <void*> (eglGetProcAddress (name));
}
#endif
CVideo::CVideo (Core::CVideo* video, CRenderContext& context, CAudioContext& audioContext) : CVideo::CVideo (Core::CVideo* video, CRenderContext& context, CAudioContext& audioContext) :
CWallpaper (video, Type, context, audioContext), CWallpaper (video, Type, context, audioContext),
m_width (16), m_width (16),
@ -47,8 +40,7 @@ CVideo::CVideo (Core::CVideo* video, CRenderContext& context, CAudioContext& aud
mpv_set_option (this->m_mpv, "volume", MPV_FORMAT_DOUBLE, &volume); mpv_set_option (this->m_mpv, "volume", MPV_FORMAT_DOUBLE, &volume);
// initialize gl context for mpv // initialize gl context for mpv
mpv_opengl_init_params gl_init_params {get_proc_address_wayland, nullptr}; mpv_opengl_init_params gl_init_params {get_proc_address, this};
// mpv_opengl_init_params gl_init_params {this->getContext().getDriver().getWindowHandle() ? get_proc_address_glfw : get_proc_address_wayland, nullptr};
mpv_render_param params[] { mpv_render_param params[] {
{MPV_RENDER_PARAM_API_TYPE, const_cast <char*> (MPV_RENDER_API_TYPE_OPENGL)}, {MPV_RENDER_PARAM_API_TYPE, const_cast <char*> (MPV_RENDER_API_TYPE_OPENGL)},
{MPV_RENDER_PARAM_OPENGL_INIT_PARAMS, &gl_init_params}, {MPV_RENDER_PARAM_OPENGL_INIT_PARAMS, &gl_init_params},

View File

@ -66,6 +66,11 @@ namespace WallpaperEngine::Render::Drivers
* @return The number of rendered frames since the start of the driver * @return The number of rendered frames since the start of the driver
*/ */
[[nodiscard]] virtual uint32_t getFrameCounter () const = 0; [[nodiscard]] virtual uint32_t getFrameCounter () const = 0;
/**
* @param name
* @return GetProcAddress for this video driver
*/
[[nodiscard]] virtual void* getProcAddress (const char* name) const = 0;
/** /**
* Process events on the driver and renders a frame * Process events on the driver and renders a frame
*/ */

View File

@ -349,6 +349,11 @@ CWaylandOpenGLDriver::SEGLContext* CWaylandOpenGLDriver::getEGLContext ()
return &this->m_eglContext; return &this->m_eglContext;
} }
void* CWaylandOpenGLDriver::getProcAddress (const char* name) const
{
return reinterpret_cast <void*> (eglGetProcAddress (name));
}
CWaylandOpenGLDriver::SWaylandContext* CWaylandOpenGLDriver::getWaylandContext () CWaylandOpenGLDriver::SWaylandContext* CWaylandOpenGLDriver::getWaylandContext ()
{ {
return &this->m_waylandContext; return &this->m_waylandContext;

View File

@ -77,6 +77,7 @@ namespace WallpaperEngine::Render::Drivers
void swapBuffers () override; void swapBuffers () override;
uint32_t getFrameCounter () const override; uint32_t getFrameCounter () const override;
void dispatchEventQueue() const override; void dispatchEventQueue() const override;
[[nodiscard]] void* getProcAddress (const char* name) const override;
void onLayerClose(Output::CWaylandOutputViewport*); void onLayerClose(Output::CWaylandOutputViewport*);
Output::CWaylandOutputViewport* surfaceToViewport(wl_surface*); Output::CWaylandOutputViewport* surfaceToViewport(wl_surface*);

View File

@ -6,6 +6,8 @@
#define GLFW_EXPOSE_NATIVE_X11 #define GLFW_EXPOSE_NATIVE_X11
#include <GLFW/glfw3native.h> #include <GLFW/glfw3native.h>
#include <unistd.h>
using namespace WallpaperEngine::Render::Drivers; using namespace WallpaperEngine::Render::Drivers;
void CustomGLFWErrorHandler (int errorCode, const char* reason) void CustomGLFWErrorHandler (int errorCode, const char* reason)
@ -162,6 +164,11 @@ void CX11OpenGLDriver::dispatchEventQueue() const
usleep ((minimumTime - (endTime - startTime)) * CLOCKS_PER_SEC); usleep ((minimumTime - (endTime - startTime)) * CLOCKS_PER_SEC);
} }
void* CX11OpenGLDriver::getProcAddress (const char* name) const
{
return reinterpret_cast <void*> (glfwGetProcAddress (name));
}
GLFWwindow* CX11OpenGLDriver::getWindow () GLFWwindow* CX11OpenGLDriver::getWindow ()
{ {
return this->m_window; return this->m_window;

View File

@ -37,6 +37,7 @@ namespace WallpaperEngine::Render::Drivers
void swapBuffers () override; void swapBuffers () override;
[[nodiscard]] uint32_t getFrameCounter () const override; [[nodiscard]] uint32_t getFrameCounter () const override;
void dispatchEventQueue() const override; void dispatchEventQueue() const override;
[[nodiscard]] void* getProcAddress (const char* name) const override;
GLFWwindow* getWindow (); GLFWwindow* getWindow ();