I believe it is a combination of time + shift in perspective. Forgiveness is bandied about like it's a major thing to strive for, but I have come to see it as something happens organically when you put in the grind for your internal work.
Putting in practices to love yourself and forgive yourself first leads to love and forgiveness for others. Check out this amazing podcast interview with Kamal Ravikant on the Aubrey Marcus podcast. Deals with the exact question at hand.
Here is how I practice forgiveness. I look back at the mistakes in my marriage and remind myself that I did the absolute best I could do with what I knew at that time. I remind myself of all the constraints that I faced in having better knowledge and how I would use the wisdom that I have now to not make the same mistakes.
However, this is only half of the equation. If I can be compassionate and gentle with myself and say that I did the best that I could with what I had and knew, then I have to offer the same perspective for what exW did and is continuing to do. Without extension of that same empathy, your forgiveness pattern is incomplete.
Now do this over a period of time and you will experience more self-love and detachment. This has to be a regular practice and it's never over. Time alone will not allow for that mindset shift. You have to put in the work. Go listen to that podcast episode. It is incredible IMHO.