randr: remember crtcid for fast lookup on reconnect
authorSebastian Dransfeld <sd@tango.flipp.net>
Tue, 16 Dec 2014 08:21:02 +0000 (09:21 +0100)
committerSebastian Dransfeld <sd@tango.flipp.net>
Tue, 16 Dec 2014 08:21:02 +0000 (09:21 +0100)
When an output is set inactive, it is disconnected from a crtc. Now we
remember the id of the last crtc it was connected to, so we get a faster
lookup on reconnect.

src/bin/e_randr.c
src/bin/e_randr.h

index d8c074e..4def8c3 100644 (file)
@@ -475,6 +475,7 @@ _e_randr_load(void)
              output->is_lid = _e_randr_is_lid(output);
              output->edid = _e_randr_output_edid_string_get(root, output->xid);
              output->status = ecore_x_randr_output_connection_status_get(root, output->xid);
+             output->crtcid = ecore_x_randr_output_crtc_get(root, output->xid);
              output->cfg = _e_randr_config_output_find(output);
              if (!output->cfg)
                {
@@ -781,6 +782,7 @@ _e_randr_event_cb_output_change(void *data EINA_UNUSED, int type EINA_UNUSED, vo
         if ((!output->crtc) || (output->crtc->xid == 0)) unknown = EINA_TRUE;
 
         /* connected */
+        output->crtcid = ev->crtc;
         if ((ev->crtc != 0) && ((!unknown) && (output->crtc->xid != ev->crtc)))
           {
              /* remove from old crtc */
@@ -1049,17 +1051,17 @@ _e_randr_output_crtc_find(E_Randr_Output *output)
    int num = 0, i = 0;
    int nmodes, pref;
 
-   /* grab the root window */
-   root = ecore_x_window_root_first_get();
-
    /* check if current is available */
-   if ((crtc = _e_randr_crtc_find(ecore_x_randr_output_crtc_get(root, output->xid))))
+   if ((crtc = _e_randr_crtc_find(output->crtcid)))
      {
         if (!crtc->outputs)
           goto done;
      }
    crtc = NULL;
 
+   /* grab the root window */
+   root = ecore_x_window_root_first_get();
+
    /* get a list of possible crtcs for this output */
    possible = ecore_x_randr_output_possible_crtcs_get(root, output->xid, &num);
    if (num == 0) goto error;
@@ -1096,6 +1098,7 @@ done:
    free(possible);
    free(modes);
 
+   output->crtcid = crtc->xid;
    output->crtc = crtc;
    return;
 
@@ -1302,6 +1305,7 @@ _e_randr_output_active_set(E_Randr_Output *output, Eina_Bool active)
              output->crtc->outputs =
                 eina_list_remove(output->crtc->outputs, output);
              e_randr->active--;
+             output->crtc = NULL;
              printf("RR:  ... remove output for crtc now\n");
           }
      }
index 654a7e4..30e355d 100644 (file)
@@ -55,6 +55,7 @@ struct _E_Randr_Output
 
    E_Config_Randr_Output *cfg;
    E_Randr_Crtc *crtc;
+   Ecore_X_Randr_Crtc crtcid;
 };
 
 struct _E_Randr_Crtc