2
我正在嘗試獲取有關處於焦點的窗口的信息。看起來我從xcb_get_input_focus_reply_t->focus
獲得了一個正確的窗口ID:它對於我的Eclipse IDE(56623164)保持不變,並且對於其他任何焦點窗口都是另一個。但是,對於XCB_ATOM_WM_NAME
,值長度始終爲0。使用XCB獲取窗口標題
縮短代碼
cookie = xcb_get_property(c, 0, fr->focus, XCB_ATOM_WM_NAME,
XCB_ATOM_STRING, 0, 0);
if ((reply = xcb_get_property_reply(c, cookie, NULL))) {
int len = xcb_get_property_value_length(reply);
if (len == 0) {
printf("Zero Length\n");
free(reply);
return;
}
printf("WM_NAME is %.*s\n", len, (char*) xcb_get_property_value(reply));
}
Eclipse調試器
reply xcb_get_property_reply_t * 0x60bd40
response_type uint8_t 1 '\001'
format uint8_t 0 '\0'
sequence uint16_t 2
length uint32_t 0
type xcb_atom_t 0
bytes_after uint32_t 0
value_len uint32_t 0
pad0 unsigned char [12] 0x60bd54
沒有錯誤(I傳遞和檢查一個xcb_generic_error_t
)。你有什麼想法可能會出錯?也許我應該用Xlib的,而不是...
這聽起來很合理。當我找到時間去嘗試時,我會接受答案。非常感謝! – Matthias