Have you got a source on that? Not questioning that it does sound like an EU thing, but it could come in handy at my current company if there's legislation on that and I can't seem to find any.
It is different country by country. In some countries if it wasn't done on a company equipment regarding your assignments the company cannot do anything about it and they cannot limit you to work on opensource/unpaid projects.