[英]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.