Index: uspace/srv/hid/display/seat.c
===================================================================
--- uspace/srv/hid/display/seat.c	(revision 8a4ceaa18d4887f34b4452ea99ba93c9651a919d)
+++ uspace/srv/hid/display/seat.c	(revision acd7ac27615c878223fa2b8f1f6c1bdbd38cd3e3)
@@ -204,9 +204,9 @@
 
 	/* Find alternate window that is neither system nor minimized */
-	nwnd = ds_window_find_alt(wnd, ~(wndf_minimized | wndf_system));
+	nwnd = ds_window_find_prev(wnd, ~(wndf_minimized | wndf_system));
 
 	if (nwnd == NULL) {
 		/* Find alternate window that is not minimized */
-		nwnd = ds_window_find_alt(wnd, ~wndf_minimized);
+		nwnd = ds_window_find_prev(wnd, ~wndf_minimized);
 	}
 
@@ -224,5 +224,5 @@
 
 	/* Find alternate window that is not a system window */
-	nwnd = ds_window_find_alt(seat->focus, ~wndf_system);
+	nwnd = ds_window_find_next(seat->focus, ~wndf_system);
 
 	/* Only switch focus if there is another window */
Index: uspace/srv/hid/display/test/seat.c
===================================================================
--- uspace/srv/hid/display/test/seat.c	(revision 8a4ceaa18d4887f34b4452ea99ba93c9651a919d)
+++ uspace/srv/hid/display/test/seat.c	(revision acd7ac27615c878223fa2b8f1f6c1bdbd38cd3e3)
@@ -212,10 +212,12 @@
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
+	/* w0 is at the top, then w1, then w2 */
+
 	PCUT_ASSERT_EQUALS(w0, seat->focus);
 
 	ds_window_unfocus(w0);
 
-	/* The previous window, w2, should be focused now */
-	PCUT_ASSERT_EQUALS(w2, seat->focus);
+	/* The previous window, w1, should be focused now */
+	PCUT_ASSERT_EQUALS(w1, seat->focus);
 
 	ds_window_destroy(w0);
Index: uspace/srv/hid/display/test/window.c
===================================================================
--- uspace/srv/hid/display/test/window.c	(revision 8a4ceaa18d4887f34b4452ea99ba93c9651a919d)
+++ uspace/srv/hid/display/test/window.c	(revision acd7ac27615c878223fa2b8f1f6c1bdbd38cd3e3)
@@ -1169,6 +1169,6 @@
 }
 
-/** ds_window_find_alt() finds alternate window by flags */
-PCUT_TEST(window_find_alt)
+/** ds_window_find_next() finds next window by flags */
+PCUT_TEST(window_find_next)
 {
 	gfx_context_t *gc;
@@ -1210,11 +1210,69 @@
 	w2->flags |= wndf_system;
 
-	wnd = ds_window_find_alt(w0, wndf_minimized);
+	wnd = ds_window_find_next(w0, wndf_minimized);
 	PCUT_ASSERT_EQUALS(w1, wnd);
 
-	wnd = ds_window_find_alt(w0, wndf_system);
+	wnd = ds_window_find_next(w0, wndf_system);
 	PCUT_ASSERT_EQUALS(w2, wnd);
 
-	wnd = ds_window_find_alt(w0, wndf_maximized);
+	wnd = ds_window_find_next(w0, wndf_maximized);
+	PCUT_ASSERT_NULL(wnd);
+
+	ds_window_destroy(w0);
+	ds_window_destroy(w1);
+	ds_window_destroy(w2);
+	ds_seat_destroy(seat);
+	ds_client_destroy(client);
+	ds_display_destroy(disp);
+}
+
+/** ds_window_find_prev() finds previous window by flags */
+PCUT_TEST(window_find_prev)
+{
+	gfx_context_t *gc;
+	ds_display_t *disp;
+	ds_client_t *client;
+	ds_seat_t *seat;
+	ds_window_t *w0;
+	ds_window_t *w1;
+	ds_window_t *w2;
+	ds_window_t *wnd;
+	display_wnd_params_t params;
+	errno_t rc;
+
+	rc = gfx_context_new(&dummy_ops, NULL, &gc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = ds_display_create(gc, df_none, &disp);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = ds_client_create(disp, NULL, NULL, &client);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = ds_seat_create(disp, "Alice", &seat);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	display_wnd_params_init(&params);
+	params.rect.p0.x = params.rect.p0.y = 0;
+	params.rect.p1.x = params.rect.p1.y = 1;
+
+	rc = ds_window_create(client, &params, &w2);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	w2->flags |= wndf_system;
+
+	rc = ds_window_create(client, &params, &w1);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	w1->flags |= wndf_minimized;
+
+	rc = ds_window_create(client, &params, &w0);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	wnd = ds_window_find_prev(w0, wndf_minimized);
+	PCUT_ASSERT_EQUALS(w1, wnd);
+
+	wnd = ds_window_find_prev(w0, wndf_system);
+	PCUT_ASSERT_EQUALS(w2, wnd);
+
+	wnd = ds_window_find_prev(w0, wndf_maximized);
 	PCUT_ASSERT_NULL(wnd);
 
Index: uspace/srv/hid/display/window.c
===================================================================
--- uspace/srv/hid/display/window.c	(revision 8a4ceaa18d4887f34b4452ea99ba93c9651a919d)
+++ uspace/srv/hid/display/window.c	(revision acd7ac27615c878223fa2b8f1f6c1bdbd38cd3e3)
@@ -1092,5 +1092,44 @@
  * @return Alternate window matching the criteria or @c NULL if there is none
  */
-ds_window_t *ds_window_find_alt(ds_window_t *wnd,
+ds_window_t *ds_window_find_prev(ds_window_t *wnd,
+    display_wnd_flags_t allowed_flags)
+{
+	ds_window_t *nwnd;
+
+	/* Try preceding windows in display order */
+	nwnd = ds_display_next_window(wnd);
+	while (nwnd != NULL && (nwnd->flags & ~allowed_flags) != 0) {
+		nwnd = ds_display_next_window(nwnd);
+	}
+
+	/* Do we already have a matching window? */
+	if (nwnd != NULL && (nwnd->flags & ~allowed_flags) == 0) {
+		return nwnd;
+	}
+
+	/* Try succeeding windows in display order */
+	nwnd = ds_display_first_window(wnd->display);
+	while (nwnd != NULL && nwnd != wnd &&
+	    (nwnd->flags & ~allowed_flags) != 0) {
+		nwnd = ds_display_next_window(nwnd);
+	}
+
+	if (nwnd == wnd)
+		return NULL;
+
+	return nwnd;
+}
+
+/** Find alternate window with the allowed flags.
+ *
+ * An alternate window is a *different* window that is preferably previous
+ * in the display order and only has the @a allowed flags.
+ *
+ * @param wnd Window
+ * @param allowed_flags Bitmask of flags that the window is allowed to have
+ *
+ * @return Alternate window matching the criteria or @c NULL if there is none
+ */
+ds_window_t *ds_window_find_next(ds_window_t *wnd,
     display_wnd_flags_t allowed_flags)
 {
Index: uspace/srv/hid/display/window.h
===================================================================
--- uspace/srv/hid/display/window.h	(revision 8a4ceaa18d4887f34b4452ea99ba93c9651a919d)
+++ uspace/srv/hid/display/window.h	(revision acd7ac27615c878223fa2b8f1f6c1bdbd38cd3e3)
@@ -78,5 +78,6 @@
 extern errno_t ds_window_set_cursor(ds_window_t *, display_stock_cursor_t);
 extern errno_t ds_window_set_caption(ds_window_t *, const char *);
-extern ds_window_t *ds_window_find_alt(ds_window_t *, display_wnd_flags_t);
+extern ds_window_t *ds_window_find_next(ds_window_t *, display_wnd_flags_t);
+extern ds_window_t *ds_window_find_prev(ds_window_t *, display_wnd_flags_t);
 extern void ds_window_unfocus(ds_window_t *);
 extern bool ds_window_orig_seat(ds_window_t *, sysarg_t);
