Index: uspace/app/uidemo/uidemo.c
===================================================================
--- uspace/app/uidemo/uidemo.c	(revision f7a90df6adfcf1a8e402e71eed9795cd4e9eabf6)
+++ uspace/app/uidemo/uidemo.c	(revision d284ce9c9580c7380258756c41f4a9b67073797c)
@@ -33,8 +33,8 @@
  */
 
-#include <display.h>
 #include <gfx/color.h>
 #include <gfx/coord.h>
 #include <gfx/render.h>
+#include <io/pos_event.h>
 #include <stdio.h>
 #include <str.h>
@@ -43,19 +43,15 @@
 #include <ui/pbutton.h>
 #include <ui/resource.h>
+#include <ui/ui.h>
 #include <ui/wdecor.h>
+#include <ui/window.h>
 #include "uidemo.h"
 
-static void wnd_close_event(void *);
-static void wnd_focus_event(void *);
-static void wnd_kbd_event(void *, kbd_event_t *);
-static void wnd_pos_event(void *, pos_event_t *);
-static void wnd_unfocus_event(void *);
-
-static display_wnd_cb_t wnd_cb = {
-	.close_event = wnd_close_event,
-	.focus_event = wnd_focus_event,
-	.kbd_event = wnd_kbd_event,
-	.pos_event = wnd_pos_event,
-	.unfocus_event = wnd_unfocus_event
+static void wnd_close(ui_window_t *, void *);
+static void wnd_pos(ui_window_t *, void *, pos_event_t *pos);
+
+static ui_window_cb_t window_cb = {
+	.close = wnd_close,
+	.pos = wnd_pos
 };
 
@@ -66,68 +62,31 @@
 };
 
-static void wd_close(ui_wdecor_t *, void *);
-static void wd_move(ui_wdecor_t *, void *, gfx_coord2_t *);
-
-static ui_wdecor_cb_t wdecor_cb = {
-	.close = wd_close,
-	.move = wd_move
-};
-
-/** Print syntax. */
-static void print_syntax(void)
-{
-	printf("Syntax: uidemo [-d <display>]\n");
-}
-
-/** Handle window close event. */
-static void wnd_close_event(void *arg)
+/** Window close button was clicked.
+ *
+ * @param window Window
+ * @param arg Argument (demo)
+ */
+static void wnd_close(ui_window_t *window, void *arg)
 {
 	ui_demo_t *demo = (ui_demo_t *) arg;
 
-	demo->quit = true;
-}
-
-/** Handle window focus event. */
-static void wnd_focus_event(void *arg)
+	ui_quit(demo->ui);
+}
+
+/** Window position event.
+ *
+ * @param window Window
+ * @param arg Argument (demo)
+ */
+static void wnd_pos(ui_window_t *window, void *arg, pos_event_t *event)
 {
 	ui_demo_t *demo = (ui_demo_t *) arg;
 
-	if (demo->wdecor != NULL) {
-		ui_wdecor_set_active(demo->wdecor, true);
-		ui_wdecor_paint(demo->wdecor);
-	}
-}
-
-/** Handle window keyboard event */
-static void wnd_kbd_event(void *arg, kbd_event_t *event)
-{
-	ui_demo_t *demo = (ui_demo_t *) arg;
-
-	(void) demo;
-}
-
-/** Handle window position event */
-static void wnd_pos_event(void *arg, pos_event_t *event)
-{
-	ui_demo_t *demo = (ui_demo_t *) arg;
-
 	/* Make sure we don't process events until fully initialized */
-	if (demo->wdecor == NULL || demo->pb1 == NULL || demo->pb2 == NULL)
+	if (demo->pb1 == NULL || demo->pb2 == NULL)
 		return;
 
-	ui_wdecor_pos_event(demo->wdecor, event);
 	ui_pbutton_pos_event(demo->pb1, event);
 	ui_pbutton_pos_event(demo->pb2, event);
-}
-
-/** Handle window unfocus event. */
-static void wnd_unfocus_event(void *arg)
-{
-	ui_demo_t *demo = (ui_demo_t *) arg;
-
-	if (demo->wdecor != NULL) {
-		ui_wdecor_set_active(demo->wdecor, false);
-		ui_wdecor_paint(demo->wdecor);
-	}
 }
 
@@ -155,49 +114,26 @@
 }
 
-/** Window decoration requested window closure.
- *
- * @param wdecor Window decoration
- * @param arg Argument (demo)
- */
-static void wd_close(ui_wdecor_t *wdecor, void *arg)
-{
-	ui_demo_t *demo = (ui_demo_t *) arg;
-
-	demo->quit = true;
-}
-
-/** Window decoration requested window move.
- *
- * @param wdecor Window decoration
- * @param arg Argument (demo)
- * @param pos Position where the title bar was pressed
- */
-static void wd_move(ui_wdecor_t *wdecor, void *arg, gfx_coord2_t *pos)
-{
-	ui_demo_t *demo = (ui_demo_t *) arg;
-
-	(void) display_window_move_req(demo->dwindow, pos);
-}
-
 /** Run UI demo on display server. */
-static errno_t ui_demo_display(const char *display_svc)
-{
-	display_t *display = NULL;
-	gfx_context_t *gc;
-	display_wnd_params_t params;
-	display_window_t *window = NULL;
-	ui_resource_t *ui_res;
+static errno_t ui_demo(const char *display_spec)
+{
+	ui_t *ui = NULL;
+	ui_wnd_params_t params;
+	ui_window_t *window = NULL;
 	ui_demo_t demo;
 	gfx_rect_t rect;
-	gfx_color_t *color = NULL;
+	gfx_rect_t app_rect;
+	gfx_color_t *color;
+	ui_resource_t *ui_res;
+	gfx_context_t *gc;
 	errno_t rc;
 
-	rc = display_open(display_svc, &display);
-	if (rc != EOK) {
-		printf("Error opening display.\n");
-		return rc;
-	}
-
-	display_wnd_params_init(&params);
+	rc = ui_create(display_spec, &ui);
+	if (rc != EOK) {
+		printf("Error creating UI on display %s.\n", display_spec);
+		return rc;
+	}
+
+	ui_wnd_params_init(&params);
+	params.caption = "UI Demo";
 	params.rect.p0.x = 0;
 	params.rect.p0.y = 0;
@@ -206,7 +142,7 @@
 
 	memset((void *) &demo, 0, sizeof(demo));
-
-	rc = display_window_create(display, &params, &wnd_cb, (void *) &demo,
-	    &window);
+	demo.ui = ui;
+
+	rc = ui_window_create(ui, &params, &window);
 	if (rc != EOK) {
 		printf("Error creating window.\n");
@@ -214,29 +150,12 @@
 	}
 
-	demo.quit = false;
-	demo.dwindow = window;
-
-	rc = display_window_get_gc(window, &gc);
-	if (rc != EOK) {
-		printf("Error getting graphics context.\n");
-		return rc;
-	}
+	ui_window_set_cb(window, &window_cb, (void *) &demo);
+	demo.window = window;
 
 	task_retval(0);
 
-	rc = ui_resource_create(gc, &ui_res);
-	if (rc != EOK) {
-		printf("Error creating UI.\n");
-		return rc;
-	}
-
-	rc = ui_wdecor_create(ui_res, "UI Demo", &demo.wdecor);
-	if (rc != EOK) {
-		printf("Error creating window decoration.\n");
-		return rc;
-	}
-
-	ui_wdecor_set_rect(demo.wdecor, &params.rect);
-	ui_wdecor_set_cb(demo.wdecor, &wdecor_cb, (void *) &demo);
+	ui_res = ui_window_get_res(window);
+	gc = ui_window_get_gc(window);
+	ui_window_get_app_rect(window, &app_rect);
 
 	rc = ui_label_create(ui_res, "Hello there!", &demo.label);
@@ -295,5 +214,5 @@
 	}
 
-	rc = gfx_fill_rect(gc, &params.rect);
+	rc = gfx_fill_rect(gc, &app_rect);
 	if (rc != EOK) {
 		printf("Error filling background.\n");
@@ -301,13 +220,4 @@
 	}
 
-	gfx_color_delete(color);
-	color = NULL;
-
-	rc = ui_wdecor_paint(demo.wdecor);
-	if (rc != EOK) {
-		printf("Error painting window decoration.\n");
-		return rc;
-	}
-
 	rc = ui_label_paint(demo.label);
 	if (rc != EOK) {
@@ -328,25 +238,23 @@
 	}
 
-	while (!demo.quit) {
-		fibril_usleep(100 * 1000);
-	}
-
-	ui_wdecor_destroy(demo.wdecor);
+	ui_run(ui);
+
 	ui_pbutton_destroy(demo.pb1);
 	ui_pbutton_destroy(demo.pb2);
 
-	rc = gfx_context_delete(gc);
-	if (rc != EOK)
-		return rc;
-
-	display_window_destroy(window);
-	display_close(display);
+	ui_window_destroy(window);
+	ui_destroy(ui);
 
 	return EOK;
 }
 
