Applications occasionally freeze when monitor is plugged in to laptop

I usually have a monitor plugged into my laptop. I have it configured as the primary display instead of the laptop display because I use it a lot more. Occasionally (maybe every 10 minutes or so) a program’s window will completely freeze. This only occurs when the monitor is plugged in and seems to mainly affect programs open on the laptop screen.

The process is still running, if it was playing audio I can still hear it after it freezes, if it was running a server I can still connect to it, etc. but I can’t interact with the window at all. In place of the window it shows whatever was on the screen last, ex. if I switch workspaces and switch back it will show whatever I had open on that workspace. The only way to close these windows is with kill, Super+Q (my regular closing shortcut) does not work.

My laptop is a Lenovo Yoga 720-13IKB with a 3840x2160 display. The graphics card is broken so I use the Intel integrated graphics. The monitor’s resolution is 2560x1440. I’m using the testing branch of Manjaro. The kernel version is 5.11.22 and the version of i3-gaps is 4.19.1. I installed Manjaro from the KDE installer, but have since uninstalled KDE and replaced it entirely with i3.

Thanks for any help!