!!!ATTENTION!!!
FINALLY A SOLVE HERE--!!!!!!!!!!
If you don't have time to read diagnosis and understand the problem and you just want to solve the problem, jump to (2) but I suggested to read it all so you have some idea of the problem.
(1)--DIAGNOSIS
After a lot and when I say a lot I mean a lot of research finally I found a solve in mi forum. A guy help out.
First of all it's not software issue. After I tested several miui roms and Lingeage OS software is not causing that. I know you start to worry because it is hardware issue but don't worry, this solution is so easyyyy!!
Pay attention.
The problem causing this is LCD connector. I attached a photo so you can check.
A guy suggested that we should put insulation tape on battery connector and button connector as shown in the picture. After some tests figured out that those weren't causing any trouble but the LCD connector is doing the damage. Through some tests I believe that the problem is heat. I think LCD connector (without being complete sure) when it's heating up it is starting malfunctioning. Another guy suggested that we should put insulation tape in that LCD connector. I also tested it. It worked for a while but still issue appeared again. So what I did it might you permanent solution. Well, the problem is not really the LCD connector but the foam on the plate is defective. What I did is removing the foam from the plate by pulling it. I didn't even apply insulation tape, giving the LCD connector space to 'breathe' and function properly. This might be caused by poor material of LCD connector.
(2)
Solve step by step.
a) Open up phone's back cover. Use this site to see how:
http://www.myfixguide.com/manual/xiaomi-mi5-teardown/
b) Remove screws from top side in the back of the phone.
c) Remove LCD connector's foam (that soft think on the plastic plate)
d) that's it. Put it all back as it was but don't make the screw too tight. Good as new!!
I have attached photos to help you
I didnt find the fix. I just added the idea to remove just the foam.
These guys did find it. Give them a thanks. here:
http://en.miui.com/thread-291453-7-1.html
You can try their methods too. Whatever it works for you. This thing with foam remove maybe works for me and maybe for some other will work with insulation tape.
Good luck!