+static void print_syntax(void)
+{
+	printf("Syntax: uidemo [-d <display-spec>]\n");
+}
+
 int main(int argc, char *argv[])
 {
-	const char *display_svc = DISPLAY_DEFAULT;
+	const char *display_spec = UI_DISPLAY_DEFAULT;
 	errno_t rc;
 	int i;
@@ -362,5 +270,5 @@
 			}
 
-			display_svc = argv[i++];
+			display_spec = argv[i++];
 		} else {
 			printf("Invalid option '%s'.\n", argv[i]);
@@ -375,5 +283,5 @@
 	}
 
-	rc = ui_demo_display(display_svc);
+	rc = ui_demo(display_spec);
 	if (rc != EOK)
 		return 1;
Index: uspace/app/uidemo/uidemo.h
===================================================================
--- uspace/app/uidemo/uidemo.h	(revision f7a90df6adfcf1a8e402e71eed9795cd4e9eabf6)
+++ uspace/app/uidemo/uidemo.h	(revision d284ce9c9580c7380258756c41f4a9b67073797c)
@@ -40,14 +40,14 @@
 #include <ui/label.h>
 #include <ui/pbutton.h>
-#include <ui/wdecor.h>
+#include <ui/ui.h>
+#include <ui/window.h>
 
 /** User interface demo */
 typedef struct {
-	display_window_t *dwindow;
-	ui_wdecor_t *wdecor;
+	ui_t *ui;
+	ui_window_t *window;
 	ui_label_t *label;
 	ui_pbutton_t *pb1;
 	ui_pbutton_t *pb2;
-	bool quit;
 } ui_demo_t;
 
Index: uspace/lib/ui/include/types/ui/window.h
===================================================================
--- uspace/lib/ui/include/types/ui/window.h	(revision f7a90df6adfcf1a8e402e71eed9795cd4e9eabf6)
+++ uspace/lib/ui/include/types/ui/window.h	(revision d284ce9c9580c7380258756c41f4a9b67073797c)
@@ -37,4 +37,6 @@
 #define _UI_TYPES_WINDOW_H
 
+#include <io/pos_event.h>
+
 struct ui_window;
 typedef struct ui_window ui_window_t;
@@ -43,8 +45,14 @@
 typedef struct {
 	/** Window rectangle */
-	gfx_rect_t *rect;
+	gfx_rect_t rect;
 	/** Window caption */
 	const char *caption;
-} ui_window_params_t;
+} ui_wnd_params_t;
+
+/** Window callbacks */
+typedef struct ui_window_cb {
+	void (*close)(ui_window_t *, void *);
+	void (*pos)(ui_window_t *, void *, pos_event_t *);
+} ui_window_cb_t;
 
 #endif
Index: uspace/lib/ui/include/ui/ui.h
===================================================================
--- uspace/lib/ui/include/ui/ui.h	(revision f7a90df6adfcf1a8e402e71eed9795cd4e9eabf6)
+++ uspace/lib/ui/include/ui/ui.h	(revision d284ce9c9580c7380258756c41f4a9b67073797c)
@@ -44,4 +44,6 @@
 extern errno_t ui_create_disp(display_t *, ui_t **);
 extern void ui_destroy(ui_t *);
+extern void ui_quit(ui_t *);
+extern void ui_run(ui_t *);
 
 #endif
Index: uspace/lib/ui/include/ui/window.h
===================================================================
--- uspace/lib/ui/include/ui/window.h	(revision f7a90df6adfcf1a8e402e71eed9795cd4e9eabf6)
+++ uspace/lib/ui/include/ui/window.h	(revision d284ce9c9580c7380258756c41f4a9b67073797c)
@@ -38,11 +38,18 @@
 
 #include <errno.h>
