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