Skip to content

Commit 4f90df4

Browse files
author
ftk
committed
fixes
1 parent f163d76 commit 4f90df4

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

kbled2.c

+6-8
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ int main(void)
4444
if(prev_en_us != en_us && cur_thread != prev_thread) // switched to other process with different layout
4545
{
4646
// change fg window layout
47-
//ActivateKeyboardLayout(prev_hkl, KLF_ACTIVATE | KLF_SETFORPROCESS); - doesn't work (changes for our process probably)
48-
4947
PostMessage(cur_window,
5048
WM_INPUTLANGCHANGEREQUEST,
5149
0,
@@ -56,6 +54,8 @@ int main(void)
5654
#else // method 2
5755
if(prev_en_us != en_us && cur_thread == prev_thread) // switched layout manually
5856
{
57+
SystemParametersInfo(SPI_SETDEFAULTINPUTLANG, 0, &cur_hkl, 0);
58+
5959
// send all windows message to switch their layout
6060
// (by default windows sends it only to the current window (?))
6161
PostMessage(HWND_BROADCAST,
@@ -65,14 +65,12 @@ int main(void)
6565
}
6666
#endif
6767

68-
static bool tried_pressing_scroll = false;
69-
if(prev_en_us != en_us && prev_thread == cur_thread)
70-
tried_pressing_scroll = false;
71-
// setup light
72-
if(!tried_pressing_scroll && en_us == get_scroll()) // en_us - scroll off, else on
68+
// setup led
69+
70+
// press scroll only if changed layout and current led status is incorrect
71+
if(prev_en_us != en_us && prev_thread == cur_thread && en_us == get_scroll()) // en_us - scroll off, else on
7372
{
7473
press_scroll();
75-
tried_pressing_scroll = true; // dont spam scroll presses if fg program doesnt handle it correctly (emacs...)
7674
}
7775

7876

0 commit comments

Comments
 (0)