Skip to content

Commit ea5342b

Browse files
authored
Merge pull request #1216 from asarium/fix/1051
Create main window at 0,0 if its the same size as the display
2 parents 58b4948 + 6c1d526 commit ea5342b

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

freespace2/SDLGraphicsOperations.cpp

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,28 @@ std::unique_ptr<os::Viewport> SDLGraphicsOperations::createViewport(const os::Vi
163163
windowflags |= SDL_WINDOW_RESIZABLE;
164164
}
165165

166+
SDL_Rect bounds;
167+
if (SDL_GetDisplayBounds(props.display, &bounds) != 0) {
168+
mprintf(("Failed to get display bounds: %s\n", SDL_GetError()));
169+
return nullptr;
170+
}
171+
172+
int x;
173+
int y;
174+
175+
if (bounds.w == (int)props.width && bounds.h == (int)props.height) {
176+
// If we have the same size as the desktop we explicitly specify 0,0 to make sure that the window borders aren't hidden
177+
mprintf(("SDL: Creating window at %d,%d because window has same size as desktop.\n", bounds.x, bounds.y));
178+
x = bounds.x;
179+
y = bounds.y;
180+
} else {
181+
x = SDL_WINDOWPOS_CENTERED_DISPLAY(props.display);
182+
y = SDL_WINDOWPOS_CENTERED_DISPLAY(props.display);
183+
}
184+
166185
SDL_Window* window = SDL_CreateWindow(props.title.c_str(),
167-
SDL_WINDOWPOS_CENTERED_DISPLAY(props.display),
168-
SDL_WINDOWPOS_CENTERED_DISPLAY(props.display),
186+
x,
187+
y,
169188
props.width,
170189
props.height,
171190
windowflags);

0 commit comments

Comments
 (0)