34 lines
No EOL
682 B
C++
34 lines
No EOL
682 B
C++
#include "XRandR.h"
|
|
#include <Spectre/System/Log.h>
|
|
#include <algorithm>
|
|
|
|
namespace sp {
|
|
|
|
bool XRandR::FindMode(::Display* disp, unsigned int width, unsigned int height, unsigned int bpp, SizeID *id, short *rate)
|
|
{
|
|
::XRRScreenSize *xrrs;
|
|
int num_sizes;
|
|
|
|
xrrs = XRRSizes(disp, 0, &num_sizes);
|
|
for(int i = 0; i < num_sizes; i++) {
|
|
|
|
Log::debug("Mode %dx%d", xrrs[i].width, xrrs[i].height);
|
|
|
|
if (xrrs[i].width != width && xrrs[i].height != height) {
|
|
continue;
|
|
}
|
|
|
|
short *rates;
|
|
int num_rates;
|
|
|
|
rates = XRRRates(disp, 0, i, &num_rates);
|
|
if (num_rates > 0) {
|
|
*id = i;
|
|
*rate = rates[num_rates - 1];
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
} // namespace sp
|