Index: uspace/lib/ui/src/ui.c
===================================================================
--- uspace/lib/ui/src/ui.c	(revision 983052cc42855347de98acc1f926d82ed26c7a5d)
+++ uspace/lib/ui/src/ui.c	(revision 3d10a2fd37dcc38fbf91bdcdfeaa4f2c6938fd76)
@@ -1,4 +1,4 @@
 /*
- * Copyright (c) 2023 Jiri Svoboda
+ * Copyright (c) 2021 Jiri Svoboda
  * All rights reserved.
  *
@@ -39,7 +39,5 @@
 #include <errno.h>
 #include <fibril.h>
-#include <fibril_synch.h>
 #include <gfx/color.h>
-#include <gfx/cursor.h>
 #include <gfx/render.h>
 #include <io/console.h>
@@ -48,10 +46,7 @@
 #include <str.h>
 #include <task.h>
-#include <types/common.h>
-#include <ui/clickmatic.h>
 #include <ui/ui.h>
 #include <ui/wdecor.h>
 #include <ui/window.h>
-#include "../private/wdecor.h"
 #include "../private/window.h"
 #include "../private/ui.h"
@@ -66,18 +61,15 @@
  * @param ws Place to store window system type (protocol)
  * @param osvc Place to store pointer to output service name
- * @param ridev_id Place to store input device ID
- * @return EOK on success, EINVAL if syntax is invalid, ENOMEM if out of
- *         memory
- */
-static errno_t ui_ospec_parse(const char *ospec, ui_winsys_t *ws,
-    char **osvc, sysarg_t *ridev_id)
+ */
+static void ui_ospec_parse(const char *ospec, ui_winsys_t *ws,
+    const char **osvc)
 {
 	const char *cp;
-	const char *qm;
-	const char *endptr;
-	uint64_t idev_id;
-	errno_t rc;
-
-	*ridev_id = 0;
+
+	if (ospec == UI_DISPLAY_DEFAULT) {
+		*ws = ui_ws_display;
+		*osvc = DISPLAY_DEFAULT;
+		return;
+	}
 
 	cp = ospec;
@@ -85,5 +77,4 @@
 		++cp;
 
-	/* Window system / protocol */
 	if (*cp == '@') {
 		if (str_lcmp(ospec, "disp@", str_length("disp@")) == 0) {
@@ -93,54 +84,16 @@
 		} else if (str_lcmp(ospec, "null@", str_length("null@")) == 0) {
 			*ws = ui_ws_null;
-		} else if (str_lcmp(ospec, "@", str_length("@")) == 0) {
-			*ws = ui_ws_any;
 		} else {
 			*ws = ui_ws_unknown;
 		}
 
-		++cp;
+		if (cp[1] != '\0')
+			*osvc = cp + 1;
+		else
+			*osvc = NULL;
 	} else {
 		*ws = ui_ws_display;
-	}
-
-	/* Output service is the part before question mark */
-	qm = str_chr(cp, '?');
-	if (qm != NULL) {
-		*osvc = str_ndup(cp, qm - cp);
-	} else {
-		/* No question mark */
-		*osvc = str_dup(cp);
-	}
-
-	if (*osvc == NULL)
-		return ENOMEM;
-
-	if (qm != NULL) {
-		/* The part after the question mark */
-		cp = qm + 1;
-
-		/* Input device ID parameter */
-		if (str_lcmp(cp, "idev=", str_length("idev=")) == 0) {
-			cp += str_length("idev=");
-
-			rc = str_uint64_t(cp, &endptr, 10, false, &idev_id);
-			if (rc != EOK)
-				goto error;
-
-			*ridev_id = idev_id;
-			cp = endptr;
-		}
-	}
-
-	if (*cp != '\0') {
-		rc = EINVAL;
-		goto error;
-	}
-
-	return EOK;
-error:
-	free(*osvc);
-	*osvc = NULL;
-	return rc;
+		*osvc = ospec;
+	}
 }
 
@@ -161,43 +114,30 @@
 	console_gc_t *cgc;
 	ui_winsys_t ws;
-	char *osvc;
+	const char *osvc;
 	sysarg_t cols;
 	sysarg_t rows;
-	sysarg_t idev_id;
 	ui_t *ui;
 
