以前的筆記, 轉存到這裡。
很遺憾qt沒有這個函數
隻好直接用x11shape的 XShapeCombineRectangles(QX11Info::display(), winId(), ShapeInput, 0, 0, NULL, 0, ShapeSet, YXBanded)
焦點穿透的意思是所有滑鼠鍵盤操作全部會穿透視窗到下方視窗。
有個 Qt::WA_TransparentForMouseEvents 可以對子部件實 現,而視窗本身不行。很多 osd 桌面歌詞程式經常用
#ifdef Q_OS_LINUX
#include <X11/extensions/shape.h>
#endif
#ifdef Q_OS_WIN
#include <windows.h>
#endif
#ifdef Q_OS_LINUX
XShapeCombineRectangles(QX11Info::display(), winId(), ShapeInput, 0,
0, NULL, 0, ShapeSet, YXBanded);
#endif
#ifdef Q_OS_WIN
SetWindowLong(winId(), GWL_EXSTYLE, GetWindowLong(winId(), GWL_EXSTYLE) |
WS_EX_TRANSPARENT | WS_EX_LAYERED);
#endif
void XShapeCombineRectangles (
Display *dpy,
XID dest,
int destKind,
int xOff,
int yOff,
XRectangle *rects,
int n_rects,
int op,
int ordering);