C++/libscreen 无法更新可见性

C++/libscreen fails to update visibility

我正在使用屏幕窗口系统为 Neutrino 6.5.0 和 QNX CAR 2.0 使用 C++ (qcc) 编写 GUI,遵循文档教程。没有生成可见输出,并且 /dev/screen/{pid}/win-{n}/win-{n}status = WIN_STATUS_INVISIBLE.

(使用 {n}{pid} 表示替换 runtime/dynamic 变量的值)

我尝试严格按照教程进行操作,但结果相同。特别是,window_group_namemainwindowgroupveryuniquewgn)的值没有区别;前者是教程建议的值,后者是我自己的。

我构建了一个 MCVE:

#include <cstdlib>   // for EXIT_ constants
#include <stdio.h>   // for printf(), getchar()
#include <process.h> // for getpid()

#include <screen.h>

#define screen_err(desc) \
    if(screen_res != 0) { \
        printf("ERR screen: failed to %s\n", desc); \
        return EXIT_FAILURE; \
    }

int main_withwindow(screen_context_t scr_ctx, screen_window_t scr_win) {
    static const char *window_group_name = "veryuniquewgn";

    // Dummy to pass as ptr to enum values
    int prop;

    int screen_res;

    screen_res = screen_create_window_group(scr_win, window_group_name);
    screen_err("create window group");

    prop = SCREEN_FORMAT_RGBA8888;
    screen_res = screen_set_window_property_iv(scr_win, SCREEN_PROPERTY_FORMAT,
            &prop);
    screen_err("set window property: format -> RGBA");

    prop = SCREEN_USAGE_NATIVE;
    screen_res = screen_set_window_property_iv(scr_win, SCREEN_PROPERTY_USAGE,
            &prop);
    screen_err("set window property: usage -> native");

    screen_res = screen_create_window_buffers(scr_win, 1);
    screen_err("create window buffers");

    int win_buf_rect[4] = { 0, 0 };
    screen_res = screen_get_window_property_iv(scr_win,
            SCREEN_PROPERTY_BUFFER_SIZE, win_buf_rect + 2);
    screen_err("get window property: buffer_size");

    // Array type to easily support multi-buffering in future
    screen_buffer_t scr_buf[1];

    screen_res = screen_get_window_property_pv(scr_win,
            SCREEN_PROPERTY_RENDER_BUFFERS, (void **)scr_buf);
    screen_err("get window property: render_buffers");

    int bg[] = { SCREEN_BLIT_COLOR, 0xffffff00, SCREEN_BLIT_END };
    screen_res = screen_fill(scr_ctx, scr_buf[0], bg);
    screen_err("fill buffer with yellow");

    screen_res = screen_post_window(scr_win, scr_buf[0], 1, win_buf_rect, 0);
    screen_err("post window");

    prop = 255;
    screen_res = screen_set_window_property_iv(scr_win,
            SCREEN_PROPERTY_ZORDER, &prop);
    screen_err("set window property: zorder -> 255");

    prop = 1;
    screen_res = screen_set_window_property_iv(scr_win,
            SCREEN_PROPERTY_VISIBLE, &prop);
    screen_err("set window property: visible -> true");

    screen_res = screen_flush_context(scr_ctx, SCREEN_WAIT_IDLE);
    screen_err("flush context to idle");

    getchar();

    return EXIT_SUCCESS;
}


int main_withcontext(screen_context_t scr_ctx) {
    screen_window_t scr_win;

    int ret;
    int screen_res;

    screen_res = screen_create_window(&scr_win, scr_ctx);
    screen_err("create window");

    ret = main_withwindow(scr_ctx, scr_win);

    screen_res = screen_destroy_window(scr_win);
    screen_err("destroy window");

    return ret;
}

int main(int argc, char *argv[]) {
    printf("%d\n", getpid());

    screen_context_t scr_ctx;
    int ret;
    int screen_res;

    screen_res = screen_create_context(&scr_ctx, SCREEN_APPLICATION_CONTEXT);
    screen_err("create context");

    ret = main_withcontext(scr_ctx);

    screen_res = screen_destroy_context(scr_ctx);
    screen_err("destroy context");

    return ret;
}

鉴于使用 screen_err() 定义,没有输出 - 除了 pid 的第一个 printf - 表明 screen_...() 调用没有错误。这正是我在 运行 时看到的。

查看 /dev/screen/{pid},我看到了一个 ctx-{n}/ctx-{n} 和一个 win-{n}/win-{n} 文件,正如预期的那样。前者不是人类可读的,但后者,以及它与 nto 6.5.0 + CAR 2.0 + libscreen 应用程序中的对应物的差异,产生了一些洞察力。

工作应用程序是一个 HMI,我没有源代码,它是从 /etc/ro 以 root 身份启动的,我的是从 ksh 启动的,以 root 身份登录。

它们都是 98 行文件,因此我生成了一个差异 - win-{n} 来自左侧的工作应用程序,右侧是我的 - 不包括指标: (垂直比较超过 39 个字符的行)

autonomous = 0                           autonomous = 1
status = WIN_STATUS_FULLSCREEN           status = WIN_STATUS_INVISIBLE
id string = DPY_HMI                      id string =
insert id = 1                            insert id = 3
reclip = 0                               reclip = 1

flags = WIN_FLAG_VISIBLE WIN_FLAG_FLOATING
flags = WIN_FLAG_FLOATING

usage = SCREEN_USAGE_OPENGL_ES2          usage = SCREEN_USAGE_NATIVE
order = 240                              order = 0
regions = (0,0;800,480)                  regions = (none)

clipped source viewport = (0,0;800,480 800x480)
clipped source viewport = (0,0;0,0 0x0)


clipped destination rectangle = (0,0;800,480 800x480)
clipped destination rectangle = (0,0;0,0 0x0)

transform = [[1 0 0],[0 1 0],[0 0 1]]    transform = [[0 0 0],[0 0 0],[0 0 0]]

在这些差异中,usage 是唯一具有我预期值的差异,考虑到它反映了对 screen_set_window_property_iv(...) 的相关调用的参数。对于所有其余部分,尤其是 regionsflags,我不明白为什么它们的值与工作应用程序的值不同。

目标显示器的原始分辨率为 800x480。

事实证明,该代码完全有效且正确。它失败的原因是 window 管理器守护程序,我不知道它抑制了 window。关闭它解决了问题。