Make policies work again.
authorLeif Middelschulte <leif.middelschulte@gmail.com>
Mon, 20 Feb 2012 19:14:26 +0000 (19:14 +0000)
committerLeif Middelschulte <leif.middelschulte@gmail.com>
Mon, 20 Feb 2012 19:14:26 +0000 (19:14 +0000)
SVN revision: 68171

src/bin/e_randr_12.c
src/bin/e_randr_12_crtc.c
src/bin/e_randr_12_output.c
src/bin/e_randr_private.h

index 58b352640887f346e6e8e15c3b0f3584763d806f..7f485422c563402273718561a9d5bc9343508cd0 100644 (file)
@@ -698,7 +698,16 @@ _try_enable_output(E_Randr_Output_Info *output_info, Eina_Bool force)
            }
          if ((ret = ecore_x_randr_crtc_mode_set(e_randr_screen_info.root, usable_crtc->xid, &output_info->xid, 1, mode_info->xid)))
            {
-              ret &= _crtc_move_policy(usable_crtc);
+              //WORKAROUND
+              //Reason: the CRTC event, that'd bring the new info about the set
+              //mode is arriving too late here.
+              usable_crtc->current_mode = mode_info;
+              crtc_info->geometry.x = 0;
+              crtc_info->geometry.y = 0;
+              crtc_info->geometry.w = mode_info->width;
+              crtc_info->geometry.h = mode_info->height;
+              //WORKAROUND END
+              ret &= _crtc_move_policy(usable_crtc, output_info->policy);
            }
      }
    if (ret)
index 8360271e33ce947845fa30d2093bd259ccdad821..f74fae04db8d29ac85b7fff81a6599083b2e0769 100644 (file)
@@ -194,24 +194,25 @@ _crtc_outputs_mode_max_set(E_Randr_Crtc_Info *crtc_info)
  * other crtcs are accordingly moved instead, so the result is the same.
  */
 Eina_Bool
-_crtc_move_policy(E_Randr_Crtc_Info *new_crtc)
+_crtc_move_policy(E_Randr_Crtc_Info *new_crtc, Ecore_X_Randr_Output_Policy policy)
 {
    const E_Randr_Crtc_Info *crtc_rel;
-   E_Randr_Output_Info *first_output = NULL;
    int dx = Ecore_X_Randr_None, dy = Ecore_X_Randr_None;
    Eina_Bool ret = EINA_TRUE;
 
-   //use the policy of the new crtc's first output
-   first_output = (E_Randr_Output_Info *)eina_list_data_get(new_crtc->outputs);
-   if (!first_output)
-     return EINA_FALSE;
+   EINA_SAFETY_ON_NULL_RETURN_VAL(new_crtc, EINA_FALSE);
+
    //get the crtc we will place our's relative to. If it's NULL, this is the
    //only output attached, work done.
-   if (!(crtc_rel = _crtc_according_to_policy_get(new_crtc, first_output->policy)))
-     return EINA_TRUE;
+   if (!(crtc_rel = _crtc_according_to_policy_get(new_crtc, policy)))
+     {
+        fprintf(stderr, "E_RANDR: Moving CRTC %d, there is no other CRTC to move this one relative to.\n", new_crtc->xid);
+        return EINA_TRUE;
+     }
 
+   fprintf(stderr, "E_RANDR: Moved CRTC %d has geometry (x,y,wxh): %d, %d, %dx%d.\n", new_crtc->xid, new_crtc->geometry.x, new_crtc->geometry.y, new_crtc->geometry.w, new_crtc->geometry.h);
    //following is policy dependend.
-   switch (first_output->policy)
+   switch (policy)
      {
       case ECORE_X_RANDR_OUTPUT_POLICY_ABOVE:
         dy = (crtc_rel->geometry.y - new_crtc->geometry.h);
@@ -224,6 +225,7 @@ _crtc_move_policy(E_Randr_Crtc_Info *new_crtc)
                                                     1,
                                                     dx,
                                                     dy);
+             fprintf(stderr, "E_RANDR: Moving all CRTCs but %d, by %dx%d delta.\n", new_crtc->xid, dx, dy);
           }
         break;
 
@@ -238,13 +240,14 @@ _crtc_move_policy(E_Randr_Crtc_Info *new_crtc)
                                                     1,
                                                     dx,
                                                     dy);
+             fprintf(stderr, "E_RANDR: Moving all CRTCs but %d, by %dx%d delta.\n", new_crtc->xid, dx, dy);
           }
         break;
 
       default:
         break;
      }
-   ret &= ecore_x_randr_crtc_pos_relative_set(e_randr_screen_info.root, new_crtc->xid, crtc_rel->xid, first_output->policy, e_randr_screen_info.rrvd_info.randr_info_12->alignment);
+   ret &= ecore_x_randr_crtc_pos_relative_set(e_randr_screen_info.root, new_crtc->xid, crtc_rel->xid, policy, e_randr_screen_info.rrvd_info.randr_info_12->alignment);
 
    return ret;
 }
index d38f1564a418408d63ad86eb5a583967b0246c00..08c42aec20755399fa400f1b86dd78b699e4ea2c 100644 (file)
@@ -24,9 +24,9 @@ _monitor_modes_refs_set(E_Randr_Monitor_Info *mi, Ecore_X_Randr_Output o)
              mode_info = ecore_x_randr_mode_info_get(e_randr_screen_info.root, modes[nmodes]);
              e_randr_screen_info.rrvd_info.randr_info_12->modes = eina_list_append(e_randr_screen_info.rrvd_info.randr_info_12->modes, mode_info);
           }
-        mi->modes = eina_list_append(mi->modes, mode_info);
-        if (nmodes >= npreferred)
-          mi->preferred_modes = eina_list_append(mi->preferred_modes, mode_info);
+        mi->modes = eina_list_prepend(mi->modes, mode_info);
+        if (nmodes <= npreferred)
+          mi->preferred_modes = eina_list_prepend(mi->preferred_modes, mode_info);
      }
    free(modes);
 }
@@ -106,6 +106,7 @@ _output_info_new(Ecore_X_Randr_Output output)
    output_info->signalformats = Ecore_X_Randr_Unset;
    output_info->signalformat = Ecore_X_Randr_Unset;
    output_info->connector_number = 0;
+   output_info->monitor = NULL;
    output_info->connector_type = Ecore_X_Randr_Unset;
    output_info->policy = ECORE_X_RANDR_OUTPUT_POLICY_NONE;
    output_info->compatibility_list = NULL;
index 60cb299d1ca2f0fe98cb34d0c59d054ac8af2f83..43deb903c6f5c485f061e905d6cabce625dbfc2c 100644 (file)
@@ -61,7 +61,7 @@ E_Randr_Crtc_Info *      _crtc_info_new(Ecore_X_Randr_Crtc crtc);
 void                     _crtc_info_free(E_Randr_Crtc_Info *crtc_info);
 void                     _crtc_refs_set(E_Randr_Crtc_Info *crtc_info);
 void                     _crtc_outputs_refs_set(E_Randr_Crtc_Info *crtc_info);
-Eina_Bool                _crtc_move_policy(E_Randr_Crtc_Info *new_crtc);
+Eina_Bool                _crtc_move_policy(E_Randr_Crtc_Info *new_crtc, Ecore_X_Randr_Output_Policy policy);
 const E_Randr_Crtc_Info *_crtc_according_to_policy_get(E_Randr_Crtc_Info *but, Ecore_X_Randr_Output_Policy policy);
 
 #endif