+#include <gfx/context.h>
+#include <gfx/coord.h>
 #include <types/ui/ui.h>
+#include <types/ui/resource.h>
 #include <types/ui/window.h>
 
-extern void ui_window_params_init(ui_window_params_t *);
-extern errno_t ui_window_create(ui_t *, ui_window_params_t *,
+extern void ui_wnd_params_init(ui_wnd_params_t *);
+extern errno_t ui_window_create(ui_t *, ui_wnd_params_t *,
     ui_window_t **);
+extern void ui_window_set_cb(ui_window_t *, ui_window_cb_t *, void *);
 extern void ui_window_destroy(ui_window_t *);
+extern ui_resource_t *ui_window_get_res(ui_window_t *);
+extern gfx_context_t *ui_window_get_gc(ui_window_t *);
+extern void ui_window_get_app_rect(ui_window_t *, gfx_rect_t *);
 
 #endif
Index: uspace/lib/ui/private/ui.h
===================================================================
--- uspace/lib/ui/private/ui.h	(revision f7a90df6adfcf1a8e402e71eed9795cd4e9eabf6)
+++ uspace/lib/ui/private/ui.h	(revision d284ce9c9580c7380258756c41f4a9b67073797c)
@@ -50,4 +50,6 @@
 	/** Output owned by UI, clean up when destroying UI */
 	bool myoutput;
+	/** @c true if terminating */
+	bool quit;
 };
 
Index: uspace/lib/ui/private/window.h
===================================================================
--- uspace/lib/ui/private/window.h	(revision f7a90df6adfcf1a8e402e71eed9795cd4e9eabf6)
+++ uspace/lib/ui/private/window.h	(revision d284ce9c9580c7380258756c41f4a9b67073797c)
@@ -40,4 +40,5 @@
 #include <display.h>
 #include <gfx/context.h>
+#include <io/pos_event.h>
 
 /** Actual structure of window.
@@ -48,4 +49,8 @@
 	/** Containing user interface */
 	struct ui *ui;
+	/** Callbacks */
+	struct ui_window_cb *cb;
+	/** Callback argument */
+	void *arg;
 	/** Display window */
 	display_window_t *dwindow;
@@ -58,4 +63,7 @@
 };
 
+extern void ui_window_close(ui_window_t *);
+extern void ui_window_pos(ui_window_t *, pos_event_t *);
+
 #endif
 
Index: uspace/lib/ui/src/ui.c
===================================================================
--- uspace/lib/ui/src/ui.c	(revision f7a90df6adfcf1a8e402e71eed9795cd4e9eabf6)
+++ uspace/lib/ui/src/ui.c	(revision d284ce9c9580c7380258756c41f4a9b67073797c)
@@ -36,4 +36,5 @@
 #include <display.h>
 #include <errno.h>
+#include <fibril.h>
 #include <stdlib.h>
 #include <ui/ui.h>
@@ -65,4 +66,5 @@
 	ui->display = display;
 	ui->myoutput = true;
+	*rui = ui;
 	return EOK;
 }
@@ -101,4 +103,30 @@
 }
 
+/** Execute user interface.
+ *
+ * This function returns once the application starts the termination
+ * process by calling ui_quit(@a ui).
+ *
+ * @param ui User interface
+ */
+void ui_run(ui_t *ui)
+{
+	while (!ui->quit)
+		fibril_usleep(100000);
+}
+
+/** Terminate user interface.
+ *
+ * Calling this function causes the user interface to terminate
+ * (i.e. exit from ui_run()). This would be typically called from
+ * an event handler.
+ *
+ * @param ui User interface
+ */
+void ui_quit(ui_t *ui)
+{
+	ui->quit = true;
+}
+
 /** @}
  */
Index: uspace/lib/ui/src/wdecor.c
===================================================================
--- uspace/lib/ui/src/wdecor.c	(revision f7a90df6adfcf1a8e402e71eed9795cd4e9eabf6)
+++ uspace/lib/ui/src/wdecor.c	(revision d284ce9c9580c7380258756c41f4a9b67073797c)
@@ -226,5 +226,4 @@
  *
  * @param wdecor Window decoration
- * @param pos Position where the title bar was pressed
  */
 void ui_wdecor_close(ui_wdecor_t *wdecor)
