(x11_common.c) cleanups

This commit is contained in:
twinaphex 2015-01-18 21:49:00 +01:00
parent 20d844d15a
commit c95668f2d5
1 changed files with 31 additions and 29 deletions

View File

@ -160,15 +160,19 @@ static bool get_video_mode(Display *dpy, unsigned width, unsigned height,
for (i = 0; i < num_modes; i++)
{
float refresh, diff;
const XF86VidModeModeInfo *m = modes[i];
if (!m)
continue;
if (m->hdisplay == width && m->vdisplay == height)
{
float refresh = refresh_mod * m->dotclock * 1000.0f / (m->htotal * m->vtotal);
float diff = fabsf(refresh - g_settings.video.refresh_rate);
if (m->hdisplay != width)
continue;
if (m->vdisplay != height)
continue;
refresh = refresh_mod * m->dotclock * 1000.0f / (m->htotal * m->vtotal);
diff = fabsf(refresh - g_settings.video.refresh_rate);
if (!ret || diff < minimum_fps_diff)
{
@ -177,7 +181,6 @@ static bool get_video_mode(Display *dpy, unsigned width, unsigned height,
}
ret = true;
}
}
XFree(modes);
return ret;
@ -188,17 +191,15 @@ bool x11_enter_fullscreen(Display *dpy, unsigned width,
{
XF86VidModeModeInfo mode;
if (get_video_mode(dpy, width, height, &mode, desktop_mode))
{
if (XF86VidModeSwitchToMode(dpy, DefaultScreen(dpy), &mode))
{
if (!get_video_mode(dpy, width, height, &mode, desktop_mode))
return false;
if (!XF86VidModeSwitchToMode(dpy, DefaultScreen(dpy), &mode))
return false;
XF86VidModeSetViewPort(dpy, DefaultScreen(dpy), 0, 0);
return true;
}
}
return false;
}
void x11_exit_fullscreen(Display *dpy, XF86VidModeModeInfo *desktop_mode)
{
@ -234,8 +235,9 @@ bool x11_get_xinerama_coord(Display *dpy, int screen,
for (i = 0; i < num_screens; i++)
{
if (info[i].screen_number == screen)
{
if (info[i].screen_number != screen)
continue;
*x = info[i].x_org;
*y = info[i].y_org;
*w = info[i].width;
@ -243,7 +245,6 @@ bool x11_get_xinerama_coord(Display *dpy, int screen,
ret = true;
break;
}
}
XFree(info);
return ret;
@ -270,7 +271,8 @@ unsigned x11_get_xinerama_monitor(Display *dpy, int x, int y,
int len_x = min_rx - max_lx;
int len_y = min_by - max_ty;
if (len_x < 0 || len_y < 0) /* The whole window is outside the screen. */
/* The whole window is outside the screen. */
if (len_x < 0 || len_y < 0)
continue;
area = len_x * len_y;