mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2025-10-29 05:40:21 -04:00
opt: use nearest refresh for monitor rule
This commit is contained in:
parent
d05c2755c3
commit
50e4a49c2e
1 changed files with 12 additions and 5 deletions
17
src/mango.c
17
src/mango.c
|
|
@ -2506,15 +2506,22 @@ void createlocksurface(struct wl_listener *listener, void *data) {
|
|||
|
||||
struct wlr_output_mode *get_output_mode(struct wlr_output *output, int width,
|
||||
int height, float refresh) {
|
||||
struct wlr_output_mode *mode;
|
||||
struct wlr_output_mode *mode, *nearest_mode = NULL;
|
||||
float min_diff = 99999.0f;
|
||||
|
||||
wl_list_for_each(mode, &output->modes, link) {
|
||||
if (mode->width == width && mode->height == height &&
|
||||
(int)round(mode->refresh / 1000) == (int)round(refresh)) {
|
||||
return mode;
|
||||
if (mode->width == width && mode->height == height) {
|
||||
float mode_refresh = mode->refresh / 1000.0f;
|
||||
float diff = fabsf(mode_refresh - refresh);
|
||||
|
||||
if (diff < min_diff) {
|
||||
min_diff = diff;
|
||||
nearest_mode = mode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nearest_mode;
|
||||
}
|
||||
|
||||
void createmon(struct wl_listener *listener, void *data) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue