Index: uspace/app/uidemo/uidemo.c
===================================================================
--- uspace/app/uidemo/uidemo.c	(revision de9992c5dcfe392011d18f6d641c7151c514607a)
+++ uspace/app/uidemo/uidemo.c	(revision 17696938536729f8e143b51c1b0e5b84bbb276e7)
@@ -42,14 +42,19 @@
 #include <ui/pbutton.h>
 #include <ui/resource.h>
+#include <ui/wdecor.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
+	.pos_event = wnd_pos_event,
+	.unfocus_event = wnd_unfocus_event
 };
 
@@ -60,4 +65,10 @@
 };
 
+static void wd_move(ui_wdecor_t *, void *, gfx_coord2_t *);
+
+static ui_wdecor_cb_t wdecor_cb = {
+	.move = wd_move
+};
+
 static bool quit = false;
 
@@ -73,4 +84,15 @@
 	printf("Close event\n");
 	quit = true;
+}
+
+/** Handle window focus event. */
+static void wnd_focus_event(void *arg)
+{
+	ui_demo_t *demo = (ui_demo_t *) arg;
+
+	if (demo->wdecor != NULL) {
+		ui_wdecor_set_active(demo->wdecor, true);
+		ui_wdecor_paint(demo->wdecor);
+	}
 }
 
@@ -88,6 +110,22 @@
 	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)
+		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);
+	}
 }
 
@@ -106,4 +144,17 @@
 		printf("Clicked 'Cancel' button\n");
 	}
+}
+
+/** 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);
 }
 
@@ -135,4 +186,6 @@
 	params.rect.p1.y = 100;
 
+	memset((void *) &demo, 0, sizeof(demo));
+
 	rc = display_window_create(display, &params, &wnd_cb, (void *) &demo,
 	    &window);
@@ -142,4 +195,6 @@
 	}
 
+	demo.dwindow = window;
+
 	rc = display_window_get_gc(window, &gc);
 	if (rc != EOK) {
@@ -155,4 +210,14 @@
 		return rc;
 	}
+
+	printf("Create window decoration\n");
+	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);
 
 	rc = ui_pbutton_create(ui_res, "Confirm", &demo.pb1);
@@ -207,4 +272,10 @@
 	color = NULL;
 
+	rc = ui_wdecor_paint(demo.wdecor);
+	if (rc != EOK) {
+		printf("Error painting window decoration.\n");
+		return rc;
+	}
+
 	rc = ui_pbutton_paint(demo.pb1);
 	if (rc != EOK) {
@@ -223,4 +294,5 @@
 	}
 
+	ui_wdecor_destroy(demo.wdecor);
 	ui_pbutton_destroy(demo.pb1);
 	ui_pbutton_destroy(demo.pb2);
Index: uspace/app/uidemo/uidemo.h
===================================================================
--- uspace/app/uidemo/uidemo.h	(revision de9992c5dcfe392011d18f6d641c7151c514607a)
+++ uspace/app/uidemo/uidemo.h	(revision 17696938536729f8e143b51c1b0e5b84bbb276e7)
@@ -37,6 +37,12 @@
 #define UIDEMO_H
 
+#include <display.h>
+#include <ui/pbutton.h>
+#include <ui/wdecor.h>
+
 /** User interface demo */
 typedef struct {
+	display_window_t *dwindow;
+	ui_wdecor_t *wdecor;
 	ui_pbutton_t *pb1;
 	ui_pbutton_t *pb2;
Index: uspace/lib/ui/include/types/ui/wdecor.h
===================================================================
--- uspace/lib/ui/include/types/ui/wdecor.h	(revision 17696938536729f8e143b51c1b0e5b84bbb276e7)
+++ uspace/lib/ui/include/types/ui/wdecor.h	(revision 17696938536729f8e143b51c1b0e5b84bbb276e7)
@@ -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 decoration
+ */
+
+#ifndef _UI_TYPES_WDECOR_H
+#define _UI_TYPES_WDECOR_H
+
+#include <gfx/coord.h>
+
+struct ui_wdecor;
+typedef struct ui_wdecor ui_wdecor_t;
+
+/** Window decoration callbacks */
+typedef struct ui_wdecor_cb {
+	void (*close)(ui_wdecor_t *, void *);
+	void (*move)(ui_wdecor_t *, void *, gfx_coord2_t *);
+} ui_wdecor_cb_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/ui/include/ui/wdecor.h
===================================================================
--- uspace/lib/ui/include/ui/wdecor.h	(revision 17696938536729f8e143b51c1b0e5b84bbb276e7)
+++ uspace/lib/ui/include/ui/wdecor.h	(revision 17696938536729f8e143b51c1b0e5b84bbb276e7)
@@ -0,0 +1,58 @@
+/*
+ * 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 decoration
+ */
+
+#ifndef _UI_WDECOR_H
+#define _UI_WDECOR_H
+
+#include <errno.h>
+#include <gfx/coord.h>
+#include <io/pos_event.h>
+#include <stdbool.h>
+#include <types/ui/resource.h>
+#include <types/ui/wdecor.h>
+
+extern errno_t ui_wdecor_create(ui_resource_t *, const char *,
+    ui_wdecor_t **);
+extern void ui_wdecor_destroy(ui_wdecor_t *);
+extern void ui_wdecor_set_cb(ui_wdecor_t *, ui_wdecor_cb_t *, void *);
+extern void ui_wdecor_set_rect(ui_wdecor_t *, gfx_rect_t *);
+extern void ui_wdecor_set_active(ui_wdecor_t *, bool);
+extern errno_t ui_wdecor_paint(ui_wdecor_t *);
+extern void ui_wdecor_pos_event(ui_wdecor_t *, pos_event_t *);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/ui/meson.build
===================================================================
--- uspace/lib/ui/meson.build	(revision de9992c5dcfe392011d18f6d641c7151c514607a)
+++ uspace/lib/ui/meson.build	(revision 17696938536729f8e143b51c1b0e5b84bbb276e7)
@@ -32,4 +32,5 @@
 	'src/pbutton.c',
 	'src/resource.c',
+	'src/wdecor.c'
 )
 
