Merge pull request #318 from emersion/drm-null-outputs
Create globals only for enabled outputs in DRM backend
This commit is contained in:
commit
86be449a3f
|
@ -748,7 +748,6 @@ void wlr_drm_scan_connectors(struct wlr_drm_backend *drm) {
|
||||||
free(edid);
|
free(edid);
|
||||||
|
|
||||||
wl_list_insert(&drm->outputs, &wlr_conn->link);
|
wl_list_insert(&drm->outputs, &wlr_conn->link);
|
||||||
wlr_output_create_global(&wlr_conn->output, drm->display);
|
|
||||||
wlr_log(L_INFO, "Found display '%s'", wlr_conn->output.name);
|
wlr_log(L_INFO, "Found display '%s'", wlr_conn->output.name);
|
||||||
} else {
|
} else {
|
||||||
seen[index] = true;
|
seen[index] = true;
|
||||||
|
@ -756,7 +755,6 @@ void wlr_drm_scan_connectors(struct wlr_drm_backend *drm) {
|
||||||
|
|
||||||
if (wlr_conn->state == WLR_DRM_CONN_DISCONNECTED &&
|
if (wlr_conn->state == WLR_DRM_CONN_DISCONNECTED &&
|
||||||
drm_conn->connection == DRM_MODE_CONNECTED) {
|
drm_conn->connection == DRM_MODE_CONNECTED) {
|
||||||
|
|
||||||
wlr_log(L_INFO, "'%s' connected", wlr_conn->output.name);
|
wlr_log(L_INFO, "'%s' connected", wlr_conn->output.name);
|
||||||
wlr_log(L_INFO, "Detected modes:");
|
wlr_log(L_INFO, "Detected modes:");
|
||||||
|
|
||||||
|
@ -778,14 +776,17 @@ void wlr_drm_scan_connectors(struct wlr_drm_backend *drm) {
|
||||||
wl_list_insert(&wlr_conn->output.modes, &mode->wlr_mode.link);
|
wl_list_insert(&wlr_conn->output.modes, &mode->wlr_mode.link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wlr_output_create_global(&wlr_conn->output, drm->display);
|
||||||
|
|
||||||
wlr_conn->state = WLR_DRM_CONN_NEEDS_MODESET;
|
wlr_conn->state = WLR_DRM_CONN_NEEDS_MODESET;
|
||||||
wlr_log(L_INFO, "Sending modesetting signal for '%s'",
|
wlr_log(L_INFO, "Sending modesetting signal for '%s'",
|
||||||
wlr_conn->output.name);
|
wlr_conn->output.name);
|
||||||
wl_signal_emit(&drm->backend.events.output_add, &wlr_conn->output);
|
wl_signal_emit(&drm->backend.events.output_add, &wlr_conn->output);
|
||||||
} else if (wlr_conn->state == WLR_DRM_CONN_CONNECTED &&
|
} else if (wlr_conn->state == WLR_DRM_CONN_CONNECTED &&
|
||||||
drm_conn->connection != DRM_MODE_CONNECTED) {
|
drm_conn->connection != DRM_MODE_CONNECTED) {
|
||||||
|
|
||||||
wlr_log(L_INFO, "'%s' disconnected", wlr_conn->output.name);
|
wlr_log(L_INFO, "'%s' disconnected", wlr_conn->output.name);
|
||||||
|
|
||||||
|
wlr_output_destroy_global(&wlr_conn->output);
|
||||||
wlr_drm_connector_cleanup(wlr_conn);
|
wlr_drm_connector_cleanup(wlr_conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -267,10 +267,6 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
struct screenshooter_output *output;
|
struct screenshooter_output *output;
|
||||||
wl_list_for_each(output, &output_list, link) {
|
wl_list_for_each(output, &output_list, link) {
|
||||||
if (output->width == 0 || output->height == 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
output->buffer = create_shm_buffer(output->width, output->height, &output->data);
|
output->buffer = create_shm_buffer(output->width, output->height, &output->data);
|
||||||
if (output->buffer == NULL) {
|
if (output->buffer == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -26,7 +26,8 @@ void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend,
|
||||||
const struct wlr_output_impl *impl);
|
const struct wlr_output_impl *impl);
|
||||||
void wlr_output_free(struct wlr_output *output);
|
void wlr_output_free(struct wlr_output *output);
|
||||||
void wlr_output_update_matrix(struct wlr_output *output);
|
void wlr_output_update_matrix(struct wlr_output *output);
|
||||||
struct wl_global *wlr_output_create_global(
|
struct wl_global *wlr_output_create_global(struct wlr_output *wlr_output,
|
||||||
struct wlr_output *wlr_output, struct wl_display *display);
|
struct wl_display *display);
|
||||||
|
void wlr_output_destroy_global(struct wlr_output *wlr_output);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -76,16 +76,20 @@ static void wl_output_bind(struct wl_client *wl_client, void *_wlr_output,
|
||||||
struct wlr_output *wlr_output = _wlr_output;
|
struct wlr_output *wlr_output = _wlr_output;
|
||||||
assert(wl_client && wlr_output);
|
assert(wl_client && wlr_output);
|
||||||
|
|
||||||
struct wl_resource *wl_resource = wl_resource_create(
|
struct wl_resource *wl_resource = wl_resource_create(wl_client,
|
||||||
wl_client, &wl_output_interface, version, id);
|
&wl_output_interface, version, id);
|
||||||
wl_resource_set_implementation(wl_resource, &wl_output_impl,
|
wl_resource_set_implementation(wl_resource, &wl_output_impl, wlr_output,
|
||||||
wlr_output, wl_output_destroy);
|
wl_output_destroy);
|
||||||
wl_list_insert(&wlr_output->wl_resources, wl_resource_get_link(wl_resource));
|
wl_list_insert(&wlr_output->wl_resources,
|
||||||
|
wl_resource_get_link(wl_resource));
|
||||||
wl_output_send_to_resource(wl_resource);
|
wl_output_send_to_resource(wl_resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wl_global *wlr_output_create_global(
|
struct wl_global *wlr_output_create_global(struct wlr_output *wlr_output,
|
||||||
struct wlr_output *wlr_output, struct wl_display *display) {
|
struct wl_display *display) {
|
||||||
|
if (wlr_output->wl_global != NULL) {
|
||||||
|
return wlr_output->wl_global;
|
||||||
|
}
|
||||||
struct wl_global *wl_global = wl_global_create(display,
|
struct wl_global *wl_global = wl_global_create(display,
|
||||||
&wl_output_interface, 3, wlr_output, wl_output_bind);
|
&wl_output_interface, 3, wlr_output, wl_output_bind);
|
||||||
wlr_output->wl_global = wl_global;
|
wlr_output->wl_global = wl_global;
|
||||||
|
@ -93,6 +97,19 @@ struct wl_global *wlr_output_create_global(
|
||||||
return wl_global;
|
return wl_global;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wlr_output_destroy_global(struct wlr_output *wlr_output) {
|
||||||
|
if (wlr_output->wl_global == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
struct wl_resource *resource, *tmp;
|
||||||
|
wl_resource_for_each_safe(resource, tmp, &wlr_output->wl_resources) {
|
||||||
|
struct wl_list *link = wl_resource_get_link(resource);
|
||||||
|
wl_list_remove(link);
|
||||||
|
}
|
||||||
|
wl_global_destroy(wlr_output->wl_global);
|
||||||
|
wlr_output->wl_global = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void wlr_output_update_matrix(struct wlr_output *output) {
|
void wlr_output_update_matrix(struct wlr_output *output) {
|
||||||
wlr_matrix_texture(output->transform_matrix, output->width, output->height, output->transform);
|
wlr_matrix_texture(output->transform_matrix, output->width, output->height, output->transform);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue