@@ -44,8 +44,6 @@ int main(void)
44
44
if (prev_en_us != en_us && cur_thread != prev_thread ) // switched to other process with different layout
45
45
{
46
46
// change fg window layout
47
- //ActivateKeyboardLayout(prev_hkl, KLF_ACTIVATE | KLF_SETFORPROCESS); - doesn't work (changes for our process probably)
48
-
49
47
PostMessage (cur_window ,
50
48
WM_INPUTLANGCHANGEREQUEST ,
51
49
0 ,
@@ -56,6 +54,8 @@ int main(void)
56
54
#else // method 2
57
55
if (prev_en_us != en_us && cur_thread == prev_thread ) // switched layout manually
58
56
{
57
+ SystemParametersInfo (SPI_SETDEFAULTINPUTLANG , 0 , & cur_hkl , 0 );
58
+
59
59
// send all windows message to switch their layout
60
60
// (by default windows sends it only to the current window (?))
61
61
PostMessage (HWND_BROADCAST ,
@@ -65,14 +65,12 @@ int main(void)
65
65
}
66
66
#endif
67
67
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
73
72
{
74
73
press_scroll ();
75
- tried_pressing_scroll = true; // dont spam scroll presses if fg program doesnt handle it correctly (emacs...)
76
74
}
77
75
78
76
0 commit comments