mirror of
https://github.com/opencv/opencv.git
synced 2025-07-31 18:07:08 +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));
|
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);
|
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)
|
static bool handleMessage(MSG& message, int& keyCode)
|
||||||
{
|
{
|
||||||
// whether we have to call translate and dispatch yet
|
std::shared_ptr<CvWindow> window_;
|
||||||
// otherwise the message was handled specifically
|
{
|
||||||
bool is_processed = false;
|
AutoLock lock(getWindowMutex());
|
||||||
|
window_ = icvFindWindowByHandle(message.hwnd);
|
||||||
AutoLock lock(getWindowMutex());
|
}
|
||||||
auto& g_windows = getWindowsList();
|
if (window_)
|
||||||
for (auto it = g_windows.begin(); it != g_windows.end() && !is_processed; ++it)
|
|
||||||
{
|
{
|
||||||
auto window_ = *it;
|
|
||||||
if (!window_)
|
|
||||||
continue;
|
|
||||||
CvWindow& window = *window_;
|
CvWindow& window = *window_;
|
||||||
if (!(window.hwnd == message.hwnd || window.frame == message.hwnd))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
is_processed = true;
|
|
||||||
switch (message.message)
|
switch (message.message)
|
||||||
{
|
{
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
@ -2215,7 +2223,6 @@ static bool handleMessage(MSG& message, int& keyCode)
|
|||||||
case WM_SYSKEYDOWN:
|
case WM_SYSKEYDOWN:
|
||||||
if (message.wParam == VK_F10)
|
if (message.wParam == VK_F10)
|
||||||
{
|
{
|
||||||
is_processed = true;
|
|
||||||
keyCode = (int)(message.wParam << 16);
|
keyCode = (int)(message.wParam << 16);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2245,7 +2252,6 @@ static bool handleMessage(MSG& message, int& keyCode)
|
|||||||
message.wParam == VK_PRIOR || message.wParam == VK_NEXT)
|
message.wParam == VK_PRIOR || message.wParam == VK_NEXT)
|
||||||
{
|
{
|
||||||
DispatchMessage(&message);
|
DispatchMessage(&message);
|
||||||
is_processed = true;
|
|
||||||
keyCode = (int)(message.wParam << 16);
|
keyCode = (int)(message.wParam << 16);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2254,18 +2260,16 @@ static bool handleMessage(MSG& message, int& keyCode)
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
DispatchMessage(&message);
|
DispatchMessage(&message);
|
||||||
is_processed = true;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (!is_processed)
|
|
||||||
{
|
{
|
||||||
TranslateMessage(&message);
|
TranslateMessage(&message);
|
||||||
DispatchMessage(&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