首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用XCB删除窗口装饰?

如何使用XCB删除窗口装饰?
EN

Stack Overflow用户
提问于 2015-02-06 21:30:12
回答 2查看 1.4K关注 0票数 1

我正在尝试做与this question中相同的事情。

到目前为止,我从official documentation学到了xcb_change_property函数。

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

代码语言:javascript
复制
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 );

我做错了什么?

EN

回答 2

Stack Overflow用户

发布于 2016-05-01 05:30:51

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

适用于我的代码:

代码语言:javascript
复制
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

票数 1
EN

Stack Overflow用户

发布于 2019-01-26 01:19:07

你的问题并没有很好地解释你想要做什么。然而,你解释实际目标的评论是这样做的。如果我理解正确的话,您希望创建一个类似Compiz "Annotate“插件的应用程序。我不能百分之百肯定地说,但如果没有其他扩展,我认为这是不可能的。你真的需要一个复合扩展来很好地做到这一点,但是没有它,你可以用几种方式模拟效果……

(1)你基本上可以抓取一个屏幕截图并在其上绘制,甚至可以通过隐藏整个事情并重新拍摄屏幕截图来定期更新背景。任何接近实时更新的东西可能看起来都不是很流畅。

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

(3)你可以使用"shape“扩展,它允许你制作形状奇怪的窗口,并尝试从本质上是alpha掩模的窗口创建一个覆盖在其他窗口上的窗口。我不知道你能用这个扩展做什么,因为我从来没有用过它。您可能仅限于使用简单的多边形。

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28366896

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档