mirror of
https://github.com/opencv/opencv.git
synced 2025-07-31 01:47:12 +08:00
Merge pull request #20597 from alalek:issue_20592
This commit is contained in:
commit
053470d5a8
@ -278,6 +278,21 @@ std::shared_ptr<CvWindow> icvFindWindowByName(const char* name)
|
||||
return icvFindWindowByName(std::string(name));
|
||||
}
|
||||
|
||||
// Mutex must be locked
|
||||
static
|
||||
std::shared_ptr<CvWindow> icvFindWindowByHandle(HWND hwnd)
|
||||
{
|
||||
auto& g_windows = getWindowsList();
|
||||
for (auto it = g_windows.begin(); it != g_windows.end(); ++it)
|
||||
{
|
||||
auto window = *it;
|
||||
if (!window)
|
||||
continue;
|
||||
if (window->hwnd == hwnd || window->frame == hwnd)
|
||||
return window;
|
||||
}
|
||||
return std::shared_ptr<CvWindow>();
|
||||
}
|
||||
|
||||
|
||||
static LRESULT CALLBACK HighGUIProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
@ -2187,22 +2202,15 @@ static void showSaveDialog(CvWindow& window)
|
||||
*/
|
||||
static bool handleMessage(MSG& message, int& keyCode)
|
||||
{
|
||||
// whether we have to call translate and dispatch yet
|
||||
// otherwise the message was handled specifically
|
||||
bool is_processed = false;
|
||||
|
||||
AutoLock lock(getWindowMutex());
|
||||
auto& g_windows = getWindowsList();
|
||||
for (auto it = g_windows.begin(); it != g_windows.end() && !is_processed; ++it)
|
||||
std::shared_ptr<CvWindow> window_;
|
||||
{
|
||||
AutoLock lock(getWindowMutex());
|
||||
window_ = icvFindWindowByHandle(message.hwnd);
|
||||
}
|
||||
if (window_)
|
||||
{
|
||||
auto window_ = *it;
|
||||
if (!window_)
|
||||
continue;
|
||||
CvWindow& window = *window_;
|
||||
if (!(window.hwnd == message.hwnd || window.frame == message.hwnd))
|
||||
continue;
|
||||
|
||||
is_processed = true;
|
||||
switch (message.message)
|
||||
{
|
||||
case WM_DESTROY:
|
||||
@ -2215,7 +2223,6 @@ static bool handleMessage(MSG& message, int& keyCode)
|
||||
case WM_SYSKEYDOWN:
|
||||
if (message.wParam == VK_F10)
|
||||
{
|
||||
is_processed = true;
|
||||
keyCode = (int)(message.wParam << 16);
|
||||
return true;
|
||||
}
|
||||
@ -2245,7 +2252,6 @@ static bool handleMessage(MSG& message, int& keyCode)
|
||||
message.wParam == VK_PRIOR || message.wParam == VK_NEXT)
|
||||
{
|
||||
DispatchMessage(&message);
|
||||
is_processed = true;
|
||||
keyCode = (int)(message.wParam << 16);
|
||||
return true;
|
||||
}
|
||||
@ -2254,18 +2260,16 @@ static bool handleMessage(MSG& message, int& keyCode)
|
||||
|
||||
default:
|
||||
DispatchMessage(&message);
|
||||
is_processed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_processed)
|
||||
else
|
||||
{
|
||||
TranslateMessage(&message);
|
||||
DispatchMessage(&message);
|
||||
}
|
||||
|
||||
return false; // no value to return, keep processing
|
||||
return false; // no keyCode to return, keep processing
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user