Come to Sweden then :) As a researcher you explicitly own the rights to any foreground, i.e. results, as stated by law — the so called teacher’s excemption.
Might be, but in general the attitude and laws surrounding ownership of code (and most anything else) is very different in Norway, and I would assume Sweden. Here anything you make is explicitly yours and you have full ownership over it, even if you made it on company time. I've talked to several larger IT firms in Norway about this and they all have said that it would be suicide to force their employees to sign away their rights to personal and side projects, but that it would also more or less be impossible to enforce.