この教室の窓というのが、トットちゃんにとっては幸福なことに、先生にとっては不幸なことに、一階にあり、しかも通りは目の前だった。
I googled it ,and it only turned out ことに used like this
残念なことに、その商品はもう販売中止になりました。
but this usage obviously don't match the context I provided
The Google phrase you looked up is exactly what is happening here. It sounds like トットちゃん is trying to escape the classroom.
This ことに attaches to some i-adjectives and na-adjectives and effectively adds the English suffix 'ly'.
In this case we have 幸福なことに = "happily" and 不幸なことに = "unhappily".
This classroom window, happily for Totto and unhappily for the teacher, was on the first floor and looked out onto the street.