"Do you mind if I open the window?" would be more natural in both writing and speaking.
"Do you mind my opening the window?" is a continuous action, so you would be asking if the person would be okay with the action of you moving the window. This sounds like opening the might make a lot of noise and you want to make sure that is okay.
"Do you mind if I open the window?" is asking if the person would be okay with the window being open, in case it is windy, hot, or cold outside.
Both are grammatically okay.