mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 12:55:58 +01:00
prevents reuse of outdated wlr_output state
On the drm output the wlr_drm_connector structs are reused. This struct contains the wlr_output struct, which is reused as well. The old code kept modes/edid and output state persistent over hotplug. This nulls the relevant strings, reads newer edid data and removes old modes on unplug.
This commit is contained in:
parent
b10269e513
commit
08fda567d2
1 changed files with 27 additions and 11 deletions
|
@ -14,6 +14,7 @@
|
|||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
#include <wayland-server.h>
|
||||
#include <wayland-util.h>
|
||||
#include <wlr/backend/interface.h>
|
||||
#include <wlr/interfaces/wlr_output.h>
|
||||
#include <wlr/util/log.h>
|
||||
|
@ -759,22 +760,11 @@ void wlr_drm_scan_connectors(struct wlr_drm_backend *drm) {
|
|||
wlr_conn->old_crtc = drmModeGetCrtc(drm->fd, curr_enc->crtc_id);
|
||||
}
|
||||
|
||||
wlr_conn->output.phys_width = drm_conn->mmWidth;
|
||||
wlr_conn->output.phys_height = drm_conn->mmHeight;
|
||||
wlr_conn->output.subpixel = subpixel_map[drm_conn->subpixel];
|
||||
snprintf(wlr_conn->output.name, sizeof(wlr_conn->output.name),
|
||||
"%s-%"PRIu32,
|
||||
conn_get_name(drm_conn->connector_type),
|
||||
drm_conn->connector_type_id);
|
||||
|
||||
wlr_drm_get_connector_props(drm->fd, wlr_conn->id, &wlr_conn->props);
|
||||
|
||||
size_t edid_len = 0;
|
||||
uint8_t *edid = wlr_drm_get_prop_blob(drm->fd,
|
||||
wlr_conn->id, wlr_conn->props.edid, &edid_len);
|
||||
parse_edid(&wlr_conn->output, edid_len, edid);
|
||||
free(edid);
|
||||
|
||||
wl_list_insert(&drm->outputs, &wlr_conn->link);
|
||||
wlr_log(L_INFO, "Found display '%s'", wlr_conn->output.name);
|
||||
} else {
|
||||
|
@ -795,6 +785,21 @@ void wlr_drm_scan_connectors(struct wlr_drm_backend *drm) {
|
|||
if (wlr_conn->state == WLR_DRM_CONN_DISCONNECTED &&
|
||||
drm_conn->connection == DRM_MODE_CONNECTED) {
|
||||
wlr_log(L_INFO, "'%s' connected", wlr_conn->output.name);
|
||||
|
||||
wlr_conn->output.phys_width = drm_conn->mmWidth;
|
||||
wlr_conn->output.phys_height = drm_conn->mmHeight;
|
||||
wlr_log(L_INFO, "Physical size: %"PRId32"x%"PRId32,
|
||||
wlr_conn->output.phys_width, wlr_conn->output.phys_height);
|
||||
wlr_conn->output.subpixel = subpixel_map[drm_conn->subpixel];
|
||||
|
||||
wlr_drm_get_connector_props(drm->fd, wlr_conn->id, &wlr_conn->props);
|
||||
|
||||
size_t edid_len = 0;
|
||||
uint8_t *edid = wlr_drm_get_prop_blob(drm->fd,
|
||||
wlr_conn->id, wlr_conn->props.edid, &edid_len);
|
||||
parse_edid(&wlr_conn->output, edid_len, edid);
|
||||
free(edid);
|
||||
|
||||
wlr_log(L_INFO, "Detected modes:");
|
||||
|
||||
for (int i = 0; i < drm_conn->count_modes; ++i) {
|
||||
|
@ -947,6 +952,17 @@ void wlr_drm_connector_cleanup(struct wlr_drm_connector *conn) {
|
|||
}
|
||||
}
|
||||
|
||||
struct wlr_drm_mode *mode;
|
||||
struct wlr_drm_mode *tmp;
|
||||
wl_list_for_each_safe(mode, tmp, &conn->output.modes, wlr_mode.link) {
|
||||
wl_list_remove(&mode->wlr_mode.link);
|
||||
free(mode);
|
||||
}
|
||||
|
||||
memset(&conn->output.make, 0, sizeof(conn->output.make));
|
||||
memset(&conn->output.model, 0, sizeof(conn->output.model));
|
||||
memset(&conn->output.serial, 0, sizeof(conn->output.serial));
|
||||
|
||||
conn->crtc = NULL;
|
||||
conn->possible_crtc = 0;
|
||||
/* Fallthrough */
|
||||
|
|
Loading…
Reference in a new issue