Index: uspace/lib/ui/src/window.c
===================================================================
--- uspace/lib/ui/src/window.c	(revision f7a90df6adfcf1a8e402e71eed9795cd4e9eabf6)
+++ uspace/lib/ui/src/window.c	(revision d284ce9c9580c7380258756c41f4a9b67073797c)
@@ -37,4 +37,5 @@
 #include <errno.h>
 #include <gfx/context.h>
+#include <io/pos_event.h>
 #include <mem.h>
 #include <stdlib.h>
@@ -44,5 +45,28 @@
 #include "../private/dummygc.h"
 #include "../private/ui.h"
+#include "../private/wdecor.h"
 #include "../private/window.h"
+
+static void dwnd_close_event(void *);
+static void dwnd_focus_event(void *);
+static void dwnd_kbd_event(void *, kbd_event_t *);
+static void dwnd_pos_event(void *, pos_event_t *);
+static void dwnd_unfocus_event(void *);
+
+static display_wnd_cb_t dwnd_cb = {
+	.close_event = dwnd_close_event,
+	.focus_event = dwnd_focus_event,
+	.kbd_event = dwnd_kbd_event,
+	.pos_event = dwnd_pos_event,
+	.unfocus_event = dwnd_unfocus_event
+};
+
+static void wd_close(ui_wdecor_t *, void *);
+static void wd_move(ui_wdecor_t *, void *, gfx_coord2_t *);
+
+static ui_wdecor_cb_t wdecor_cb = {
+	.close = wd_close,
+	.move = wd_move
+};
 
 /** Initialize window parameters structure.
@@ -53,7 +77,7 @@
  * @param params Window parameters structure
  */
