Skip to content

Commit 375c686

Browse files
When opening the map window focus is returned to the main OR game window. This can cause confusion when running in full screen mode. In that case the map window will be hidden behind the game window. Therefore this bug fix does not refoucus when (part) of the map window is overlapping the game window.
1 parent 60df6ba commit 375c686

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

Source/RunActivity/Viewer3D/Map/MapForm.cs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1345,7 +1345,12 @@ void UITimer_Tick(object sender, EventArgs e)
13451345
if (Viewer.MapViewerEnabledSetToTrue)
13461346
{
13471347
GenerateView();
1348-
GameForm.Focus();
1348+
if (!mapBehindGameForm())
1349+
{
1350+
// do not return focus to the main OR game window
1351+
// when map is (partially) overlapping the game window
1352+
GameForm.Focus();
1353+
}
13491354
Viewer.MapViewerEnabledSetToTrue = false;
13501355
}
13511356

@@ -1357,6 +1362,25 @@ void UITimer_Tick(object sender, EventArgs e)
13571362
GenerateView();
13581363
}
13591364

1365+
private bool mapBehindGameForm()
1366+
{
1367+
int mapX0 = Bounds.X;
1368+
int mapY0 = Bounds.Y;
1369+
int mapX1 = mapX0 + Size.Width;
1370+
int mapY1 = mapY0 + Size.Height;
1371+
1372+
int gameX0 = GameForm.Bounds.X;
1373+
int gameY0 = GameForm.Bounds.Y;
1374+
int gameX1 = GameForm.Size.Width;
1375+
int gameY1 = GameForm.Size.Height;
1376+
1377+
return
1378+
((mapX0 >= gameX0) && (mapX0 <= gameX1)) && ((mapY0 >= gameY0) && (mapY0 <= gameY1)) ||
1379+
((mapX0 >= gameX0) && (mapX0 <= gameX1)) && ((mapY1 >= gameY0) && (mapY1 <= gameY1)) ||
1380+
((mapX1 >= gameX0) && (mapX1 <= gameX1)) && ((mapY0 >= gameY0) && (mapY0 <= gameY1)) ||
1381+
((mapX1 >= gameX0) && (mapX1 <= gameX1)) && ((mapY1 >= gameY0) && (mapY1 <= gameY1));
1382+
}
1383+
13601384
private void allowJoiningCheckbox_CheckedChanged(object sender, EventArgs e)
13611385
{
13621386
MPManager.Instance().AllowNewPlayer = allowJoiningCheckbox.Checked;

0 commit comments

Comments
 (0)