Adjust for confounder in calculating explained variability in cox-regression

My question is closely related to this one.

I am interested in the proportion of variability which is explained by a certain covariate X in a cox-model.

So I have the cox-model “outcome ~ X”, for which I would like to calculate $$R²_{PM}$$, which is a certain coefficient of determination suitable for survival data (see details here). The problem is there is a known confounder I would like to account for, but without having it in the actual model, because I am only interested in the explained variability of my variable X. A confounder has impact on the outcome and also on the variable X.

So I thought of correcting for the confounder by regressing X on the confounder (there is a linear relationship), taking the residuals as new variable Z and then calculate $$R²_{PM}$$ of this new model:

outcome ~ Z with Z= residuals of lm(X~ confounder)

I am not quite sure if this really does what I want, because I only remove the influence of the confounder on X. The variability of the outcome which is caused by the confounder is not removed (as recommended in this post).

Do you see any problems with this approach? I couldn’t find any literature about it.