+ if(i->width!=mode.width || i->height!=mode.height)
+ continue;
+
+ float ref_rate = target_rate;
+ if(!ref_rate)
+ if(const VideoMode *current_mode = i->monitor->current_settings.mode)
+ ref_rate = current_mode->rate;
+
+ float d = abs(i->rate-ref_rate);
+ if(!closest || d<rate_diff)
+ {
+ closest = &*i;
+ rate_diff = d;
+ }