FMV, Thank you so much for the words of encouragement. I'm not really someone to put myself down (or others) but in this situation I feel H's disappointment of our conversation very strongly.
But even now, I don't know how I should have acted. I'm guessing he was maybe looking for some encouragement... but that's what it is - a guess. I know you suggested to ask him what he needs, but when I did it (at another time) he said "It's not your fault" "There's nothing you can do". Which isn't what I asked. I didn't ask how to resolve the problem for him or how to help him resolve it, but when I clarified "What can I do to support you?", he said again "I have no idea, there's nothing you can do".
So I guess what I'm trying to say is that he seems to have expectations that he can't define but is unhappy when they're not met.
I'm thinking of writing him an email and saying that I know that my attempts to cheer him up have often annoyed him so I tried to listen and understand his feelings (?) rather than jump out with trying to make him see the bright side. Then I want to say that I'm not sure whether he needs me there just to listen or should I not hold back the encouragement. I'm sort of afraid he'll say he doesn't know (I know, mind-reading, but I've heard it before so I'd like to prevent it if possible).
On a side note, I just really want to give him a hug and I mention it sometimes, which I think is bad because it makes him realize it's not possible - in similar situations he sometimes commented "Well it's not going to happen for X months so it's not making anything better." (I know he'd like a hug. He said that to me before).
Accept that there is only one thing you can change in life and that is you