-	rc = ui_ospec_parse(ospec, &ws, &osvc, &idev_id);
-	if (rc != EOK)
-		return rc;
-
-	if (ws == ui_ws_display || ws == ui_ws_any) {
-		rc = display_open((str_cmp(osvc, "") != 0) ? osvc :
-		    DISPLAY_DEFAULT, &display);
+	ui_ospec_parse(ospec, &ws, &osvc);
+
+	if (ws == ui_ws_display) {
+		rc = display_open(osvc, &display);
 		if (rc != EOK)
-			goto disp_fail;
+			return rc;
 
 		rc = ui_create_disp(display, &ui);
 		if (rc != EOK) {
 			display_close(display);
-			goto disp_fail;
-		}
-
-		free(osvc);
-		ui->myoutput = true;
-		ui->idev_id = idev_id;
-		*rui = ui;
-		return EOK;
-	}
-
-disp_fail:
-	if (ws == ui_ws_console || ws == ui_ws_any) {
+			return rc;
+		}
+	} else if (ws == ui_ws_console) {
 		console = console_init(stdin, stdout);
 		if (console == NULL)
-			goto cons_fail;
+			return EIO;
 
 		rc = console_get_size(console, &cols, &rows);
 		if (rc != EOK) {
 			console_done(console);
-			goto cons_fail;
+			return rc;
 		}
 
@@ -208,5 +148,5 @@
 		if (rc != EOK) {
 			console_done(console);
-			goto cons_fail;
+			return rc;
 		}
 
@@ -215,8 +155,6 @@
 			ui_destroy(ui);
 			console_done(console);
-			goto cons_fail;
-		}
-
-		free(osvc);
+			return rc;
+		}
 
 		ui->cgc = cgc;
@@ -227,23 +165,15 @@
 
 		(void) ui_paint(ui);
-		ui->myoutput = true;
-		*rui = ui;
-		return EOK;
-	}
-
-cons_fail:
-	if (ws == ui_ws_null) {
-		free(osvc);
+	} else if (ws == ui_ws_null) {
 		rc = ui_create_disp(NULL, &ui);
 		if (rc != EOK)
 			return rc;
-
-		ui->myoutput = true;
-		*rui = ui;
-		return EOK;
-	}
-
-	free(osvc);
-	return EINVAL;
+	} else {
+		return EINVAL;
+	}
+
+	ui->myoutput = true;
+	*rui = ui;
+	return EOK;
 }
 
@@ -256,5 +186,4 @@
 {
 	ui_t *ui;
-	errno_t rc;
 
 	ui = calloc(1, sizeof(ui_t));
@@ -262,13 +191,6 @@
 		return ENOMEM;
 
-	rc = ui_clickmatic_create(ui, &ui->clickmatic);
-	if (rc != EOK) {
-		free(ui);
-		return rc;
-	}
-
 	ui->console = console;
 	list_initialize(&ui->windows);
-	fibril_mutex_initialize(&ui->lock);
 	*rui = ui;
 	return EOK;
@@ -284,5 +206,4 @@
 {
 	ui_t *ui;
-	errno_t rc;
 
 	ui = calloc(1, sizeof(ui_t));
@@ -290,13 +211,6 @@
 		return ENOMEM;
 
-	rc = ui_clickmatic_create(ui, &ui->clickmatic);
-	if (rc != EOK) {
-		free(ui);
-		return rc;
-	}
-
 	ui->display = disp;
 	list_initialize(&ui->windows);
-	fibril_mutex_initialize(&ui->lock);
 	*rui = ui;
 	return EOK;
@@ -338,7 +252,5 @@
 	switch (event->type) {
 	case CEV_KEY:
-		ui_lock(ui);
 		ui_window_send_kbd(awnd, &event->ev.key);
-		ui_unlock(ui);
 		break;
 	case CEV_POS:
@@ -350,9 +262,6 @@
 		claim = ui_wdecor_pos_event(awnd->wdecor, &pos);
 		/* Note: If event is claimed, awnd might not be valid anymore */
-		if (claim == ui_unclaimed) {
-			ui_lock(ui);
+		if (claim == ui_unclaimed)
 			ui_window_send_pos(awnd, &pos);
-			ui_unlock(ui);
-		}
 
 		break;
@@ -446,137 +355,4 @@
 }
 
-/** Free up console for other users.
- *
- * Release console resources for another application (that the current
- * task is starting). After the other application finishes, resume
- * operation with ui_resume(). No calls to UI must happen inbetween
- * and no events must be processed (i.e. the calling function must not
- * return control to UI.
- *
- * @param ui UI
- * @return EOK on success or an error code
- */
-errno_t ui_suspend(ui_t *ui)
-{
-	errno_t rc;
-
-	assert(!ui->suspended);
-
-	if (ui->cgc == NULL) {
-		ui->suspended = true;
-		return EOK;
-	}
-
-	(void) console_set_caption(ui->console, "");
-	rc = console_gc_suspend(ui->cgc);
-	if (rc != EOK)
-		return rc;
-
-	ui->suspended = true;
-	return EOK;
-}
-
-/** Resume suspended UI.
- *
- * Reclaim console resources (after child application has finished running)
- * and restore UI operation previously suspended by calling ui_suspend().
- *
- * @param ui UI
- * @return EOK on success or an error code
- */
-errno_t ui_resume(ui_t *ui)
-{
-	errno_t rc;
-	ui_window_t *awnd;
-	sysarg_t col;
-	sysarg_t row;
-	cons_event_t ev;
-
-	assert(ui->suspended);
-
-	if (ui->cgc == NULL) {
-		ui->suspended = false;
-		return EOK;
-	}
-
-	rc = console_get_pos(ui->console, &col, &row);
-	if (rc != EOK)
-		return rc;
-
-	/*
-	 * Here's a little heuristic to help determine if we need
-	 * to pause before returning to the UI. If we are in the
-	 * top-left corner, chances are the screen is empty and
-	 * there is no need to pause.
-	 */
-	if (col != 0 || row != 0) {
-		printf("Press any key or button to continue...\n");
-
-		while (true) {
-			rc = console_get_event(ui->console, &ev);
-			if (rc != EOK)
-				return EIO;
-
-			if (ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS)
-				break;
-
-			if (ev.type == CEV_POS && ev.ev.pos.type == POS_PRESS)
-				break;
-		}
-	}
-
-	rc = console_gc_resume(ui->cgc);
-	if (rc != EOK)
-		return rc;
-
-	ui->suspended = false;
-
-	awnd = ui_window_get_active(ui);
-	if (awnd != NULL)
-		(void) console_set_caption(ui->console, awnd->wdecor->caption);
-
-	rc = gfx_cursor_set_visible(console_gc_get_ctx(ui->cgc), false);
-	if (rc != EOK)
-		return rc;
-
-	return EOK;
-}
-
-/** Determine if UI is suspended.
- *
- * @param ui UI
- * @return @c true iff UI is suspended
- */
-bool ui_is_suspended(ui_t *ui)
-{
-	return ui->suspended;
-}
-
-/** Lock UI.
- *
- * Block UI from calling window callbacks. @c ui_lock() and @c ui_unlock()
- * must be used when accessing UI resources from a fibril (as opposed to
- * from a window callback).
- *
- * @param ui UI
- */
-void ui_lock(ui_t *ui)
-{
-	fibril_mutex_lock(&ui->lock);
-}
-
-/** Unlock UI.
- *
- * Allow UI to call window callbacks. @c ui_lock() and @c ui_unlock()
- * must be used when accessing window resources from a fibril (as opposed to
- * from a window callback).
- *
- * @param ui UI
- */
-void ui_unlock(ui_t *ui)
-{
-	fibril_mutex_unlock(&ui->lock);
-}
-
 /** Terminate user interface.
  *
@@ -616,47 +392,4 @@
 }
 
-/** Get UI screen rectangle.
- *
- * @param ui User interface
- * @param rect Place to store bounding rectangle
- */
-errno_t ui_get_rect(ui_t *ui, gfx_rect_t *rect)
-{
-	display_info_t info;
-	sysarg_t cols, rows;
-	errno_t rc;
-
-	if (ui->display != NULL) {
-		rc = display_get_info(ui->display, &info);
-		if (rc != EOK)
-			return rc;
-
-		*rect = info.rect;
-	} else if (ui->console != NULL) {
-		rc = console_get_size(ui->console, &cols, &rows);
-		if (rc != EOK)
-			return rc;
-
-		rect->p0.x = 0;
-		rect->p0.y = 0;
-		rect->p1.x = cols;
-		rect->p1.y = rows;
-	} else {
-		return ENOTSUP;
-	}
-
-	return EOK;
-}
-
-/** Get clickmatic from UI.
- *
- * @pararm ui UI
- * @return Clickmatic
- */
-ui_clickmatic_t *ui_get_clickmatic(ui_t *ui)
-{
-	return ui->clickmatic;
-}
-
 /** @}
  */