@@ -39,3 +40,4 @@
 	'test/pbutton.c',
 	'test/resource.c',
+	'test/wdecor.c',
 )
Index: uspace/lib/ui/private/pbutton.h
===================================================================
--- uspace/lib/ui/private/pbutton.h	(revision de9992c5dcfe392011d18f6d641c7151c514607a)
+++ uspace/lib/ui/private/pbutton.h	(revision 17696938536729f8e143b51c1b0e5b84bbb276e7)
@@ -38,5 +38,4 @@
 #define _UI_PRIVATE_PBUTTON_H
 
-#include <gfx/context.h>
 #include <gfx/coord.h>
 #include <stdbool.h>
Index: uspace/lib/ui/private/resource.h
===================================================================
--- uspace/lib/ui/private/resource.h	(revision de9992c5dcfe392011d18f6d641c7151c514607a)
+++ uspace/lib/ui/private/resource.h	(revision 17696938536729f8e143b51c1b0e5b84bbb276e7)
@@ -65,4 +65,26 @@
 	/** Button shadow color */
 	gfx_color_t *btn_shadow_color;
+
+	/** Window face color */
+	gfx_color_t *wnd_face_color;
+	/** Window text color */
+	gfx_color_t *wnd_text_color;
+	/** Window frame hightlight color */
+	gfx_color_t *wnd_frame_hi_color;
+	/** Window frame shadow color */
+	gfx_color_t *wnd_frame_sh_color;
+	/** Window highlight color */
+	gfx_color_t *wnd_highlight_color;
+	/** Window shadow color */
+	gfx_color_t *wnd_shadow_color;
+
+	/** Active titlebar background color */
+	gfx_color_t *tbar_act_bg_color;
+	/** Active titlebar text color */
+	gfx_color_t *tbar_act_text_color;
+	/** Inactive titlebar background color */
+	gfx_color_t *tbar_inact_bg_color;
+	/** Inactive titlebar text color */
+	gfx_color_t *tbar_inact_text_color;
 };
 
Index: uspace/lib/ui/private/wdecor.h
===================================================================
--- uspace/lib/ui/private/wdecor.h	(revision 17696938536729f8e143b51c1b0e5b84bbb276e7)
+++ uspace/lib/ui/private/wdecor.h	(revision 17696938536729f8e143b51c1b0e5b84bbb276e7)
@@ -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.
+ */
+
+/** @addtogroup libui
+ * @{
+ */
+/**
+ * @file Window decoration structure
+ *
+ */
+
+#ifndef _UI_PRIVATE_WDECOR_H
+#define _UI_PRIVATE_WDECOR_H
+
+#include <gfx/coord.h>
+#include <stdbool.h>
+#include <types/ui/wdecor.h>
+
+/** Actual structure of push button.
+ *
+ * This is private to libui.
+ */
+struct ui_wdecor {
+	/** UI resource */
+	struct ui_resource *res;
+	/** Callbacks */
+	struct ui_wdecor_cb *cb;
+	/** Callback argument */
+	void *arg;
+	/** Window decoration rectangle */
+	gfx_rect_t rect;
+	/** Caption */
+	const char *caption;
+	/** Window is active */
+	bool active;
+};
+
+extern void ui_wdecor_move(ui_wdecor_t *, gfx_coord2_t *);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/ui/src/resource.c
===================================================================
--- uspace/lib/ui/src/resource.c	(revision de9992c5dcfe392011d18f6d641c7151c514607a)
+++ uspace/lib/ui/src/resource.c	(revision 17696938536729f8e143b51c1b0e5b84bbb276e7)
@@ -64,4 +64,14 @@
 	gfx_color_t *btn_highlight_color = NULL;
 	gfx_color_t *btn_shadow_color = NULL;
+	gfx_color_t *wnd_face_color = NULL;
+	gfx_color_t *wnd_text_color = NULL;
+	gfx_color_t *wnd_frame_hi_color = NULL;
+	gfx_color_t *wnd_frame_sh_color = NULL;
+	gfx_color_t *wnd_highlight_color = NULL;
+	gfx_color_t *wnd_shadow_color = NULL;
+	gfx_color_t *tbar_act_bg_color = NULL;
+	gfx_color_t *tbar_inact_bg_color = NULL;
+	gfx_color_t *tbar_act_text_color = NULL;
+	gfx_color_t *tbar_inact_text_color = NULL;
 	errno_t rc;
 
@@ -105,7 +115,52 @@
 		goto error;
 
+	rc = gfx_color_new_rgb_i16(0xc8c8, 0xc8c8, 0xc8c8, &wnd_face_color);
+	if (rc != EOK)
+		goto error;
+
+	rc = gfx_color_new_rgb_i16(0, 0, 0, &wnd_text_color);
+	if (rc != EOK)
+		goto error;
+
+	rc = gfx_color_new_rgb_i16(0x8888, 0x8888, 0x8888, &wnd_frame_hi_color);
+	if (rc != EOK)
+		goto error;
+
+	rc = gfx_color_new_rgb_i16(0, 0, 0, &wnd_frame_sh_color);
+	if (rc != EOK)
+		goto error;
+
+	rc = gfx_color_new_rgb_i16(0xffff, 0xffff, 0xffff,
+	    &wnd_highlight_color);
+	if (rc != EOK)
+		goto error;
+
+	rc = gfx_color_new_rgb_i16(0x8888, 0x8888, 0x8888, &wnd_shadow_color);
+	if (rc != EOK)
+		goto error;
+
+	rc = gfx_color_new_rgb_i16(0x5858, 0x6a6a, 0xc4c4, &tbar_act_bg_color);
+	if (rc != EOK)
+		goto error;
+
+	rc = gfx_color_new_rgb_i16(0xffff, 0xffff, 0xffff,
+	    &tbar_act_text_color);
+	if (rc != EOK)
+		goto error;
+
+	rc = gfx_color_new_rgb_i16(0xdddd, 0xdddd, 0xdddd,
+	    &tbar_inact_bg_color);
+	if (rc != EOK)
+		goto error;
+
+	rc = gfx_color_new_rgb_i16(0x5858, 0x5858, 0x5858,
+	    &tbar_inact_text_color);
+	if (rc != EOK)
+		goto error;
+
 	resource->gc = gc;
 	resource->tface = tface;
 	resource->font = font;
+
 	resource->btn_frame_color = btn_frame_color;
 	resource->btn_face_color = btn_face_color;
@@ -113,4 +168,17 @@
 	resource->btn_highlight_color = btn_highlight_color;
 	resource->btn_shadow_color = btn_shadow_color;
+
+	resource->wnd_face_color = wnd_face_color;
+	resource->wnd_text_color = wnd_text_color;
+	resource->wnd_frame_hi_color = wnd_frame_hi_color;
+	resource->wnd_frame_sh_color = wnd_frame_sh_color;
+	resource->wnd_highlight_color = wnd_highlight_color;
+	resource->wnd_shadow_color = wnd_shadow_color;
+
+	resource->tbar_act_bg_color = tbar_act_bg_color;
+	resource->tbar_act_text_color = tbar_act_text_color;
+	resource->tbar_inact_bg_color = tbar_inact_bg_color;
+	resource->tbar_inact_text_color = tbar_inact_text_color;
+
 	*rresource = resource;
 	return EOK;
@@ -126,4 +194,27 @@
 	if (btn_shadow_color != NULL)
 		gfx_color_delete(btn_shadow_color);
+
+	if (wnd_face_color != NULL)
+		gfx_color_delete(wnd_face_color);
+	if (wnd_text_color != NULL)
+		gfx_color_delete(wnd_text_color);
+	if (wnd_frame_hi_color != NULL)
+		gfx_color_delete(wnd_frame_hi_color);
+	if (wnd_frame_sh_color != NULL)
+		gfx_color_delete(wnd_frame_sh_color);
+	if (wnd_highlight_color != NULL)
+		gfx_color_delete(wnd_highlight_color);
+	if (wnd_shadow_color != NULL)
+		gfx_color_delete(wnd_shadow_color);
+
+	if (tbar_act_bg_color != NULL)
+		gfx_color_delete(tbar_act_bg_color);
+	if (tbar_act_text_color != NULL)
+		gfx_color_delete(tbar_act_text_color);
+	if (tbar_inact_bg_color != NULL)
+		gfx_color_delete(tbar_inact_bg_color);
+	if (tbar_inact_text_color != NULL)
+		gfx_color_delete(tbar_inact_text_color);
+
 	if (tface != NULL)
 		gfx_typeface_destroy(tface);
@@ -147,4 +238,16 @@
 	gfx_color_delete(resource->btn_shadow_color);
 
+	gfx_color_delete(resource->wnd_face_color);
+	gfx_color_delete(resource->wnd_text_color);
+	gfx_color_delete(resource->wnd_frame_hi_color);
+	gfx_color_delete(resource->wnd_frame_sh_color);
+	gfx_color_delete(resource->wnd_highlight_color);
+	gfx_color_delete(resource->wnd_shadow_color);
+
+	gfx_color_delete(resource->tbar_act_bg_color);
+	gfx_color_delete(resource->tbar_act_text_color);
+	gfx_color_delete(resource->tbar_inact_bg_color);
+	gfx_color_delete(resource->tbar_inact_text_color);
+
 	gfx_font_close(resource->font);
 	gfx_typeface_destroy(resource->tface);
