Index: uspace/lib/display/src/display.c
===================================================================
--- uspace/lib/display/src/display.c	(revision dcfd422dba88d6b14bf3fabca029117aa9922b5e)
+++ uspace/lib/display/src/display.c	(revision f7a90df6adfcf1a8e402e71eed9795cd4e9eabf6)
@@ -198,5 +198,5 @@
 /** Destroy display window.
  *
- * @param window Window
+ * @param window Window or @c NULL
  * @return EOK on success or an error code. In both cases @a window must
  *         not be accessed anymore
@@ -206,4 +206,7 @@
 	async_exch_t *exch;
 	errno_t rc;
+
+	if (window == NULL)
+		return EOK;
 
 	exch = async_exchange_begin(window->display->sess);
Index: uspace/lib/display/test/display.c
===================================================================
--- uspace/lib/display/test/display.c	(revision dcfd422dba88d6b14bf3fabca029117aa9922b5e)
+++ uspace/lib/display/test/display.c	(revision f7a90df6adfcf1a8e402e71eed9795cd4e9eabf6)
@@ -331,4 +331,10 @@
 }
 
+/** display_window_destroy() can handle NULL argument */
+PCUT_TEST(window_destroy_null)
+{
+	display_window_destroy(NULL);
+}
+
 /** display_window_move_req() with server returning error response works. */
 PCUT_TEST(window_move_req_failure)
Index: uspace/lib/ui/include/types/ui/ui.h
===================================================================
--- uspace/lib/ui/include/types/ui/ui.h	(revision f7a90df6adfcf1a8e402e71eed9795cd4e9eabf6)
+++ uspace/lib/ui/include/types/ui/ui.h	(revision f7a90df6adfcf1a8e402e71eed9795cd4e9eabf6)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2020 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libui
+ * @{
+ */
+/**
+ * @file User interface
+ */
+
+#ifndef _UI_TYPES_UI_H
+#define _UI_TYPES_UI_H
+
+#include <gfx/coord.h>
+
+struct ui;
+typedef struct ui ui_t;
+
+/** Use the default display service (argument to ui_create() */
+#define UI_DISPLAY_DEFAULT NULL
+
+#endif
+
+/** @}
+ */
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 f7a90df6adfcf1a8e402e71eed9795cd4e9eabf6)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2020 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libui
+ * @{
+ */
+/**
+ * @file Window
+ */
+
+#ifndef _UI_TYPES_WINDOW_H
+#define _UI_TYPES_WINDOW_H
+
+struct ui_window;
+typedef struct ui_window ui_window_t;
+
+/** Window parameters */
+typedef struct {
+	/** Window rectangle */
+	gfx_rect_t *rect;
+	/** Window caption */
+	const char *caption;
+} ui_window_params_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 f7a90df6adfcf1a8e402e71eed9795cd4e9eabf6)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2020 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libui
+ * @{
+ */
+/**
+ * @file User interface
+ */
+
+#ifndef _UI_UI_H
+#define _UI_UI_H
+
+#include <display.h>
+#include <errno.h>
+#include <types/ui/ui.h>
+
+extern errno_t ui_create(const char *, ui_t **);
+extern errno_t ui_create_disp(display_t *, ui_t **);
+extern void ui_destroy(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 f7a90df6adfcf1a8e402e71eed9795cd4e9eabf6)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2020 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libui
+ * @{
+ */
+/**
+ * @file Window
+ */
+
+#ifndef _UI_WINDOW_H
+#define _UI_WINDOW_H
+
+#include <errno.h>
+#include <types/ui/ui.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 *,
+    ui_window_t **);
+extern void ui_window_destroy(ui_window_t *);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/ui/meson.build
===================================================================
--- uspace/lib/ui/meson.build	(revision dcfd422dba88d6b14bf3fabca029117aa9922b5e)
+++ uspace/lib/ui/meson.build	(revision f7a90df6adfcf1a8e402e71eed9795cd4e9eabf6)
@@ -27,11 +27,14 @@
 #
 
-deps = [ 'gfx', 'gfxfont' ]
+deps = [ 'gfx', 'gfxfont', 'display' ]
 src = files(
+	'src/dummygc.c',
 	'src/label.c',
 	'src/paint.c',
 	'src/pbutton.c',
 	'src/resource.c',
-	'src/wdecor.c'
+	'src/ui.c',
+	'src/wdecor.c',
+	'src/window.c',
 )
 
@@ -42,4 +45,6 @@
 	'test/pbutton.c',
 	'test/resource.c',
+	'test/ui.c',
 	'test/wdecor.c',
+	'test/window.c',
 )
