Hello everybody,

Is there a way to embed a foreign window into an Elementary widget?

In concreto I try to embed a mpv player into a Elementary application. There 
are to
options:

1) with a XWindow XID
Is there a way to get the xid of a single widget (for example a frame or 
similar?). Obviously
I can only get the xid of a whole window? Or can one embed a window into the 
main
window?

2) With OpenGL
I tried to adapt the SDL example at 
https://github.com/mpv-player/mpv-examples/blob/
master/libmpv/sdl/main.c and render the mpv context to a Glview widget.

Unfortunately MPV doesn't render to the Glview and I don't know why. Perhaps I 
need to
set the Glview fbo manually? How could I do this? I really don't know, how to 
get ahead...

Thanks in advance and a happy New Year 2022,
Max

This is my current state: (you can find it under 
https://github.com/MaxPerl/mpv2Efl):

// Build with: gcc -o mpv mpv.c `pkg-config --cflags --libs mpv elementary`

#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>

#include <Elementary.h>

#include <mpv/client.h>
#include <mpv/render_gl.h>

static int count = 0;
static int render_event;

typedef struct _cb_data cbd;

struct _cb_data
{
   Evas_Object *glview;
   mpv_handle   *mpv;
   mpv_render_context *mpv_gl;
   GLuint fbo;
};

static cbd *cb_data = NULL;

static void die(const char *msg)
{
    fprintf(stderr, "%s\n", msg);
    exit(1);
}

static void *get_proc_address(void *fn_ctx, const char *name)
{
    Evas_Object *glview = fn_ctx;
    Evas_GL *gl = elm_glview_evas_gl_get(glview);
    void *addr = evas_gl_proc_address_get(gl,name);
    return addr;
}

void _render_update(void *ctx) {
    printf("CALL RENDER %d\n",count);
    count = 1;

}

Eina_Bool render_event_cb(void *data, int type, void *ev) {
    elm_glview_changed_set(cb_data->glview);
    return 1;
}

void _on_render(Evas_Object *obj)
{
    mpv_render_context *mpv_gl = cb_data->mpv_gl;
    Evas_Object *gl = cb_data->glview;

        int w, h;

        elm_glview_size_get(gl, &w, &h);
        printf("RENDER %d %d\n",w,h);

        mpv_render_param params[] = {
            // Specify the default framebuffer (0) as target. This will
            // render onto the entire screen. If you want to show the video
            // in a smaller rectangle or apply fancy transformations, you'll
            // need to render into a separate FBO and draw it manually.
            {MPV_RENDER_PARAM_OPENGL_FBO, &(mpv_opengl_fbo){
                    .fbo = 0,
                    .w = w,
                    .h = h,
            }},
            // Flip rendering (needed due to flipped GL coordinate system).
            {MPV_RENDER_PARAM_FLIP_Y, &(int){1}},
            {0}
        };
        // See render_gl.h on what OpenGL environment mpv expects, and
        // other API details.
        mpv_render_context_render(mpv_gl, params);

}

static Eina_Bool
on_mpv(void *data)
{
    mpv_handle *mpv = data;
    while (1) {
                    //printf("COUNT %d",count);
                    if (count) {

_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to