{
tdm_private_module *private_module = NULL;
tdm_private_output *private_output = NULL;
+ tdm_private_output *mode_setted_output = NULL;
+ tdm_private_output *connected_output = NULL;
+ unsigned int find_primary = 0;
DISPLAY_FUNC_ENTRY_ERROR();
- if (!strncasecmp(name, "primary", 7) || !strncasecmp(name, "default", 7)) {
- return tdm_display_get_output(dpy, 0, error);
- }
+ if (!strncasecmp(name, "primary", 7) || !strncasecmp(name, "default", 7))
+ find_primary = 1;
_pthread_mutex_lock(&private_display->lock);
if (error)
*error = TDM_ERROR_NONE;
+ if (find_primary) {
+ LIST_FOR_EACH_ENTRY(private_module, &private_display->module_list, link) {
+ LIST_FOR_EACH_ENTRY(private_output, &private_module->output_list, link) {
+ if (private_output->caps.status == TDM_OUTPUT_CONN_STATUS_CONNECTED && !connected_output)
+ connected_output = private_output;
+ else if (private_output->caps.status == TDM_OUTPUT_CONN_STATUS_MODE_SETTED && !mode_setted_output)
+ mode_setted_output = private_output;
+ }
+ }
+
+ if (mode_setted_output) {
+ _pthread_mutex_unlock(&private_display->lock);
+ return mode_setted_output;
+ }
+
+ if (connected_output) {
+ _pthread_mutex_unlock(&private_display->lock);
+ return connected_output;
+ }
+
+ LIST_FOR_EACH_ENTRY(private_module, &private_display->module_list, link) {
+ LIST_FOR_EACH_ENTRY(private_output, &private_module->output_list, link) {
+ if (private_output->index == 0) {
+ _pthread_mutex_unlock(&private_display->lock);
+ return private_output;
+ }
+ }
+ }
+ }
+
LIST_FOR_EACH_ENTRY(private_module, &private_display->module_list, link) {
LIST_FOR_EACH_ENTRY(private_output, &private_module->output_list, link) {
if (strncmp(private_output->caps.model, name, TDM_NAME_LEN))