Index: uspace/lib/ui/private/dummygc.h
===================================================================
--- uspace/lib/ui/private/dummygc.h	(revision f7a90df6adfcf1a8e402e71eed9795cd4e9eabf6)
+++ uspace/lib/ui/private/dummygc.h	(revision f7a90df6adfcf1a8e402e71eed9795cd4e9eabf6)
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2020 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libui
+ * @{
+ */
+/**
+ * @file Dummy graphic context
+ *
+ */
+
+#ifndef _UI_PRIVATE_DUMMYGC_H
+#define _UI_PRIVATE_DUMMYGC_H
+
+#include <gfx/context.h>
+
+/** Dummy graphic context */
+typedef struct {
+	gfx_context_t *gc;
+	bool bm_created;
+	bool bm_destroyed;
+	gfx_bitmap_params_t bm_params;
+	void *bm_pixels;
+	gfx_rect_t bm_srect;
+	gfx_coord2_t bm_offs;
+	bool bm_rendered;
+	bool bm_got_alloc;
+} dummy_gc_t;
+
+/** Dummy GC bitmap */
+typedef struct {
+	dummy_gc_t *dgc;
+	gfx_bitmap_alloc_t alloc;
+	bool myalloc;
+} dummygc_bitmap_t;
+
+/** Dummy GC ops */
+extern gfx_context_ops_t dummygc_ops;
+
+extern errno_t dummygc_create(dummy_gc_t **);
+extern void dummygc_destroy(dummy_gc_t *);
+extern gfx_context_t *dummygc_get_ctx(dummy_gc_t *);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/ui/private/ui.h
===================================================================
--- uspace/lib/ui/private/ui.h	(revision f7a90df6adfcf1a8e402e71eed9795cd4e9eabf6)
+++ uspace/lib/ui/private/ui.h	(revision f7a90df6adfcf1a8e402e71eed9795cd4e9eabf6)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2020 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libui
+ * @{
+ */
+/**
+ * @file User interface
+ *
+ */
+
+#ifndef _UI_PRIVATE_UI_H
+#define _UI_PRIVATE_UI_H
+
+#include <display.h>
+#include <stdbool.h>
+
+/** Actual structure of user interface.
+ *
+ * This is private to libui.
+ */
+struct ui {
+	/** Display */
+	display_t *display;
+	/** Output owned by UI, clean up when destroying UI */
+	bool myoutput;
+};
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/ui/private/window.h
===================================================================
--- uspace/lib/ui/private/window.h	(revision f7a90df6adfcf1a8e402e71eed9795cd4e9eabf6)
+++ uspace/lib/ui/private/window.h	(revision f7a90df6adfcf1a8e402e71eed9795cd4e9eabf6)
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2020 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libui
+ * @{
+ */
+/**
+ * @file Window structure
+ *
+ */
+
+#ifndef _UI_PRIVATE_WINDOW_H
+#define _UI_PRIVATE_WINDOW_H
+
+#include <display.h>
+#include <gfx/context.h>
+
+/** Actual structure of window.
+ *
+ * This is private to libui.
+ */
+struct ui_window {
+	/** Containing user interface */
+	struct ui *ui;
+	/** Display window */
+	display_window_t *dwindow;
+	/** Window GC */
+	gfx_context_t *gc;
+	/** UI resource. Ideally this would be in ui_t. */
+	struct ui_resource *res;
+	/** Window decoration */
+	struct ui_wdecor *wdecor;
+};
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/ui/src/dummygc.c
===================================================================
--- uspace/lib/ui/src/dummygc.c	(revision f7a90df6adfcf1a8e402e71eed9795cd4e9eabf6)
+++ uspace/lib/ui/src/dummygc.c	(revision f7a90df6adfcf1a8e402e71eed9795cd4e9eabf6)
@@ -0,0 +1,222 @@
+/*
+ * Copyright (c) 2020 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libui
+ * @{
+ */
+/**
+ * @file Dummy graphic context
+ */
+
+#include <gfx/context.h>
+#include <gfx/coord.h>
+#include <mem.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include "../private/dummygc.h"
+
+static errno_t dummygc_set_color(void *, gfx_color_t *);
+static errno_t dummygc_fill_rect(void *, gfx_rect_t *);
+static errno_t dummygc_bitmap_create(void *, gfx_bitmap_params_t *,
+    gfx_bitmap_alloc_t *, void **);
+static errno_t dummygc_bitmap_destroy(void *);
+static errno_t dummygc_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *);
+static errno_t dummygc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *);
+
+/** Dummy GC operations */
+gfx_context_ops_t dummygc_ops = {
+	.set_color = dummygc_set_color,
+	.fill_rect = dummygc_fill_rect,
+	.bitmap_create = dummygc_bitmap_create,
+	.bitmap_destroy = dummygc_bitmap_destroy,
+	.bitmap_render = dummygc_bitmap_render,
+	.bitmap_get_alloc = dummygc_bitmap_get_alloc
+};
+
+/** Create dummy GC.
+ *
+ * @param rdgc Place to store pointer to new dummy GC
+ * @return EOK on success, ENOMEM if out of memory
+ */
+errno_t dummygc_create(dummy_gc_t **rdgc)
+{
+	dummy_gc_t *dgc;
+	gfx_context_t *gc;
+	errno_t rc;
+
+	dgc = calloc(1, sizeof(dummy_gc_t));
+	if (dgc == NULL)
+		return ENOMEM;
+
+	rc = gfx_context_new(&dummygc_ops, dgc, &gc);
+	if (rc != EOK) {
+		free(dgc);
+		return rc;
+	}
+
+	dgc->gc = gc;
+	*rdgc = dgc;
+	return EOK;
+}
+
+/** Destroy dummy GC.
+ *
+ * @param dgc Dummy GC
+ */
+void dummygc_destroy(dummy_gc_t *dgc)
+{
+	gfx_context_delete(dgc->gc);
+	free(dgc);
+}
+
+/** Get generic graphic context from dummy GC.
+ *
+ * @param dgc Dummy GC
+ * @return Graphic context
+ */
+gfx_context_t *dummygc_get_ctx(dummy_gc_t *dgc)
+{
+	return dgc->gc;
+}
+
+/** Set color on dummy GC
+ *
+ * @param arg Argument (dummy_gc_t)
+ * @param color Color
+ * @return EOK on success or an error code
+ */
+static errno_t dummygc_set_color(void *arg, gfx_color_t *color)
+{
+	(void) arg;
+	(void) color;
+	return EOK;
+}
+
+/** Fill rectangle on dummy GC
+ *
+ * @param arg Argument (dummy_gc_t)
+ * @param rect Rectangle
+ * @return EOK on success or an error code
+ */
+static errno_t dummygc_fill_rect(void *arg, gfx_rect_t *rect)
+{
+	(void) arg;
+	(void) rect;
+	return EOK;
+}
+
+/** Create bitmap on dummy GC
+ *
+ * @param arg Argument (dummy_gc_t)
+ * @param params Bitmap parameters
+ * @param alloc Bitmap allocation info or @c NULL
+ * @param rbm Place to store pointer to new bitmap
+ * @return EOK on success or an error code
+ */
+static errno_t dummygc_bitmap_create(void *arg, gfx_bitmap_params_t *params,
+    gfx_bitmap_alloc_t *alloc, void **rbm)
+{
+	dummy_gc_t *dgc = (dummy_gc_t *) arg;
+	dummygc_bitmap_t *tbm;
+
+	tbm = calloc(1, sizeof(dummygc_bitmap_t));
+	if (tbm == NULL)
+		return ENOMEM;
+
+	if (alloc == NULL) {
+		tbm->alloc.pitch = (params->rect.p1.x - params->rect.p0.x) *
+		    sizeof(uint32_t);
+		tbm->alloc.off0 = 0;
+		tbm->alloc.pixels = calloc(sizeof(uint32_t),
+		    (params->rect.p1.x - params->rect.p0.x) *
+		    (params->rect.p1.y - params->rect.p0.y));
+		tbm->myalloc = true;
+		if (tbm->alloc.pixels == NULL) {
+			free(tbm);
+			return ENOMEM;
+		}
+	} else {
+		tbm->alloc = *alloc;
+	}
+
+	tbm->dgc = dgc;
+	dgc->bm_created = true;
+	dgc->bm_params = *params;
+	dgc->bm_pixels = tbm->alloc.pixels;
+	*rbm = (void *)tbm;
+	return EOK;
+}
+
+/** Destroy bitmap on dummy GC
+ *
+ * @param bm Bitmap
+ * @return EOK on success or an error code
+ */
+static errno_t dummygc_bitmap_destroy(void *bm)
+{
+	dummygc_bitmap_t *tbm = (dummygc_bitmap_t *)bm;
+	if (tbm->myalloc)
+		free(tbm->alloc.pixels);
+	tbm->dgc->bm_destroyed = true;
+	free(tbm);
+	return EOK;
+}
+
+/** Render bitmap on dummy GC
+ *
+ * @param bm Bitmap
+ * @param srect Source rectangle or @c NULL
+ * @param offs Offset or @c NULL
+ * @return EOK on success or an error code
+ */
+static errno_t dummygc_bitmap_render(void *bm, gfx_rect_t *srect,
+    gfx_coord2_t *offs)
+{
+	dummygc_bitmap_t *tbm = (dummygc_bitmap_t *)bm;
+	tbm->dgc->bm_rendered = true;
+	tbm->dgc->bm_srect = *srect;
+	tbm->dgc->bm_offs = *offs;
+	return EOK;
+}
+
+/** Get bitmap allocation info on dummy GC
+ *
+ * @param bm Bitmap
+ * @param alloc Place to store allocation info
+ * @return EOK on success or an error code
+ */
+static errno_t dummygc_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc)
+{
+	dummygc_bitmap_t *tbm = (dummygc_bitmap_t *)bm;
+	*alloc = tbm->alloc;
+	tbm->dgc->bm_got_alloc = true;
+	return EOK;
+}
+
+/** @}
+ */
Index: uspace/lib/ui/src/ui.c
===================================================================
--- uspace/lib/ui/src/ui.c	(revision f7a90df6adfcf1a8e402e71eed9795cd4e9eabf6)
+++ uspace/lib/ui/src/ui.c	(revision f7a90df6adfcf1a8e402e71eed9795cd4e9eabf6)
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2020 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libui
+ * @{
+ */
+/**
+ * @file User interface
+ */
+
+#include <display.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <ui/ui.h>
+#include "../private/ui.h"
+
+/** Create new user interface.
+ *
+ * @param ospec Output specification or @c UI_DISPLAY_DEFAULT to use
+ *              the default output
+ * @param rui Place to store pointer to new UI
+ * @return EOK on success or an error code
+ */
+errno_t ui_create(const char *ospec, ui_t **rui)
+{
+	errno_t rc;
+	display_t *display;
+	ui_t *ui;
+
+	rc = display_open(ospec, &display);
+	if (rc != EOK)
+		return rc;
+
+	rc = ui_create_disp(display, &ui);
+	if (rc != EOK) {
+		display_close(display);
+		return rc;
+	}
+
+	ui->display = display;
+	ui->myoutput = true;
+	return EOK;
+}
+
+/** Create new user interface using display service.
+ *
+ * @param disp Display
+ * @param rui Place to store pointer to new UI
+ * @return EOK on success or an error code
+ */
+errno_t ui_create_disp(display_t *disp, ui_t **rui)
+{
+	ui_t *ui;
+
+	ui = calloc(1, sizeof(ui_t));
+	if (ui == NULL)
+		return ENOMEM;
+
+	ui->display = disp;
+	*rui = ui;
+	return EOK;
+}
+
+/** Destroy user interface.
+ *
+ * @param ui User interface or @c NULL
+ */
+void ui_destroy(ui_t *ui)
+{
+	if (ui == NULL)
+		return;
+
+	if (ui->myoutput)
+		display_close(ui->display);
+	free(ui);
+}
+
+/** @}
+ */
Index: uspace/lib/ui/src/window.c
===================================================================
--- uspace/lib/ui/src/window.c	(revision f7a90df6adfcf1a8e402e71eed9795cd4e9eabf6)
+++ uspace/lib/ui/src/window.c	(revision f7a90df6adfcf1a8e402e71eed9795cd4e9eabf6)
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2020 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libui
+ * @{
+ */
+/**
+ * @file Window
+ */
+
+#include <display.h>
+#include <errno.h>
+#include <gfx/context.h>
+#include <mem.h>
+#include <stdlib.h>
+#include <ui/resource.h>
+#include <ui/wdecor.h>
+#include <ui/window.h>
+#include "../private/dummygc.h"
+#include "../private/ui.h"
+#include "../private/window.h"
+
+/** Initialize window parameters structure.
+ *
+ * Window parameters structure must always be initialized using this function
+ * first.
+ *
+ * @param params Window parameters structure
+ */
+void ui_window_params_init(ui_window_params_t *params)
+{
+	memset(params, 0, sizeof(ui_window_params_t));
+}
+
+/** Create new window.
+ *
+ * @param ui User interface
+ * @param params Window parameters
+ * @param rwindow Place to store pointer to new window
+ * @return EOK on success or an error code
+ */
+errno_t ui_window_create(ui_t *ui, ui_window_params_t *params,
+    ui_window_t **rwindow)
+{
+	ui_window_t *window;
+	display_wnd_params_t dparams;
+	display_window_t *dwindow = NULL;
+	gfx_context_t *gc = NULL;
+	ui_resource_t *res = NULL;
+	ui_wdecor_t *wdecor = NULL;
+	dummy_gc_t *dgc = NULL;
+	errno_t rc;
+
+	window = calloc(1, sizeof(ui_window_t));
+	if (window == NULL)
+		return ENOMEM;
+
+	display_wnd_params_init(&dparams);
+
+	if (ui->display != NULL) {
+		rc = display_window_create(ui->display, &dparams, NULL, NULL,
+		    &dwindow);
+		if (rc != EOK)
+			goto error;
+
+		rc = display_window_get_gc(dwindow, &gc);
+		if (rc != EOK)
+			goto error;
+	} else {
+		/* Needed for unit tests */
+		rc = dummygc_create(&dgc);
+		if (rc != EOK)
+			goto error;
+
+		gc = dummygc_get_ctx(dgc);
+	}
+
+	rc = ui_resource_create(gc, &res);
+	if (rc != EOK)
+		goto error;
+
+	rc = ui_wdecor_create(res, params->caption, &wdecor);
+	if (rc != EOK)
+		goto error;
+
+	window->ui = ui;
+	window->dwindow = dwindow;
+	window->gc = gc;
+	window->res = res;
+	window->wdecor = wdecor;
+	*rwindow = window;
+	return EOK;
+error:
+	if (wdecor != NULL)
+		ui_wdecor_destroy(wdecor);
+	if (res != NULL)
+		ui_resource_destroy(res);
+	if (dgc != NULL)
+		dummygc_destroy(dgc);
+	if (dwindow != NULL)
+		display_window_destroy(dwindow);
+	free(window);
+	return rc;
+}
+
+/** Destroy window.
+ *
+ * @param window Window or @c NULL
+ */
+void ui_window_destroy(ui_window_t *window)
+{
+	if (window == NULL)
+		return;
+
+	ui_wdecor_destroy(window->wdecor);
+	ui_resource_destroy(window->res);
+	gfx_context_delete(window->gc);
+	display_window_destroy(window->dwindow);
+	free(window);
+}
+
+/** @}
+ */
Index: uspace/lib/ui/test/main.c
===================================================================
--- uspace/lib/ui/test/main.c	(revision dcfd422dba88d6b14bf3fabca029117aa9922b5e)
+++ uspace/lib/ui/test/main.c	(revision f7a90df6adfcf1a8e402e71eed9795cd4e9eabf6)
@@ -35,5 +35,7 @@
 PCUT_IMPORT(pbutton);
 PCUT_IMPORT(resource);
+PCUT_IMPORT(ui);
 PCUT_IMPORT(wdecor);
+PCUT_IMPORT(window);
 
 PCUT_MAIN();
Index: uspace/lib/ui/test/ui.c
===================================================================
--- uspace/lib/ui/test/ui.c	(revision f7a90df6adfcf1a8e402e71eed9795cd4e9eabf6)
+++ uspace/lib/ui/test/ui.c	(revision f7a90df6adfcf1a8e402e71eed9795cd4e9eabf6)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2020 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <pcut/pcut.h>
+#include <ui/ui.h>
+#include "../private/ui.h"
+
+PCUT_INIT;
+
+PCUT_TEST_SUITE(ui);
+
+/** Create and destroy UI */
+PCUT_TEST(create_destroy)
+{
+	ui_t *ui = NULL;
+	errno_t rc;
+
+	rc = ui_create_disp(NULL, &ui);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(ui);
+	PCUT_ASSERT_NULL(ui->display);
+
+	ui_destroy(ui);
+}
+
+/** ui_destroy() can take NULL argument (no-op) */
+PCUT_TEST(destroy_null)
+{
+	ui_destroy(NULL);
+}
+
+PCUT_EXPORT(ui);
Index: uspace/lib/ui/test/window.c
===================================================================
--- uspace/lib/ui/test/window.c	(revision f7a90df6adfcf1a8e402e71eed9795cd4e9eabf6)
+++ uspace/lib/ui/test/window.c	(revision f7a90df6adfcf1a8e402e71eed9795cd4e9eabf6)
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2020 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <mem.h>
+#include <pcut/pcut.h>
+#include <stdbool.h>
+#include <ui/ui.h>
+#include <ui/window.h>
+#include "../private/window.h"
+
+PCUT_INIT;
+
+PCUT_TEST_SUITE(window);
+
+/** Create and destroy window */
+PCUT_TEST(create_destroy)
+{
+	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);
+	params.caption = "Hello";
+
+	rc = ui_window_create(ui, &params, &window);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(window);
+
+	ui_window_destroy(window);
+	ui_destroy(ui);
+}
+
+/** ui_window_destroy() can take NULL argument (no-op) */
+PCUT_TEST(destroy_null)
+{
+	ui_window_destroy(NULL);
+}
+
+PCUT_EXPORT(window);
