Index: uspace/srv/hid/display/seat.c
===================================================================
--- uspace/srv/hid/display/seat.c	(revision 1543d4c8f0b837462c81435cd51f0aed2abf865b)
+++ uspace/srv/hid/display/seat.c	(revision d7f82635cf4b387fce37f7f70fc8cc0cffde419b)
@@ -1,4 +1,4 @@
 /*
- * Copyright (c) 2023 Jiri Svoboda
+ * Copyright (c) 2021 Jiri Svoboda
  * All rights reserved.
  *
@@ -39,9 +39,7 @@
 #include <gfx/render.h>
 #include <stdlib.h>
-#include <str.h>
 #include "client.h"
 #include "cursor.h"
 #include "display.h"
-#include "idevcfg.h"
 #include "seat.h"
 #include "window.h"
@@ -53,20 +51,10 @@
  *
  * @param display Parent display
- * @param name Seat name
  * @param rseat Place to store pointer to new seat.
  * @return EOK on success, ENOMEM if out of memory
  */
-errno_t ds_seat_create(ds_display_t *display, const char *name,
-    ds_seat_t **rseat)
+errno_t ds_seat_create(ds_display_t *display, ds_seat_t **rseat)
 {
 	ds_seat_t *seat;
-	ds_seat_t *s0;
-
-	s0 = ds_display_first_seat(display);
-	while (s0 != NULL) {
-		if (str_cmp(s0->name, name) == 0)
-			return EEXIST;
-		s0 = ds_display_next_seat(s0);
-	}
 
 	seat = calloc(1, sizeof(ds_seat_t));
@@ -74,12 +62,4 @@
 		return ENOMEM;
 
-	seat->name = str_dup(name);
-	if (seat->name == NULL) {
-		free(seat);
-		return ENOMEM;
-	}
-
-	list_initialize(&seat->idevcfgs);
-
 	ds_display_add_seat(display, seat);
 	seat->pntpos.x = 0;
@@ -88,5 +68,4 @@
 	seat->client_cursor = display->cursor[dcurs_arrow];
 	seat->wm_cursor = NULL;
-	seat->focus = ds_display_first_window(display);
 
 	*rseat = seat;
@@ -100,20 +79,5 @@
 void ds_seat_destroy(ds_seat_t *seat)
 {
-	ds_idevcfg_t *idevcfg;
-
-	/* Remove all input device configuration entries pointing to this seat */
-	idevcfg = ds_seat_first_idevcfg(seat);
-	while (idevcfg != NULL) {
-		ds_idevcfg_destroy(idevcfg);
-		idevcfg = ds_seat_first_idevcfg(seat);
-	}
-
-	/* Remove this seat's focus */
-	if (seat->focus != NULL)
-		ds_window_post_unfocus_event(seat->focus);
-
 	ds_display_remove_seat(seat);
-
-	free(seat->name);
 	free(seat);
 }
@@ -126,15 +90,7 @@
 void ds_seat_set_focus(ds_seat_t *seat, ds_window_t *wnd)
 {
-	errno_t rc;
-
 	if (wnd == seat->focus) {
 		/* Focus is not changing */
 		return;
-	}
-
-	if (wnd != NULL) {
-		rc = ds_window_unminimize(wnd);
-		if (rc != EOK)
-			return;
 	}
 
@@ -174,14 +130,23 @@
 /** Evacuate seat references to window.
  *
- * If seat's focus is @a wnd, it will be set to NULL.
+ * If seat's focus is @a wnd, it will be set to a different window.
  * If seat's popup window is @a wnd, it will be set to NULL.
  *
  * @param seat Seat
- * @param wnd Window to evacuate references from
+ * @param wnd Window to evacuate focus from
  */
 void ds_seat_evac_wnd_refs(ds_seat_t *seat, ds_window_t *wnd)
 {
-	if (seat->focus == wnd)
-		ds_seat_set_focus(seat, NULL);
+	ds_window_t *nwnd;
+
+	if (seat->focus == wnd) {
+		nwnd = ds_display_prev_window(wnd);
+		if (nwnd == NULL)
+			nwnd = ds_display_last_window(wnd->display);
+		if (nwnd == wnd)
+			nwnd = NULL;
+
+		ds_seat_set_focus(seat, nwnd);
+	}
 
 	if (seat->popup == wnd)
@@ -189,48 +154,21 @@
 }
 
-/** Unfocus window.
- *
- * If seat's focus is @a wnd, it will be set to a different window
- * that is not minimized, preferably not a system window.
- *
- * @param seat Seat
- * @param wnd Window to remove focus from
- */
-void ds_seat_unfocus_wnd(ds_seat_t *seat, ds_window_t *wnd)
+/** Switch focus to another window.
+ *
+ * @param seat Seat
+ * @param wnd Window to evacuate focus from
+ */
+void ds_seat_switch_focus(ds_seat_t *seat)
 {
 	ds_window_t *nwnd;
 
-	if (seat->focus != wnd)
-		return;
-
-	/* Find alternate window that is neither system nor minimized */
-	nwnd = ds_window_find_prev(wnd, ~(wndf_minimized | wndf_system));
-
-	if (nwnd == NULL) {
-		/* Find alternate window that is not minimized */
-		nwnd = ds_window_find_prev(wnd, ~wndf_minimized);
-	}
-
-	ds_seat_set_focus(seat, nwnd);
-}
-
-/** Switch focus to another window.
- *
- * @param seat Seat
- * @param wnd Window to evacuate focus from
- */
-void ds_seat_switch_focus(ds_seat_t *seat)
-{
-	ds_window_t *nwnd;
-
-	if (seat->focus != NULL) {
-		/* Find alternate window that is not a system window */
-		nwnd = ds_window_find_next(seat->focus, ~wndf_system);
-	} else {
-		/* Currently no focus. Focus topmost window. */
-		nwnd = ds_display_first_window(seat->display);
-	}
-
-	/* Only switch focus if there is another window */
+	if (seat->focus != NULL)
+		nwnd = ds_display_prev_window(seat->focus);
+	else
+		nwnd = NULL;
+
+	if (nwnd == NULL)
+		nwnd = ds_display_last_window(seat->display);
+
 	if (nwnd != NULL)
 		ds_seat_set_focus(seat, nwnd);
@@ -424,21 +362,8 @@
 	}
 
-	if (event->type == PTD_PRESS || event->type == PTD_RELEASE ||
-	    event->type == PTD_DCLICK) {
-		pevent.pos_id = event->pos_id;
-		switch (event->type) {
-		case PTD_PRESS:
-			pevent.type = POS_PRESS;
-			break;
-		case PTD_RELEASE:
-			pevent.type = POS_RELEASE;
-			break;
-		case PTD_DCLICK:
-			pevent.type = POS_DCLICK;
-			break;
-		default:
-			assert(false);
-		}
-
+	if (event->type == PTD_PRESS || event->type == PTD_RELEASE) {
+		pevent.pos_id = 0;
+		pevent.type = (event->type == PTD_PRESS) ?
+		    POS_PRESS : POS_RELEASE;
 		pevent.btn_num = event->btn_num;
 		pevent.hpos = seat->pntpos.x;
@@ -457,5 +382,5 @@
 		seat->pntpos = npos;
 
-		pevent.pos_id = event->pos_id;
+		pevent.pos_id = 0;
 		pevent.type = POS_UPDATE;
 		pevent.btn_num = 0;
@@ -485,5 +410,5 @@
 		seat->pntpos = npos;
 
-		pevent.pos_id = event->pos_id;
+		pevent.pos_id = 0;
 		pevent.type = POS_UPDATE;
 		pevent.btn_num = 0;
@@ -515,6 +440,12 @@
 	wnd = ds_display_window_by_pos(seat->display, &seat->pntpos);
 
+	/* Click outside popup window */
+	if (event->type == POS_PRESS && wnd != seat->popup) {
+		/* Close popup window */
+		ds_seat_set_popup(seat, NULL);
+	}
+
 	/* Deliver event to popup window. */
-	if (seat->popup != NULL && event->type != POS_PRESS) {
+	if (seat->popup != NULL) {
 		rc = ds_window_post_pos_event(seat->popup, event);
 		if (rc != EOK)
@@ -540,5 +471,5 @@
 		 * to the same window above.
 		 */
-		if (wnd != seat->popup || event->type == POS_PRESS) {
+		if (wnd != seat->popup) {
 			rc = ds_window_post_pos_event(wnd, event);
 			if (rc != EOK)
@@ -550,10 +481,4 @@
 	}
 
-	/* Click outside popup window */
-	if (event->type == POS_PRESS && wnd != seat->popup) {
-		/* Close popup window */
-		ds_seat_set_popup(seat, NULL);
-	}
-
 	return EOK;
 }
@@ -572,58 +497,4 @@
 }
 
-/** Add input device configuration entry to seat.
- *
- * @param seat Seat
- * @param idevcfg Input device configuration
- */
-void ds_seat_add_idevcfg(ds_seat_t *seat, ds_idevcfg_t *idevcfg)
-{
-	assert(idevcfg->seat == NULL);
-	assert(!link_used(&idevcfg->lseatidcfgs));
-
-	idevcfg->seat = seat;
-	list_append(&idevcfg->lseatidcfgs, &seat->idevcfgs);
-}
-
-/** Remove input device configuration entry from seat.
- *
- * @param idevcfg Input device configuration entry
- */
-void ds_seat_remove_idevcfg(ds_idevcfg_t *idevcfg)
-{
-	list_remove(&idevcfg->lseatidcfgs);
-	idevcfg->seat = NULL;
-}
-
-/** Get first input device configuration entry in seat.
- *
- * @param disp Display
- * @return First input device configuration entry or @c NULL if there is none
- */
-ds_idevcfg_t *ds_seat_first_idevcfg(ds_seat_t *seat)
-{
-	link_t *link = list_first(&seat->idevcfgs);
-
-	if (link == NULL)
-		return NULL;
-
-	return list_get_instance(link, ds_idevcfg_t, lseatidcfgs);
-}
-
-/** Get next input device configuration entry in seat.
- *
- * @param idevcfg Current input device configuration entry
- * @return Next input device configuration entry or @c NULL if there is none
- */
-ds_idevcfg_t *ds_seat_next_idevcfg(ds_idevcfg_t *idevcfg)
-{
-	link_t *link = list_next(&idevcfg->lseatidcfgs, &idevcfg->seat->idevcfgs);
-
-	if (link == NULL)
-		return NULL;
-
-	return list_get_instance(link, ds_idevcfg_t, lseatidcfgs);
-}
-
 /** @}
  */