Index: uspace/lib/ui/src/wdecor.c
===================================================================
--- uspace/lib/ui/src/wdecor.c	(revision 17696938536729f8e143b51c1b0e5b84bbb276e7)
+++ uspace/lib/ui/src/wdecor.c	(revision 17696938536729f8e143b51c1b0e5b84bbb276e7)
@@ -0,0 +1,230 @@
+/*
+ * 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 decoration
+ */
+
+#include <errno.h>
+#include <gfx/color.h>
+#include <gfx/context.h>
+#include <gfx/render.h>
+#include <gfx/text.h>
+#include <io/pos_event.h>
+#include <stdlib.h>
+#include <str.h>
+#include <ui/paint.h>
+#include <ui/wdecor.h>
+#include "../private/resource.h"
+#include "../private/wdecor.h"
+
+/** Create new window decoration.
+ *
+ * @param resource UI resource
+ * @param caption Window caption
+ * @param rwdecor Place to store pointer to new window decoration
+ * @return EOK on success, ENOMEM if out of memory
+ */
+errno_t ui_wdecor_create(ui_resource_t *resource, const char *caption,
+    ui_wdecor_t **rwdecor)
+{
+	ui_wdecor_t *wdecor;
+
+	wdecor = calloc(1, sizeof(ui_wdecor_t));
+	if (wdecor == NULL)
+		return ENOMEM;
+
+	wdecor->caption = str_dup(caption);
+	if (wdecor->caption == NULL) {
+		free(wdecor);
+		return ENOMEM;
+	}
+
+	wdecor->res = resource;
+	wdecor->active = true;
+	*rwdecor = wdecor;
+	return EOK;
+}
+
+/** Destroy window decoration.
+ *
+ * @param wdecor Window decoration or @c NULL
+ */
+void ui_wdecor_destroy(ui_wdecor_t *wdecor)
+{
+	if (wdecor == NULL)
+		return;
+
+	free(wdecor);
+}
+
+/** Set window decoration callbacks.
+ *
+ * @param wdecor Window decoration
+ * @param cb Window decoration callbacks
+ * @param arg Callback argument
+ */
+void ui_wdecor_set_cb(ui_wdecor_t *wdecor, ui_wdecor_cb_t *cb, void *arg)
+{
+	wdecor->cb = cb;
+	wdecor->arg = arg;
+}
+
+/** Set window decoration rectangle.
+ *
+ * @param wdecor Window decoration
+ * @param rect New button rectanle
+ */
+void ui_wdecor_set_rect(ui_wdecor_t *wdecor, gfx_rect_t *rect)
+{
+	wdecor->rect = *rect;
+}
+
+/** Set active flag.
+ *
+ * Active window is the one receiving keyboard events.
+ *
+ * @param wdecor Window decoration
+ * @param active @c true iff window is active
+ */
+void ui_wdecor_set_active(ui_wdecor_t *wdecor, bool active)
+{
+	wdecor->active = active;
+}
+
+/** Paint window decoration.
+ *
+ * @param wdecor Window decoration
+ * @return EOK on success or an error code
+ */
+errno_t ui_wdecor_paint(ui_wdecor_t *wdecor)
+{
+	errno_t rc;
+	gfx_rect_t rect;
+	gfx_rect_t trect;
+	gfx_text_fmt_t fmt;
+	gfx_coord2_t pos;
+
+	rect = wdecor->rect;
+
+	rc = ui_paint_bevel(wdecor->res->gc, &rect,
+	    wdecor->res->wnd_frame_hi_color,
+	    wdecor->res->wnd_frame_sh_color, 1, &rect);
+	if (rc != EOK)
+		return rc;
+
+	rc = ui_paint_bevel(wdecor->res->gc, &rect,
+	    wdecor->res->wnd_highlight_color,
+	    wdecor->res->wnd_shadow_color, 1, &rect);
+	if (rc != EOK)
+		return rc;
+
+	rc = ui_paint_bevel(wdecor->res->gc, &rect,
+	    wdecor->res->wnd_face_color,
+	    wdecor->res->wnd_face_color, 2, &rect);
+	if (rc != EOK)
+		return rc;
+
+	trect.p0 = rect.p0;
+	trect.p1.x = rect.p1.x;
+	trect.p1.y = rect.p0.y + 22;
+
+	rc = ui_paint_bevel(wdecor->res->gc, &trect,
+	    wdecor->res->wnd_shadow_color,
+	    wdecor->res->wnd_highlight_color, 1, &trect);
+	if (rc != EOK)
+		return rc;
+
+	rc = gfx_set_color(wdecor->res->gc, wdecor->active ?
+	    wdecor->res->tbar_act_bg_color :
+	    wdecor->res->tbar_inact_bg_color);
+	if (rc != EOK)
+		return rc;
+
+	rc = gfx_fill_rect(wdecor->res->gc, &trect);
+	if (rc != EOK)
+		return rc;
+
+	gfx_text_fmt_init(&fmt);
+	fmt.halign = gfx_halign_center;
+	fmt.valign = gfx_valign_center;
+
+	pos.x = (trect.p0.x + trect.p1.x) / 2;
+	pos.y = (trect.p0.y + trect.p1.y) / 2;
+
+	rc = gfx_set_color(wdecor->res->gc, wdecor->active ?
+	    wdecor->res->tbar_act_text_color :
+	    wdecor->res->tbar_inact_text_color);
+	if (rc != EOK)
+		return rc;
+
+	rc = gfx_puttext(wdecor->res->font, &pos, &fmt, wdecor->caption);
+	if (rc != EOK)
+		return rc;
+
+	return EOK;
+}
+
+/** Send decoration move event.
+ *
+ * @param wdecor Window decoration
+ * @param pos Position where the title bar was pressed
+ */
+void ui_wdecor_move(ui_wdecor_t *wdecor, gfx_coord2_t *pos)
+{
+	if (wdecor->cb != NULL && wdecor->cb->move != NULL)
+		wdecor->cb->move(wdecor, wdecor->arg, pos);
+}
+
+/** Handle window decoration position event.
+ *
+ * @param wdecor Window decoration
+ * @param pos_event Position event
+ */
+void ui_wdecor_pos_event(ui_wdecor_t *wdecor, pos_event_t *event)
+{
+	gfx_rect_t trect;
+	gfx_coord2_t pos;
+
+	trect.p0.x = wdecor->rect.p0.x + 3;
+	trect.p0.y = wdecor->rect.p0.y + 3;
+	trect.p1.x = wdecor->rect.p1.x - 3;
+	trect.p1.y = trect.p0.y + 22;
+
+	pos.x = event->hpos;
+	pos.y = event->vpos;
+
+	if (event->type == POS_PRESS && gfx_pix_inside_rect(&pos, &trect))
+		ui_wdecor_move(wdecor, &pos);
+}
+
+/** @}
+ */
Index: uspace/lib/ui/test/main.c
===================================================================
--- uspace/lib/ui/test/main.c	(revision de9992c5dcfe392011d18f6d641c7151c514607a)
+++ uspace/lib/ui/test/main.c	(revision 17696938536729f8e143b51c1b0e5b84bbb276e7)
@@ -34,4 +34,5 @@
 PCUT_IMPORT(pbutton);
 PCUT_IMPORT(resource);
