Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

Commit

Permalink
Improved no pop-up option
Browse files Browse the repository at this point in the history
Switching keyboard layout with the "nopopup" option enabled did not always work
  • Loading branch information
erryox committed Sep 10, 2022
1 parent d6a746f commit b1e0bab
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions Switchy/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ int main(int argc, char** argv)
settings.popup = GetOSVersion() >= 10;
}
#if _DEBUG
printf("Pop-up %s\n", settings.popup ? "enabled" : "disabled");
printf("Pop-up is %s\n", settings.popup ? "enabled" : "disabled");
#endif

HANDLE hMutex = CreateMutex(0, 0, "Switchy");
Expand Down Expand Up @@ -146,6 +146,13 @@ LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
winPressed = FALSE;
ReleaseKey(VK_LWIN);
}

if (enabled && !settings.popup) {
PressKey(VK_MENU);
PressKey(VK_LSHIFT);
ReleaseKey(VK_MENU);
ReleaseKey(VK_LSHIFT);
}
}

if (!enabled)
Expand All @@ -171,15 +178,6 @@ LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
ReleaseKey(VK_SPACE);
winPressed = TRUE;
}
else
{
HWND hWnd = GetForegroundWindow();
if (hWnd)
{
hWnd = GetAncestor(hWnd, GA_ROOTOWNER);
PostMessage(hWnd, WM_INPUTLANGCHANGEREQUEST, 0, (LPARAM)HKL_NEXT);
}
}
}
}

Expand Down

0 comments on commit b1e0bab

Please sign in to comment.