From 08fda567d22dfdde6a4764d8dd3466dddf39b507 Mon Sep 17 00:00:00 2001 From: Markus Ongyerth Date: Tue, 6 Feb 2018 22:45:37 +0100 Subject: [PATCH 1/4] 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. --- backend/drm/drm.c | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/backend/drm/drm.c b/backend/drm/drm.c index f6cc084e..cf5af355 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -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 */ From b181f793c393527d6bc955b4762a6945cbe65d1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Hagstr=C3=B6m?= Date: Wed, 7 Feb 2018 17:42:31 +0100 Subject: [PATCH 2/4] Make pointer button release outside window still count down the button_count. When double-clicking a maximized window title, so that the windows size is restored and the mouse pointer ends up _outside_ the window it becomes impossible to move windows. The reason is that the button_count variable is not counted down if the mouse button is released outside the window, so the button_count remains incremented even after the button is released. This patch adds a call to wlr_seat_pointer_notify_button if the mouse button is released outside the window. (I am a complete noob to wlroots, so be kind...) --- rootston/cursor.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rootston/cursor.c b/rootston/cursor.c index d8753f44..717a3da8 100644 --- a/rootston/cursor.c +++ b/rootston/cursor.c @@ -261,7 +261,9 @@ static void roots_cursor_press_button(struct roots_cursor *cursor, } } - if (view && surface) { + if ((view && surface) || + (state == WLR_BUTTON_RELEASED && + seat->seat->pointer_state.button_count != 0)) { if (!is_touch) { wlr_seat_pointer_notify_button(seat->seat, time, button, state); } From 099c80e7d6b27ad122d15e96a02816039157d3f7 Mon Sep 17 00:00:00 2001 From: Vincent Vanlaer Date: Wed, 7 Feb 2018 18:36:08 +0100 Subject: [PATCH 3/4] Fix jitter when quickly resizing windows Surfaces and views get resized only on commit, therefore we may only change the position of a window if there are no pending commits. --- rootston/xdg_shell_v6.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rootston/xdg_shell_v6.c b/rootston/xdg_shell_v6.c index 0515263b..41353199 100644 --- a/rootston/xdg_shell_v6.c +++ b/rootston/xdg_shell_v6.c @@ -101,7 +101,7 @@ static void move_resize(struct roots_view *view, double x, double y, constrained_height); if (serial > 0) { roots_surface->pending_move_resize_configure_serial = serial; - } else { + } else if(roots_surface->pending_move_resize_configure_serial == 0) { view->x = x; view->y = y; } From 712665b83b83871c52144ea36fe9469ad06b5107 Mon Sep 17 00:00:00 2001 From: Vincent Vanlaer Date: Wed, 7 Feb 2018 20:26:30 +0100 Subject: [PATCH 4/4] Fix style error --- rootston/xdg_shell_v6.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rootston/xdg_shell_v6.c b/rootston/xdg_shell_v6.c index 41353199..884d0d05 100644 --- a/rootston/xdg_shell_v6.c +++ b/rootston/xdg_shell_v6.c @@ -101,7 +101,7 @@ static void move_resize(struct roots_view *view, double x, double y, constrained_height); if (serial > 0) { roots_surface->pending_move_resize_configure_serial = serial; - } else if(roots_surface->pending_move_resize_configure_serial == 0) { + } else if (roots_surface->pending_move_resize_configure_serial == 0) { view->x = x; view->y = y; }