forked from enlightenment/enlightenment
randr: allocate hot-plugged outputs
This commit is contained in:
parent
11e21fd1ff
commit
5c6eed2307
|
@ -622,55 +622,70 @@ _e_randr_event_cb_output_change(void *data EINA_UNUSED, int type EINA_UNUSED, vo
|
||||||
output = _e_randr_output_find(ev->output);
|
output = _e_randr_output_find(ev->output);
|
||||||
if (!output)
|
if (!output)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "E_RANDR: Weird, a new output?\n");
|
E_Config_Randr_Output *output_cfg = NULL;
|
||||||
}
|
Ecore_X_Window root;
|
||||||
else
|
|
||||||
{
|
|
||||||
/* we know this output */
|
|
||||||
if (output->is_lid && _e_randr_lid_is_closed)
|
|
||||||
{
|
|
||||||
/* ignore event from disconnected lid */
|
|
||||||
fprintf(stderr, "E_RANDR: ignore event from closed lid\n");
|
|
||||||
}
|
|
||||||
else if (ev->connection == ECORE_X_RANDR_CONNECTION_STATUS_CONNECTED)
|
|
||||||
{
|
|
||||||
E_Randr_Crtc *crtc = NULL;
|
|
||||||
|
|
||||||
/* connected */
|
root = ecore_x_window_root_first_get();
|
||||||
if ((ev->crtc != 0) && (output->cfg->crtc != ev->crtc))
|
|
||||||
{
|
output = E_NEW(E_Randr_Output, 1);
|
||||||
fprintf(stderr, "E_RANDR: output changed crtc\n");
|
if (!output) goto error;
|
||||||
/* remove from old crtc */
|
output_cfg = _e_randr_config_output_find(ev->output);
|
||||||
_e_randr_output_active_set(output, EINA_FALSE);
|
if (!output_cfg)
|
||||||
/* set new crtc on output */
|
output_cfg = _e_randr_config_output_new(root, ev->output);
|
||||||
output->cfg->crtc = ev->crtc;
|
if (!output_cfg) goto error;
|
||||||
}
|
|
||||||
if (!output->active)
|
e_randr->outputs = eina_list_append(e_randr->outputs, output);
|
||||||
{
|
output->cfg = output_cfg;
|
||||||
fprintf(stderr, "E_RANDR: output connected to crtc\n");
|
|
||||||
crtc = _e_randr_output_crtc_find(output);
|
output->name = ecore_x_randr_output_name_get(root, output->cfg->xid, NULL);
|
||||||
if (crtc)
|
output->is_lid = _e_randr_is_lid(output);
|
||||||
{
|
changed = EINA_TRUE;
|
||||||
/* connect to crtc */
|
}
|
||||||
_e_randr_output_active_set(output, EINA_TRUE);
|
|
||||||
/* get orientation from crtc if not set */
|
/* we know this output */
|
||||||
if (!output->cfg->orient)
|
if (output->is_lid && _e_randr_lid_is_closed)
|
||||||
output->cfg->orient = crtc->orient;
|
{
|
||||||
/* validate output mode */
|
/* ignore event from disconnected lid */
|
||||||
_e_randr_output_mode_update(output);
|
fprintf(stderr, "E_RANDR: ignore event from closed lid\n");
|
||||||
}
|
}
|
||||||
changed = EINA_TRUE;
|
else if (ev->connection == ECORE_X_RANDR_CONNECTION_STATUS_CONNECTED)
|
||||||
}
|
{
|
||||||
}
|
E_Randr_Crtc *crtc = NULL;
|
||||||
else if (ev->connection == ECORE_X_RANDR_CONNECTION_STATUS_DISCONNECTED)
|
|
||||||
|
/* connected */
|
||||||
|
if ((ev->crtc != 0) && (output->cfg->crtc != ev->crtc))
|
||||||
{
|
{
|
||||||
/* disconnected */
|
fprintf(stderr, "E_RANDR: output changed crtc\n");
|
||||||
if (output->active)
|
/* remove from old crtc */
|
||||||
|
_e_randr_output_active_set(output, EINA_FALSE);
|
||||||
|
/* set new crtc on output */
|
||||||
|
output->cfg->crtc = ev->crtc;
|
||||||
|
}
|
||||||
|
if (!output->active)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "E_RANDR: output connected to crtc\n");
|
||||||
|
crtc = _e_randr_output_crtc_find(output);
|
||||||
|
if (crtc)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "E_RANDR: output disconnected: %s\n", output->name);
|
/* connect to crtc */
|
||||||
_e_randr_output_active_set(output, EINA_FALSE);
|
_e_randr_output_active_set(output, EINA_TRUE);
|
||||||
changed = EINA_TRUE;
|
/* get orientation from crtc if not set */
|
||||||
|
if (!output->cfg->orient)
|
||||||
|
output->cfg->orient = crtc->orient;
|
||||||
|
/* validate output mode */
|
||||||
|
_e_randr_output_mode_update(output);
|
||||||
}
|
}
|
||||||
|
changed = EINA_TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (ev->connection == ECORE_X_RANDR_CONNECTION_STATUS_DISCONNECTED)
|
||||||
|
{
|
||||||
|
/* disconnected */
|
||||||
|
if (output->active)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "E_RANDR: output disconnected: %s\n", output->name);
|
||||||
|
_e_randr_output_active_set(output, EINA_FALSE);
|
||||||
|
changed = EINA_TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -684,6 +699,9 @@ _e_randr_event_cb_output_change(void *data EINA_UNUSED, int type EINA_UNUSED, vo
|
||||||
}
|
}
|
||||||
|
|
||||||
return ECORE_CALLBACK_RENEW;
|
return ECORE_CALLBACK_RENEW;
|
||||||
|
error:
|
||||||
|
free(output);
|
||||||
|
return ECORE_CALLBACK_RENEW;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
|
|
Loading…
Reference in New Issue