מַה־טֹּ֥בוּ אֹהָלֶ֖יךָ יַעֲקֹ֑ב מִשְׁכְּנֹתֶ֖יךָ יִשְׂרָאֵֽל
(2) As Bilam looked up and saw Israel encamped tribe by tribe, the spirit of God came upon him. ... (5) How fair are your tents, O Jacob, Your dwellings, O Israel!
MISHNA: A person may not open an entrance opposite another entrance or a window opposite another window toward a courtyard belonging to partners, so as to ensure that the residents will enjoy a measure of privacy...
But one may open an entrance opposite another entrance or a window opposite another window toward the public domain.
GEMARA: The Gemara asks: From where are these matters, i.e., that one may not open an entrance opposite another entrance, or a window opposite another window, derived?
Rabbi Yoḥanan says that the verse states: “And Bilam lifted up his eyes, and he saw Israel dwelling tribe by tribe; and the spirit of God came upon him” (Numbers 24:2).
The Gemara explains: What was it that Bilam saw that so inspired him? He saw that the entrances of their tents were not aligned with each other, ensuring that each family enjoyed a measure of privacy. And he said: If this is the case, these people are worthy of having the Divine Presence rest on them.
Since they wished to divide the jointly owned courtyard, they build a proper wall in the center even against the will of one of the partners. Apparently, it may be concluded that damage caused by sight is called damage (hezek re'iyah, i.e. is legally actionable.
Me'iri on Bava Batra 2a
As long as the damage from sight is remedied, the type of wall required follows local custom, even if that is a very thin wall. And we are not concerned about damage from hearing at all, meaning even if sound passes around or through the wall, because people are generally careful about what they say.
Shulchan Aruch Harav, Laws of Monetary Damage 11
It is prohibited to covertly observe the activity that another person does in their house or on their property, because they may not want others to know what they're doing. Therefore, poor people who divide a courtyard but can't afford a wall to prevent visual trespass should accept charity in order to build a minimal wall. If that's not an option, they should be careful to the best of their ability not to look at what the other is doing in the courtyard.
It's unnecessary to say that it's prohibited to peer into someone's courtyard without their knowledge, and even more obviously into their house. This applies even if they know they are being observed and don't protest, because they may just be embarrassed to say anything. Even when one's neighbor gives permission to make a window overlooking their courtyard, the permission is presumably intended only for the light. It is still prohibited to stand at the window and observe the neighbor's courtyard.
Teshuvos Maharam MiRottenberg
A ban was issued by Rabbeinu Gershom not to look at a letter of one’s friend that was sent to another friend, without his knowledge.
Responsa of the Rashba, Volume 1 Siman 557
Rabbeinu Gershom did not make his decrees so that people might violate Torah or Rabbinic law because of them. Just the opposite, they were instituted only to insure compliance with our Torah and to insure that Jewish people act in a correct and modest manner. Therefore, if a court objectively determines that in a certain situation they can only insure compliance with our law by "violating the privacy" of an individual by reading their mail, there is no doubt that Rabbeinu Gershom would agree that it would be a mitzva to do so.