The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Allow selecting wayland direct connector by name

Splits the connector selection code into a separate function that
accepts a connector name to match against.

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2283>

authored by

Joel Valenciano and committed by
Marge Bot
dbd0098d f9d02319

+53 -20
+53 -20
src/xrt/compositor/main/comp_window_direct_wayland.c
··· 371 371 .global_remove = _registry_global_remove_cb, 372 372 }; 373 373 374 + // Find the connector matching name, return the first available if no match 375 + static bool 376 + get_named_connector_or_first(struct comp_window_direct_wayland *w, const char *name) 377 + { 378 + struct direct_wayland_lease_device *dev = w->devices; 379 + struct direct_wayland_lease_connector *conn = NULL; 380 + 381 + while (dev) { 382 + if (!dev->done) { 383 + wl_display_dispatch(w->display); 384 + continue; 385 + } 386 + if (dev->connectors) { 387 + /* Use the first connector available as default */ 388 + if (!w->selected_connector) { 389 + w->selected_device = dev; 390 + w->selected_connector = dev->connectors; 391 + if (!name) { 392 + return false; 393 + } 394 + } 395 + 396 + // If no connector is chosen, we're done. 397 + conn = dev->connectors; 398 + while (conn) { 399 + if (!strcmp(name, conn->name)) { 400 + w->selected_device = dev; 401 + w->selected_connector = conn; 402 + return true; 403 + } 404 + conn = conn->next; 405 + } 406 + } 407 + dev = dev->next; 408 + } 409 + return false; 410 + } 411 + 374 412 static bool 375 413 comp_window_direct_wayland_init(struct comp_target *w) 376 414 { ··· 392 430 return false; 393 431 } 394 432 395 - struct direct_wayland_lease_device *dev = w_wayland->devices; 396 - while (dev) { 397 - if (!dev->done) { 398 - wl_display_dispatch(w_wayland->display); 399 - continue; 400 - } 401 - /* TODO: Choose the connector with an environment variable 402 - * or from `ct->c->settings.display` */ 433 + // Replace this with the value of an env variable 434 + const char *connector_name = NULL; 403 435 404 - /* Pick the first connector available */ 405 - if (dev->connectors) { 406 - w_wayland->selected_device = dev; 407 - w_wayland->selected_connector = dev->connectors; 408 - 409 - COMP_INFO(w->c, "Using DRM node %s", dev->path); 410 - COMP_INFO(w->c, "Connector id %d %s (%s)", w_wayland->selected_connector->id, 411 - w_wayland->selected_connector->name, w_wayland->selected_connector->description); 412 - break; 413 - } 414 - dev = dev->next; 436 + if (!connector_name) { 437 + COMP_INFO(w->c, "No connector was chosen, will use first available connector"); 415 438 } 439 + 440 + bool found = get_named_connector_or_first(w_wayland, connector_name); 416 441 417 442 if (!w_wayland->selected_connector) { 418 443 COMP_INFO(w->c, "Found no connectors available for direct mode"); 419 444 return false; 420 445 } 446 + 447 + // Inform when chosen connector was not found 448 + if (connector_name && !found) { 449 + COMP_INFO(w->c, "Could not find requested connector, selected first available connector"); 450 + } 451 + 452 + COMP_INFO(w->c, "Using DRM node %s", w_wayland->selected_device->path); 453 + COMP_INFO(w->c, "Connector id %d %s (%s)", w_wayland->selected_connector->id, 454 + w_wayland->selected_connector->name, w_wayland->selected_connector->description); 421 455 422 456 struct wp_drm_lease_request_v1 *request = 423 457 wp_drm_lease_device_v1_create_lease_request(w_wayland->selected_device->device); ··· 449 483 COMP_ERROR(w->c, "Failed to lease connector"); 450 484 return false; 451 485 } 452 - 453 486 454 487 return true; 455 488 }