@@ -12,6 +12,36 @@ static inline void AvCallback(void*, int level, const char* szFmt, va_list varg)
1212}
1313#endif
1414
15+ struct handle_data {
16+ unsigned long process_id;
17+ HWND window_handle;
18+ };
19+
20+ BOOL IsMainWindow (HWND handle)
21+ {
22+ return GetWindow (handle, GW_OWNER) == (HWND)0 && IsWindowVisible (handle);
23+ }
24+
25+ BOOL CALLBACK EnumWindowsCallback (HWND handle, LPARAM lParam)
26+ {
27+ handle_data& data = *(handle_data*)lParam;
28+ unsigned long process_id = 0 ;
29+ GetWindowThreadProcessId (handle, &process_id);
30+ if (data.process_id != process_id || !IsMainWindow (handle))
31+ return TRUE ;
32+ data.window_handle = handle;
33+ return FALSE ;
34+ }
35+
36+ HWND FindMainWindow (unsigned long process_id)
37+ {
38+ handle_data data;
39+ data.process_id = process_id;
40+ data.window_handle = 0 ;
41+ EnumWindows (EnumWindowsCallback, (LPARAM)&data);
42+ return data.window_handle ;
43+ }
44+
1545class actctx_activator
1646{
1747protected:
@@ -39,9 +69,14 @@ CVoukoder::CVoukoder():
3969 av_log_set_callback (AvCallback);
4070#endif
4171
42- wchar_t wnd_title[256 ];
43- HWND hwnd = GetForegroundWindow (); // get handle of currently active window
44- GetWindowText (hwnd, wnd_title, sizeof (wnd_title));
72+ // Add window title to log
73+ wchar_t text[256 ];
74+ HWND hwnd = FindMainWindow (GetCurrentProcessId ());
75+ if (GetWindowText (hwnd, text, sizeof (text)))
76+ {
77+ vkLogInfo (wxString::Format (" Plugin running in %s" , text));
78+ vkLogInfo (" ---------------------------------------------" );
79+ }
4580}
4681
4782CVoukoder::~CVoukoder ()
0 commit comments