mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2025-10-29 05:40:21 -04:00
opt: monitor rule prefer to use internal mode
This commit is contained in:
parent
87b094c958
commit
095af2b3c8
2 changed files with 29 additions and 5 deletions
|
|
@ -2583,6 +2583,7 @@ void reapply_monitor_rules(void) {
|
|||
Monitor *m;
|
||||
int ji, jk;
|
||||
struct wlr_output_state state;
|
||||
struct wlr_output_mode *internal_mode = NULL;
|
||||
wlr_output_state_init(&state);
|
||||
|
||||
wl_list_for_each(m, &mons, link) {
|
||||
|
|
@ -2611,9 +2612,11 @@ void reapply_monitor_rules(void) {
|
|||
}
|
||||
|
||||
if (mr->width > 0 && mr->height > 0 && mr->refresh > 0) {
|
||||
wlr_output_state_set_custom_mode(
|
||||
&state, mr->width, mr->height,
|
||||
(int)roundf(mr->refresh * 1000));
|
||||
internal_mode = get_output_mode(m->wlr_output, mr->width,
|
||||
mr->height, mr->refresh);
|
||||
if (internal_mode) {
|
||||
wlr_output_state_set_mode(&state, internal_mode);
|
||||
}
|
||||
}
|
||||
|
||||
wlr_output_state_set_scale(&state, mr->scale);
|
||||
|
|
|
|||
25
src/mango.c
25
src/mango.c
|
|
@ -616,6 +616,10 @@ static struct wlr_box setclient_coordinate_center(Client *c,
|
|||
int offsetx, int offsety);
|
||||
static unsigned int get_tags_first_tag(unsigned int tags);
|
||||
|
||||
static struct wlr_output_mode *get_output_mode(struct wlr_output *output,
|
||||
int width, int height,
|
||||
float refresh);
|
||||
|
||||
static void client_commit(Client *c);
|
||||
static void layer_commit(LayerSurface *l);
|
||||
static void apply_border(Client *c);
|
||||
|
|
@ -2439,6 +2443,19 @@ void createlocksurface(struct wl_listener *listener, void *data) {
|
|||
client_notify_enter(lock_surface->surface, wlr_seat_get_keyboard(seat));
|
||||
}
|
||||
|
||||
struct wlr_output_mode *get_output_mode(struct wlr_output *output, int width,
|
||||
int height, float refresh) {
|
||||
struct wlr_output_mode *mode;
|
||||
wl_list_for_each(mode, &output->modes, link) {
|
||||
if (mode->width == width && mode->height == height &&
|
||||
(int)(mode->refresh / 1000) == (int)refresh) {
|
||||
return mode;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void createmon(struct wl_listener *listener, void *data) {
|
||||
/* This event is raised by the backend when a new output (aka a display or
|
||||
* monitor) becomes available. */
|
||||
|
|
@ -2448,6 +2465,7 @@ void createmon(struct wl_listener *listener, void *data) {
|
|||
int ji, jk;
|
||||
struct wlr_output_state state;
|
||||
Monitor *m;
|
||||
struct wlr_output_mode *internal_mode = NULL;
|
||||
bool custom_monitor_mode = false;
|
||||
|
||||
if (!wlr_output_init_render(wlr_output, alloc, drw))
|
||||
|
|
@ -2501,8 +2519,11 @@ void createmon(struct wl_listener *listener, void *data) {
|
|||
|
||||
if (r->width > 0 && r->height > 0 && r->refresh > 0) {
|
||||
custom_monitor_mode = true;
|
||||
wlr_output_state_set_custom_mode(&state, r->width, r->height,
|
||||
r->refresh * 1000);
|
||||
internal_mode = get_output_mode(m->wlr_output, r->width,
|
||||
r->height, r->refresh);
|
||||
if (internal_mode) {
|
||||
wlr_output_state_set_mode(&state, internal_mode);
|
||||
}
|
||||
}
|
||||
wlr_output_state_set_scale(&state, r->scale);
|
||||
wlr_output_state_set_transform(&state, r->rr);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue