Index: uspace/app/terminal/terminal.c
===================================================================
--- uspace/app/terminal/terminal.c	(revision d55ab8231eb545c1c99c91124cfdc1401993cbe7)
+++ uspace/app/terminal/terminal.c	(revision 8c772c4652b43b3ca58c297c04ff5b6fab69691a)
@@ -835,5 +835,4 @@
 
 	term->gc = ui_window_get_gc(term->window);
-	term->ui_res = ui_window_get_res(term->window);
 
 	ui_window_set_cb(term->window, &terminal_window_cb, (void *) term);
Index: uspace/app/terminal/terminal.h
===================================================================
--- uspace/app/terminal/terminal.h	(revision d55ab8231eb545c1c99c91124cfdc1401993cbe7)
+++ uspace/app/terminal/terminal.h	(revision 8c772c4652b43b3ca58c297c04ff5b6fab69691a)
@@ -57,5 +57,4 @@
 	ui_t *ui;
 	ui_window_t *window;
-	ui_resource_t *ui_res;
 	gfx_context_t *gc;
 
Index: uspace/app/uidemo/uidemo.c
===================================================================
--- uspace/app/uidemo/uidemo.c	(revision d55ab8231eb545c1c99c91124cfdc1401993cbe7)
+++ uspace/app/uidemo/uidemo.c	(revision 8c772c4652b43b3ca58c297c04ff5b6fab69691a)
@@ -99,5 +99,4 @@
 	ui_demo_t demo;
 	gfx_rect_t rect;
-	ui_resource_t *ui_res;
 	errno_t rc;
 
@@ -127,6 +126,4 @@
 	demo.window = window;
 
-	ui_res = ui_window_get_res(window);
-
 	rc = ui_fixed_create(&demo.fixed);
 	if (rc != EOK) {
@@ -135,5 +132,5 @@
 	}
 
-	rc = ui_label_create(ui_res, "Hello there!", &demo.label);
+	rc = ui_label_create(ui, "Hello there!", &demo.label);
 	if (rc != EOK) {
 		printf("Error creating label.\n");
@@ -154,5 +151,5 @@
 	}
 
-	rc = ui_pbutton_create(ui_res, "Confirm", &demo.pb1);
+	rc = ui_pbutton_create(ui, "Confirm", &demo.pb1);
 	if (rc != EOK) {
 		printf("Error creating button.\n");
@@ -176,5 +173,5 @@
 	}
 
