I’d wager that it’s your scheduler.
How did you know??
Linux used the CFS scheduler which is outdated and not really optimal for desktop usage.
And Linux kernel is full of outdated math. Like outdated addtion, outdated subtraction. /s
If you want “like on windows”, then you need dynamic priority, not another scheduling algorithm. Basically you want your compositor to set lower priority value(which means higher priority) to process whoose window now is focused.