Let $X$ be a set, and let $f\colon X\to X$ be a map. It is idempotent when for each $x\in X$, $f(f(x))=f(x)$. It is equivalent to the requirement that the restriction of $f$ on its image $f(X)$ is the inclusion of $f(X)$ into $X$. It then follows quite easily that the set of all such idempotent endomaps corresponds one-one to the set of all pairs $(Y,r)$, where $Y$ is a subset of $X$ and $r\colon X\to Y$ is onto. (To an idempotent endomap $f\colon X\to X$, is associated $(f(X),f_0)$, where $f_0\colon X\to f(X)$ is the co-restriction of $f$, and given a pair $(Y,r)$ as above, $X\xrightarrow{r}Y\hookrightarrow X$ provides an idempotent endomap.)
Now given endomaps $f,g\colon X\to X$. They commute when $f\circ g=g\circ f$.
My question: is there a simple or nice characterization of commuting idempotent endomaps in terms of their images?
E.g., if $f,g\colon X\to X$ are commuting idempotent endomaps, then $f(g(X))=f(X)\cap g(X)=g(f(X))$ and $f\circ g=g\circ f$ is an idempotent endomap too. Is their a kind of converse?