-	rc = ui_pbutton_create(ui_res, "Cancel", &demo.pb2);
+	rc = ui_pbutton_create(ui, "Cancel", &demo.pb2);
 	if (rc != EOK) {
 		printf("Error creating button.\n");
Index: uspace/lib/ui/include/ui/label.h
===================================================================
--- uspace/lib/ui/include/ui/label.h	(revision d55ab8231eb545c1c99c91124cfdc1401993cbe7)
+++ uspace/lib/ui/include/ui/label.h	(revision 8c772c4652b43b3ca58c297c04ff5b6fab69691a)
@@ -42,7 +42,7 @@
 #include <types/ui/control.h>
 #include <types/ui/label.h>
-#include <types/ui/resource.h>
+#include <types/ui/ui.h>
 
-extern errno_t ui_label_create(ui_resource_t *, const char *,
+extern errno_t ui_label_create(ui_t *, const char *,
     ui_label_t **);
 extern void ui_label_destroy(ui_label_t *);
Index: uspace/lib/ui/include/ui/pbutton.h
===================================================================
--- uspace/lib/ui/include/ui/pbutton.h	(revision d55ab8231eb545c1c99c91124cfdc1401993cbe7)
+++ uspace/lib/ui/include/ui/pbutton.h	(revision 8c772c4652b43b3ca58c297c04ff5b6fab69691a)
@@ -43,8 +43,8 @@
 #include <types/ui/event.h>
 #include <types/ui/pbutton.h>
-#include <types/ui/resource.h>
+#include <types/ui/ui.h>
 #include <stdbool.h>
 
-extern errno_t ui_pbutton_create(ui_resource_t *, const char *,
+extern errno_t ui_pbutton_create(ui_t *, const char *,
     ui_pbutton_t **);
 extern void ui_pbutton_destroy(ui_pbutton_t *);
Index: uspace/lib/ui/include/ui/wdecor.h
===================================================================
--- uspace/lib/ui/include/ui/wdecor.h	(revision d55ab8231eb545c1c99c91124cfdc1401993cbe7)
+++ uspace/lib/ui/include/ui/wdecor.h	(revision 8c772c4652b43b3ca58c297c04ff5b6fab69691a)
@@ -41,8 +41,8 @@
 #include <io/pos_event.h>
 #include <stdbool.h>
-#include <types/ui/resource.h>
+#include <types/ui/ui.h>
 #include <types/ui/wdecor.h>
 
-extern errno_t ui_wdecor_create(ui_resource_t *, const char *,
+extern errno_t ui_wdecor_create(ui_t *, const char *,
     ui_wdecor_t **);
 extern void ui_wdecor_destroy(ui_wdecor_t *);
Index: uspace/lib/ui/include/ui/window.h
===================================================================
--- uspace/lib/ui/include/ui/window.h	(revision d55ab8231eb545c1c99c91124cfdc1401993cbe7)
+++ uspace/lib/ui/include/ui/window.h	(revision 8c772c4652b43b3ca58c297c04ff5b6fab69691a)
@@ -53,5 +53,4 @@
 extern void ui_window_add(ui_window_t *, ui_control_t *);
 extern void ui_window_remove(ui_window_t *, ui_control_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 *);
Index: uspace/lib/ui/private/ui.h
===================================================================
--- uspace/lib/ui/private/ui.h	(revision d55ab8231eb545c1c99c91124cfdc1401993cbe7)
+++ uspace/lib/ui/private/ui.h	(revision 8c772c4652b43b3ca58c297c04ff5b6fab69691a)
@@ -48,4 +48,6 @@
 	/** Display */
 	display_t *display;
+	/** UI resource */
+	struct ui_resource *resource;
 	/** Output owned by UI, clean up when destroying UI */
 	bool myoutput;
Index: uspace/lib/ui/src/label.c
===================================================================
--- uspace/lib/ui/src/label.c	(revision d55ab8231eb545c1c99c91124cfdc1401993cbe7)
+++ uspace/lib/ui/src/label.c	(revision 8c772c4652b43b3ca58c297c04ff5b6fab69691a)
@@ -45,4 +45,5 @@
 #include "../private/label.h"
 #include "../private/resource.h"
+#include "../private/ui.h"
 
 static void ui_label_ctl_destroy(void *);
@@ -64,5 +65,5 @@
  * @return EOK on success, ENOMEM if out of memory
  */
-errno_t ui_label_create(ui_resource_t *resource, const char *text,
+errno_t ui_label_create(ui_t *ui, const char *text,
     ui_label_t **rlabel)
 {
@@ -87,5 +88,5 @@
 	}
 
-	label->res = resource;
+	label->res = ui->resource;
 	label->halign = gfx_halign_left;
 	*rlabel = label;
Index: uspace/lib/ui/src/pbutton.c
===================================================================
--- uspace/lib/ui/src/pbutton.c	(revision d55ab8231eb545c1c99c91124cfdc1401993cbe7)
+++ uspace/lib/ui/src/pbutton.c	(revision 8c772c4652b43b3ca58c297c04ff5b6fab69691a)
@@ -47,4 +47,5 @@
 #include "../private/pbutton.h"
 #include "../private/resource.h"
+#include "../private/ui.h"
 
 /** Caption movement when button is pressed down */
@@ -72,5 +73,5 @@
  * @return EOK on success, ENOMEM if out of memory
  */
-errno_t ui_pbutton_create(ui_resource_t *resource, const char *caption,
+errno_t ui_pbutton_create(ui_t *ui, const char *caption,
     ui_pbutton_t **rpbutton)
 {
@@ -96,5 +97,5 @@
 	}
 
-	pbutton->res = resource;
+	pbutton->res = ui->resource;
 	*rpbutton = pbutton;
 	return EOK;
Index: uspace/lib/ui/src/wdecor.c
===================================================================
--- uspace/lib/ui/src/wdecor.c	(revision d55ab8231eb545c1c99c91124cfdc1401993cbe7)
+++ uspace/lib/ui/src/wdecor.c	(revision 8c772c4652b43b3ca58c297c04ff5b6fab69691a)
@@ -46,4 +46,5 @@
 #include <ui/wdecor.h>
 #include "../private/resource.h"
+#include "../private/ui.h"
 #include "../private/wdecor.h"
 
@@ -61,5 +62,5 @@
  * @return EOK on success, ENOMEM if out of memory
  */
-errno_t ui_wdecor_create(ui_resource_t *resource, const char *caption,
+errno_t ui_wdecor_create(ui_t *ui, const char *caption,
     ui_wdecor_t **rwdecor)
 {
@@ -77,5 +78,5 @@
 	}
 
-	rc = ui_pbutton_create(resource, "X", &wdecor->btn_close);
+	rc = ui_pbutton_create(ui, "X", &wdecor->btn_close);
 	if (rc != EOK) {
 		free(wdecor->caption);
@@ -87,5 +88,5 @@
 	    (void *)wdecor);
 
-	wdecor->res = resource;
+	wdecor->res = ui->resource;
 	wdecor->active = true;
 	*rwdecor = wdecor;
Index: uspace/lib/ui/src/window.c
===================================================================
--- uspace/lib/ui/src/window.c	(revision d55ab8231eb545c1c99c91124cfdc1401993cbe7)
+++ uspace/lib/ui/src/window.c	(revision 8c772c4652b43b3ca58c297c04ff5b6fab69691a)
@@ -135,5 +135,7 @@
 		goto error;
 
-	rc = ui_wdecor_create(res, params->caption, &wdecor);
+	ui->resource = res;
+
+	rc = ui_wdecor_create(ui, params->caption, &wdecor);
 	if (rc != EOK)
 		goto error;
@@ -223,9 +225,12 @@
 }
 
-ui_resource_t *ui_window_get_res(ui_window_t *window)
-{
-	return window->res;
-}
-
+/** Get window GC.
+ *
+ * Return the grapic context of the window. It is relative to the upper-left
+ * corner of the window.
+ *
+ * @param window Window
+ * @return Graphic context
+ */
 gfx_context_t *ui_window_get_gc(ui_window_t *window)
 {
@@ -233,4 +238,12 @@
 }
 
+/** Get window application rectangle.
+ *
+ * Return the window's application rectangle. This is a rectangle covering
+ * everything apart from the window frame and title bar.
+ *
+ * @param window Window
+ * @param rect Place to store application rectangle
+ */
 void ui_window_get_app_rect(ui_window_t *window, gfx_rect_t *rect)
 {
@@ -241,4 +254,9 @@
 }
 
+/** Paint window.
+ *
+ * @param window Window
+ * @return EOK on success or an error code
+ */
 errno_t ui_window_paint(ui_window_t *window)
 {
Index: uspace/lib/ui/test/label.c
===================================================================
--- uspace/lib/ui/test/label.c	(revision d55ab8231eb545c1c99c91124cfdc1401993cbe7)
+++ uspace/lib/ui/test/label.c	(revision 8c772c4652b43b3ca58c297c04ff5b6fab69691a)
@@ -34,5 +34,5 @@
 #include <ui/control.h>
 #include <ui/label.h>
-#include <ui/resource.h>
+#include <ui/ui.h>
 #include "../private/label.h"
 
@@ -40,38 +40,4 @@
 
 PCUT_TEST_SUITE(label);
-
-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
-};
-
-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 {
@@ -183,18 +149,11 @@
 {
 	errno_t rc;
-	gfx_context_t *gc = NULL;
-	test_gc_t tgc;
-	ui_resource_t *resource = NULL;
+	ui_t *ui;
 	ui_label_t *label;
 
-	memset(&tgc, 0, sizeof(tgc));
-	rc = gfx_context_new(&ops, &tgc, &gc);
+	rc = ui_create_disp(NULL, &ui);
 	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_label_create(resource, "Hello", &label);
+	rc = ui_label_create(ui, "Hello", &label);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
@@ -203,84 +162,5 @@
 
 	ui_label_destroy(label);
-	ui_resource_destroy(resource);
-
-	rc = gfx_context_delete(gc);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-}
-
-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;
+	ui_destroy(ui);
 }
 
Index: uspace/lib/ui/test/pbutton.c
===================================================================
--- uspace/lib/ui/test/pbutton.c	(revision d55ab8231eb545c1c99c91124cfdc1401993cbe7)
+++ uspace/lib/ui/test/pbutton.c	(revision 8c772c4652b43b3ca58c297c04ff5b6fab69691a)
@@ -34,5 +34,5 @@
 #include <ui/control.h>
 #include <ui/pbutton.h>
-#include <ui/resource.h>
+#include <ui/ui.h>
 #include "../private/pbutton.h"
 
@@ -40,21 +40,4 @@
 
 PCUT_TEST_SUITE(pbutton);
-
-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_pbutton_clicked(ui_pbutton_t *, void *);
@@ -66,21 +49,4 @@
 static ui_pbutton_cb_t dummy_pbutton_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 {
@@ -169,18 +135,11 @@
 {
 	errno_t rc;
-	gfx_context_t *gc = NULL;
-	test_gc_t tgc;
-	ui_resource_t *resource = NULL;
-	ui_pbutton_t *pbutton;
-
-	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_pbutton_create(resource, "Hello", &pbutton);
+	ui_t *ui;
+	ui_pbutton_t *pbutton;
+
+	rc = ui_create_disp(NULL, &ui);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = ui_pbutton_create(ui, "Hello", &pbutton);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
@@ -189,8 +148,5 @@
 
 	ui_pbutton_destroy(pbutton);
-	ui_resource_destroy(resource);
-
-	rc = gfx_context_delete(gc);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	ui_destroy(ui);
 }
 
@@ -225,19 +181,12 @@
 {
 	errno_t rc;
-	gfx_context_t *gc = NULL;
-	test_gc_t tgc;
-	ui_resource_t *resource = NULL;
+	ui_t *ui;
 	ui_pbutton_t *pbutton;
 	test_cb_resp_t resp;
 
-	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_pbutton_create(resource, "Hello", &pbutton);
+	rc = ui_create_disp(NULL, &ui);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = ui_pbutton_create(ui, "Hello", &pbutton);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
@@ -259,8 +208,5 @@
 
 	ui_pbutton_destroy(pbutton);
-	ui_resource_destroy(resource);
-
-	rc = gfx_context_delete(gc);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	ui_destroy(ui);
 }
 
@@ -269,19 +215,12 @@
 {
 	errno_t rc;
-	gfx_context_t *gc = NULL;
-	test_gc_t tgc;
-	ui_resource_t *resource = NULL;
+	ui_t *ui;
 	ui_pbutton_t *pbutton;
 	test_cb_resp_t resp;
 
-	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_pbutton_create(resource, "Hello", &pbutton);
+	rc = ui_create_disp(NULL, &ui);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = ui_pbutton_create(ui, "Hello", &pbutton);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
@@ -308,8 +247,5 @@
 
 	ui_pbutton_destroy(pbutton);
-	ui_resource_destroy(resource);
-
-	rc = gfx_context_delete(gc);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	ui_destroy(ui);
 }
 
@@ -318,19 +254,12 @@
 {
 	errno_t rc;
-	gfx_context_t *gc = NULL;
-	test_gc_t tgc;
-	ui_resource_t *resource = NULL;
+	ui_t *ui;
 	ui_pbutton_t *pbutton;
 	test_cb_resp_t resp;
 
-	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_pbutton_create(resource, "Hello", &pbutton);
+	rc = ui_create_disp(NULL, &ui);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = ui_pbutton_create(ui, "Hello", &pbutton);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
@@ -362,8 +291,5 @@
 
 	ui_pbutton_destroy(pbutton);
-	ui_resource_destroy(resource);
-
-	rc = gfx_context_delete(gc);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	ui_destroy(ui);
 }
 
@@ -372,7 +298,5 @@
 {
 	errno_t rc;
-	gfx_context_t *gc = NULL;
-	test_gc_t tgc;
-	ui_resource_t *resource = NULL;
+	ui_t *ui;
 	ui_pbutton_t *pbutton;
 	ui_evclaim_t claim;
@@ -380,13 +304,8 @@
 	gfx_rect_t rect;
 
-	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_pbutton_create(resource, "Hello", &pbutton);
+	rc = ui_create_disp(NULL, &ui);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = ui_pbutton_create(ui, "Hello", &pbutton);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
@@ -424,8 +343,5 @@
 
 	ui_pbutton_destroy(pbutton);
-	ui_resource_destroy(resource);
-
-	rc = gfx_context_delete(gc);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	ui_destroy(ui);
 }
 
@@ -434,20 +350,13 @@
 {
 	errno_t rc;
-	gfx_context_t *gc = NULL;
-	test_gc_t tgc;
-	ui_resource_t *resource = NULL;
+	ui_t *ui;
 	ui_pbutton_t *pbutton;
 	pos_event_t event;
 	gfx_rect_t rect;
 
-	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_pbutton_create(resource, "Hello", &pbutton);
+	rc = ui_create_disp(NULL, &ui);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = ui_pbutton_create(ui, "Hello", &pbutton);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
@@ -482,84 +391,5 @@
 
 	ui_pbutton_destroy(pbutton);
-	ui_resource_destroy(resource);
-
-	rc = gfx_context_delete(gc);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
-}
-
-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;
+	ui_destroy(ui);
 }
 
Index: uspace/lib/ui/test/wdecor.c
===================================================================
--- uspace/lib/ui/test/wdecor.c	(revision d55ab8231eb545c1c99c91124cfdc1401993cbe7)
+++ uspace/lib/ui/test/wdecor.c	(revision 8c772c4652b43b3ca58c297c04ff5b6fab69691a)
@@ -33,5 +33,5 @@
 #include <stdbool.h>
 #include <ui/pbutton.h>
-#include <ui/resource.h>
+#include <ui/ui.h>
 #include <ui/wdecor.h>
 #include "../private/wdecor.h"
@@ -40,21 +40,4 @@
 
 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_close(ui_wdecor_t *, void *);
@@ -68,21 +51,4 @@
 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 {
@@ -159,18 +125,11 @@
 {
 	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);
+	ui_t *ui;
+	ui_wdecor_t *wdecor;
+
+	rc = ui_create_disp(NULL, &ui);
+	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+
+	rc = ui_wdecor_create(ui, "Hello", &wdecor);
 	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
 
@@ -179,8 +138,5 @@
 
 	ui_wdecor_destroy(wdecor);
-	ui_resource_destroy(resource);
-
-	rc = gfx_context_delete(gc);
-	PCUT_ASSERT_ERRNO_VAL(EOK, rc);
+	ui_destroy(ui);
 }
 
@@ -371,80 +327,4 @@
 }
 
-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_close(ui_wdecor_t *wdecor, void *arg)
 {
Index: uspace/lib/ui/test/window.c
===================================================================
--- uspace/lib/ui/test/window.c	(revision d55ab8231eb545c1c99c91124cfdc1401993cbe7)
+++ uspace/lib/ui/test/window.c	(revision 8c772c4652b43b3ca58c297c04ff5b6fab69691a)
@@ -35,5 +35,4 @@
 #include <stdbool.h>
 #include <ui/control.h>
-#include <ui/resource.h>
 #include <ui/ui.h>
 #include <ui/window.h>
@@ -174,12 +173,11 @@
 }
 
-/** 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;
+/** ui_window_get_gc/rect() return valid objects */
+PCUT_TEST(gc_rect)
+{
+	errno_t rc;
+	ui_t *ui = NULL;
+	ui_wnd_params_t params;
+	ui_window_t *window = NULL;
 	gfx_context_t *gc;
 	gfx_rect_t rect;
@@ -194,7 +192,4 @@
 	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);