-void ui_window_params_init(ui_window_params_t *params)
-{
-	memset(params, 0, sizeof(ui_window_params_t));
+void ui_wnd_params_init(ui_wnd_params_t *params)
+{
+	memset(params, 0, sizeof(ui_wnd_params_t));
 }
 
@@ -65,5 +89,5 @@
  * @return EOK on success or an error code
  */
-errno_t ui_window_create(ui_t *ui, ui_window_params_t *params,
+errno_t ui_window_create(ui_t *ui, ui_wnd_params_t *params,
     ui_window_t **rwindow)
 {
@@ -82,8 +106,9 @@
 
 	display_wnd_params_init(&dparams);
+	dparams.rect = params->rect;
 
 	if (ui->display != NULL) {
-		rc = display_window_create(ui->display, &dparams, NULL, NULL,
-		    &dwindow);
+		rc = display_window_create(ui->display, &dparams, &dwnd_cb,
+		    (void *) window, &dwindow);
 		if (rc != EOK)
 			goto error;
@@ -108,4 +133,8 @@
 	if (rc != EOK)
 		goto error;
+
+	ui_wdecor_set_rect(wdecor, &params->rect);
+	ui_wdecor_set_cb(wdecor, &wdecor_cb, (void *) window);
+	ui_wdecor_paint(wdecor);
 
 	window->ui = ui;
@@ -145,4 +174,131 @@
 }
 
+/** Set window callbacks.
+ *
+ * @param window Window
+ * @param cb Window decoration callbacks
+ * @param arg Callback argument
+ */
+void ui_window_set_cb(ui_window_t *window, ui_window_cb_t *cb, void *arg)
+{
+	window->cb = cb;
+	window->arg = arg;
+}
+
+ui_resource_t *ui_window_get_res(ui_window_t *window)
+{
+	return window->res;
+}
+
+gfx_context_t *ui_window_get_gc(ui_window_t *window)
+{
+	return window->gc;
+}
+
+void ui_window_get_app_rect(ui_window_t *window, gfx_rect_t *rect)
+{
+	ui_wdecor_geom_t geom;
+
+	ui_wdecor_get_geom(window->wdecor, &geom);
+	*rect = geom.app_area_rect;
+}
+
+/** Handle window close event. */
+static void dwnd_close_event(void *arg)
+{
+	ui_window_t *window = (ui_window_t *) arg;
+
+	ui_window_close(window);
+}
+
+/** Handle window focus event. */
+static void dwnd_focus_event(void *arg)
+{
+	ui_window_t *window = (ui_window_t *) arg;
+
+	if (window->wdecor != NULL) {
+		ui_wdecor_set_active(window->wdecor, true);
+		ui_wdecor_paint(window->wdecor);
+	}
+}
+
+/** Handle window keyboard event */
+static void dwnd_kbd_event(void *arg, kbd_event_t *kbd_event)
+{
+	ui_window_t *window = (ui_window_t *) arg;
+
+	(void) window;
+	(void) kbd_event;
+}
+
+/** Handle window position event */
+static void dwnd_pos_event(void *arg, pos_event_t *event)
+{
+	ui_window_t *window = (ui_window_t *) arg;
+
+	/* Make sure we don't process events until fully initialized */
+	if (window->wdecor == NULL)
+		return;
+
+	ui_wdecor_pos_event(window->wdecor, event);
+	ui_window_pos(window, event);
+}
+
+/** Handle window unfocus event. */
+static void dwnd_unfocus_event(void *arg)
+{
+	ui_window_t *window = (ui_window_t *) arg;
+
+	if (window->wdecor != NULL) {
+		ui_wdecor_set_active(window->wdecor, false);
+		ui_wdecor_paint(window->wdecor);
+	}
+}
+
+/** Window decoration requested window closure.
+ *
+ * @param wdecor Window decoration
+ * @param arg Argument (demo)
+ */
+static void wd_close(ui_wdecor_t *wdecor, void *arg)
+{
+	ui_window_t *window = (ui_window_t *) arg;
+
+	ui_window_close(window);
+}
+
+/** Window decoration requested window move.
+ *
+ * @param wdecor Window decoration
+ * @param arg Argument (demo)
+ * @param pos Position where the title bar was pressed
+ */
+static void wd_move(ui_wdecor_t *wdecor, void *arg, gfx_coord2_t *pos)
+{
+	ui_window_t *window = (ui_window_t *) arg;
+
+	(void) display_window_move_req(window->dwindow, pos);
+}
+
+/** Send window close event.
+ *
+ * @param window Window
+ */
+void ui_window_close(ui_window_t *window)
+{
+	if (window->cb != NULL && window->cb->close != NULL)
+		window->cb->close(window, window->arg);
+}
+
+/** Send window position event.
+ *
+ * @param window Window
+ */
+void ui_window_pos(ui_window_t *window, pos_event_t *pos)
+{
+	if (window->cb != NULL && window->cb->pos != NULL)
+		window->cb->pos(window, window->arg, pos);
+}
+
 /** @}
  */
Index: uspace/lib/ui/test/window.c
===================================================================
--- uspace/lib/ui/test/window.c	(revision f7a90df6adfcf1a8e402e71eed9795cd4e9eabf6)
+++ uspace/lib/ui/test/window.c	(revision d284ce9c9580c7380258756c41f4a9b67073797c)
@@ -27,7 +27,11 @@
  */
 
+#include <gfx/context.h>
+#include <gfx/coord.h>
+#include <io/pos_event.h>
 #include <mem.h>
 #include <pcut/pcut.h>
 #include <stdbool.h>
+#include <ui/resource.h>
 #include <ui/ui.h>
 #include <ui/window.h>
@@ -38,4 +42,21 @@
 PCUT_TEST_SUITE(window);
 
+static void test_window_close(ui_window_t *, void *);
+static void test_window_pos(ui_window_t *, void *, pos_event_t *);
+
+static ui_window_cb_t test_window_cb = {
+	.close = test_window_close,
+	.pos = test_window_pos
+};
+
+static ui_window_cb_t dummy_window_cb = {
+};
+
+typedef struct {
+	bool close;
+	bool pos;
+	pos_event_t pos_event;
+} test_cb_resp_t;
+
 /** Create and destroy window */
 PCUT_TEST(create_destroy)
@@ -43,11 +64,11 @@
 	errno_t rc;
 	ui_t *ui = NULL;
-	ui_window_params_t params;
-	ui_window_t *window = NULL;
-
-	rc = ui_create_disp(NULL, &ui);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-
-	ui_window_params_init(&params);
+	ui_wnd_params_t params;
+	ui_window_t *window = NULL;
+
+	rc = ui_create_disp(NULL, &ui);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	ui_wnd_params_init(&params);
 	params.caption = "Hello";
 
@@ -66,3 +87,136 @@
 }
 
+/** ui_window_get_res/gc/rect() return valid objects */
+PCUT_TEST(get_res_gc_rect)
+{
+	errno_t rc;
+	ui_t *ui = NULL;
+	ui_wnd_params_t params;
+	ui_window_t *window = NULL;
+	ui_resource_t *res;
+	gfx_context_t *gc;
+	gfx_rect_t rect;
+
+	rc = ui_create_disp(NULL, &ui);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	ui_wnd_params_init(&params);
+	params.caption = "Hello";
+
+	rc = ui_window_create(ui, &params, &window);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(window);
+
+	res = ui_window_get_res(window);
+	PCUT_ASSERT_NOT_NULL(res);
+
+	gc = ui_window_get_gc(window);
+	PCUT_ASSERT_NOT_NULL(gc);
+
+	ui_window_get_app_rect(window, &rect);
+
+	ui_window_destroy(window);
+	ui_destroy(ui);
+}
+
+/** ui_window_close() calls close callback set via ui_window_set_cb() */
+PCUT_TEST(close)
+{
+	errno_t rc;
+	ui_t *ui = NULL;
+	ui_wnd_params_t params;
+	ui_window_t *window = NULL;
+	test_cb_resp_t resp;
+
+	rc = ui_create_disp(NULL, &ui);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	ui_wnd_params_init(&params);
+	params.caption = "Hello";
+
+	rc = ui_window_create(ui, &params, &window);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(window);
+
+	/* Close callback with no callbacks set */
+	ui_window_close(window);
+
+	/* Close callback with close callback not implemented */
+	ui_window_set_cb(window, &dummy_window_cb, NULL);
+	ui_window_close(window);
+
+	/* Close callback with real callback set */
+	resp.close = false;
+	ui_window_set_cb(window, &test_window_cb, &resp);
+	ui_window_close(window);
+	PCUT_ASSERT_TRUE(resp.close);
+
+	ui_window_destroy(window);
+	ui_destroy(ui);
+}
+
+/** ui_window_pos() calls pos callback set via ui_window_set_cb() */
+PCUT_TEST(pos)
+{
+	errno_t rc;
+	ui_t *ui = NULL;
+	ui_wnd_params_t params;
+	ui_window_t *window = NULL;
+	pos_event_t pos_event;
+	test_cb_resp_t resp;
+
+	rc = ui_create_disp(NULL, &ui);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	ui_wnd_params_init(&params);
+	params.caption = "Hello";
+
+	rc = ui_window_create(ui, &params, &window);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(window);
+
+	pos_event.pos_id = 1;
+	pos_event.type = POS_PRESS;
+	pos_event.btn_num = 2;
+	pos_event.hpos = 3;
+	pos_event.vpos = 4;
+
+	/* Pos callback with no callbacks set */
+	ui_window_pos(window, &pos_event);
+
+	/* Pos callback with pos callback not implemented */
+	ui_window_set_cb(window, &dummy_window_cb, NULL);
+	ui_window_pos(window, &pos_event);
+
+	/* Pos callback with real callback set */
+	resp.pos = false;
+	ui_window_set_cb(window, &test_window_cb, &resp);
+	ui_window_pos(window, &pos_event);
+	PCUT_ASSERT_TRUE(resp.pos);
+	PCUT_ASSERT_INT_EQUALS(pos_event.pos_id, resp.pos_event.pos_id);
+	PCUT_ASSERT_EQUALS(pos_event.type, resp.pos_event.type);
+	PCUT_ASSERT_INT_EQUALS(pos_event.btn_num, resp.pos_event.btn_num);
+	PCUT_ASSERT_INT_EQUALS(pos_event.hpos, resp.pos_event.hpos);
+	PCUT_ASSERT_INT_EQUALS(pos_event.vpos, resp.pos_event.vpos);
+
+	ui_window_destroy(window);
+	ui_destroy(ui);
+}
+
+static void test_window_close(ui_window_t *window, void *arg)
+{
+	test_cb_resp_t *resp = (test_cb_resp_t *) arg;
+
+	resp->close = true;
+}
+
+static void test_window_pos(ui_window_t *window, void *arg,
+    pos_event_t *event)
+{
+	test_cb_resp_t *resp = (test_cb_resp_t *) arg;
+
+	resp->pos = true;
+	resp->pos_event = *event;
+}
+
 PCUT_EXPORT(window);
