Shortest path in a dynamic tree with vertex updates
One can improve your naive method by augmenting the data structure.  At each node in the tree, store an extra field that contains the distance to the closest descendant of type 1.  Assume each node as a pointer to its parent.  Let the depth of the tree be $d$.

Now Set(X) takes $O(d)$ time: you traverse the parent pointers to visit each of X's ancestors and update their distance field.  Also Dist(X) takes $O(d)$ time: the distance field for X tells you the shortest path to a descendant of X, and by looking at the distance fields for the siblings of the nodes along the path from X to the root, you can find the shortest path to a non-descendant of X.  Thus, both operations can be done in $O(d)$ time.

If the tree is balanced, we'll have $d = O(\lg n)$, so both operations run in $O(\lg n)$ time -- a significant improvement over the naive method you mention.

Of course, in the worst case the depth of the tree could be $\Theta(n)$, so this method won't help for such trees.  But in practice many trees (e.g., random trees) tend to have depth $O(\lg n)$.  And if you need an algorithm that works for all trees, you might be able to take advantage of a heavy-light decomposition to achieve good worst-case running time bounds.