[英]How to remove window decorations with XCB?
我正在尝试做与此问题相同的事情。
到目前为止,我已经从官方文档中学到了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 );
我究竟做错了什么?
关键是两次使用(* 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
也有帮助。
您的问题并不能很好地说明您要做什么。 但是,您的注释可以解释实际目标。 如果我理解正确,则您想创建一个工作类似于Compiz“ Annotate”插件的应用程序。 我不能百分百确定地说,但是如果没有其他扩展,我不认为这是可能的。 您确实需要一个复合扩展程序才能很好地做到这一点,但是没有它,您可以通过几种方式来模拟效果。
(1)您基本上可以抓取屏幕截图并进行绘制,甚至可以通过隐藏整个内容并重新获取屏幕截图来定期更新背景。 任何接近实时更新的内容可能看起来都不十分平滑。
(2)您可以收听所有鼠标移动和/或键盘事件,并在屏幕上创建许多小窗口。 您可能会到达一个点,即它不允许您创建更多窗口,并且可能不会太漂亮。
(3)您可以使用“形状”扩展名,该扩展名允许您制作形状奇特的窗口,并尝试从本质上是Alpha蒙版的窗口创建窗口,以覆盖其他窗口。 我不确定该扩展程序能做什么,因为我从未使用过。 您可能仅限于简单的多边形。
当然,还有其他解决方案,这些解决方案的某些组合显然可以工作。 显然,如果可以使用复合材料,最好的解决方案就是使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.