Interesting summary in the Bird Atlas 2007-11 (p. 478):
"In the areas of gain, reduced control by humans is probably the main driver of change and probably also explains the significant increase in nest survival and productivity. In some areas, increased availability of suitable nesting sites in conifer plantations may have aided colonisation. Magpies may be more difficult to detect at the edge of their range, and especially in areas where keepering may still persist, as they become unobtrusive."
This summary reflects well what it says in Birds of Scotland (p. 1341) about their distribution which extended right up to Sutherland until the 1880s, before they were subjected to widespread control, causing a retraction to the Central Lowlands by 1938.
It appears that after the Second World War their range and population started to expand, but only very slowly, with more marked increase into Dundee and Angus by the mid-1990s, and the latest Bird Atlas has identified continuing increase in this area.
Their sedentary nature is marked by a 1991 Birkhead study which showed that 21 out of 27 recoveries moved less than 9 km, five 10-99 km, and only one over 100 km. (Birds of Scotland, p. 1342).