The restlessness that seems to foil productivity may be your mind trying to think. It is not comfortable with your current activities and is signaling the desire for reflection.
Rather than reproaching yourself for laziness or a lack of self-discipline and attempt to steer your thoughts back on the work that is before you, it is wiser to retreat to a spot that will permit you to identify and think about which topic is crying for attention.
You will know when you've directed your focus to the right area. It will feel right. You will sense the right fit between your focus and the subject. Once that is discovered, you are ready to think.