[PATCH 1/2] RDP compositor: make the seat dynamic and don't destroy it on removal

David FORT rdp.effort at gmail.com
Tue May 19 01:07:39 PDT 2015


This patch makes the seat dynamic and leak it on purpose during seat removal to
prevent the ghost object case.
---
 src/compositor-rdp.c | 39 +++++++++++++++++++++++++++------------
 1 file changed, 27 insertions(+), 12 deletions(-)

diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
index 3185141..f1dcda0 100644
--- a/src/compositor-rdp.c
+++ b/src/compositor-rdp.c
@@ -105,7 +105,7 @@ enum peer_item_flags {
 struct rdp_peers_item {
 	int flags;
 	freerdp_peer *peer;
-	struct weston_seat seat;
+	struct weston_seat *seat;
 
 	struct wl_list link;
 };
@@ -606,6 +606,7 @@ static void
 rdp_peer_context_free(freerdp_peer* client, RdpPeerContext* context)
 {
 	int i;
+	struct weston_seat *seat;
 	if (!context)
 		return;
 
@@ -616,9 +617,17 @@ rdp_peer_context_free(freerdp_peer* client, RdpPeerContext* context)
 	}
 
 	if (context->item.flags & RDP_PEER_ACTIVATED) {
-		weston_seat_release_keyboard(&context->item.seat);
-		weston_seat_release_pointer(&context->item.seat);
-		weston_seat_release(&context->item.seat);
+		seat = context->item.seat;
+		weston_seat_release_keyboard(seat);
+		weston_seat_release_pointer(seat);
+
+		/* picked from weston_seat_release(context->item.seat); */
+		wl_list_remove(&seat->link);
+		if (seat->saved_kbd_focus)
+			wl_list_remove(&seat->saved_kbd_focus_listener.link);
+		wl_global_destroy(seat->global);
+		wl_signal_emit(&seat->destroy_signal, seat);
+
 	}
 
 	Stream_Free(context->encode_stream, TRUE);
@@ -887,9 +896,15 @@ xf_peer_activate(freerdp_peer* client)
 	else
 		snprintf(seat_name, sizeof(seat_name), "RDP peer @%s", settings->ClientAddress);
 
-	weston_seat_init(&peersItem->seat, &c->base, seat_name);
-	weston_seat_init_keyboard(&peersItem->seat, keymap);
-	weston_seat_init_pointer(&peersItem->seat);
+	peersItem->seat = zalloc(sizeof(*peersItem->seat));
+	if (!peersItem->seat) {
+		weston_log("unable to allocate the seat for %s", seat_name);
+		return FALSE;
+	}
+
+	weston_seat_init(peersItem->seat, &c->base, seat_name);
+	weston_seat_init_keyboard(peersItem->seat, keymap);
+	weston_seat_init_pointer(peersItem->seat);
 
 	peersItem->flags |= RDP_PEER_ACTIVATED;
 
@@ -929,7 +944,7 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, UINT16 y) {
 		if (x < output->base.width && y < output->base.height) {
 			wl_x = wl_fixed_from_int((int)x);
 			wl_y = wl_fixed_from_int((int)y);
-			notify_motion_absolute(&peerContext->item.seat, weston_compositor_get_time(),
+			notify_motion_absolute(peerContext->item.seat, weston_compositor_get_time(),
 					wl_x, wl_y);
 		}
 	}
@@ -942,7 +957,7 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, UINT16 y) {
 		button = BTN_MIDDLE;
 
 	if (button) {
-		notify_button(&peerContext->item.seat, weston_compositor_get_time(), button,
+		notify_button(peerContext->item.seat, weston_compositor_get_time(), button,
 			(flags & PTR_FLAGS_DOWN) ? WL_POINTER_BUTTON_STATE_PRESSED : WL_POINTER_BUTTON_STATE_RELEASED
 		);
 	}
@@ -958,7 +973,7 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, UINT16 y) {
 		if (flags & PTR_FLAGS_WHEEL_NEGATIVE)
 			axis = -axis;
 
-		notify_axis(&peerContext->item.seat, weston_compositor_get_time(),
+		notify_axis(peerContext->item.seat, weston_compositor_get_time(),
 					    WL_POINTER_AXIS_VERTICAL_SCROLL,
 					    axis);
 	}
@@ -976,7 +991,7 @@ xf_extendedMouseEvent(rdpInput *input, UINT16 flags, UINT16 x, UINT16 y) {
 	if (x < output->base.width && y < output->base.height) {
 		wl_x = wl_fixed_from_int((int)x);
 		wl_y = wl_fixed_from_int((int)y);
-		notify_motion_absolute(&peerContext->item.seat, weston_compositor_get_time(),
+		notify_motion_absolute(peerContext->item.seat, weston_compositor_get_time(),
 				wl_x, wl_y);
 	}
 
@@ -1039,7 +1054,7 @@ xf_input_keyboard_event(rdpInput *input, UINT16 flags, UINT16 code)
 
 		/*weston_log("code=%x ext=%d vk_code=%x scan_code=%x\n", code, (flags & KBD_FLAGS_EXTENDED) ? 1 : 0,
 				vk_code, scan_code);*/
-		notify_key(&peerContext->item.seat, weston_compositor_get_time(),
+		notify_key(peerContext->item.seat, weston_compositor_get_time(),
 					scan_code - 8, keyState, STATE_UPDATE_AUTOMATIC);
 	}
 
-- 
1.9.1



More information about the wayland-devel mailing list