Index: tools/xcw/demo/Makefile
===================================================================
--- tools/xcw/demo/Makefile	(revision 2c9fdeedc215dcd9caf895b28b729baafa0f3971)
+++ tools/xcw/demo/Makefile	(revision 38f55980b853a6d2953396322e7620146fa59ad2)
@@ -50,7 +50,7 @@
 INSTALL = install
 TEST = helenos-test
-CFLAGS = -std=gnu11 -Wall `helenos-pkg-config --cflags libgui libdraw libmath` \
+CFLAGS = -std=gnu11 -Wall `helenos-pkg-config --cflags libui libdraw libmath` \
     -D_HELENOS_SOURCE
-LIBS = `helenos-pkg-config --libs libgui libdraw libmath`
+LIBS = `helenos-pkg-config --libs libui libdraw libmath`
 PREFIX = `helenos-bld-config --install-dir`
 output = viewer
Index: pace/lib/gui/button.c
===================================================================
--- uspace/lib/gui/button.c	(revision 2c9fdeedc215dcd9caf895b28b729baafa0f3971)
+++ 	(revision )
@@ -1,211 +1,0 @@
-/*
- * Copyright (c) 2012 Petr Koupy
- * 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 gui
- * @{
- */
-/**
- * @file
- */
-
-#include <str.h>
-#include <stdlib.h>
-#include <draw/drawctx.h>
-#include <draw/surface.h>
-#include <draw/font.h>
-#include <errno.h>
-#include "common.h"
-#include "window.h"
-#include "button.h"
-
-static pixel_t color_highlight = PIXEL(255, 255, 255, 255);
-static pixel_t color_shadow = PIXEL(255, 85, 85, 85);
-
-static void paint_internal(widget_t *widget)
-{
-	button_t *btn = (button_t *) widget;
-
-	surface_t *surface = window_claim(btn->widget.window);
-	if (!surface)
-		window_yield(btn->widget.window);
-
-	source_t source;
-	source_init(&source);
-
-	drawctx_t drawctx;
-	drawctx_init(&drawctx, surface);
-
-	drawctx_set_compose(&drawctx, compose_over);
-	drawctx_set_source(&drawctx, &btn->background);
-	drawctx_transfer(&drawctx, widget->hpos, widget->vpos,
-	    widget->width, widget->height);
-
-	if ((widget->width >= 8) && (widget->height >= 8)) {
-		drawctx_set_source(&drawctx, &source);
-		draw_bevel(&drawctx, &source, widget->hpos + 3, widget->vpos + 3,
-		    widget->width - 6, widget->height - 6, color_highlight,
-		    color_shadow);
-
-		drawctx_set_source(&drawctx, &btn->foreground);
-		drawctx_transfer(&drawctx, widget->hpos + 4, widget->vpos + 4,
-		    widget->width - 8, widget->height - 8);
-	}
-
-	sysarg_t cpt_width;
-	sysarg_t cpt_height;
-	font_get_box(btn->font, btn->caption, &cpt_width, &cpt_height);
-
-	if ((widget->width >= cpt_width) && (widget->height >= cpt_height)) {
-		sysarg_t x = ((widget->width - cpt_width) / 2) + widget->hpos;
-		sysarg_t y = ((widget->height - cpt_height) / 2) + widget->vpos;
-
-		drawctx_set_source(&drawctx, &btn->text);
-		drawctx_set_font(&drawctx, btn->font);
-
-		if (btn->caption)
-			drawctx_print(&drawctx, btn->caption, x, y);
-	}
-
-	window_yield(btn->widget.window);
-}
-
-void deinit_button(button_t *btn)
-{
-	widget_deinit(&btn->widget);
-	free(btn->caption);
-	font_release(btn->font);
-}
-
-static void button_destroy(widget_t *widget)
-{
-	button_t *btn = (button_t *) widget;
-
-	deinit_button(btn);
-	free(btn);
-}
-
-static void button_reconfigure(widget_t *widget)
-{
-	/* no-op */
-}
-
-static void button_rearrange(widget_t *widget, sysarg_t hpos, sysarg_t vpos,
-    sysarg_t width, sysarg_t height)
-{
-	widget_modify(widget, hpos, vpos, width, height);
-	paint_internal(widget);
-}
-
-static void button_repaint(widget_t *widget)
-{
-	paint_internal(widget);
-	window_damage(widget->window);
-}
-
-static void button_handle_keyboard_event(widget_t *widget, kbd_event_t event)
-{
-	button_t *btn = (button_t *) widget;
-
-	if (event.key == KC_ENTER && event.type == KEY_PRESS)
-		sig_send(&btn->clicked, NULL);
-}
-
-static void button_handle_position_event(widget_t *widget, pos_event_t event)
-{
-	button_t *btn = (button_t *) widget;
-	widget->window->focus = widget;
-
-	// TODO make the click logic more robust (mouse grabbing, mouse moves)
-	if (event.btn_num == 1) {
-		if (event.type == POS_RELEASE)
-			sig_send(&btn->clicked, NULL);
-	}
-}
-
-bool init_button(button_t *btn, widget_t *parent, const void *data,
-    const char *caption, uint16_t points, pixel_t background,
-    pixel_t foreground, pixel_t text)
-{
-	widget_init(&btn->widget, parent, data);
-
-	btn->widget.destroy = button_destroy;
-	btn->widget.reconfigure = button_reconfigure;
-	btn->widget.rearrange = button_rearrange;
-	btn->widget.repaint = button_repaint;
-	btn->widget.handle_keyboard_event = button_handle_keyboard_event;
-	btn->widget.handle_position_event = button_handle_position_event;
-
-	source_init(&btn->background);
-	source_set_color(&btn->background, background);
-
-	source_init(&btn->foreground);
-	source_set_color(&btn->foreground, foreground);
-
-	source_init(&btn->text);
-	source_set_color(&btn->text, text);
-
-	if (caption == NULL)
-		btn->caption = NULL;
-	else
-		btn->caption = str_dup(caption);
-
-	errno_t rc = embedded_font_create(&btn->font, points);
-	if (rc != EOK) {
-		free(btn->caption);
-		btn->caption = NULL;
-		return false;
-	}
-
-	sysarg_t cpt_width;
-	sysarg_t cpt_height;
-	font_get_box(btn->font, btn->caption, &cpt_width, &cpt_height);
-	btn->widget.width_min = cpt_width + 10;
-	btn->widget.height_min = cpt_height + 10;
-	btn->widget.width_ideal = cpt_width + 30;
-	btn->widget.height_ideal = cpt_height + 10;
-
-	return true;
-}
-
-button_t *create_button(widget_t *parent, const void *data, const char *caption,
-    uint16_t points, pixel_t background, pixel_t foreground, pixel_t text)
-{
-	button_t *btn = (button_t *) malloc(sizeof(button_t));
-	if (!btn)
-		return NULL;
-
-	if (init_button(btn, parent, data, caption, points, background, foreground,
-	    text))
-		return btn;
-
-	free(btn);
-	return NULL;
-}
-
-/** @}
- */
Index: pace/lib/gui/button.h
===================================================================
--- uspace/lib/gui/button.h	(revision 2c9fdeedc215dcd9caf895b28b729baafa0f3971)
+++ 	(revision )
@@ -1,67 +1,0 @@
-/*
- * Copyright (c) 2012 Petr Koupy
- * 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 gui
- * @{
- */
-/**
- * @file
- */
-
-#ifndef GUI_BUTTON_H_
-#define GUI_BUTTON_H_
-
-#include <stdint.h>
-#include <io/pixel.h>
-
-#include <draw/source.h>
-#include <draw/font.h>
-
-#include "connection.h"
-#include "widget.h"
-
-typedef struct button {
-	widget_t widget;
-	source_t background;
-	source_t foreground;
-	source_t text;
-	char *caption;
-	font_t *font;
-	signal_t clicked;
-} button_t;
-
-extern bool init_button(button_t *, widget_t *, const void *, const char *,
-    uint16_t, pixel_t, pixel_t, pixel_t);
-extern button_t *create_button(widget_t *, const void *, const char *, uint16_t,
-    pixel_t, pixel_t, pixel_t);
-extern void deinit_button(button_t *);
-
-#endif
-
-/** @}
- */
Index: pace/lib/gui/canvas.c
===================================================================
--- uspace/lib/gui/canvas.c	(revision 2c9fdeedc215dcd9caf895b28b729baafa0f3971)
+++ 	(revision )
@@ -1,178 +1,0 @@
-/*
- * Copyright (c) 2013 Martin Decky
- * 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 gui
- * @{
- */
-/**
- * @file
- */
-
-#include <stdlib.h>
-#include <transform.h>
-#include <draw/source.h>
-#include <draw/surface.h>
-#include <draw/drawctx.h>
-#include "window.h"
-#include "canvas.h"
-
-static void paint_internal(widget_t *widget)
-{
-	canvas_t *canvas = (canvas_t *) widget;
-
-	surface_t *surface = window_claim(canvas->widget.window);
-	if (!surface) {
-		window_yield(canvas->widget.window);
-	}
-
-	transform_t transform;
-	transform_identity(&transform);
-	transform_translate(&transform, widget->hpos, widget->vpos);
-
-	source_t source;
-	source_init(&source);
-	source_set_transform(&source, transform);
-	source_set_texture(&source, canvas->surface,
-	    PIXELMAP_EXTEND_TRANSPARENT_BLACK);
-
-	drawctx_t drawctx;
-	drawctx_init(&drawctx, surface);
-
-	drawctx_set_source(&drawctx, &source);
-	drawctx_transfer(&drawctx, widget->hpos, widget->vpos, widget->width,
-	    widget->height);
-
-	window_yield(canvas->widget.window);
-}
-
-void deinit_canvas(canvas_t *canvas)
-{
-	widget_deinit(&canvas->widget);
-}
-
-static void canvas_destroy(widget_t *widget)
-{
-	canvas_t *canvas = (canvas_t *) widget;
-
-	deinit_canvas(canvas);
-	free(canvas);
-}
-
-static void canvas_reconfigure(widget_t *widget)
-{
-	/* No-op */
-}
-
-static void canvas_rearrange(widget_t *widget, sysarg_t hpos, sysarg_t vpos,
-    sysarg_t width, sysarg_t height)
-{
-	canvas_t *canvas = (canvas_t *) widget;
-
-	widget_modify(widget, hpos, vpos, canvas->width, canvas->height);
-	paint_internal(widget);
-}
-
-static void canvas_repaint(widget_t *widget)
-{
-	paint_internal(widget);
-	window_damage(widget->window);
-}
-
-static void canvas_handle_keyboard_event(widget_t *widget, kbd_event_t event)
-{
-	canvas_t *canvas = (canvas_t *) widget;
-
-	sig_send(&canvas->keyboard_event, &event);
-}
-
-static void canvas_handle_position_event(widget_t *widget, pos_event_t event)
-{
-	canvas_t *canvas = (canvas_t *) widget;
-	pos_event_t tevent;
-
-	tevent = event;
-	tevent.hpos -= widget->hpos;
-	tevent.vpos -= widget->vpos;
-
-	sig_send(&canvas->position_event, &tevent);
-}
-
-bool init_canvas(canvas_t *canvas, widget_t *parent, const void *data,
-    sysarg_t width, sysarg_t height, surface_t *surface)
-{
-	widget_init(&canvas->widget, parent, data);
-
-	canvas->widget.width = width;
-	canvas->widget.height = height;
-
-	canvas->widget.width_min = width;
-	canvas->widget.height_min = height;
-	canvas->widget.width_ideal = width;
-	canvas->widget.height_ideal = height;
-	canvas->widget.width_max = width;
-	canvas->widget.height_max = height;
-
-	canvas->widget.destroy = canvas_destroy;
-	canvas->widget.reconfigure = canvas_reconfigure;
-	canvas->widget.rearrange = canvas_rearrange;
-	canvas->widget.repaint = canvas_repaint;
-	canvas->widget.handle_keyboard_event = canvas_handle_keyboard_event;
-	canvas->widget.handle_position_event = canvas_handle_position_event;
-
-	canvas->width = width;
-	canvas->height = height;
-	canvas->surface = surface;
-
-	return true;
-}
-
-bool update_canvas(canvas_t *canvas, surface_t *surface)
-{
-	if (surface != NULL)
-		canvas->surface = surface;
-
-	canvas_repaint(&canvas->widget);
-	return true;
-}
-
-canvas_t *create_canvas(widget_t *parent, const void *data, sysarg_t width,
-    sysarg_t height, surface_t *surface)
-{
-	canvas_t *canvas = (canvas_t *) malloc(sizeof(canvas_t));
-	if (!canvas)
-		return NULL;
-
-	if (init_canvas(canvas, parent, data, width, height, surface))
-		return canvas;
-
-	free(canvas);
-	return NULL;
-}
-
-/** @}
- */
Index: pace/lib/gui/canvas.h
===================================================================
--- uspace/lib/gui/canvas.h	(revision 2c9fdeedc215dcd9caf895b28b729baafa0f3971)
+++ 	(revision )
@@ -1,64 +1,0 @@
-/*
- * Copyright (c) 2013 Martin Decky
- * 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 gui
- * @{
- */
-/**
- * @file
- */
-
-#ifndef GUI_CANVAS_H_
-#define GUI_CANVAS_H_
-
-#include <stdbool.h>
-#include <io/pixel.h>
-#include <draw/surface.h>
-#include "widget.h"
-#include "connection.h"
-
-typedef struct {
-	widget_t widget;
-	sysarg_t width;
-	sysarg_t height;
-	surface_t *surface;
-	signal_t keyboard_event;
-	signal_t position_event;
-} canvas_t;
-
-extern bool init_canvas(canvas_t *, widget_t *, const void *, sysarg_t,
-    sysarg_t, surface_t *);
-extern canvas_t *create_canvas(widget_t *, const void *, sysarg_t, sysarg_t,
-    surface_t *);
-extern bool update_canvas(canvas_t *, surface_t *);
-extern void deinit_canvas(canvas_t *);
-
-#endif
-
-/** @}
- */
Index: pace/lib/gui/common.c
===================================================================
--- uspace/lib/gui/common.c	(revision 2c9fdeedc215dcd9caf895b28b729baafa0f3971)
+++ 	(revision )
@@ -1,86 +1,0 @@
-/*
- * Copyright (c) 2014 Martin Decky
- * 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 gui
- * @{
- */
-/**
- * @file
- */
-
-#include <stddef.h>
-#include <stdint.h>
-#include <draw/drawctx.h>
-#include "common.h"
-
-#define CROSS_WIDTH   14
-#define CROSS_HEIGHT  14
-
-static uint8_t cross_texture[] = {
-	0x00, 0x00, 0x02, 0x08, 0x04, 0x04, 0x08, 0x02, 0x10, 0x01, 0xa0, 0x00,
-	0x40, 0x00, 0xa0, 0x00, 0x10, 0x01, 0x08, 0x02, 0x04, 0x04, 0x02, 0x08,
-	0x01, 0x10, 0x00, 0x00
-};
-
-static uint8_t cross_mask[] = {
-	0x00, 0x00, 0x02, 0x18, 0x06, 0x0c, 0x0c, 0x06, 0x18, 0x03, 0xb0, 0x01,
-	0xe0, 0x00, 0xe0, 0x00, 0xb0, 0x01, 0x18, 0x03, 0x0c, 0x06, 0x06, 0x0c,
-	0x03, 0x18, 0x00, 0x00
-};
-
-void draw_icon_cross(surface_t *surface, sysarg_t hpos, sysarg_t vpos,
-    pixel_t highlight, pixel_t shadow)
-{
-	for (unsigned int y = 0; y < CROSS_HEIGHT; y++) {
-		for (unsigned int x = 0; x < CROSS_WIDTH; x++) {
-			size_t offset = y * ((CROSS_WIDTH - 1) / 8 + 1) + x / 8;
-			bool visible = cross_mask[offset] & (1 << (x % 8));
-			pixel_t pixel = (cross_texture[offset] & (1 << (x % 8))) ?
-			    highlight : shadow;
-
-			if (visible)
-				surface_put_pixel(surface, hpos + x, vpos + y, pixel);
-		}
-	}
-}
-
-void draw_bevel(drawctx_t *drawctx, source_t *source, sysarg_t hpos,
-    sysarg_t vpos, sysarg_t width, sysarg_t height, pixel_t highlight,
-    pixel_t shadow)
-{
-	source_set_color(source, highlight);
-	drawctx_transfer(drawctx, hpos, vpos, width - 1, 1);
-	drawctx_transfer(drawctx, hpos, vpos + 1, 1, height - 2);
-
-	source_set_color(source, shadow);
-	drawctx_transfer(drawctx, hpos, vpos + height - 1, width, 1);
-	drawctx_transfer(drawctx, hpos + width - 1, vpos, 1, height);
-}
-
-/** @}
- */
Index: pace/lib/gui/common.h
===================================================================
--- uspace/lib/gui/common.h	(revision 2c9fdeedc215dcd9caf895b28b729baafa0f3971)
+++ 	(revision )
@@ -1,48 +1,0 @@
-/*
- * Copyright (c) 2014 Martin Decky
- * 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 gui
- * @{
- */
-/**
- * @file
- */
-
-#ifndef GUI_COMMON_H_
-#define GUI_COMMON_H_
-
-#include <draw/drawctx.h>
-
-extern void draw_icon_cross(surface_t *, sysarg_t, sysarg_t, pixel_t, pixel_t);
-extern void draw_bevel(drawctx_t *, source_t *, sysarg_t, sysarg_t, sysarg_t,
-    sysarg_t, pixel_t, pixel_t);
-
-#endif
-
-/** @}
- */
Index: pace/lib/gui/connection.c
===================================================================
--- uspace/lib/gui/connection.c	(revision 2c9fdeedc215dcd9caf895b28b729baafa0f3971)
+++ 	(revision )
@@ -1,226 +1,0 @@
-/*
- * Copyright (c) 2012 Petr Koupy
- * 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 gui
- * @{
- */
-/**
- * @file
- */
-
-#include <mem.h>
-#include <stdlib.h>
-#include <adt/list.h>
-#include <adt/prodcons.h>
-#include <fibril_synch.h>
-#include <io/window.h>
-
-#include "window.h"
-#include "widget.h"
-#include "connection.h"
-
-typedef struct {
-	link_t link;
-	widget_t *widget;
-	slot_t slot;
-} slot_node_t;
-
-typedef struct {
-	link_t link;
-	signal_t *signal;
-	list_t slots;
-} signal_node_t;
-
-static FIBRIL_RWLOCK_INITIALIZE(connection_guard);
-static LIST_INITIALIZE(connection_list);
-
-void sig_connect(signal_t *signal, widget_t *widget, slot_t slot)
-{
-	fibril_rwlock_write_lock(&connection_guard);
-
-	signal_node_t *sig_node = NULL;
-	list_foreach(connection_list, link, signal_node_t, cur) {
-		if (cur->signal == signal) {
-			sig_node = cur;
-			break;
-		}
-	}
-
-	if (!sig_node) {
-		sig_node = (signal_node_t *) malloc(sizeof(signal_node_t));
-		if (!sig_node) {
-			fibril_rwlock_write_unlock(&connection_guard);
-			return;
-		}
-
-		sig_node->signal = signal;
-		link_initialize(&sig_node->link);
-		list_initialize(&sig_node->slots);
-
-		list_append(&sig_node->link, &connection_list);
-	}
-
-	slot_node_t *slt_node = NULL;
-	list_foreach(sig_node->slots, link, slot_node_t, cur) {
-		if (cur->widget == widget && cur->slot == slot) {
-			slt_node = cur;
-			fibril_rwlock_write_unlock(&connection_guard);
-			break;
-		}
-	}
-
-	if (!slt_node) {
-		slt_node = (slot_node_t *) malloc(sizeof(slot_node_t));
-		if (!slt_node) {
-			fibril_rwlock_write_unlock(&connection_guard);
-			return;
-		}
-
-		slt_node->widget = widget;
-		slt_node->slot = slot;
-		link_initialize(&slt_node->link);
-
-		list_append(&slt_node->link, &sig_node->slots);
-	} else {
-		/* Already connected. */
-	}
-
-	fibril_rwlock_write_unlock(&connection_guard);
-}
-
-void sig_disconnect(signal_t *signal, widget_t *widget, slot_t slot)
-{
-	fibril_rwlock_write_lock(&connection_guard);
-
-	signal_node_t *sig_node = NULL;
-	list_foreach(connection_list, link, signal_node_t, cur) {
-		if (cur->signal == signal) {
-			sig_node = cur;
-			break;
-		}
-	}
-
-	if (!sig_node) {
-		fibril_rwlock_write_unlock(&connection_guard);
-		return;
-	}
-
-	slot_node_t *slt_node = NULL;
-	list_foreach(sig_node->slots, link, slot_node_t, cur) {
-		if (cur->widget == widget && cur->slot == slot) {
-			slt_node = cur;
-			break;
-		}
-	}
-
-	if (!slt_node) {
-		fibril_rwlock_write_unlock(&connection_guard);
-		return;
-	}
-
-	list_remove(&slt_node->link);
-	free(slt_node);
-
-	if (list_empty(&sig_node->slots)) {
-		list_remove(&sig_node->link);
-		free(sig_node);
-	}
-
-	fibril_rwlock_write_unlock(&connection_guard);
-}
-
-void sig_send(signal_t *signal, void *data)
-{
-	fibril_rwlock_read_lock(&connection_guard);
-
-	signal_node_t *sig_node = NULL;
-	list_foreach(connection_list, link, signal_node_t, cur) {
-		if (cur->signal == signal) {
-			sig_node = cur;
-			break;
-		}
-	}
-
-	if (!sig_node) {
-		fibril_rwlock_read_unlock(&connection_guard);
-		return;
-	}
-
-	list_foreach(sig_node->slots, link, slot_node_t, cur) {
-		cur->slot(cur->widget, data);
-	}
-
-	fibril_rwlock_read_unlock(&connection_guard);
-}
-
-void sig_post(signal_t *signal, void *data, size_t data_size)
-{
-	fibril_rwlock_read_lock(&connection_guard);
-
-	signal_node_t *sig_node = NULL;
-	list_foreach(connection_list, link, signal_node_t, cur) {
-		if (cur->signal == signal) {
-			sig_node = cur;
-			break;
-		}
-	}
-
-	if (!sig_node) {
-		fibril_rwlock_read_unlock(&connection_guard);
-		return;
-	}
-
-	list_foreach(sig_node->slots, link, slot_node_t, cur) {
-		void *data_copy = NULL;
-		if (data != NULL)
-			data_copy = malloc(data_size);
-
-		if (data_copy != NULL)
-			memcpy(data_copy, data, data_size);
-
-		window_event_t *event =
-		    (window_event_t *) malloc(sizeof(window_event_t));
-
-		if (event) {
-			link_initialize(&event->link);
-			event->type = ET_SIGNAL_EVENT;
-			event->data.signal.object = (sysarg_t) cur->widget;
-			event->data.signal.slot = (sysarg_t) cur->slot;
-			event->data.signal.argument = (sysarg_t) data_copy;
-			prodcons_produce(&cur->widget->window->events, &event->link);
-		} else {
-			if (data_copy != NULL)
-				free(data_copy);
-		}
-	}
-
-	fibril_rwlock_read_unlock(&connection_guard);
-}
-
-/** @}
- */
Index: pace/lib/gui/connection.h
===================================================================
--- uspace/lib/gui/connection.h	(revision 2c9fdeedc215dcd9caf895b28b729baafa0f3971)
+++ 	(revision )
@@ -1,54 +1,0 @@
-/*
- * Copyright (c) 2012 Petr Koupy
- * 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 gui
- * @{
- */
-/**
- * @file
- */
-
-#ifndef GUI_CONNECTION_H_
-#define GUI_CONNECTION_H_
-
-#include <stddef.h>
-#include "widget.h"
-
-typedef sysarg_t signal_t;
-typedef void (*slot_t)(widget_t *, void *);
-
-extern void sig_connect(signal_t *, widget_t *, slot_t);
-extern void sig_disconnect(signal_t *, widget_t *, slot_t);
-
-extern void sig_send(signal_t *, void *);
-extern void sig_post(signal_t *, void *, size_t);
-
-#endif
-
-/** @}
- */
Index: pace/lib/gui/doc/doxygroups.h
===================================================================
--- uspace/lib/gui/doc/doxygroups.h	(revision 2c9fdeedc215dcd9caf895b28b729baafa0f3971)
+++ 	(revision )
@@ -1,3 +1,0 @@
-/** @addtogroup gui libgui
- * @ingroup libs
- */
Index: pace/lib/gui/grid.c
===================================================================
--- uspace/lib/gui/grid.c	(revision 2c9fdeedc215dcd9caf895b28b729baafa0f3971)
+++ 	(revision )
@@ -1,409 +1,0 @@
-/*
- * Copyright (c) 2012 Petr Koupy
- * Copyright (c) 2013 Martin Decky
- * 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 gui
- * @{
- */
-/**
- * @file
- */
-
-#include <assert.h>
-#include <mem.h>
-#include <stdlib.h>
-#include <draw/surface.h>
-#include "window.h"
-#include "grid.h"
-
-typedef struct {
-	sysarg_t min;
-	sysarg_t max;
-	sysarg_t val;
-} constraints_t;
-
-static void paint_internal(widget_t *widget)
-{
-	grid_t *grid = (grid_t *) widget;
-
-	surface_t *surface = window_claim(grid->widget.window);
-	if (!surface) {
-		window_yield(grid->widget.window);
-		return;
-	}
-
-	// FIXME: Replace with (accelerated) rectangle fill
-	for (sysarg_t y = widget->vpos; y < widget->vpos + widget->height; y++) {
-		for (sysarg_t x = widget->hpos; x < widget->hpos + widget->width; x++)
-			surface_put_pixel(surface, x, y, grid->background);
-	}
-
-	window_yield(grid->widget.window);
-}
-
-static grid_cell_t *grid_cell_at(grid_t *grid, size_t col, size_t row)
-{
-	if ((col < grid->cols) && (row < grid->rows))
-		return grid->layout + (row * grid->cols + col);
-
-	return NULL;
-}
-
-static grid_cell_t *grid_coords_at(grid_t *grid, sysarg_t hpos, sysarg_t vpos)
-{
-	for (size_t c = 0; c < grid->cols; c++) {
-		for (size_t r = 0; r < grid->rows; r++) {
-			grid_cell_t *cell = grid_cell_at(grid, c, r);
-			if (cell) {
-				widget_t *widget = cell->widget;
-
-				if ((widget) && (hpos >= widget->hpos) &&
-				    (vpos >= widget->vpos) &&
-				    (hpos < widget->hpos + widget->width) &&
-				    (vpos < widget->vpos + widget->height))
-					return cell;
-			}
-		}
-	}
-
-	return NULL;
-}
-
-void deinit_grid(grid_t *grid)
-{
-	widget_deinit(&grid->widget);
-	free(grid->layout);
-}
-
-static void grid_destroy(widget_t *widget)
-{
-	grid_t *grid = (grid_t *) widget;
-
-	deinit_grid(grid);
-	free(grid);
-}
-
-static void grid_reconfigure(widget_t *widget)
-{
-	/* No-op */
-}
-
-static void adjust_constraints(constraints_t *cons, size_t run,
-    sysarg_t dim_min, sysarg_t dim_max)
-{
-	assert(run > 0);
-
-	sysarg_t dim_min_part = dim_min / run;
-	sysarg_t dim_min_rem = dim_min % run;
-
-	sysarg_t dim_max_part = dim_max / run;
-	sysarg_t dim_max_rem = dim_max % run;
-
-	for (size_t i = 0; i < run; i++) {
-		sysarg_t dim_min_cur = dim_min_part;
-		sysarg_t dim_max_cur = dim_max_part;
-
-		if (i == run - 1) {
-			dim_min_cur += dim_min_rem;
-			dim_max_cur += dim_max_rem;
-		}
-
-		/*
-		 * We want the strongest constraint
-		 * for the minimum.
-		 */
-		if (cons[i].min < dim_min_cur)
-			cons[i].min = dim_min_cur;
-
-		/*
-		 * The comparison is correct, we want
-		 * the weakest constraint for the
-		 * maximum.
-		 */
-		if (cons[i].max < dim_max_cur)
-			cons[i].max = dim_max_cur;
-	}
-}
-
-static void solve_constraints(constraints_t *cons, size_t run, sysarg_t sum)
-{
-	/* Initial solution */
-	sysarg_t cur_sum = 0;
-
-	for (size_t i = 0; i < run; i++) {
-		cons[i].val = cons[i].min;
-		cur_sum += cons[i].val;
-	}
-
-	/* Iterative improvement */
-	while (cur_sum < sum) {
-		sysarg_t delta = (sum - cur_sum) / run;
-		if (delta == 0)
-			break;
-
-		cur_sum = 0;
-
-		for (size_t i = 0; i < run; i++) {
-			if (cons[i].val + delta < cons[i].max)
-				cons[i].val += delta;
-
-			cur_sum += cons[i].val;
-		}
-	}
-}
-
-static void grid_rearrange(widget_t *widget, sysarg_t hpos, sysarg_t vpos,
-    sysarg_t width, sysarg_t height)
-{
-	grid_t *grid = (grid_t *) widget;
-
-	widget_modify(widget, hpos, vpos, width, height);
-	paint_internal(widget);
-
-	/* Compute column widths */
-	constraints_t *widths =
-	    (constraints_t *) calloc(grid->cols, sizeof(constraints_t));
-	if (widths) {
-		/* Constrain widths */
-		for (size_t c = 0; c < grid->cols; c++) {
-			widths[c].min = 0;
-
-			for (size_t r = 0; r < grid->rows; r++) {
-				grid_cell_t *cell = grid_cell_at(grid, c, r);
-				if (!cell)
-					continue;
-
-				widget_t *widget = cell->widget;
-				if (widget)
-					adjust_constraints(&widths[c], cell->cols,
-					    widget->width_min, widget->width_max);
-			}
-		}
-
-		solve_constraints(widths, grid->cols, width);
-	}
-
-	/* Compute row heights */
-	constraints_t *heights =
-	    (constraints_t *) calloc(grid->rows, sizeof(constraints_t));
-	if (heights) {
-		/* Constrain heights */
-		for (size_t r = 0; r < grid->rows; r++) {
-			heights[r].min = 0;
-
-			for (size_t c = 0; c < grid->cols; c++) {
-				grid_cell_t *cell = grid_cell_at(grid, c, r);
-				if (!cell)
-					continue;
-
-				widget_t *widget = cell->widget;
-				if (widget) {
-					adjust_constraints(&heights[r], cell->rows,
-					    widget->height_min, widget->height_max);
-				}
-			}
-		}
-
-		solve_constraints(heights, grid->rows, height);
-	}
-
-	/* Rearrange widgets */
-	if ((widths) && (heights)) {
-		sysarg_t cur_vpos = vpos;
-
-		for (size_t r = 0; r < grid->rows; r++) {
-			sysarg_t cur_hpos = hpos;
-
-			for (size_t c = 0; c < grid->cols; c++) {
-				grid_cell_t *cell = grid_cell_at(grid, c, r);
-				if (!cell)
-					continue;
-
-				widget_t *widget = cell->widget;
-				if (widget) {
-					sysarg_t cur_width = 0;
-					sysarg_t cur_height = 0;
-
-					for (size_t cd = 0; cd < cell->cols; cd++)
-						cur_width += widths[c + cd].val;
-
-					for (size_t rd = 0; rd < cell->rows; rd++)
-						cur_height += heights[r + rd].val;
-
-					if ((cur_width > 0) && (cur_height > 0)) {
-						sysarg_t wwidth = cur_width;
-						sysarg_t wheight = cur_height;
-
-						/*
-						 * Make sure the widget is respects its
-						 * maximal constrains.
-						 */
-
-						if ((widget->width_max > 0) &&
-						    (wwidth > widget->width_max))
-							wwidth = widget->width_max;
-
-						if ((widget->height_max > 0) &&
-						    (wheight > widget->height_max))
-							wheight = widget->height_max;
-
-						widget->rearrange(widget, cur_hpos, cur_vpos,
-						    wwidth, wheight);
-					}
-
-				}
-
-				cur_hpos += widths[c].val;
-			}
-
-			cur_vpos += heights[r].val;
-		}
-	}
-
-	if (widths)
-		free(widths);
-
-	if (heights)
-		free(heights);
-}
-
-static void grid_repaint(widget_t *widget)
-{
-	paint_internal(widget);
-
-	list_foreach(widget->children, link, widget_t, child) {
-		child->repaint(child);
-	}
-
-	window_damage(widget->window);
-}
-
-static void grid_handle_keyboard_event(widget_t *widget, kbd_event_t event)
-{
-	/* No-op */
-}
-
-static void grid_handle_position_event(widget_t *widget, pos_event_t event)
-{
-	grid_t *grid = (grid_t *) widget;
-
-	grid_cell_t *cell = grid_coords_at(grid, event.hpos, event.vpos);
-	if ((cell) && (cell->widget))
-		cell->widget->handle_position_event(cell->widget, event);
-}
-
-static bool grid_add(struct grid *grid, widget_t *widget, size_t col,
-    size_t row, size_t cols, size_t rows)
-{
-	if ((cols == 0) || (rows == 0) || (col + cols > grid->cols) ||
-	    (row + rows > grid->rows))
-		return false;
-
-	grid_cell_t *cell = grid_cell_at(grid, col, row);
-	if (!cell)
-		return false;
-
-	/*
-	 * Check whether the cell is not occupied by an
-	 * extension of a different cell.
-	 */
-	if ((!cell->widget) && (cell->cols > 0) && (cell->rows > 0))
-		return false;
-
-	widget->parent = (widget_t *) grid;
-
-	list_append(&widget->link, &grid->widget.children);
-	widget->window = grid->widget.window;
-
-	/* Mark cells in layout */
-	for (size_t r = row; r < row + rows; r++) {
-		for (size_t c = col; c < col + cols; c++) {
-			if ((r == row) && (c == col)) {
-				cell->widget = widget;
-				cell->cols = cols;
-				cell->rows = rows;
-			} else {
-				grid_cell_t *extension = grid_cell_at(grid, c, r);
-				if (extension) {
-					extension->widget = NULL;
-					extension->cols = 1;
-					extension->rows = 1;
-				}
-			}
-		}
-	}
-
-	return true;
-}
-
-bool init_grid(grid_t *grid, widget_t *parent, const void *data, size_t cols,
-    size_t rows, pixel_t background)
-{
-	if ((cols == 0) || (rows == 0))
-		return false;
-
-	grid->layout =
-	    (grid_cell_t *) calloc(cols * rows, sizeof(grid_cell_t));
-	if (!grid->layout)
-		return false;
-
-	memset(grid->layout, 0, cols * rows * sizeof(grid_cell_t));
-
-	widget_init(&grid->widget, parent, data);
-
-	grid->widget.destroy = grid_destroy;
-	grid->widget.reconfigure = grid_reconfigure;
-	grid->widget.rearrange = grid_rearrange;
-	grid->widget.repaint = grid_repaint;
-	grid->widget.handle_keyboard_event = grid_handle_keyboard_event;
-	grid->widget.handle_position_event = grid_handle_position_event;
-
-	grid->add = grid_add;
-	grid->background = background;
-	grid->cols = cols;
-	grid->rows = rows;
-
-	return true;
-}
-
-grid_t *create_grid(widget_t *parent, const void *data, size_t cols,
-    size_t rows, pixel_t background)
-{
-	grid_t *grid = (grid_t *) malloc(sizeof(grid_t));
-	if (!grid)
-		return NULL;
-
-	if (init_grid(grid, parent, data, cols, rows, background))
-		return grid;
-
-	free(grid);
-	return NULL;
-}
-
-/** @}
- */
Index: pace/lib/gui/grid.h
===================================================================
--- uspace/lib/gui/grid.h	(revision 2c9fdeedc215dcd9caf895b28b729baafa0f3971)
+++ 	(revision )
@@ -1,66 +1,0 @@
-/*
- * Copyright (c) 2012 Petr Koupy
- * 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 gui
- * @{
- */
-/**
- * @file
- */
-
-#ifndef GUI_GRID_H_
-#define GUI_GRID_H_
-
-#include <stddef.h>
-#include <io/pixel.h>
-#include "widget.h"
-
-typedef struct {
-	widget_t *widget;
-	size_t cols;
-	size_t rows;
-} grid_cell_t;
-
-typedef struct grid {
-	widget_t widget;
-	pixel_t background;
-	size_t cols;
-	size_t rows;
-	grid_cell_t *layout;
-	bool (*add)(struct grid *, widget_t *, size_t, size_t, size_t, size_t);
-} grid_t;
-
-extern bool init_grid(grid_t *, widget_t *, const void *, size_t, size_t,
-    pixel_t);
-extern grid_t *create_grid(widget_t *, const void *, size_t, size_t, pixel_t);
-extern void deinit_grid(grid_t *);
-
-#endif
-
-/** @}
- */
Index: pace/lib/gui/label.c
===================================================================
--- uspace/lib/gui/label.c	(revision 2c9fdeedc215dcd9caf895b28b729baafa0f3971)
+++ 	(revision )
@@ -1,201 +1,0 @@
-/*
- * Copyright (c) 2012 Petr Koupy
- * 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 gui
- * @{
- */
-/**
- * @file
- */
-
-#include <str.h>
-#include <draw/drawctx.h>
-#include <stdlib.h>
-#include <draw/surface.h>
-#include <draw/font.h>
-#include <errno.h>
-#include "window.h"
-#include "label.h"
-
-static void paint_internal(widget_t *widget)
-{
-	label_t *lbl = (label_t *) widget;
-
-	surface_t *surface = window_claim(lbl->widget.window);
-	if (!surface)
-		window_yield(lbl->widget.window);
-
-	drawctx_t drawctx;
-	drawctx_init(&drawctx, surface);
-
-	drawctx_set_source(&drawctx, &lbl->background);
-	drawctx_transfer(&drawctx, widget->hpos, widget->vpos, widget->width,
-	    widget->height);
-
-	sysarg_t cpt_width;
-	sysarg_t cpt_height;
-	font_get_box(lbl->font, lbl->caption, &cpt_width, &cpt_height);
-
-	if ((widget->width >= cpt_width) && (widget->height >= cpt_height)) {
-		sysarg_t x = ((widget->width - cpt_width) / 2) + widget->hpos;
-		sysarg_t y = ((widget->height - cpt_height) / 2) + widget->vpos;
-
-		drawctx_set_source(&drawctx, &lbl->text);
-		drawctx_set_font(&drawctx, lbl->font);
-
-		if (lbl->caption)
-			drawctx_print(&drawctx, lbl->caption, x, y);
-	}
-
-	window_yield(lbl->widget.window);
-}
-
-static void on_rewrite(widget_t *widget, void *data)
-{
-	if (data != NULL) {
-		label_t *lbl = (label_t *) widget;
-
-		const char *new_caption = (const char *) data;
-		lbl->caption = str_dup(new_caption);
-
-		sysarg_t cpt_width;
-		sysarg_t cpt_height;
-		font_get_box(lbl->font, lbl->caption, &cpt_width, &cpt_height);
-
-		lbl->widget.width_min = cpt_width + 4;
-		lbl->widget.height_min = cpt_height + 4;
-		lbl->widget.width_ideal = lbl->widget.width_min;
-		lbl->widget.height_ideal = lbl->widget.height_min;
-
-		window_refresh(lbl->widget.window);
-	}
-}
-
-void deinit_label(label_t *lbl)
-{
-	widget_deinit(&lbl->widget);
-	free(lbl->caption);
-	font_release(lbl->font);
-}
-
-static void label_destroy(widget_t *widget)
-{
-	label_t *lbl = (label_t *) widget;
-
-	deinit_label(lbl);
-	free(lbl);
-}
-
-static void label_reconfigure(widget_t *widget)
-{
-	/* no-op */
-}
-
-static void label_rearrange(widget_t *widget, sysarg_t hpos, sysarg_t vpos,
-    sysarg_t width, sysarg_t height)
-{
-	widget_modify(widget, hpos, vpos, width, height);
-	paint_internal(widget);
-}
-
-static void label_repaint(widget_t *widget)
-{
-	paint_internal(widget);
-	window_damage(widget->window);
-}
-
-static void label_handle_keyboard_event(widget_t *widget, kbd_event_t event)
-{
-	/* no-op */
-}
-
-static void label_handle_position_event(widget_t *widget, pos_event_t event)
-{
-	/* no-op */
-}
-
-bool init_label(label_t *lbl, widget_t *parent, const void *data,
-    const char *caption, uint16_t points, pixel_t background, pixel_t text)
-{
-	widget_init(&lbl->widget, parent, data);
-
-	lbl->widget.destroy = label_destroy;
-	lbl->widget.reconfigure = label_reconfigure;
-	lbl->widget.rearrange = label_rearrange;
-	lbl->widget.repaint = label_repaint;
-	lbl->widget.handle_keyboard_event = label_handle_keyboard_event;
-	lbl->widget.handle_position_event = label_handle_position_event;
-
-	source_init(&lbl->background);
-	source_set_color(&lbl->background, background);
-
-	source_init(&lbl->text);
-	source_set_color(&lbl->text, text);
-
-	if (caption == NULL)
-		lbl->caption = NULL;
-	else
-		lbl->caption = str_dup(caption);
-
-	errno_t rc = embedded_font_create(&lbl->font, points);
-	if (rc != EOK) {
-		free(lbl->caption);
-		lbl->caption = NULL;
-		return false;
-	}
-
-	sysarg_t cpt_width;
-	sysarg_t cpt_height;
-	font_get_box(lbl->font, lbl->caption, &cpt_width, &cpt_height);
-
-	lbl->widget.width_min = cpt_width + 4;
-	lbl->widget.height_min = cpt_height + 4;
-	lbl->widget.width_ideal = lbl->widget.width_min;
-	lbl->widget.height_ideal = lbl->widget.height_min;
-
-	lbl->rewrite = on_rewrite;
-
-	return true;
-}
-
-label_t *create_label(widget_t *parent, const void *data, const char *caption,
-    uint16_t points, pixel_t background, pixel_t text)
-{
-	label_t *lbl = (label_t *) malloc(sizeof(label_t));
-	if (!lbl)
-		return NULL;
-
-	if (init_label(lbl, parent, data, caption, points, background, text))
-		return lbl;
-
-	free(lbl);
-	return NULL;
-}
-
-/** @}
- */
Index: pace/lib/gui/label.h
===================================================================
--- uspace/lib/gui/label.h	(revision 2c9fdeedc215dcd9caf895b28b729baafa0f3971)
+++ 	(revision )
@@ -1,66 +1,0 @@
-/*
- * Copyright (c) 2012 Petr Koupy
- * 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 gui
- * @{
- */
-/**
- * @file
- */
-
-#ifndef GUI_LABEL_H_
-#define GUI_LABEL_H_
-
-#include <stdint.h>
-#include <io/pixel.h>
-
-#include <draw/source.h>
-#include <draw/font.h>
-
-#include "connection.h"
-#include "widget.h"
-
-typedef struct label {
-	widget_t widget;
-	source_t background;
-	source_t text;
-	char *caption;
-	font_t *font;
-	slot_t rewrite;
-} label_t;
-
-extern bool init_label(label_t *, widget_t *, const void *, const char *,
-    uint16_t, pixel_t, pixel_t);
-extern label_t *create_label(widget_t *, const void *, const char *, uint16_t,
-    pixel_t, pixel_t);
-extern void deinit_label(label_t *);
-
-#endif
-
-/** @}
- */
Index: pace/lib/gui/meson.build
===================================================================
--- uspace/lib/gui/meson.build	(revision 2c9fdeedc215dcd9caf895b28b729baafa0f3971)
+++ 	(revision )
@@ -1,41 +1,0 @@
-#
-# Copyright (c) 2012 Petr Koupy
-# 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.
-#
-
-deps = [ 'draw' , 'softrend', 'fbfont', 'display' ]
-src = files(
-	'common.c',
-	'button.c',
-	'canvas.c',
-	'connection.c',
-	'grid.c',
-	'label.c',
-	'minimal.c',
-	'terminal.c',
-	'widget.c',
-	'window.c',
-)
Index: pace/lib/gui/minimal.c
===================================================================
--- uspace/lib/gui/minimal.c	(revision 2c9fdeedc215dcd9caf895b28b729baafa0f3971)
+++ 	(revision )
@@ -1,149 +1,0 @@
-/*
- * Copyright (c) 2012 Petr Koupy
- * 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 gui
- * @{
- */
-/**
- * @file
- */
-
-#include <stdlib.h>
-#include <draw/surface.h>
-
-#include "window.h"
-#include "minimal.h"
-
-static void paint_internal(widget_t *w)
-{
-	minimal_t *min = (minimal_t *) w;
-
-	surface_t *surface = window_claim(min->widget.window);
-	if (!surface) {
-		window_yield(min->widget.window);
-	}
-
-	for (sysarg_t y = w->vpos; y <  w->vpos + w->height; ++y) {
-		for (sysarg_t x = w->hpos; x < w->hpos + w->width; ++x) {
-			if (y % 2) {
-				if (x % 2) {
-					surface_put_pixel(surface, x, y, min->pix_a);
-				} else {
-					surface_put_pixel(surface, x, y, min->pix_b);
-				}
-			} else {
-				if (x % 2) {
-					surface_put_pixel(surface, x, y, min->pix_b);
-				} else {
-					surface_put_pixel(surface, x, y, min->pix_a);
-				}
-			}
-		}
-	}
-
-	window_yield(min->widget.window);
-}
-
-void deinit_minimal(minimal_t *min)
-{
-	widget_deinit(&min->widget);
-}
-
-static void minimal_destroy(widget_t *widget)
-{
-	minimal_t *min = (minimal_t *) widget;
-
-	deinit_minimal(min);
-
-	free(min);
-}
-
-static void minimal_reconfigure(widget_t *widget)
-{
-	/* no-op */
-}
-
-static void minimal_rearrange(widget_t *widget, sysarg_t hpos, sysarg_t vpos,
-    sysarg_t width, sysarg_t height)
-{
-	widget_modify(widget, hpos, vpos, width, height);
-	paint_internal(widget);
-}
-
-static void minimal_repaint(widget_t *widget)
-{
-	paint_internal(widget);
-	window_damage(widget->window);
-}
-
-static void minimal_handle_keyboard_event(widget_t *widget, kbd_event_t event)
-{
-	/* no-op */
-}
-
-static void minimal_handle_position_event(widget_t *widget, pos_event_t event)
-{
-	/* no-op */
-}
-
-bool init_minimal(minimal_t *min, widget_t *parent, const void *data, pixel_t a,
-    pixel_t b)
-{
-	widget_init(&min->widget, parent, data);
-
-	min->widget.destroy = minimal_destroy;
-	min->widget.reconfigure = minimal_reconfigure;
-	min->widget.rearrange = minimal_rearrange;
-	min->widget.repaint = minimal_repaint;
-	min->widget.handle_keyboard_event = minimal_handle_keyboard_event;
-	min->widget.handle_position_event = minimal_handle_position_event;
-
-	min->pix_a = a;
-	min->pix_b = b;
-
-	return true;
-}
-
-minimal_t *create_minimal(widget_t *parent, const void *data, pixel_t a,
-    pixel_t b)
-{
-	minimal_t *min = (minimal_t *) malloc(sizeof(minimal_t));
-	if (!min) {
-		return NULL;
-	}
-
-	if (init_minimal(min, parent, data, a, b)) {
-		return min;
-	} else {
-		free(min);
-		return NULL;
-	}
-}
-
-/** @}
- */
Index: pace/lib/gui/minimal.h
===================================================================
--- uspace/lib/gui/minimal.h	(revision 2c9fdeedc215dcd9caf895b28b729baafa0f3971)
+++ 	(revision )
@@ -1,58 +1,0 @@
-/*
- * Copyright (c) 2012 Petr Koupy
- * 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 gui
- * @{
- */
-/**
- * @file
- */
-
-#ifndef GUI_MINIMAL_H_
-#define GUI_MINIMAL_H_
-
-#include <stdbool.h>
-#include <io/pixel.h>
-
-#include "widget.h"
-
-typedef struct minimal {
-	widget_t widget;
-	pixel_t pix_a;
-	pixel_t pix_b;
-} minimal_t;
-
-extern bool init_minimal(minimal_t *, widget_t *, const void *, pixel_t,
-    pixel_t);
-extern minimal_t *create_minimal(widget_t *, const void *, pixel_t, pixel_t);
-extern void deinit_minimal(minimal_t *);
-
-#endif
-
-/** @}
- */
Index: pace/lib/gui/terminal.c
===================================================================
--- uspace/lib/gui/terminal.c	(revision 2c9fdeedc215dcd9caf895b28b729baafa0f3971)
+++ 	(revision )
@@ -1,795 +1,0 @@
-/*
- * Copyright (c) 2012 Petr Koupy
- * 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 gui
- * @{
- */
-/**
- * @file
- */
-
-#include <errno.h>
-#include <stdlib.h>
-#include <io/chargrid.h>
-#include <draw/surface.h>
-#include <draw/gfx.h>
-#include <fbfont/font-8x16.h>
-#include <io/con_srv.h>
-#include <io/concaps.h>
-#include <io/console.h>
-#include <loc.h>
-#include <task.h>
-#include <adt/list.h>
-#include <adt/prodcons.h>
-#include <stdarg.h>
-#include <str.h>
-#include "window.h"
-#include "terminal.h"
-
-#define NAME       "terminal"
-#define NAMESPACE  "terminal"
-
-#define LOCFS_MOUNT_POINT  "/loc"
-
-#define APP_GETTERM  "/app/getterm"
-
-#define TERM_CAPS \
-	(CONSOLE_CAP_STYLE | CONSOLE_CAP_INDEXED | CONSOLE_CAP_RGB)
-
-static LIST_INITIALIZE(terms);
-
-static errno_t term_open(con_srvs_t *, con_srv_t *);
-static errno_t term_close(con_srv_t *);
-static errno_t term_read(con_srv_t *, void *, size_t, size_t *);
-static errno_t term_write(con_srv_t *, void *, size_t, size_t *);
-static void term_sync(con_srv_t *);
-static void term_clear(con_srv_t *);
-static void term_set_pos(con_srv_t *, sysarg_t col, sysarg_t row);
-static errno_t term_get_pos(con_srv_t *, sysarg_t *, sysarg_t *);
-static errno_t term_get_size(con_srv_t *, sysarg_t *, sysarg_t *);
-static errno_t term_get_color_cap(con_srv_t *, console_caps_t *);
-static void term_set_style(con_srv_t *, console_style_t);
-static void term_set_color(con_srv_t *, console_color_t, console_color_t,
-    console_color_attr_t);
-static void term_set_rgb_color(con_srv_t *, pixel_t, pixel_t);
-static void term_set_cursor_visibility(con_srv_t *, bool);
-static errno_t term_get_event(con_srv_t *, cons_event_t *);
-
-static con_ops_t con_ops = {
-	.open = term_open,
-	.close = term_close,
-	.read = term_read,
-	.write = term_write,
-	.sync = term_sync,
-	.clear = term_clear,
-	.set_pos = term_set_pos,
-	.get_pos = term_get_pos,
-	.get_size = term_get_size,
-	.get_color_cap = term_get_color_cap,
-	.set_style = term_set_style,
-	.set_color = term_set_color,
-	.set_rgb_color = term_set_rgb_color,
-	.set_cursor_visibility = term_set_cursor_visibility,
-	.get_event = term_get_event
-};
-
-static terminal_t *srv_to_terminal(con_srv_t *srv)
-{
-	return srv->srvs->sarg;
-}
-
-static void getterm(const char *svc, const char *app)
-{
-	task_spawnl(NULL, NULL, APP_GETTERM, APP_GETTERM, svc,
-	    LOCFS_MOUNT_POINT, "--msg", "--wait", "--", app, NULL);
-}
-
-static pixel_t color_table[16] = {
-	[COLOR_BLACK]       = PIXEL(255, 0, 0, 0),
-	[COLOR_BLUE]        = PIXEL(255, 0, 0, 240),
-	[COLOR_GREEN]       = PIXEL(255, 0, 240, 0),
-	[COLOR_CYAN]        = PIXEL(255, 0, 240, 240),
-	[COLOR_RED]         = PIXEL(255, 240, 0, 0),
-	[COLOR_MAGENTA]     = PIXEL(255, 240, 0, 240),
-	[COLOR_YELLOW]      = PIXEL(255, 240, 240, 0),
-	[COLOR_WHITE]       = PIXEL(255, 240, 240, 240),
-
-	[COLOR_BLACK + 8]   = PIXEL(255, 0, 0, 0),
-	[COLOR_BLUE + 8]    = PIXEL(255, 0, 0, 255),
-	[COLOR_GREEN + 8]   = PIXEL(255, 0, 255, 0),
-	[COLOR_CYAN + 8]    = PIXEL(255, 0, 255, 255),
-	[COLOR_RED + 8]     = PIXEL(255, 255, 0, 0),
-	[COLOR_MAGENTA + 8] = PIXEL(255, 255, 0, 255),
-	[COLOR_YELLOW + 8]  = PIXEL(255, 255, 255, 0),
-	[COLOR_WHITE + 8]   = PIXEL(255, 255, 255, 255),
-};
-
-static inline void attrs_rgb(char_attrs_t attrs, pixel_t *bgcolor, pixel_t *fgcolor)
-{
-	switch (attrs.type) {
-	case CHAR_ATTR_STYLE:
-		switch (attrs.val.style) {
-		case STYLE_NORMAL:
-			*bgcolor = color_table[COLOR_WHITE];
-			*fgcolor = color_table[COLOR_BLACK];
-			break;
-		case STYLE_EMPHASIS:
-			*bgcolor = color_table[COLOR_WHITE];
-			*fgcolor = color_table[COLOR_RED];
-			break;
-		case STYLE_INVERTED:
-			*bgcolor = color_table[COLOR_BLACK];
-			*fgcolor = color_table[COLOR_WHITE];
-			break;
-		case STYLE_SELECTED:
-			*bgcolor = color_table[COLOR_RED];
-			*fgcolor = color_table[COLOR_WHITE];
-			break;
-		}
-		break;
-	case CHAR_ATTR_INDEX:
-		*bgcolor = color_table[(attrs.val.index.bgcolor & 7) |
-		    ((attrs.val.index.attr & CATTR_BRIGHT) ? 8 : 0)];
-		*fgcolor = color_table[(attrs.val.index.fgcolor & 7) |
-		    ((attrs.val.index.attr & CATTR_BRIGHT) ? 8 : 0)];
-		break;
-	case CHAR_ATTR_RGB:
-		*bgcolor = 0xff000000 | attrs.val.rgb.bgcolor;
-		*fgcolor = 0xff000000 | attrs.val.rgb.fgcolor;
-		break;
-	}
-}
-
-static void term_update_char(terminal_t *term, surface_t *surface,
-    sysarg_t sx, sysarg_t sy, sysarg_t col, sysarg_t row)
-{
-	charfield_t *field =
-	    chargrid_charfield_at(term->backbuf, col, row);
-
-	bool inverted = chargrid_cursor_at(term->backbuf, col, row);
-
-	sysarg_t bx = sx + (col * FONT_WIDTH);
-	sysarg_t by = sy + (row * FONT_SCANLINES);
-
-	pixel_t bgcolor = 0;
-	pixel_t fgcolor = 0;
-
-	if (inverted)
-		attrs_rgb(field->attrs, &fgcolor, &bgcolor);
-	else
-		attrs_rgb(field->attrs, &bgcolor, &fgcolor);
-
-	// FIXME: Glyph type should be actually uint32_t
-	//        for full UTF-32 coverage.
-
-	uint16_t glyph = fb_font_glyph(field->ch, NULL);
-
-	for (unsigned int y = 0; y < FONT_SCANLINES; y++) {
-		pixel_t *dst = pixelmap_pixel_at(
-		    surface_pixmap_access(surface), bx, by + y);
-		pixel_t *dst_max = pixelmap_pixel_at(
-		    surface_pixmap_access(surface), bx + FONT_WIDTH - 1, by + y);
-		if (!dst || !dst_max)
-			continue;
-		int count = FONT_WIDTH;
-		while (count-- != 0) {
-			*dst++ = (fb_font[glyph][y] & (1 << count)) ? fgcolor : bgcolor;
-		}
-	}
-	surface_add_damaged_region(surface, bx, by, FONT_WIDTH, FONT_SCANLINES);
-}
-
-static bool term_update_scroll(terminal_t *term, surface_t *surface,
-    sysarg_t sx, sysarg_t sy)
-{
-	sysarg_t top_row = chargrid_get_top_row(term->frontbuf);
-
-	if (term->top_row == top_row)
-		return false;
-
-	term->top_row = top_row;
-
-	for (sysarg_t row = 0; row < term->rows; row++) {
-		for (sysarg_t col = 0; col < term->cols; col++) {
-			charfield_t *front_field =
-			    chargrid_charfield_at(term->frontbuf, col, row);
-			charfield_t *back_field =
-			    chargrid_charfield_at(term->backbuf, col, row);
-			bool update = false;
-
-			if (front_field->ch != back_field->ch) {
-				back_field->ch = front_field->ch;
-				update = true;
-			}
-
-			if (!attrs_same(front_field->attrs, back_field->attrs)) {
-				back_field->attrs = front_field->attrs;
-				update = true;
-			}
-
-			front_field->flags &= ~CHAR_FLAG_DIRTY;
-
-			if (update)
-				term_update_char(term, surface, sx, sy, col, row);
-		}
-	}
-
-	return true;
-}
-
-static bool term_update_cursor(terminal_t *term, surface_t *surface,
-    sysarg_t sx, sysarg_t sy)
-{
-	bool damage = false;
-
-	sysarg_t front_col;
-	sysarg_t front_row;
-	chargrid_get_cursor(term->frontbuf, &front_col, &front_row);
-
-	sysarg_t back_col;
-	sysarg_t back_row;
-	chargrid_get_cursor(term->backbuf, &back_col, &back_row);
-
-	bool front_visibility =
-	    chargrid_get_cursor_visibility(term->frontbuf) &&
-	    term->widget.window->is_focused;
-	bool back_visibility =
-	    chargrid_get_cursor_visibility(term->backbuf);
-
-	if (front_visibility != back_visibility) {
-		chargrid_set_cursor_visibility(term->backbuf,
-		    front_visibility);
-		term_update_char(term, surface, sx, sy, back_col, back_row);
-		damage = true;
-	}
-
-	if ((front_col != back_col) || (front_row != back_row)) {
-		chargrid_set_cursor(term->backbuf, front_col, front_row);
-		term_update_char(term, surface, sx, sy, back_col, back_row);
-		term_update_char(term, surface, sx, sy, front_col, front_row);
-		damage = true;
-	}
-
-	return damage;
-}
-
-static void term_update(terminal_t *term)
-{
-	fibril_mutex_lock(&term->mtx);
-
-	surface_t *surface = window_claim(term->widget.window);
-	if (!surface) {
-		window_yield(term->widget.window);
-		fibril_mutex_unlock(&term->mtx);
-		return;
-	}
-
-	bool damage = false;
-	sysarg_t sx = term->widget.hpos;
-	sysarg_t sy = term->widget.vpos;
-
-	if (term_update_scroll(term, surface, sx, sy)) {
-		damage = true;
-	} else {
-		for (sysarg_t y = 0; y < term->rows; y++) {
-			for (sysarg_t x = 0; x < term->cols; x++) {
-				charfield_t *front_field =
-				    chargrid_charfield_at(term->frontbuf, x, y);
-				charfield_t *back_field =
-				    chargrid_charfield_at(term->backbuf, x, y);
-				bool update = false;
-
-				if ((front_field->flags & CHAR_FLAG_DIRTY) ==
-				    CHAR_FLAG_DIRTY) {
-					if (front_field->ch != back_field->ch) {
-						back_field->ch = front_field->ch;
-						update = true;
-					}
-
-					if (!attrs_same(front_field->attrs,
-					    back_field->attrs)) {
-						back_field->attrs = front_field->attrs;
-						update = true;
-					}
-
-					front_field->flags &= ~CHAR_FLAG_DIRTY;
-				}
-
-				if (update) {
-					term_update_char(term, surface, sx, sy, x, y);
-					damage = true;
-				}
-			}
-		}
-	}
-
-	if (term_update_cursor(term, surface, sx, sy))
-		damage = true;
-
-	window_yield(term->widget.window);
-
-	if (damage)
-		window_damage(term->widget.window);
-
-	fibril_mutex_unlock(&term->mtx);
-}
-
-static void term_damage(terminal_t *term)
-{
-	fibril_mutex_lock(&term->mtx);
-
-	surface_t *surface = window_claim(term->widget.window);
-	if (!surface) {
-		window_yield(term->widget.window);
-		fibril_mutex_unlock(&term->mtx);
-		return;
-	}
-
-	sysarg_t sx = term->widget.hpos;
-	sysarg_t sy = term->widget.vpos;
-
-	if (!term_update_scroll(term, surface, sx, sy)) {
-		for (sysarg_t y = 0; y < term->rows; y++) {
-			for (sysarg_t x = 0; x < term->cols; x++) {
-				charfield_t *front_field =
-				    chargrid_charfield_at(term->frontbuf, x, y);
-				charfield_t *back_field =
-				    chargrid_charfield_at(term->backbuf, x, y);
-
-				back_field->ch = front_field->ch;
-				back_field->attrs = front_field->attrs;
-				front_field->flags &= ~CHAR_FLAG_DIRTY;
-
-				term_update_char(term, surface, sx, sy, x, y);
-			}
-		}
-	}
-
-	term_update_cursor(term, surface, sx, sy);
-
-	window_yield(term->widget.window);
-	window_damage(term->widget.window);
-
-	fibril_mutex_unlock(&term->mtx);
-}
-
-static errno_t term_open(con_srvs_t *srvs, con_srv_t *srv)
-{
-	return EOK;
-}
-
-static errno_t term_close(con_srv_t *srv)
-{
-	return EOK;
-}
-
-static errno_t term_read(con_srv_t *srv, void *buf, size_t size, size_t *nread)
-{
-	terminal_t *term = srv_to_terminal(srv);
-	uint8_t *bbuf = buf;
-	size_t pos = 0;
-
-	/*
-	 * Read input from keyboard and copy it to the buffer.
-	 * We need to handle situation when wchar is split by 2 following
-	 * reads.
-	 */
-	while (pos < size) {
-		/* Copy to the buffer remaining characters. */
-		while ((pos < size) && (term->char_remains_len > 0)) {
-			bbuf[pos] = term->char_remains[0];
-			pos++;
-
-			/* Unshift the array. */
-			for (size_t i = 1; i < term->char_remains_len; i++)
-				term->char_remains[i - 1] = term->char_remains[i];
-
-			term->char_remains_len--;
-		}
-
-		/* Still not enough? Then get another key from the queue. */
-		if (pos < size) {
-			link_t *link = prodcons_consume(&term->input_pc);
-			cons_event_t *event = list_get_instance(link, cons_event_t, link);
-
-			/* Accept key presses of printable chars only. */
-			if (event->type == CEV_KEY && event->ev.key.type == KEY_PRESS &&
-			    event->ev.key.c != 0) {
-				char32_t tmp[2] = {
-					event->ev.key.c,
-					0
-				};
-
-				wstr_to_str(term->char_remains, UTF8_CHAR_BUFFER_SIZE, tmp);
-				term->char_remains_len = str_size(term->char_remains);
-			}
-
-			free(event);
-		}
-	}
-
-	*nread = size;
-	return EOK;
-}
-
-static void term_write_char(terminal_t *term, char32_t ch)
-{
-	sysarg_t updated = 0;
-
-	fibril_mutex_lock(&term->mtx);
-
-	switch (ch) {
-	case '\n':
-		updated = chargrid_newline(term->frontbuf);
-		break;
-	case '\r':
-		break;
-	case '\t':
-		updated = chargrid_tabstop(term->frontbuf, 8);
-		break;
-	case '\b':
-		updated = chargrid_backspace(term->frontbuf);
-		break;
-	default:
-		updated = chargrid_putuchar(term->frontbuf, ch, true);
-	}
-
-	fibril_mutex_unlock(&term->mtx);
-
-	if (updated > 1)
-		term_update(term);
-}
-
-static errno_t term_write(con_srv_t *srv, void *data, size_t size, size_t *nwritten)
-{
-	terminal_t *term = srv_to_terminal(srv);
-
-	size_t off = 0;
-	while (off < size)
-		term_write_char(term, str_decode(data, &off, size));
-
-	*nwritten = size;
-	return EOK;
-}
-
-static void term_sync(con_srv_t *srv)
-{
-	terminal_t *term = srv_to_terminal(srv);
-
-	term_update(term);
-}
-
-static void term_clear(con_srv_t *srv)
-{
-	terminal_t *term = srv_to_terminal(srv);
-
-	fibril_mutex_lock(&term->mtx);
-	chargrid_clear(term->frontbuf);
-	fibril_mutex_unlock(&term->mtx);
-
-	term_update(term);
-}
-
-static void term_set_pos(con_srv_t *srv, sysarg_t col, sysarg_t row)
-{
-	terminal_t *term = srv_to_terminal(srv);
-
-	fibril_mutex_lock(&term->mtx);
-	chargrid_set_cursor(term->frontbuf, col, row);
-	fibril_mutex_unlock(&term->mtx);
-
-	term_update(term);
-}
-
-static errno_t term_get_pos(con_srv_t *srv, sysarg_t *col, sysarg_t *row)
-{
-	terminal_t *term = srv_to_terminal(srv);
-
-	fibril_mutex_lock(&term->mtx);
-	chargrid_get_cursor(term->frontbuf, col, row);
-	fibril_mutex_unlock(&term->mtx);
-
-	return EOK;
-}
-
-static errno_t term_get_size(con_srv_t *srv, sysarg_t *cols, sysarg_t *rows)
-{
-	terminal_t *term = srv_to_terminal(srv);
-
-	fibril_mutex_lock(&term->mtx);
-	*cols = term->cols;
-	*rows = term->rows;
-	fibril_mutex_unlock(&term->mtx);
-
-	return EOK;
-}
-
-static errno_t term_get_color_cap(con_srv_t *srv, console_caps_t *caps)
-{
-	(void) srv;
-	*caps = TERM_CAPS;
-
-	return EOK;
-}
-
-static void term_set_style(con_srv_t *srv, console_style_t style)
-{
-	terminal_t *term = srv_to_terminal(srv);
-
-	fibril_mutex_lock(&term->mtx);
-	chargrid_set_style(term->frontbuf, style);
-	fibril_mutex_unlock(&term->mtx);
-}
-
-static void term_set_color(con_srv_t *srv, console_color_t bgcolor,
-    console_color_t fgcolor, console_color_attr_t attr)
-{
-	terminal_t *term = srv_to_terminal(srv);
-
-	fibril_mutex_lock(&term->mtx);
-	chargrid_set_color(term->frontbuf, bgcolor, fgcolor, attr);
-	fibril_mutex_unlock(&term->mtx);
-}
-
-static void term_set_rgb_color(con_srv_t *srv, pixel_t bgcolor,
-    pixel_t fgcolor)
-{
-	terminal_t *term = srv_to_terminal(srv);
-
-	fibril_mutex_lock(&term->mtx);
-	chargrid_set_rgb_color(term->frontbuf, bgcolor, fgcolor);
-	fibril_mutex_unlock(&term->mtx);
-}
-
-static void term_set_cursor_visibility(con_srv_t *srv, bool visible)
-{
-	terminal_t *term = srv_to_terminal(srv);
-
-	fibril_mutex_lock(&term->mtx);
-	chargrid_set_cursor_visibility(term->frontbuf, visible);
-	fibril_mutex_unlock(&term->mtx);
-
-	term_update(term);
-}
-
-static errno_t term_get_event(con_srv_t *srv, cons_event_t *event)
-{
-	terminal_t *term = srv_to_terminal(srv);
-	link_t *link = prodcons_consume(&term->input_pc);
-	cons_event_t *ev = list_get_instance(link, cons_event_t, link);
-
-	*event = *ev;
-	free(ev);
-	return EOK;
-}
-
-void deinit_terminal(terminal_t *term)
-{
-	list_remove(&term->link);
-	widget_deinit(&term->widget);
-
-	if (term->frontbuf)
-		chargrid_destroy(term->frontbuf);
-
-	if (term->backbuf)
-		chargrid_destroy(term->backbuf);
-}
-
-static void terminal_destroy(widget_t *widget)
-{
-	terminal_t *term = (terminal_t *) widget;
-
-	deinit_terminal(term);
-	free(term);
-}
-
-static void terminal_reconfigure(widget_t *widget)
-{
-	/* No-op */
-}
-
-static void terminal_rearrange(widget_t *widget, sysarg_t hpos, sysarg_t vpos,
-    sysarg_t width, sysarg_t height)
-{
-	terminal_t *term = (terminal_t *) widget;
-
-	widget_modify(widget, hpos, vpos, width, height);
-	widget->width_ideal = width;
-	widget->height_ideal = height;
-
-	term_damage(term);
-}
-
-static void terminal_repaint(widget_t *widget)
-{
-	terminal_t *term = (terminal_t *) widget;
-
-	term_damage(term);
-}
-
-static void terminal_queue_cons_event(terminal_t *term, cons_event_t *ev)
-{
-	/* Got key press/release event */
-	cons_event_t *event =
-	    (cons_event_t *) malloc(sizeof(cons_event_t));
-	if (event == NULL)
-		return;
-
-	*event = *ev;
-	link_initialize(&event->link);
-
-	prodcons_produce(&term->input_pc, &event->link);
-}
-
-/* Got key press/release event */
-static void terminal_handle_keyboard_event(widget_t *widget,
-    kbd_event_t kbd_event)
-{
-	terminal_t *term = (terminal_t *) widget;
-	cons_event_t event;
-
-	event.type = CEV_KEY;
-	event.ev.key = kbd_event;
-
-	terminal_queue_cons_event(term, &event);
-}
-
-static void terminal_handle_position_event(widget_t *widget, pos_event_t pos_event)
-{
-	cons_event_t event;
-	terminal_t *term = (terminal_t *) widget;
-	sysarg_t sx = term->widget.hpos;
-	sysarg_t sy = term->widget.vpos;
-
-	if (pos_event.type == POS_PRESS) {
-		event.type = CEV_POS;
-		event.ev.pos.type = pos_event.type;
-		event.ev.pos.pos_id = pos_event.pos_id;
-		event.ev.pos.btn_num = pos_event.btn_num;
-
-		event.ev.pos.hpos = (pos_event.hpos - sx) / FONT_WIDTH;
-		event.ev.pos.vpos = (pos_event.vpos - sy) / FONT_SCANLINES;
-		terminal_queue_cons_event(term, &event);
-	}
-}
-
-static void term_connection(ipc_call_t *icall, void *arg)
-{
-	terminal_t *term = NULL;
-
-	list_foreach(terms, link, terminal_t, cur) {
-		if (cur->dsid == (service_id_t) ipc_get_arg2(icall)) {
-			term = cur;
-			break;
-		}
-	}
-
-	if (term == NULL) {
-		async_answer_0(icall, ENOENT);
-		return;
-	}
-
-	if (!atomic_flag_test_and_set(&term->refcnt))
-		chargrid_set_cursor_visibility(term->frontbuf, true);
-
-	con_conn(icall, &term->srvs);
-}
-
-bool init_terminal(terminal_t *term, widget_t *parent, const void *data,
-    sysarg_t width, sysarg_t height)
-{
-	widget_init(&term->widget, parent, data);
-
-	link_initialize(&term->link);
-	fibril_mutex_initialize(&term->mtx);
-	atomic_flag_clear(&term->refcnt);
-
-	prodcons_initialize(&term->input_pc);
-	term->char_remains_len = 0;
-
-	term->widget.width = width;
-	term->widget.height = height;
-	term->widget.width_ideal = width;
-	term->widget.height_ideal = height;
-
-	term->widget.destroy = terminal_destroy;
-	term->widget.reconfigure = terminal_reconfigure;
-	term->widget.rearrange = terminal_rearrange;
-	term->widget.repaint = terminal_repaint;
-	term->widget.handle_keyboard_event = terminal_handle_keyboard_event;
-	term->widget.handle_position_event = terminal_handle_position_event;
-
-	term->cols = width / FONT_WIDTH;
-	term->rows = height / FONT_SCANLINES;
-
-	term->frontbuf = NULL;
-	term->backbuf = NULL;
-
-	term->frontbuf = chargrid_create(term->cols, term->rows,
-	    CHARGRID_FLAG_NONE);
-	if (!term->frontbuf) {
-		widget_deinit(&term->widget);
-		return false;
-	}
-
-	term->backbuf = chargrid_create(term->cols, term->rows,
-	    CHARGRID_FLAG_NONE);
-	if (!term->backbuf) {
-		widget_deinit(&term->widget);
-		return false;
-	}
-
-	chargrid_clear(term->frontbuf);
-	chargrid_clear(term->backbuf);
-	term->top_row = 0;
-
-	async_set_fallback_port_handler(term_connection, NULL);
-	con_srvs_init(&term->srvs);
-	term->srvs.ops = &con_ops;
-	term->srvs.sarg = term;
-
-	errno_t rc = loc_server_register(NAME);
-	if (rc != EOK) {
-		widget_deinit(&term->widget);
-		return false;
-	}
-
-	char vc[LOC_NAME_MAXLEN + 1];
-	snprintf(vc, LOC_NAME_MAXLEN, "%s/%" PRIu64, NAMESPACE,
-	    task_get_id());
-
-	rc = loc_service_register(vc, &term->dsid);
-	if (rc != EOK) {
-		widget_deinit(&term->widget);
-		return false;
-	}
-
-	list_append(&term->link, &terms);
-	getterm(vc, "/app/bdsh");
-
-	return true;
-}
-
-terminal_t *create_terminal(widget_t *parent, const void *data, sysarg_t width,
-    sysarg_t height)
-{
-	terminal_t *term = (terminal_t *) malloc(sizeof(terminal_t));
-	if (!term)
-		return NULL;
-
-	bool ret = init_terminal(term, parent, data, width, height);
-	if (!ret) {
-		free(term);
-		return NULL;
-	}
-
-	return term;
-}
-
-/** @}
- */
Index: pace/lib/gui/terminal.h
===================================================================
--- uspace/lib/gui/terminal.h	(revision 2c9fdeedc215dcd9caf895b28b729baafa0f3971)
+++ 	(revision )
@@ -1,83 +1,0 @@
-/*
- * Copyright (c) 2012 Petr Koupy
- * 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 gui
- * @{
- */
-/**
- * @file
- */
-
-#ifndef GUI_TERMINAL_H_
-#define GUI_TERMINAL_H_
-
-#include <stddef.h>
-#include <fibril_synch.h>
-#include <draw/font.h>
-#include <io/chargrid.h>
-#include <io/con_srv.h>
-#include <loc.h>
-#include <adt/list.h>
-#include <adt/prodcons.h>
-#include <stdatomic.h>
-#include <str.h>
-#include "widget.h"
-
-#define UTF8_CHAR_BUFFER_SIZE  (STR_BOUNDS(1) + 1)
-
-typedef struct terminal {
-	widget_t widget;
-
-	fibril_mutex_t mtx;
-	link_t link;
-	atomic_flag refcnt;
-
-	prodcons_t input_pc;
-	char char_remains[UTF8_CHAR_BUFFER_SIZE];
-	size_t char_remains_len;
-
-	sysarg_t cols;
-	sysarg_t rows;
-	chargrid_t *frontbuf;
-	chargrid_t *backbuf;
-	sysarg_t top_row;
-
-	service_id_t dsid;
-	con_srvs_t srvs;
-} terminal_t;
-
-extern bool init_terminal(terminal_t *, widget_t *, const void *, sysarg_t,
-    sysarg_t);
-extern terminal_t *create_terminal(widget_t *, const void *, sysarg_t,
-    sysarg_t);
-extern void deinit_terminal(terminal_t *);
-
-#endif
-
-/** @}
- */
Index: pace/lib/gui/widget.c
===================================================================
--- uspace/lib/gui/widget.c	(revision 2c9fdeedc215dcd9caf895b28b729baafa0f3971)
+++ 	(revision )
@@ -1,92 +1,0 @@
-/*
- * Copyright (c) 2012 Petr Koupy
- * 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 gui
- * @{
- */
-/**
- * @file
- */
-
-#include "widget.h"
-
-/** Link widget with parent and initialize default position and size. */
-void widget_init(widget_t *widget, widget_t *parent, const void *data)
-{
-	link_initialize(&widget->link);
-	list_initialize(&widget->children);
-
-	if (parent) {
-		widget->parent = parent;
-		list_append(&widget->link, &parent->children);
-		widget->window = parent->window;
-	} else {
-		widget->parent = NULL;
-		widget->window = NULL;
-	}
-
-	widget->data = data;
-
-	widget->hpos = 0;
-	widget->vpos = 0;
-	widget->width = 0;
-	widget->height = 0;
-
-	widget->width_min = 0;
-	widget->height_min = 0;
-	widget->width_ideal = 0;
-	widget->height_ideal = 0;
-	widget->width_max = SIZE_MAX;
-	widget->height_max = SIZE_MAX;
-}
-
-/** Change position and size of the widget. */
-void widget_modify(widget_t *widget, sysarg_t hpos, sysarg_t vpos,
-    sysarg_t width, sysarg_t height)
-{
-	widget->hpos = hpos;
-	widget->vpos = vpos;
-	widget->width = width;
-	widget->height = height;
-}
-
-/** Get custom client data */
-const void *widget_get_data(widget_t *widget)
-{
-	return widget->data;
-}
-
-/** Unlink widget from its parent. */
-void widget_deinit(widget_t *widget)
-{
-	if (widget->parent)
-		list_remove(&widget->link);
-}
-
-/** @}
- */
Index: pace/lib/gui/widget.h
===================================================================
--- uspace/lib/gui/widget.h	(revision 2c9fdeedc215dcd9caf895b28b729baafa0f3971)
+++ 	(revision )
@@ -1,144 +1,0 @@
-/*
- * Copyright (c) 2012 Petr Koupy
- * 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 gui
- * @{
- */
-/**
- * @file
- */
-
-#ifndef GUI_WIDGET_H_
-#define GUI_WIDGET_H_
-
-#include <adt/list.h>
-#include <io/window.h>
-
-struct window;
-typedef struct window window_t;
-
-struct widget;
-typedef struct widget widget_t;
-
-/**
- * Base class for all widgets. This structure should be first data member of
- * any derived widget structure.
- */
-struct widget {
-	link_t link;
-	widget_t *parent;  /**< Parent widget of this widget. NULL for root widget. */
-	list_t children;   /**< Children widgets of this widget. */
-	window_t *window;  /**< Window into which this widget belongs. */
-	const void *data;  /**< Custom client data. */
-
-	sysarg_t hpos; /**< Horizontal position in window coordinates. */
-	sysarg_t vpos; /**< Vertical position in window coordinates. */
-	sysarg_t width;
-	sysarg_t height;
-
-	sysarg_t width_min;
-	sysarg_t height_min;
-	sysarg_t width_ideal; /**< Width size hint for initialization. */
-	sysarg_t height_ideal; /**< Height size hint for initialization, */
-	sysarg_t width_max;
-	sysarg_t height_max;
-
-	/**
-	 * Virtual destructor. Apart from deallocating the resources specific for
-	 * the particular widget, each widget shall remove itself from parents
-	 * children and deallocate itself.
-	 */
-	void (*destroy)(widget_t *);
-
-	/**
-	 * Reserved for bottom-top traversal when widget changes its properties and
-	 * want to inform its ancestors in widget hierarchy to consider rearranging
-	 * their children. As a reaction to this call, each widget shall fetch
-	 * information from its children and decide whether its own properties have
-	 * to be changed. If not, widget shall calculate new layout for its children
-	 * and call rearrange() on each of them. Otherwise, widget shall change its
-	 * own properties and call reconfigure() on its parent.
-	 */
-	void (*reconfigure)(widget_t *);
-
-	/**
-	 * Reserved for top-bottom traversal when widget decides to change layout
-	 * of its childer. As a reaction to this call, widget shall change its
-	 * position and size according to provided arguments, paint itself,
-	 * calculate new layout for its children and call rearrange() on each
-	 * of them.
-	 */
-	void (*rearrange)(widget_t *, sysarg_t, sysarg_t, sysarg_t, sysarg_t);
-
-	/**
-	 * As a reaction to window refresh event, widget hierarchy is traversed
-	 * in top-bottom order and repaint() is called on each widget. Widget shall
-	 * either paint itself or copy its private buffer onto window surface.
-	 * Widget shall also post damage event into window event loop.
-	 */
-	void (*repaint)(widget_t *);
-
-	/**
-	 * Keyboard events are delivered to widgets that have keyboard focus. As a
-	 * reaction to the event, widget might call reconfigure() on its parent or
-	 * rearrange() on its children. If the widget wants to change its visual
-	 * information, refresh event should be posted to the window event loop.
-	 */
-	void (*handle_keyboard_event)(widget_t *, kbd_event_t);
-
-	/**
-	 * Position events are delivered to those widgets that have mouse grab or
-	 * those that intersects with cursor. As a reaction to the event, widget
-	 * might call reconfigure() on its parent or rearrange() on its children.
-	 * If the widget wants to change its visual information, refresh event
-	 * should be posted to the window event loop. If the widget accepts
-	 * keyboard events, it should take ownership of keyboard focus. Widget can
-	 * also acquire or release mouse grab.
-	 */
-	void (*handle_position_event)(widget_t *, pos_event_t);
-};
-
-/*
- * Note on derived widget constructor/destructor:
- * In order to support inheritance, wach widget shall provide init and deinit
- * function. These functions take already allocated widget and are responsible
- * for (de)initializing all widget-specific resources, inserting/removing the
- * widget into/from widget hierarchy and (de)initializing all data and functions
- * from the top-level base class defined above. For convenience, each widget
- * should also provide constructor to allocate and init the widget in one step.
- */
-
-extern void widget_init(widget_t *, widget_t *, const void *);
-extern void widget_modify(widget_t *, sysarg_t, sysarg_t, sysarg_t, sysarg_t);
-extern const void *widget_get_data(widget_t *);
-extern void widget_deinit(widget_t *);
-
-#endif
-
-/** @}
- */
Index: pace/lib/gui/window.c
===================================================================
--- uspace/lib/gui/window.c	(revision 2c9fdeedc215dcd9caf895b28b729baafa0f3971)
+++ 	(revision )
@@ -1,921 +1,0 @@
-/*
- * Copyright (c) 2012 Petr Koupy
- * 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 gui
- * @{
- */
-/**
- * @file
- */
-
-#include <stdbool.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <as.h>
-#include <stdlib.h>
-#include <str.h>
-
-#include <fibril.h>
-#include <task.h>
-#include <adt/prodcons.h>
-#include <adt/list.h>
-
-#include <loc.h>
-
-#include <io/pixel.h>
-#include <draw/source.h>
-#include <draw/font.h>
-#include <draw/drawctx.h>
-#include <draw/surface.h>
-#include <display.h>
-
-#include "common.h"
-#include "connection.h"
-#include "widget.h"
-#include "window.h"
-
-static sysarg_t border_thickness = 4;
-static sysarg_t bevel_thickness = 1;
-static sysarg_t header_height = 20;
-static sysarg_t header_min_width = 40;
-static sysarg_t close_thickness = 20;
-static sysarg_t corner_size = 24;
-static sysarg_t window_initial_size = 1;
-
-static pixel_t color_highlight = PIXEL(255, 255, 255, 255);
-static pixel_t color_shadow = PIXEL(255, 85, 85, 85);
-static pixel_t color_surface = PIXEL(255, 186, 186, 186);
-
-static pixel_t color_header_focus_highlight = PIXEL(255, 120, 145, 255);
-static pixel_t color_header_focus_shadow = PIXEL(255, 40, 48, 89);
-static pixel_t color_header_focus_surface = PIXEL(255, 88, 106, 196);
-
-static pixel_t color_header_unfocus_highlight = PIXEL(255, 16, 78, 126);
-static pixel_t color_header_unfocus_shadow = PIXEL(255, 5, 26, 42);
-static pixel_t color_header_unfocus_surface = PIXEL(255, 12, 57, 92);
-
-static pixel_t color_caption_focus = PIXEL(255, 255, 255, 255);
-static pixel_t color_caption_unfocus = PIXEL(255, 207, 207, 207);
-
-static void window_close_event(void *);
-static void window_focus_event(void *);
-static void window_kbd_event(void *, kbd_event_t *);
-static void window_pos_event(void *, pos_event_t *);
-static void window_resize_event(void *, gfx_rect_t *);
-static void window_unfocus_event(void *);
-
-static display_wnd_cb_t window_cb = {
-	.close_event = window_close_event,
-	.focus_event = window_focus_event,
-	.kbd_event = window_kbd_event,
-	.pos_event = window_pos_event,
-	.resize_event = window_resize_event,
-	.unfocus_event = window_unfocus_event
-};
-
-static void set_cursor(window_t *window, display_stock_cursor_t cursor)
-{
-	if (cursor != window->cursor) {
-		(void) display_window_set_cursor(window->dwindow, cursor);
-		window->cursor = cursor;
-	}
-}
-
-static void paint_internal(widget_t *widget)
-{
-	surface_t *surface = window_claim(widget->window);
-	if (!surface)
-		window_yield(widget->window);
-
-	source_t source;
-	source_init(&source);
-
-	drawctx_t drawctx;
-	drawctx_init(&drawctx, surface);
-	drawctx_set_source(&drawctx, &source);
-
-	/* Window border outer bevel */
-
-	draw_bevel(&drawctx, &source, widget->vpos, widget->hpos,
-	    widget->width, widget->height, color_highlight, color_shadow);
-
-	/* Window border surface */
-
-	source_set_color(&source, color_surface);
-	drawctx_transfer(&drawctx, widget->hpos + 1, widget->vpos + 1,
-	    widget->width - 2, 2);
-	drawctx_transfer(&drawctx, widget->hpos + 1, widget->vpos + 1,
-	    2, widget->height - 2);
-	drawctx_transfer(&drawctx, widget->hpos + 1,
-	    widget->vpos + widget->height - 3, widget->width - 2, 2);
-	drawctx_transfer(&drawctx, widget->hpos + widget->width - 3,
-	    widget->vpos + 1, 2, widget->height - 4);
-
-	/* Window border inner bevel */
-
-	draw_bevel(&drawctx, &source, widget->hpos + 3, widget->vpos + 3,
-	    widget->width - 6, widget->height - 6, color_shadow,
-	    color_highlight);
-
-	/* Header bevel */
-
-	sysarg_t header_hpos = widget->hpos + border_thickness;
-	sysarg_t header_vpos = widget->vpos + border_thickness;
-	sysarg_t header_width = widget->width - 2 * border_thickness -
-	    close_thickness;
-
-	draw_bevel(&drawctx, &source, header_hpos, header_vpos,
-	    header_width, header_height, widget->window->is_focused ?
-	    color_header_focus_highlight : color_header_unfocus_highlight,
-	    widget->window->is_focused ?
-	    color_header_focus_shadow : color_header_unfocus_shadow);
-
-	/* Header surface */
-
-	source_set_color(&source, widget->window->is_focused ?
-	    color_header_focus_surface : color_header_unfocus_surface);
-	drawctx_transfer(&drawctx, header_hpos + 1, header_vpos + 1,
-	    header_width - 2, header_height - 2);
-
-	/* Close button bevel */
-
-	sysarg_t close_hpos = widget->hpos + widget->width -
-	    border_thickness - close_thickness;
-	sysarg_t close_vpos = widget->vpos + border_thickness;
-
-	draw_bevel(&drawctx, &source, close_hpos, close_vpos,
-	    close_thickness, close_thickness, color_highlight, color_shadow);
-
-	/* Close button surface */
-
-	source_set_color(&source, color_surface);
-	drawctx_transfer(&drawctx, close_hpos + 1, close_vpos + 1,
-	    close_thickness - 2, close_thickness - 2);
-
-	/* Close button icon */
-
-	draw_icon_cross(surface, close_hpos + 3, close_vpos + 3,
-	    color_highlight, color_shadow);
-
-	/* Window caption */
-
-	font_t *font;
-	errno_t rc = embedded_font_create(&font, 16);
-	if (rc != EOK) {
-		window_yield(widget->window);
-		return;
-	}
-
-	drawctx_set_font(&drawctx, font);
-	source_set_color(&source, widget->window->is_focused ?
-	    color_caption_focus : color_caption_unfocus);
-
-	sysarg_t cpt_width;
-	sysarg_t cpt_height;
-	font_get_box(font, widget->window->caption, &cpt_width, &cpt_height);
-
-	bool draw_title =
-	    (widget->width >= 2 * border_thickness + 2 * bevel_thickness +
-	    close_thickness + cpt_width);
-	if (draw_title) {
-		sysarg_t cpt_x = ((widget->width - cpt_width) / 2) + widget->hpos;
-		sysarg_t cpt_y = ((header_height - cpt_height) / 2) +
-		    widget->vpos + border_thickness;
-
-		if (widget->window->caption)
-			drawctx_print(&drawctx, widget->window->caption, cpt_x, cpt_y);
-	}
-
-	font_release(font);
-	window_yield(widget->window);
-}
-
-static void root_destroy(widget_t *widget)
-{
-	widget_deinit(widget);
-}
-
-static void root_reconfigure(widget_t *widget)
-{
-	if (widget->window->is_decorated) {
-		list_foreach(widget->children, link, widget_t, child) {
-			child->rearrange(child,
-			    widget->hpos + border_thickness,
-			    widget->vpos + border_thickness + header_height,
-			    widget->width - 2 * border_thickness,
-			    widget->height - 2 * border_thickness - header_height);
-		}
-	} else {
-		list_foreach(widget->children, link, widget_t, child) {
-			child->rearrange(child, widget->hpos, widget->vpos,
-			    widget->width, widget->height);
-		}
-	}
-}
-
-static void root_rearrange(widget_t *widget, sysarg_t hpos, sysarg_t vpos,
-    sysarg_t width, sysarg_t height)
-{
-	widget_modify(widget, hpos, vpos, width, height);
-	if (widget->window->is_decorated) {
-		paint_internal(widget);
-		list_foreach(widget->children, link, widget_t, child) {
-			child->rearrange(child,
-			    hpos + border_thickness,
-			    vpos + border_thickness + header_height,
-			    width - 2 * border_thickness,
-			    height - 2 * border_thickness - header_height);
-		}
-	} else {
-		list_foreach(widget->children, link, widget_t, child) {
-			child->rearrange(child, hpos, vpos, width, height);
-		}
-	}
-}
-
-static void root_repaint(widget_t *widget)
-{
-	if (widget->window->is_decorated) {
-		paint_internal(widget);
-	}
-	list_foreach(widget->children, link, widget_t, child) {
-		child->repaint(child);
-	}
-	if (widget->window->is_decorated) {
-		window_damage(widget->window);
-	}
-}
-
-static void root_handle_keyboard_event(widget_t *widget, kbd_event_t event)
-{
-	if (!list_empty(&widget->children)) {
-		widget_t *child = (widget_t *) list_first(&widget->children);
-		child->handle_keyboard_event(child, event);
-	}
-}
-
-static void root_handle_position_event(widget_t *widget, pos_event_t event)
-{
-	gfx_coord2_t pos;
-
-	if (widget->window->is_decorated) {
-		sysarg_t width = widget->width;
-		sysarg_t height = widget->height;
-
-		bool btn_left = (event.btn_num == 1) && (event.type == POS_PRESS);
-
-		bool left = (event.hpos < border_thickness);
-		bool right = (event.hpos >= width - border_thickness);
-		bool top = (event.vpos < border_thickness);
-		bool bottom = (event.vpos >= height - border_thickness);
-		bool edge = left || right || top || bottom;
-
-		bool cleft = (event.hpos < corner_size);
-		bool cright = (event.hpos >= width - corner_size);
-		bool ctop = (event.vpos < corner_size);
-		bool cbottom = (event.vpos >= height - corner_size);
-
-		bool header = (event.hpos >= border_thickness) &&
-		    (event.hpos < width - border_thickness) &&
-		    (event.vpos >= border_thickness) &&
-		    (event.vpos < border_thickness + header_height);
-		bool close = (header) &&
-		    (event.hpos >= width - border_thickness - close_thickness);
-
-		bool isresize = widget->window->is_resizable;
-		display_wnd_rsztype_t rsztype = 0;
-
-		if (edge && ctop && cleft) {
-			rsztype = display_wr_top_left;
-		} else if (edge && cbottom && cleft) {
-			rsztype = display_wr_bottom_left;
-		} else if (edge && cbottom && cright) {
-			rsztype = display_wr_bottom_right;
-		} else if (edge && ctop && cright) {
-			rsztype = display_wr_top_right;
-		} else if (top) {
-			rsztype = display_wr_top;
-		} else if (left) {
-			rsztype = display_wr_left;
-		} else if (bottom) {
-			rsztype = display_wr_bottom;
-		} else if (right) {
-			rsztype = display_wr_right;
-		} else {
-			isresize = false;
-		}
-
-		if (isresize) {
-			(void) set_cursor(widget->window,
-			    display_cursor_from_wrsz(rsztype));
-		} else {
-			(void) set_cursor(widget->window, dcurs_arrow);
-		}
-
-		pos.x = event.hpos;
-		pos.y = event.vpos;
-
-		if (isresize && btn_left) {
-			(void) display_window_resize_req(
-			    widget->window->dwindow, rsztype, &pos);
-		} else if (close && btn_left) {
-			window_close(widget->window);
-		} else if (header && btn_left) {
-			(void) display_window_move_req(widget->window->dwindow,
-			    &pos);
-		} else {
-			list_foreach(widget->children, link, widget_t, child) {
-				child->handle_position_event(child, event);
-			}
-		}
-	} else {
-		list_foreach(widget->children, link, widget_t, child) {
-			child->handle_position_event(child, event);
-		}
-	}
-}
-
-static void deliver_keyboard_event(window_t *win, kbd_event_t event)
-{
-	if (win->focus) {
-		win->focus->handle_keyboard_event(win->focus, event);
-	} else {
-		win->root.handle_keyboard_event(&win->root, event);
-	}
-}
-
-static void deliver_position_event(window_t *win, pos_event_t event)
-{
-	if (win->grab) {
-		win->grab->handle_position_event(win->grab, event);
-	} else {
-		win->root.handle_position_event(&win->root, event);
-	}
-}
-
-static void handle_signal_event(window_t *win, signal_event_t event)
-{
-	widget_t *widget = (widget_t *) event.object;
-	slot_t slot = (slot_t) event.slot;
-	void *data = (void *) event.argument;
-
-	slot(widget, data);
-
-	free(data);
-}
-
-static void handle_resize(window_t *win, sysarg_t offset_x, sysarg_t offset_y,
-    sysarg_t width, sysarg_t height, window_placement_flags_t placement_flags)
-{
-	gfx_bitmap_params_t params;
-	gfx_bitmap_alloc_t alloc;
-	gfx_bitmap_t *new_bitmap = NULL;
-	gfx_coord2_t offs;
-	gfx_coord2_t dpos;
-	display_info_t dinfo;
-	gfx_rect_t drect;
-	gfx_rect_t nrect;
-	errno_t rc;
-
-	if (width < 2 * border_thickness + header_min_width)
-		return;
-
-	if (height < 2 * border_thickness + header_height)
-		return;
-
-	fibril_mutex_lock(&win->guard);
-
-	/* Deallocate old bitmap. */
-	if (win->bitmap != NULL) {
-		gfx_bitmap_destroy(win->bitmap);
-		win->bitmap = NULL;
-	}
-
-	/* Deallocate old surface. */
-	if (win->surface != NULL) {
-		surface_destroy(win->surface);
-		win->surface = NULL;
-	}
-
-	/* Place window, if appropriate */
-	if (placement_flags != WINDOW_PLACEMENT_ANY) {
-		dpos.x = 0;
-		dpos.y = 0;
-
-		rc = display_get_info(win->display, &dinfo);
-		if (rc != EOK) {
-			fibril_mutex_unlock(&win->guard);
-			return;
-		}
-
-		drect = dinfo.rect;
-
-		if (placement_flags & WINDOW_PLACEMENT_LEFT)
-			dpos.x = drect.p0.x;
-		else if (placement_flags & WINDOW_PLACEMENT_CENTER_X)
-			dpos.x = (drect.p0.x + drect.p1.x - width) / 2;
-		else
-			dpos.x = drect.p1.x - width;
-
-		if (placement_flags & WINDOW_PLACEMENT_TOP)
-			dpos.y = drect.p0.y;
-		else if (placement_flags & WINDOW_PLACEMENT_CENTER_Y)
-			dpos.y = (drect.p0.y + drect.p1.y - height) / 2;
-		else
-			dpos.y = drect.p1.y - height;
-
-		(void) display_window_move(win->dwindow, &dpos);
-	}
-
-	/* Resize the display window. */
-	offs.x = offset_x;
-	offs.y = offset_y;
-	nrect.p0.x = 0;
-	nrect.p0.y = 0;
-	nrect.p1.x = width;
-	nrect.p1.y = height;
-
-	rc = display_window_resize(win->dwindow, &offs, &nrect);
-	if (rc != EOK) {
-		fibril_mutex_unlock(&win->guard);
-		return;
-	}
-
-	gfx_bitmap_params_init(&params);
-#ifndef CONFIG_WIN_DOUBLE_BUF
-	params.flags = bmpf_direct_output;
-#else
-	params.flags = 0;
-#endif
-	params.rect.p0.x = 0;
-	params.rect.p0.y = 0;
-	params.rect.p1.x = width;
-	params.rect.p1.y = height;
-
-	rc = gfx_bitmap_create(win->gc, &params, NULL, &new_bitmap);
-	if (rc != EOK) {
-		if (rc == ENOTSUP) {
-			/* Direct output is not supported */
-			params.flags &= ~bmpf_direct_output;
-			rc = gfx_bitmap_create(win->gc, &params, NULL, &new_bitmap);
-			if (rc != EOK) {
-				fibril_mutex_unlock(&win->guard);
-				return;
-			}
-		}
-	}
-
-	rc = gfx_bitmap_get_alloc(new_bitmap, &alloc);
-	if (rc != EOK) {
-		fibril_mutex_unlock(&win->guard);
-		return;
-	}
-
-	/* Allocate new surface. */
-	surface_t *new_surface = surface_create(width, height, alloc.pixels,
-	    SURFACE_FLAG_SHARED);
-	if (!new_surface) {
-		gfx_bitmap_destroy(new_bitmap);
-		fibril_mutex_unlock(&win->guard);
-		return;
-	}
-
-	/* Switch in new surface and bitmap. */
-	win->surface = new_surface;
-	win->bitmap = new_bitmap;
-	fibril_mutex_unlock(&win->guard);
-
-	/*
-	 * Let all widgets in the tree alter their position and size.
-	 * Widgets might also paint themselves onto the new surface.
-	 */
-	win->root.rearrange(&win->root, 0, 0, width, height);
-
-	fibril_mutex_lock(&win->guard);
-	surface_reset_damaged_region(win->surface);
-	fibril_mutex_unlock(&win->guard);
-
-	(void) gfx_bitmap_render(win->bitmap, NULL, NULL);
-}
-
-static void handle_refresh(window_t *win)
-{
-	win->root.repaint(&win->root);
-}
-
-static void handle_damage(window_t *win)
-{
-	sysarg_t x, y, width, height;
-	gfx_rect_t rect;
-	fibril_mutex_lock(&win->guard);
-	surface_get_damaged_region(win->surface, &x, &y, &width, &height);
-	surface_reset_damaged_region(win->surface);
-	fibril_mutex_unlock(&win->guard);
-
-	if (width > 0 && height > 0) {
-		rect.p0.x = x;
-		rect.p0.y = y;
-		rect.p1.x = x + width;
-		rect.p1.y = y + height;
-
-		if (win->bitmap != NULL)
-			(void) gfx_bitmap_render(win->bitmap, &rect, NULL);
-	}
-}
-
-static void destroy_children(widget_t *widget)
-{
-	/* Recursively destroy widget tree in bottom-top order. */
-	while (!list_empty(&widget->children)) {
-		widget_t *child =
-		    list_get_instance(list_first(&widget->children), widget_t, link);
-		destroy_children(child);
-		child->destroy(child);
-	}
-}
-
-static void handle_close(window_t *win)
-{
-	destroy_children(&win->root);
-	win->root.destroy(&win->root);
-	win->grab = NULL;
-	win->focus = NULL;
-
-	gfx_bitmap_destroy(win->bitmap);
-
-	/*
-	 * XXX Here we should properly destroy the IPC GC. We only have
-	 * the generic GC so either it would need to be cast back or
-	 * GC needs a virtual destructor.
-	 */
-
-	display_window_destroy(win->dwindow);
-	display_close(win->display);
-
-	while (!list_empty(&win->events.list)) {
-		window_event_t *event = (window_event_t *) list_first(&win->events.list);
-		list_remove(&event->link);
-		free(event);
-	}
-
-	if (win->surface) {
-		surface_destroy(win->surface);
-	}
-
-	free(win->caption);
-
-	free(win);
-}
-
-/* Window event loop. Runs in own dedicated fibril. */
-static errno_t event_loop(void *arg)
-{
-	bool is_main = false;
-	bool terminate = false;
-	window_t *win = (window_t *) arg;
-
-	while (true) {
-		window_event_t *event = (window_event_t *) prodcons_consume(&win->events);
-
-		switch (event->type) {
-		case ET_KEYBOARD_EVENT:
-			deliver_keyboard_event(win, event->data.kbd);
-			break;
-		case ET_POSITION_EVENT:
-			deliver_position_event(win, event->data.pos);
-			break;
-		case ET_SIGNAL_EVENT:
-			handle_signal_event(win, event->data.signal);
-			break;
-		case ET_WINDOW_RESIZE:
-			handle_resize(win, event->data.resize.offset_x,
-			    event->data.resize.offset_y, event->data.resize.width,
-			    event->data.resize.height, event->data.resize.placement_flags);
-			break;
-		case ET_WINDOW_FOCUS:
-			if (!win->is_focused) {
-				win->is_focused = true;
-				handle_refresh(win);
-			}
-			break;
-		case ET_WINDOW_UNFOCUS:
-			if (win->is_focused) {
-				win->is_focused = false;
-				handle_refresh(win);
-			}
-			break;
-		case ET_WINDOW_REFRESH:
-			handle_refresh(win);
-			break;
-		case ET_WINDOW_DAMAGE:
-			handle_damage(win);
-			break;
-		case ET_WINDOW_CLOSE:
-			is_main = win->is_main;
-			handle_close(win);
-			terminate = true;
-			break;
-		default:
-			break;
-		}
-
-		free(event);
-		if (terminate) {
-			break;
-		}
-	}
-
-	if (is_main) {
-		exit(0); /* Terminate whole task. */
-	}
-	return 0;
-}
-
-window_t *window_open(const char *winreg, const void *data,
-    window_flags_t flags, const char *caption)
-{
-	display_wnd_params_t wparams;
-
-	window_t *win = (window_t *) calloc(1, sizeof(window_t));
-	if (!win)
-		return NULL;
-
-	win->is_main = flags & WINDOW_MAIN;
-	win->is_decorated = flags & WINDOW_DECORATED;
-	win->is_resizable = flags & WINDOW_RESIZEABLE;
-	win->is_focused = true;
-	prodcons_initialize(&win->events);
-	fibril_mutex_initialize(&win->guard);
-
-	widget_init(&win->root, NULL, data);
-	win->root.window = win;
-	win->root.destroy = root_destroy;
-	win->root.reconfigure = root_reconfigure;
-	win->root.rearrange = root_rearrange;
-	win->root.repaint = root_repaint;
-	win->root.handle_keyboard_event = root_handle_keyboard_event;
-	win->root.handle_position_event = root_handle_position_event;
-	win->grab = NULL;
-	win->focus = NULL;
-	win->cursor = dcurs_arrow;
-
-	/* Allocate resources for new surface. */
-	win->surface = surface_create(window_initial_size,
-	    window_initial_size, NULL, SURFACE_FLAG_SHARED);
-	if (win->surface == NULL) {
-		free(win);
-		return NULL;
-	}
-
-	errno_t rc = display_open(winreg, &win->display);
-	if (rc != EOK) {
-		surface_destroy(win->surface);
-		free(win);
-		return NULL;
-	}
-
-	/* Window dimensions are not know at this time */
-	display_wnd_params_init(&wparams);
-	wparams.rect.p0.x = 0;
-	wparams.rect.p0.y = 0;
-	wparams.rect.p1.x = window_initial_size;
-	wparams.rect.p1.y = window_initial_size;
-	wparams.min_size.x = 2 * border_thickness + header_min_width;
-	wparams.min_size.y = 2 * border_thickness + header_height;
-
-	rc = display_window_create(win->display, &wparams, &window_cb,
-	    (void *) win, &win->dwindow);
-	if (rc != EOK) {
-		display_close(win->display);
-		surface_destroy(win->surface);
-		free(win);
-		return NULL;
-	}
-
-	rc = display_window_get_gc(win->dwindow, &win->gc);
-	if (rc != EOK) {
-		display_window_destroy(win->dwindow);
-		display_close(win->display);
-		surface_destroy(win->surface);
-		free(win);
-		return NULL;
-	}
-
-	if (caption == NULL)
-		win->caption = NULL;
-	else
-		win->caption = str_dup(caption);
-
-	return win;
-}
-
-void window_resize(window_t *win, sysarg_t offset_x, sysarg_t offset_y,
-    sysarg_t width, sysarg_t height, window_placement_flags_t placement_flags)
-{
-	window_event_t *event = (window_event_t *) malloc(sizeof(window_event_t));
-	if (event) {
-		link_initialize(&event->link);
-		event->type = ET_WINDOW_RESIZE;
-		event->data.resize.offset_x = offset_x;
-		event->data.resize.offset_y = offset_y;
-		event->data.resize.width = width;
-		event->data.resize.height = height;
-		event->data.resize.placement_flags = placement_flags;
-		prodcons_produce(&win->events, &event->link);
-	}
-}
-
-errno_t window_set_caption(window_t *win, const char *caption)
-{
-	char *cap;
-
-	if (caption == NULL) {
-		win->caption = NULL;
-	} else {
-		cap = str_dup(caption);
-		if (cap == NULL)
-			return ENOMEM;
-		free(win->caption);
-		win->caption = cap;
-	}
-
-	win->is_focused = false;
-	handle_refresh(win);
-
-	return EOK;
-}
-
-void window_refresh(window_t *win)
-{
-	window_event_t *event = (window_event_t *) malloc(sizeof(window_event_t));
-	if (event) {
-		link_initialize(&event->link);
-		event->type = ET_WINDOW_REFRESH;
-		prodcons_produce(&win->events, &event->link);
-	}
-}
-
-void window_damage(window_t *win)
-{
-	window_event_t *event = (window_event_t *) malloc(sizeof(window_event_t));
-	if (event) {
-		link_initialize(&event->link);
-		event->type = ET_WINDOW_DAMAGE;
-		prodcons_produce(&win->events, &event->link);
-	}
-}
-
-widget_t *window_root(window_t *win)
-{
-	return &win->root;
-}
-
-void window_exec(window_t *win)
-{
-	fid_t ev_fid = fibril_create(event_loop, win);
-	if (!ev_fid) {
-		return;
-	}
-	fibril_add_ready(ev_fid);
-}
-
-surface_t *window_claim(window_t *win)
-{
-	fibril_mutex_lock(&win->guard);
-	return win->surface;
-}
-
-void window_yield(window_t *win)
-{
-	fibril_mutex_unlock(&win->guard);
-}
-
-void window_close(window_t *win)
-{
-	window_event_t *event;
-
-	event = (window_event_t *) calloc(1, sizeof(window_event_t));
-	if (event == NULL)
-		return;
-
-	link_initialize(&event->link);
-	event->type = ET_WINDOW_CLOSE;
-	prodcons_produce(&win->events, &event->link);
-}
-
-static void window_close_event(void *arg)
-{
-	window_t *win = (window_t *) arg;
-
-	window_close(win);
-}
-
-static void window_focus_event(void *arg)
-{
-	window_t *win = (window_t *) arg;
-	window_event_t *event;
-
-	event = (window_event_t *) calloc(1, sizeof(window_event_t));
-	if (event == NULL)
-		return;
-
-	link_initialize(&event->link);
-	event->type = ET_WINDOW_FOCUS;
-	prodcons_produce(&win->events, &event->link);
-}
-
-static void window_kbd_event(void *arg, kbd_event_t *kevent)
-{
-	window_t *win = (window_t *) arg;
-	window_event_t *event;
-
-	event = (window_event_t *) calloc(1, sizeof(window_event_t));
-	if (event == NULL)
-		return;
-
-	link_initialize(&event->link);
-	event->type = ET_KEYBOARD_EVENT;
-	event->data.kbd = *kevent;
-	prodcons_produce(&win->events, &event->link);
-}
-
-static void window_pos_event(void *arg, pos_event_t *pevent)
-{
-	window_t *win = (window_t *) arg;
-	window_event_t *event;
-
-	event = (window_event_t *) calloc(1, sizeof(window_event_t));
-	if (event == NULL)
-		return;
-
-	link_initialize(&event->link);
-	event->type = ET_POSITION_EVENT;
-	event->data.pos = *pevent;
-	prodcons_produce(&win->events, &event->link);
-}
-
-static void window_resize_event(void *arg, gfx_rect_t *nrect)
-{
-	window_t *win = (window_t *) arg;
-	window_event_t *event;
-
-	if (!win->is_resizable)
-		return;
-
-	event = (window_event_t *) calloc(1, sizeof(window_event_t));
-	if (event == NULL)
-		return;
-
-	link_initialize(&event->link);
-	event->type = ET_WINDOW_RESIZE;
-	event->data.resize.offset_x = nrect->p0.x;
-	event->data.resize.offset_y = nrect->p0.y;
-	event->data.resize.width = nrect->p1.x - nrect->p0.x;
-	event->data.resize.height = nrect->p1.y - nrect->p0.y;
-	event->data.resize.placement_flags = WINDOW_PLACEMENT_ANY;
-	prodcons_produce(&win->events, &event->link);
-}
-
-static void window_unfocus_event(void *arg)
-{
-	window_t *win = (window_t *) arg;
-	window_event_t *event;
-
-	event = (window_event_t *) calloc(1, sizeof(window_event_t));
-	if (event == NULL)
-		return;
-
-	link_initialize(&event->link);
-	event->type = ET_WINDOW_UNFOCUS;
-	prodcons_produce(&win->events, &event->link);
-}
-
-/** @}
- */
Index: pace/lib/gui/window.h
===================================================================
--- uspace/lib/gui/window.h	(revision 2c9fdeedc215dcd9caf895b28b729baafa0f3971)
+++ 	(revision )
@@ -1,141 +1,0 @@
-/*
- * Copyright (c) 2012 Petr Koupy
- * 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 gui
- * @{
- */
-/**
- * @file
- */
-
-#ifndef GUI_WINDOW_H_
-#define GUI_WINDOW_H_
-
-#include <adt/prodcons.h>
-#include <fibril_synch.h>
-#include <ipc/window.h>
-#include <io/window.h>
-#include <draw/surface.h>
-#include <display.h>
-#include <gfx/bitmap.h>
-#include <gfx/context.h>
-
-#include "widget.h"
-
-struct window {
-	bool is_main; /**< True for the main window of the application. */
-	bool is_decorated; /**< True if the window decorations should be rendered. */
-	bool is_focused; /**< True for the top level window of the desktop. */
-	bool is_resizable; /**< True if window is resizable */
-	char *caption; /**< Text title of the window header. */
-	display_t *display; /**< Display service */
-	display_window_t *dwindow; /**< Display window */
-	gfx_context_t *gc; /**< GC of the window */
-	prodcons_t events; /**< Queue for window event loop. */
-	widget_t root; /**< Decoration widget serving as a root of widget hiearchy. */
-	widget_t *grab; /**< Widget owning the mouse or NULL. */
-	widget_t *focus; /**< Widget owning the keyboard or NULL. */
-	fibril_mutex_t guard; /**< Mutex guarding window surface. */
-	surface_t *surface; /**< Window surface shared with display server. */
-	gfx_bitmap_t *bitmap; /**< Window bitmap */
-	display_stock_cursor_t cursor; /**< Selected cursor */
-};
-
-/**
- * Allocate all resources for new window and register it in the display server.
- * If the window is declared as main, its closure causes termination of the
- * whole application. Note that opened window does not have any surface yet.
- */
-extern window_t *window_open(const char *, const void *, window_flags_t,
-    const char *);
-
-/**
- * Post resize event into event loop. Window negotiates new surface with
- * display server and asks all widgets in the tree to calculate their new
- * properties and to paint themselves on the new surface (top-bottom order).
- * Should be called also after opening new window to obtain surface.
- */
-extern void window_resize(window_t *, sysarg_t, sysarg_t, sysarg_t, sysarg_t,
-    window_placement_flags_t);
-
-/** Change window caption. */
-extern errno_t window_set_caption(window_t *, const char *);
-
-/**
- * Post refresh event into event loop. Widget tree is traversed and all widgets
- * are asked to repaint themselves in top-bottom order. Should be called by
- * widget after such change of its internal state that does not need resizing
- * of neither parent nor children ().
- */
-extern void window_refresh(window_t *);
-
-/**
- * Post damage event into event loop. Handler informs display server to update
- * the window surface on the screen. Should be called by widget after painting
- * itself or copying its buffer onto window surface.
- */
-extern void window_damage(window_t *);
-
-/**
- * Retrieve dummy root widget of the window widget tree. Intended to be called
- * by proper top-level widget to set his parent.
- */
-extern widget_t *window_root(window_t *);
-
-/**
- * Prepare and enqueue window fibrils for event loop and input fetching. When
- * async_manager() function is called, event loop is executed.
- */
-extern void window_exec(window_t *);
-
-/**
- * Claim protected window surface. Intended for widgets painting from their
- * internal fibrils (e.g. terminal, animation, video).
- */
-extern surface_t *window_claim(window_t *);
-
-/**
- * Yield protected window surface after painting.
- */
-extern void window_yield(window_t *);
-
-/**
- * Initiate the closing cascade for the window. First, display sever deallocates
- * output resources, prepares special closing input event for the window and
- * deallocates input resources after the event is dispatched. When window
- * fetches closing event, it is posted into event loop and input fibril
- * terminates. When event loop fibril handles closing event, all window
- * resources are deallocated and fibril also terminates. Moreover, if the
- * window is main window of the application, whole task terminates.
- */
-extern void window_close(window_t *);
-
-#endif
-
-/** @}
- */
Index: uspace/lib/meson.build
===================================================================
--- uspace/lib/meson.build	(revision 2c9fdeedc215dcd9caf895b28b729baafa0f3971)
+++ uspace/lib/meson.build	(revision 38f55980b853a6d2953396322e7620146fa59ad2)
@@ -34,5 +34,4 @@
 	'math',
 	'display',
-	'gui',
 	'draw',
 	'softrend',
@@ -44,4 +43,5 @@
 	'ipcgfx',
 	'display',
+	'ui',
 ]
 
@@ -98,5 +98,4 @@
 	'display',
 
-	'gui',
 	'ui',
 ]
