mirror of
https://github.com/Zaarrg/stremio-community-v5.git
synced 2026-01-11 20:10:31 +00:00
tray menu not working on some systems fix
- Fixed tray menu not working on certain systems
This commit is contained in:
parent
ca406bcb2a
commit
bcdc814d33
2 changed files with 20 additions and 28 deletions
|
|
@ -41,7 +41,7 @@ Ensure the following are installed on your system:
|
||||||
|
|
||||||
1. Download vcpkg [here](https://github.com/microsoft/vcpkg).
|
1. Download vcpkg [here](https://github.com/microsoft/vcpkg).
|
||||||
|
|
||||||
2. Install using vcpkg ``openssl:x64-windows-static``, ``nlohmann-json:x64-windows-static`` and ``curl:x64-windows-static``
|
2. Install using vcpkg ``openssl:x64-windows-static``, ``nlohmann-json:x64-windows-static``, ``webview2:x64-windows-static`` and ``curl:x64-windows-static``
|
||||||
|
|
||||||
> **⏳ Note:** To deploy x86 install the x86 versions of the dependencies above.
|
> **⏳ Note:** To deploy x86 install the x86 versions of the dependencies above.
|
||||||
|
|
||||||
|
|
|
||||||
46
src/main.cpp
46
src/main.cpp
|
|
@ -227,7 +227,7 @@ static bool FocusExistingInstance(const std::wstring &protocolArg)
|
||||||
ShowWindow(hExistingWnd, SW_SHOW);
|
ShowWindow(hExistingWnd, SW_SHOW);
|
||||||
}
|
}
|
||||||
SetForegroundWindow(hExistingWnd);
|
SetForegroundWindow(hExistingWnd);
|
||||||
|
SetFocus(hExistingWnd);
|
||||||
// Send protocolArg if available
|
// Send protocolArg if available
|
||||||
if (!protocolArg.empty()) {
|
if (!protocolArg.empty()) {
|
||||||
COPYDATASTRUCT cds;
|
COPYDATASTRUCT cds;
|
||||||
|
|
@ -273,27 +273,6 @@ static bool CheckSingleInstance(int argc, char* argv[])
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT CALLBACK LowLevelMouseProc(int nCode, WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
|
||||||
if (nCode == HC_ACTION && (wParam == WM_LBUTTONDOWN || wParam == WM_RBUTTONDOWN))
|
|
||||||
{
|
|
||||||
PMSLLHOOKSTRUCT pmsh = (PMSLLHOOKSTRUCT)lParam;
|
|
||||||
if (g_trayHwnd)
|
|
||||||
{
|
|
||||||
RECT rc;
|
|
||||||
if (GetWindowRect(g_trayHwnd, &rc))
|
|
||||||
{
|
|
||||||
// If click point is outside our tray menu window, close the menu
|
|
||||||
if (pmsh->pt.x < rc.left || pmsh->pt.x > rc.right ||
|
|
||||||
pmsh->pt.y < rc.top || pmsh->pt.y > rc.bottom)
|
|
||||||
{
|
|
||||||
PostMessage(g_trayHwnd, WM_CLOSE, 0, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return CallNextHookEx(g_hMouseHook, nCode, wParam, lParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Helper Functions
|
// Helper Functions
|
||||||
|
|
@ -1115,14 +1094,15 @@ static void ShowDarkTrayMenu()
|
||||||
if(posY < 0) posY = 0;
|
if(posY < 0) posY = 0;
|
||||||
if(posY + totalH > screenHeight) posY = screenHeight - totalH;
|
if(posY + totalH > screenHeight) posY = screenHeight - totalH;
|
||||||
|
|
||||||
|
SetCapture(hMenuWnd);
|
||||||
// Set window position and size
|
// Set window position and size
|
||||||
SetWindowPos(hMenuWnd, HWND_TOPMOST, posX, posY, w, totalH, SWP_SHOWWINDOW);
|
SetWindowPos(hMenuWnd, HWND_TOPMOST, posX, posY, w, totalH, SWP_SHOWWINDOW);
|
||||||
|
|
||||||
CreateRoundedRegion(hMenuWnd, w, totalH, 10);
|
CreateRoundedRegion(hMenuWnd, w, totalH, 10);
|
||||||
ShowWindow(hMenuWnd, SW_SHOW);
|
ShowWindow(hMenuWnd, SW_SHOW);
|
||||||
UpdateWindow(hMenuWnd);
|
UpdateWindow(hMenuWnd);
|
||||||
|
SetForegroundWindow(hMenuWnd);
|
||||||
g_hMouseHook = SetWindowsHookExW(WH_MOUSE_LL, LowLevelMouseProc, NULL, 0);
|
SetFocus(hMenuWnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static LRESULT CALLBACK DarkTrayMenuProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
static LRESULT CALLBACK DarkTrayMenuProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
|
@ -1235,7 +1215,7 @@ static LRESULT CALLBACK DarkTrayMenuProc(HWND hWnd, UINT msg, WPARAM wParam, LPA
|
||||||
EndPaint(hWnd, &ps);
|
EndPaint(hWnd, &ps);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
case WM_MOUSEMOVE:
|
case WM_MOUSEMOVE:
|
||||||
{
|
{
|
||||||
int xPos = GET_X_LPARAM(lParam);
|
int xPos = GET_X_LPARAM(lParam);
|
||||||
int yPos = GET_Y_LPARAM(lParam);
|
int yPos = GET_Y_LPARAM(lParam);
|
||||||
|
|
@ -1268,14 +1248,25 @@ static LRESULT CALLBACK DarkTrayMenuProc(HWND hWnd, UINT msg, WPARAM wParam, LPA
|
||||||
}
|
}
|
||||||
case WM_LBUTTONUP:
|
case WM_LBUTTONUP:
|
||||||
{
|
{
|
||||||
|
// Get current mouse position in screen coordinates
|
||||||
|
POINT pt;
|
||||||
|
GetCursorPos(&pt);
|
||||||
|
|
||||||
|
// Get the window's rectangle in screen coordinates
|
||||||
|
RECT rc;
|
||||||
|
GetWindowRect(hWnd, &rc);
|
||||||
|
|
||||||
|
// Determine if the mouse is inside the window rectangle
|
||||||
|
bool inside = PtInRect(&rc, pt);
|
||||||
|
|
||||||
// Unhook the low-level mouse hook to prevent interference
|
// Unhook the low-level mouse hook to prevent interference
|
||||||
if (g_hMouseHook) {
|
if (g_hMouseHook) {
|
||||||
UnhookWindowsHookEx(g_hMouseHook);
|
UnhookWindowsHookEx(g_hMouseHook);
|
||||||
g_hMouseHook = nullptr;
|
g_hMouseHook = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if there's a hovered, non-separator item
|
// Only process a selection if the click was inside the menu
|
||||||
if (g_hoverIndex >= 0 && g_hoverIndex < (int)g_menuItems.size())
|
if (inside && g_hoverIndex >= 0 && g_hoverIndex < (int)g_menuItems.size())
|
||||||
{
|
{
|
||||||
auto &it = g_menuItems[g_hoverIndex];
|
auto &it = g_menuItems[g_hoverIndex];
|
||||||
if (!it.separator)
|
if (!it.separator)
|
||||||
|
|
@ -2726,6 +2717,7 @@ int main(int argc, char* argv[])
|
||||||
InitWebView2(g_hWnd);
|
InitWebView2(g_hWnd);
|
||||||
|
|
||||||
SetForegroundWindow(g_hWnd);
|
SetForegroundWindow(g_hWnd);
|
||||||
|
SetFocus(g_hWnd);
|
||||||
|
|
||||||
MSG msg;
|
MSG msg;
|
||||||
while(GetMessage(&msg,nullptr,0,0)){
|
while(GetMessage(&msg,nullptr,0,0)){
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue