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

C++/libscreen fails to update visibility

本文关键字:更新 可见性 libscreen C++      更新时间:2023-10-16

我正在按照文档教程,使用 QNX CAR 2.0 为 Neutrino 6.5.0 编写 C++ (qcc( 的 GUI。不生成可见输出,/dev/screen/{pid}/win-{n}/win-{n}具有status = WIN_STATUS_INVISIBLE

(使用{n}{pid}来指示运行时/动态变量值的替换(

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

我已经构建了一个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 %sn", 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("%dn", 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 应用程序中与对应物的差异,产生了一些见解。

工作应用程序是一个我没有源代码的人机界面,以 root 身份从/etc/ro启动,我的应用程序从 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。

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