1

我正在尝试做与这个问题相同的事情。

到目前为止,我是从官方文档xcb_change_property中了解功能的。

但是下面的代码仍然没有给出任何结果。

xcb_connection_t *c = xcb_connect ( NULL, NULL );

/* get the first screen */
xcb_screen_t *screen = xcb_setup_roots_iterator (xcb_get_setup (c)).data;

xcb_window_t win = xcb_generate_id ( c );

xcb_create_window ( c,                             /* Connection          */
                    XCB_COPY_FROM_PARENT,          /* depth (same as root)*/
                    win,                           /* window Id           */
                    screen->root,                  /* parent window       */
                    0, 0,                          /* x, y                */
                    system::getCore()->screen.width(), /* width */
                    system::getCore()->screen.height(), /* height       */
                    0,                            /* border_width        */
                    XCB_WINDOW_CLASS_INPUT_OUTPUT, /* class               */
                    screen->root_visual,           /* visual              */
                    0,
                    NULL );                     /* masks*/


xcb_intern_atom_cookie_t cookie = xcb_intern_atom ( c, 0, strlen ( "_MOTIF_WM_HINTS" ), "_MOTIF_WM_HINTS" );
xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply ( c, cookie, NULL );

xcb_change_property ( c,
                     XCB_PROP_MODE_REPLACE,
                     win,
                     (*reply).atom,
                     XCB_ATOM_INTEGER,
                     32,
                     0,
                     0 );

xcb_map_window ( c, win );
xcb_flush ( c );

我究竟做错了什么?

4

2 回答 2

1

关键是使用 (*reply).atom 两次,而不是 XCB_ATOM_INTEGER:

适合我的代码:

xcb_intern_atom_cookie_t cookie3 = xcb_intern_atom(connection, 0, strlen ( "_MOTIF_WM_HINTS" ), "_MOTIF_WM_HINTS" );
xcb_intern_atom_reply_t *reply3 = xcb_intern_atom_reply ( connection, cookie3, NULL );

// motif hints
typedef struct MotifHints
{
    uint32_t   flags;
    uint32_t   functions;
    uint32_t   decorations;
    int32_t    input_mode;
    uint32_t   status;
};

MotifHints hints;

hints.flags = 2;
hints.functions = 0;
hints.decorations = 0;
hints.input_mode = 0;
hints.status = 0;

xcb_change_property ( connection,
    XCB_PROP_MODE_REPLACE,
    window,
    reply3->atom,
    reply3->atom,  // THIS is essential
    32,  // format of property
    5,   // length of data (5x32 bit) , followed by pointer to data
    &hints ); // is this is a motif hints struct

free(reply3);

查看 SFML 源代码也有帮助,文件WindowImplX11.cpp.

于 2016-04-30T21:30:51.413 回答
0

您的问题并不能很好地解释您要做什么。但是,您解释实际目标的评论确实如此。如果我理解正确,您想创建一个类似于 Compiz“注释”插件的应用程序。我不能 100% 肯定地说,但如果没有其他扩展,我不相信这是可能的。你真的需要一个复合扩展来做到这一点,但没有它你可以通过几种方式模拟效果......

(1) 你基本上可以截取屏幕截图并在上面绘制,甚至可以通过隐藏整个内容并重新截取屏幕截图来定期更新背景。任何接近实时更新的东西都可能看起来不太顺利。

(2) 您可以监听所有鼠标移动和/或键盘事件,并在屏幕上创建许多小窗口。你可能会到一个地步,它不会让你创建更多的窗口,而且它可能不会太漂亮。

(3) 您可以使用“shape”扩展,它允许您制作形状奇特的窗口,并尝试从本质上是 alpha 蒙版的窗口创建一个覆盖在其他窗口上的窗口。我不确定您可以使用该扩展程序做什么,因为我从未使用过它。您可能仅限于简单的多边形。

肯定还有其他解决方案,这些解决方案的某种组合显然可以奏效。显然,如果复合材料可用,您最好的解决方案就是使用它。

于 2019-01-25T17:19:06.757 回答