diff mbox series

[FFmpeg-devel,1/2] libavdevice/gdigrab: make region window click-throughable

Message ID tencent_93C78442E09EBD171632DE86F8D94FFD7609@qq.com
State New
Headers show
Series [FFmpeg-devel,1/2] libavdevice/gdigrab: make region window click-throughable | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

1160386205@qq.com March 31, 2021, 11:49 a.m. UTC
From: He Yang <1160386205@qq.com>

the region window created by option `-show_region`, though only 3 pixel
width, is not click-throughable.

Signed-off-by: He Yang <1160386205@qq.com>
---
 libavdevice/gdigrab.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavdevice/gdigrab.c b/libavdevice/gdigrab.c
index 9b2c55fe90..e9d646999f 100644
--- a/libavdevice/gdigrab.c
+++ b/libavdevice/gdigrab.c
@@ -126,7 +126,7 @@  gdigrab_region_wnd_init(AVFormatContext *s1, struct gdigrab *gdigrab)
     HRGN region_interior = NULL;
 
     DWORD style = WS_POPUP | WS_VISIBLE;
-    DWORD ex = WS_EX_TOOLWINDOW | WS_EX_TOPMOST | WS_EX_TRANSPARENT;
+    DWORD ex = WS_EX_TOOLWINDOW | WS_EX_TOPMOST | WS_EX_LAYERED | WS_EX_TRANSPARENT;
 
     rect.left -= REGION_WND_BORDER; rect.top -= REGION_WND_BORDER;
     rect.right += REGION_WND_BORDER; rect.bottom += REGION_WND_BORDER;
@@ -143,6 +143,9 @@  gdigrab_region_wnd_init(AVFormatContext *s1, struct gdigrab *gdigrab)
         goto error;
     }
 
+    // Set the window transparency to 255 (opaque)
+    SetLayeredWindowAttributes(hwnd, 0, 255, LWA_ALPHA);
+
     // Set the window shape to only include the border area
     GetClientRect(hwnd, &rect);
     region = CreateRectRgn(0, 0,