Skip to content

Commit

Permalink
When restoring the fullscreen window on windows, use the monitor the …
Browse files Browse the repository at this point in the history
…window is on.
  • Loading branch information
SiegeLordEx authored and SiegeLord committed Jun 15, 2024
1 parent 846c6f5 commit a77519c
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/win/wwindow.c
Original file line number Diff line number Diff line change
Expand Up @@ -1236,6 +1236,23 @@ void _al_win_get_window_position(HWND window, int *x, int *y)
}


static void update_adapter(ALLEGRO_DISPLAY *display)
{
ALLEGRO_DISPLAY_WIN *win_display = (void*)display;
int x, y, adapter, num_adapters;
al_get_window_position(display, &x, &y);
num_adapters = al_get_num_video_adapters();
for (adapter = 0; adapter < num_adapters; adapter++) {
ALLEGRO_MONITOR_INFO mi;
al_get_monitor_info(adapter, &mi);
if (x >= mi.x1 && x < mi.x2 && y >= mi.y1 && y < mi.y2) {
win_display->adapter = adapter;
break;
}
}
}


void _al_win_set_window_frameless(ALLEGRO_DISPLAY *display, HWND hWnd,
bool frameless)
{
Expand Down Expand Up @@ -1310,6 +1327,7 @@ bool _al_win_set_display_flag(ALLEGRO_DISPLAY *display, int flag, bool onoff)
}

if (onoff) {
update_adapter(display);
int adapter = win_display->adapter;
al_get_monitor_info(adapter, &mi);
display->flags |= ALLEGRO_FULLSCREEN_WINDOW;
Expand Down

0 comments on commit a77519c

Please sign in to comment.