+PCUT_IMPORT(wdecor);
 
 PCUT_MAIN();
Index: uspace/lib/ui/test/wdecor.c
===================================================================
--- uspace/lib/ui/test/wdecor.c	(revision 17696938536729f8e143b51c1b0e5b84bbb276e7)
+++ uspace/lib/ui/test/wdecor.c	(revision 17696938536729f8e143b51c1b0e5b84bbb276e7)
@@ -0,0 +1,338 @@
+/*
+ * 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 <gfx/context.h>
+#include <gfx/coord.h>
+#include <mem.h>
+#include <pcut/pcut.h>
+#include <stdbool.h>
+#include <ui/resource.h>
+#include <ui/wdecor.h>
+#include "../private/wdecor.h"
+
+PCUT_INIT;
+
+PCUT_TEST_SUITE(wdecor);
+
+static errno_t testgc_set_color(void *, gfx_color_t *);
+static errno_t testgc_fill_rect(void *, gfx_rect_t *);
+static errno_t testgc_bitmap_create(void *, gfx_bitmap_params_t *,
+    gfx_bitmap_alloc_t *, void **);
+static errno_t testgc_bitmap_destroy(void *);
+static errno_t testgc_bitmap_render(void *, gfx_rect_t *, gfx_coord2_t *);
+static errno_t testgc_bitmap_get_alloc(void *, gfx_bitmap_alloc_t *);
+
+static gfx_context_ops_t ops = {
+	.set_color = testgc_set_color,
+	.fill_rect = testgc_fill_rect,
+	.bitmap_create = testgc_bitmap_create,
+	.bitmap_destroy = testgc_bitmap_destroy,
+	.bitmap_render = testgc_bitmap_render,
+	.bitmap_get_alloc = testgc_bitmap_get_alloc
+};
+
+static void test_wdecor_move(ui_wdecor_t *, void *, gfx_coord2_t *);
+
+static ui_wdecor_cb_t test_wdecor_cb = {
+	.move = test_wdecor_move
+};
+
+static ui_wdecor_cb_t dummy_wdecor_cb = {
+};
+
+typedef struct {
+	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;
+} test_gc_t;
+
+typedef struct {
+	test_gc_t *tgc;
+	gfx_bitmap_alloc_t alloc;
+	bool myalloc;
+} testgc_bitmap_t;
+
+typedef struct {
+	bool move;
+	gfx_coord2_t pos;
+} test_cb_resp_t;
+
+/** Create and destroy button */
+PCUT_TEST(create_destroy)
+{
+	ui_wdecor_t *wdecor = NULL;
+	errno_t rc;
+
+	rc = ui_wdecor_create(NULL, "Hello", &wdecor);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(wdecor);
+
+	ui_wdecor_destroy(wdecor);
+}
+
+/** ui_wdecor_destroy() can take NULL argument (no-op) */
+PCUT_TEST(destroy_null)
+{
+	ui_wdecor_destroy(NULL);
+}
+
+/** Set window decoration rectangle sets internal field */
+PCUT_TEST(set_rect)
+{
+	ui_wdecor_t *wdecor;
+	gfx_rect_t rect;
+	errno_t rc;
+
+	rc = ui_wdecor_create(NULL, "Hello", &wdecor);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rect.p0.x = 1;
+	rect.p0.y = 2;
+	rect.p1.x = 3;
+	rect.p1.y = 4;
+
+	ui_wdecor_set_rect(wdecor, &rect);
+	PCUT_ASSERT_INT_EQUALS(rect.p0.x, wdecor->rect.p0.x);
+	PCUT_ASSERT_INT_EQUALS(rect.p0.y, wdecor->rect.p0.y);
+	PCUT_ASSERT_INT_EQUALS(rect.p1.x, wdecor->rect.p1.x);
+	PCUT_ASSERT_INT_EQUALS(rect.p1.y, wdecor->rect.p1.y);
+
+	ui_wdecor_destroy(wdecor);
+}
+
+/** Set window decoration active sets internal field */
+PCUT_TEST(set_active)
+{
+	ui_wdecor_t *wdecor;
+	errno_t rc;
+
+	rc = ui_wdecor_create(NULL, "Hello", &wdecor);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	PCUT_ASSERT_TRUE(wdecor->active);
+
+	ui_wdecor_set_active(wdecor, false);
+	PCUT_ASSERT_FALSE(wdecor->active);
+
+	ui_wdecor_set_active(wdecor, true);
+	PCUT_ASSERT_TRUE(wdecor->active);
+
+	ui_wdecor_destroy(wdecor);
+}
+
+/** Paint button */
+PCUT_TEST(paint)
+{
+	errno_t rc;
+	gfx_context_t *gc = NULL;
+	test_gc_t tgc;
+	ui_resource_t *resource = NULL;
+	ui_wdecor_t *wdecor;
+
+	memset(&tgc, 0, sizeof(tgc));
+	rc = gfx_context_new(&ops, &tgc, &gc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = ui_resource_create(gc, &resource);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	PCUT_ASSERT_NOT_NULL(resource);
+
+	rc = ui_wdecor_create(resource, "Hello", &wdecor);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = ui_wdecor_paint(wdecor);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	ui_wdecor_destroy(wdecor);
+	ui_resource_destroy(resource);
+
+	rc = gfx_context_delete(gc);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+}
+
+/** Test ui_wdecor_move() */
+PCUT_TEST(move)
+{
+	errno_t rc;
+	ui_wdecor_t *wdecor;
+	test_cb_resp_t resp;
+	gfx_coord2_t pos;
+
+	rc = ui_wdecor_create(NULL, "Hello", &wdecor);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	pos.x = 3;
+	pos.y = 4;
+
+	/* Move callback with no callbacks set */
+	ui_wdecor_move(wdecor, &pos);
+
+	/* Move callback with move callback not implemented */
+	ui_wdecor_set_cb(wdecor, &dummy_wdecor_cb, NULL);
+	ui_wdecor_move(wdecor, &pos);
+
+	/* Move callback with real callback set */
+	resp.move = false;
+	resp.pos.x = 0;
+	resp.pos.y = 0;
+	ui_wdecor_set_cb(wdecor, &test_wdecor_cb, &resp);
+	ui_wdecor_move(wdecor, &pos);
+	PCUT_ASSERT_TRUE(resp.move);
+	PCUT_ASSERT_INT_EQUALS(pos.x, resp.pos.x);
+	PCUT_ASSERT_INT_EQUALS(pos.y, resp.pos.y);
+
+	ui_wdecor_destroy(wdecor);
+}
+
+/** Button press on title bar generates move callback */
+PCUT_TEST(pos_event_move)
+{
+	ui_wdecor_t *wdecor;
+	gfx_rect_t rect;
+	pos_event_t event;
+	test_cb_resp_t resp;
+	errno_t rc;
+
+	rc = ui_wdecor_create(NULL, "Hello", &wdecor);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rect.p0.x = 10;
+	rect.p0.y = 20;
+	rect.p1.x = 100;
+	rect.p1.y = 200;
+
+	ui_wdecor_set_rect(wdecor, &rect);
+
+	ui_wdecor_set_cb(wdecor, &test_wdecor_cb, (void *) &resp);
+
+	resp.move = false;
+	resp.pos.x = 0;
+	resp.pos.y = 0;
+
+	event.type = POS_PRESS;
+	event.hpos = 50;
+	event.vpos = 25;
+	ui_wdecor_pos_event(wdecor, &event);
+
+	PCUT_ASSERT_TRUE(resp.move);
+	PCUT_ASSERT_INT_EQUALS(event.hpos, resp.pos.x);
+	PCUT_ASSERT_INT_EQUALS(event.vpos, resp.pos.y);
+
+	ui_wdecor_destroy(wdecor);
+}
+
+static errno_t testgc_set_color(void *arg, gfx_color_t *color)
+{
+	(void) arg;
+	(void) color;
+	return EOK;
+}
+
+static errno_t testgc_fill_rect(void *arg, gfx_rect_t *rect)
+{
+	(void) arg;
+	(void) rect;
+	return EOK;
+}
+
+static errno_t testgc_bitmap_create(void *arg, gfx_bitmap_params_t *params,
+    gfx_bitmap_alloc_t *alloc, void **rbm)
+{
+	test_gc_t *tgc = (test_gc_t *) arg;
+	testgc_bitmap_t *tbm;
+
+	tbm = calloc(1, sizeof(testgc_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->tgc = tgc;
+	tgc->bm_created = true;
+	tgc->bm_params = *params;
+	tgc->bm_pixels = tbm->alloc.pixels;
+	*rbm = (void *)tbm;
+	return EOK;
+}
+
+static errno_t testgc_bitmap_destroy(void *bm)
+{
+	testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
+	if (tbm->myalloc)
+		free(tbm->alloc.pixels);
+	tbm->tgc->bm_destroyed = true;
+	free(tbm);
+	return EOK;
+}
+
+static errno_t testgc_bitmap_render(void *bm, gfx_rect_t *srect,
+    gfx_coord2_t *offs)
+{
+	testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
+	tbm->tgc->bm_rendered = true;
+	tbm->tgc->bm_srect = *srect;
+	tbm->tgc->bm_offs = *offs;
+	return EOK;
+}
+
+static errno_t testgc_bitmap_get_alloc(void *bm, gfx_bitmap_alloc_t *alloc)
+{
+	testgc_bitmap_t *tbm = (testgc_bitmap_t *)bm;
+	*alloc = tbm->alloc;
+	tbm->tgc->bm_got_alloc = true;
+	return EOK;
+}
+
+static void test_wdecor_move(ui_wdecor_t *wdecor, void *arg, gfx_coord2_t *pos)
+{
+	test_cb_resp_t *resp = (test_cb_resp_t *) arg;
+
+	resp->move = true;
+	resp->pos = *pos;
+}
+
+PCUT_EXPORT(wdecor);
