From cf0a43b844b15444bc8e3b0be92ec76dd11c3614 Mon Sep 17 00:00:00 2001 From: "Carsten Haitzler (Rasterman)" Date: Sun, 7 Jun 2020 00:57:13 +0100 Subject: [PATCH] e randr - x - only apply/modify randr if xurrent config not the same so if already the same - leave it as-is. --- src/bin/e_comp.h | 2 +- src/bin/e_comp_x_randr.c | 91 +++++++++++++++++++++++++++------ src/bin/e_comp_x_randr.h | 2 +- src/bin/e_randr2.c | 10 ++-- src/modules/wl_drm/e_mod_main.c | 2 +- 5 files changed, 82 insertions(+), 25 deletions(-) diff --git a/src/bin/e_comp.h b/src/bin/e_comp.h index ec8b80ea0..e07022b84 100644 --- a/src/bin/e_comp.h +++ b/src/bin/e_comp.h @@ -68,7 +68,7 @@ typedef struct E_Comp_Screen_Iface /* gather screen info */ E_Randr2 *(*create)(void); /* apply current config */ - void (*apply)(void); + void (*apply)(Eina_Bool can_skip); /* set dpms (on, standby, suspend, off) */ void (*dpms)(int); /* is key event eaten */ diff --git a/src/bin/e_comp_x_randr.c b/src/bin/e_comp_x_randr.c index da1b0759d..3b02af87b 100644 --- a/src/bin/e_comp_x_randr.c +++ b/src/bin/e_comp_x_randr.c @@ -478,7 +478,7 @@ e_comp_x_randr_shutdown(void) } E_API void -e_comp_x_randr_config_apply(void) +e_comp_x_randr_config_apply(Eina_Bool can_skip) { Eina_List *l; E_Randr2_Screen *s; @@ -580,11 +580,13 @@ e_comp_x_randr_config_apply(void) { Ecore_X_Rectangle *scrs = alloca(crtcs_num * sizeof(Ecore_X_Rectangle)); int scrs_num; + Eina_Bool do_it; scrs_num = 0; // set up a crtc to drive each output (or not) for (i = 0; i < crtcs_num; i++) { + do_it = EINA_FALSE; // XXX: find clones and set them as outputs in an array if (outconf[i]) { @@ -608,12 +610,6 @@ e_comp_x_randr_config_apply(void) screenconf[i]->config.geom.w, screenconf[i]->config.geom.h, orient, mode, outconf[i]); - if (!ecore_x_randr_crtc_settings_set - (root, crtcs[i], &(outconf[i]), 1, - screenconf[i]->config.geom.x, - screenconf[i]->config.geom.y, - mode, orient)) - printf("RRR: failed to set crtc!!!!!!\n"); if (E_INSIDE(px, py, screenconf[i]->config.geom.x, screenconf[i]->config.geom.y, @@ -624,12 +620,54 @@ e_comp_x_randr_config_apply(void) (screenconf[i]->config.geom.w / 2); py = screenconf[i]->config.geom.y + (screenconf[i]->config.geom.h / 2); - ecore_x_randr_crtc_panning_area_set - (root, crtcs[i], - screenconf[i]->config.geom.x, - screenconf[i]->config.geom.y, - screenconf[i]->config.geom.w, - screenconf[i]->config.geom.h); + if (!can_skip) do_it = EINA_TRUE; + else + { + Ecore_X_Randr_Crtc_Info *inf; + + inf = ecore_x_randr_crtc_info_get(root, crtcs[i]); + if (inf) + { + // current setup differs + if ((inf->noutput == 0) || + (inf->mode != mode) || + (inf->x != screenconf[i]->config.geom.x) || + (inf->y != screenconf[i]->config.geom.y) || + (inf->width != (unsigned int)screenconf[i]->config.geom.w) || + (inf->height != (unsigned int)screenconf[i]->config.geom.h) || + (inf->rotation != orient)) + { + if (inf->noutput != 1) + do_it = EINA_TRUE; + else + { + if (inf->outputs[0] != outconf[0]) + do_it = EINA_TRUE; + } + } + ecore_x_randr_crtc_info_free(inf); + } + else do_it = EINA_TRUE; + } + if (do_it) + { + printf("RRR: crtc configure: %i ...\n", i); + if (!ecore_x_randr_crtc_settings_set + (root, crtcs[i], &(outconf[i]), 1, + screenconf[i]->config.geom.x, + screenconf[i]->config.geom.y, + mode, orient)) + printf("RRR: failed to set crtc!!!!!!\n"); + ecore_x_randr_crtc_panning_area_set + (root, crtcs[i], + screenconf[i]->config.geom.x, + screenconf[i]->config.geom.y, + screenconf[i]->config.geom.w, + screenconf[i]->config.geom.h); + } + else + printf("RRR: (SKIP) crtc configure: %i\n", i); + if (screenconf[i]->config.priority == top_priority) { ecore_x_randr_primary_output_set(root, outconf[i]); @@ -643,10 +681,29 @@ e_comp_x_randr_config_apply(void) } else { - printf("RRR: crtc off: %i\n", i); - ecore_x_randr_crtc_settings_set - (root, crtcs[i], NULL, 0, 0, 0, 0, - ECORE_X_RANDR_ORIENTATION_ROT_0); + if (!can_skip) do_it = EINA_TRUE; + else + { + Ecore_X_Randr_Crtc_Info *inf; + + inf = ecore_x_randr_crtc_info_get(root, crtcs[i]); + if (inf) + { + // it's somehow on - we need to turn it off + if (inf->noutput != 0) do_it = EINA_TRUE; + ecore_x_randr_crtc_info_free(inf); + } + // else -> already nort enabled + } + if (do_it) + { + printf("RRR: crtc off: %i\n", i); + ecore_x_randr_crtc_settings_set + (root, crtcs[i], NULL, 0, 0, 0, 0, + ECORE_X_RANDR_ORIENTATION_ROT_0); + } + else + printf("RRR: (SKIP) crtc off: %i\n", i); } } ecore_x_root_screen_barriers_set(scrs, scrs_num); diff --git a/src/bin/e_comp_x_randr.h b/src/bin/e_comp_x_randr.h index 41ca659a6..db18a1264 100644 --- a/src/bin/e_comp_x_randr.h +++ b/src/bin/e_comp_x_randr.h @@ -3,7 +3,7 @@ E_API void e_comp_x_randr_init(void); E_API void e_comp_x_randr_shutdown(void); -E_API void e_comp_x_randr_config_apply(void); +E_API void e_comp_x_randr_config_apply(Eina_Bool can_ckip); E_API Eina_Bool e_comp_x_randr_available(void); E_API E_Randr2 *e_comp_x_randr_create(void); diff --git a/src/bin/e_randr2.c b/src/bin/e_randr2.c index 9b8f38357..474708a5e 100644 --- a/src/bin/e_randr2.c +++ b/src/bin/e_randr2.c @@ -9,7 +9,7 @@ static void _cb_delay_init_save(void *data); static Eina_Bool _cb_delay_timer(void *data); static Eina_Bool _cb_fade_animator(void *data); static void _animated_apply(void); -static void _do_apply(void); +static void _do_apply(Eina_Bool at_init); static void _info_free(E_Randr2 *r); static E_Config_Randr2 *_config_load(void); static void _config_free(E_Config_Randr2 *cfg); @@ -107,7 +107,7 @@ e_randr2_init(void) if (_config_update(e_randr2, e_randr2_cfg, 1)) e_randr2_config_save(); } - _do_apply(); + _do_apply(EINA_TRUE); } else { @@ -226,7 +226,7 @@ _cb_fade_animator(void *data EINA_UNUSED) if (_target_to == 255) { _apply_delay = ecore_timer_loop_add(1.0, _cb_delay_timer, NULL); - _do_apply(); + _do_apply(EINA_FALSE); } else { @@ -263,7 +263,7 @@ _animated_apply(void) } static void -_do_apply(void) +_do_apply(Eina_Bool at_init) { // take current screen config and apply it to the driver printf("RRR: re-get info before applying..\n"); @@ -277,7 +277,7 @@ _do_apply(void) printf("RRR: eval config...\n"); _screen_config_eval(); printf("RRR: really apply config...\n"); - e_comp->screen->apply(); + e_comp->screen->apply(at_init); printf("RRR: done config...\n"); } diff --git a/src/modules/wl_drm/e_mod_main.c b/src/modules/wl_drm/e_mod_main.c index 45f589361..17e915ce5 100644 --- a/src/modules/wl_drm/e_mod_main.c +++ b/src/modules/wl_drm/e_mod_main.c @@ -574,7 +574,7 @@ _drm2_rotation_exists(Ecore_Drm2_Output *output, int rot) } static void -_drm2_randr_apply(void) +_drm2_randr_apply(Eina_Bool can_skip EINA_UNUSED) { Ecore_Drm2_Device *dev; Ecore_Drm2_Output **outconf, *out;