glouw / paperview

A high performance X11 animated wallpaper setter
https://glouw.com/2020/08/02/Paperview.html
MIT License
1.45k stars 46 forks source link

not work on macOS Catalina 10.15.6 #12

Open MarcoQin opened 4 years ago

MarcoQin commented 4 years ago

Build command: gcc -std=c99 -O2 -Wall -Wextra -Wpedantic main.c -I/usr/X11R6/include -L/usr/X11R6/lib -lSDL2 -lX11 -o paperview

Run command: ./paperview cyber 5

Output:

2020-08-05 16:56:07.067 paperview[39543:6127143] -[__NSTaggedDate title]: unrecognized selector sent to instance 0x1d1
2020-08-05 16:56:07.067 paperview[39543:6127143] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSTaggedDate title]: unrecognized selector sent to instance 0x1d1'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff36cfcb57 __exceptionPreprocess + 250
    1   libobjc.A.dylib                     0x00007fff6f9aa5bf objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff36d7bbe7 -[NSObject(NSObject) __retain_OA] + 0
    3   CoreFoundation                      0x00007fff36c613bb ___forwarding___ + 1427
    4   CoreFoundation                      0x00007fff36c60d98 _CF_forwarding_prep_0 + 120
    5   libSDL2-2.0.0.dylib                 0x0000000101047b5c Cocoa_CreateWindowFrom + 44
    6   libSDL2-2.0.0.dylib                 0x000000010101f160 SDL_CreateWindowFrom_REAL + 186
    7   paperview                           0x0000000100f998f3 main + 115
    8   libdyld.dylib                       0x00007fff70b52cc9 start + 1
    9   ???                                 0x0000000000000003 0x0 + 3
)
libc++abi.dylib: terminating with uncaught exception of type NSException
glouw commented 4 years ago

Does this example work for you? https://stackoverflow.com/questions/34425799/use-root-x11-window-as-the-main-sdl2-window

It should just paint the screen one solid color.

MarcoQin commented 4 years ago

No, it's not work, too. And the example result in the same error.

But X11 window is runnable, following snippet is working:

#include <X11/Xlib.h> // Every Xlib program must include this
#include <assert.h>   // I include this to test return values the lazy way
#include <unistd.h>   // So we got the profile for 10 seconds

#define NIL (0)       // A name for the void pointer

main()
{
      Display *dpy = XOpenDisplay(NIL);
      assert(dpy);
      Window w = XCreateWindow(dpy, DefaultRootWindow(dpy), 0, 0,
                   200, 100, 0,
                   CopyFromParent, CopyFromParent, CopyFromParent,
                   NIL, 0);
      XMapWindow(dpy, w);
      XFlush(dpy);
      sleep(10);
}

Snipet that not work:

#include <SDL2/SDL.h>

#include <X11/Xlib.h>

#include <stdio.h>

// clang -lSDL2 -lX11 -I/usr/include/SDL2 -Weverything x11.c -o x11

int main(void)
{
    Display *x11_d;
    int x11_s;
    Window x11_w;
    SDL_Window *w;
    SDL_Renderer *r;

    x11_d = XOpenDisplay(NULL);

    if(!x11_d) {
        fprintf(stderr, "couldn't open display\n");
        return 1;
    }

    /* x11_s = DefaultScreen(x11_d); */
    /* x11_w = RootWindow(x11_d, x11_s); */

    x11_w = XCreateWindow(x11_d, DefaultRootWindow(x11_d), 0, 0,
            200, 100, 0,
            CopyFromParent, CopyFromParent, CopyFromParent,
            0, 0);
    XMapWindow(x11_d, x11_w);

    if(SDL_Init(SDL_INIT_VIDEO) != 0) {
        fprintf(stderr, "couldn't initialize SDL: %s\n", SDL_GetError());
        return 1;
    }

    w = SDL_CreateWindowFrom((void *)x11_w);

    /* XCloseDisplay(x11_d); */

    if(!w) {
        fprintf(stderr, "couldn't attach to the root X11 window: %s\n", SDL_GetError());
        return 1;
    }
    printf("here haha\n");

    r = SDL_CreateRenderer(w, -1, 0);

    SDL_SetRenderDrawColor(r, 255, 0, 0, 255);
    SDL_RenderClear(r);
    SDL_RenderPresent(r);

    SDL_Delay(5700);

    SDL_Quit();
    return 0;
}
glouw commented 4 years ago

This looks to be a similar error:

https://stackoverflow.com/questions/30185781/sdl-createwindowfrom-with-qt-widget-under-mac-os

Maybe the problem lies with how the window is being created. Since this is OSX specific I am not of much help

MarcoQin commented 4 years ago

Anyway, thank you! I will try again when I have time.