Skip to content

Commit

Permalink
check if scale is inf
Browse files Browse the repository at this point in the history
  • Loading branch information
ColleagueRiley committed Nov 9, 2024
1 parent f3d72c8 commit f93c2fd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions RGFW.h
Original file line number Diff line number Diff line change
Expand Up @@ -1640,7 +1640,7 @@ RGFW_window* RGFW_window_basic_init(RGFW_rect rect, u16 args) {
void RGFW_window_scaleToMonitor(RGFW_window* win) {
RGFW_monitor monitor = RGFW_window_getMonitor(win);

RGFW_window_resize(win, RGFW_AREA((u32)(monitor.scaleX * (float)win->r.w), (u32)(monitor.scaleX * (float)win->r.h)));
RGFW_window_resize(win, RGFW_AREA((u32)(monitor.scaleX * (float)win->r.w), (u32)(monitor.scaleY * (float)win->r.h)));
}
#endif

Expand Down Expand Up @@ -3766,10 +3766,10 @@ Start of Linux / Unix defines
monitor.scaleX = (float) (dpi_width) / (float) 96;
monitor.scaleY = (float) (dpi_height) / (float) 96;

if (monitor.scaleX > 1 && monitor.scaleX < 1.1)
if (isinf(monitor.scaleX) || (monitor.scaleX > 1 && monitor.scaleX < 1.1))
monitor.scaleX = 1;

if (monitor.scaleY > 1 && monitor.scaleY < 1.1)
if (isinf(monitor.scaleY) || (monitor.scaleY > 1 && monitor.scaleY < 1.1))
monitor.scaleY = 1;

XRRFreeCrtcInfo(ci);
Expand Down

2 comments on commit f93c2fd

@chris-montero
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this feels like a bit of a cheap fix. wouldn't it be better to try to investigate why it's (inf, inf) in the first place?

@ColleagueRiley
Copy link
Owner Author

@ColleagueRiley ColleagueRiley commented on f93c2fd Nov 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chris-montero Yes, but this should prevent this specific issue from occurring again.

Please sign in to comment.