Index: uspace/lib/c/generic/io/window.c
===================================================================
--- uspace/lib/c/generic/io/window.c	(revision ff98ce8df9f54c43b6caa89a9108a3efa35ffcf7)
+++ uspace/lib/c/generic/io/window.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -40,8 +40,9 @@
 #include <stdio.h>
 
-int win_register(async_sess_t *sess, service_id_t *in, service_id_t *out)
+int win_register(async_sess_t *sess, service_id_t *in, service_id_t *out, 
+    sysarg_t x_offset, sysarg_t y_offset)
 {
 	async_exch_t *exch = async_exchange_begin(sess);
-	int ret = async_req_0_2(exch, WINDOW_REGISTER, in, out);
+	int ret = async_req_2_2(exch, WINDOW_REGISTER, x_offset, y_offset, in, out);
 	async_exchange_end(exch);
 
Index: uspace/lib/c/include/io/pixel.h
===================================================================
--- uspace/lib/c/include/io/pixel.h	(revision ff98ce8df9f54c43b6caa89a9108a3efa35ffcf7)
+++ uspace/lib/c/include/io/pixel.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -42,4 +42,6 @@
 	((channel) >> (8 - (bits)))
 
+#define INVERT(pixel) ((pixel) ^ 0x00ffffff)
+
 #define ALPHA(pixel)  ((pixel) >> 24)
 #define RED(pixel)    (((pixel) & 0x00ff0000) >> 16)
Index: uspace/lib/c/include/io/pixelmap.h
===================================================================
--- uspace/lib/c/include/io/pixelmap.h	(revision ff98ce8df9f54c43b6caa89a9108a3efa35ffcf7)
+++ uspace/lib/c/include/io/pixelmap.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -52,7 +52,11 @@
     sysarg_t y)
 {
-	size_t offset = y * pixelmap->width + x;
-	pixel_t *pixel = pixelmap->data + offset;
-	return pixel;
+	if (x < pixelmap->width && y < pixelmap->height) {
+		size_t offset = y * pixelmap->width + x;
+		pixel_t *pixel = pixelmap->data + offset;
+		return pixel;
+	} else {
+		return NULL;
+	}
 }
 
Index: uspace/lib/c/include/io/window.h
===================================================================
--- uspace/lib/c/include/io/window.h	(revision ff98ce8df9f54c43b6caa89a9108a3efa35ffcf7)
+++ uspace/lib/c/include/io/window.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -71,4 +71,6 @@
 	ET_POSITION_EVENT,
 	ET_SIGNAL_EVENT,
+	ET_WINDOW_FOCUS,
+	ET_WINDOW_UNFOCUS,
 	ET_WINDOW_RESIZE,
 	ET_WINDOW_REFRESH,
@@ -100,5 +102,5 @@
 } window_grab_flags_t;
 
-extern int win_register(async_sess_t *, service_id_t *, service_id_t *);
+extern int win_register(async_sess_t *, service_id_t *, service_id_t *, sysarg_t, sysarg_t);
 
 extern int win_get_event(async_sess_t *, window_event_t *);
Index: uspace/lib/draw/drawctx.c
===================================================================
--- uspace/lib/draw/drawctx.c	(revision ff98ce8df9f54c43b6caa89a9108a3efa35ffcf7)
+++ uspace/lib/draw/drawctx.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -129,26 +129,48 @@
 	}
 
-	bool clipped = false;
-	bool masked = false;
-
-	for (sysarg_t _y = y; _y < y + height; ++_y) {
-		for (sysarg_t _x = x; _x < x + width; ++_x) {
-			if (context->shall_clip) {
-				clipped = _x < context->clip_x && _x >= context->clip_width
-				    && _y < context->clip_y && _y >= context->clip_height;
-			}
-			
-			if (context->mask) {
-				pixel_t p = surface_get_pixel(context->mask, _x, _y);
-				masked = p > 0 ? false : true;
-			}
-
-			if (!clipped && !masked) {
-				pixel_t p_src = source_determine_pixel(context->source, _x, _y);
-				pixel_t p_dst = surface_get_pixel(context->surface, _x, _y);
-				pixel_t p_res = context->compose(p_src, p_dst);
-				surface_put_pixel(context->surface, _x, _y, p_res);
+	bool transfer_fast = source_is_fast(context->source)
+	    && (context->shall_clip == false)
+	    && (context->mask == NULL)
+	    && (context->compose == compose_src || context->compose == compose_over);
+
+	if (transfer_fast) {
+
+		for (sysarg_t _y = y; _y < y + height; ++_y) {
+			pixel_t *src = source_direct_access(context->source, x, _y);
+			pixel_t *dst = pixelmap_pixel_at(surface_pixmap_access(context->surface), x, _y);
+			if (src && dst) {
+				sysarg_t count = width;
+				while (count-- != 0) {
+					*dst++ = *src++;
+				}
 			}
 		}
+		surface_add_damaged_region(context->surface, x, y, width, height);
+
+	} else {
+
+		bool clipped = false;
+		bool masked = false;
+		for (sysarg_t _y = y; _y < y + height; ++_y) {
+			for (sysarg_t _x = x; _x < x + width; ++_x) {
+				if (context->shall_clip) {
+					clipped = _x < context->clip_x && _x >= context->clip_width
+					    && _y < context->clip_y && _y >= context->clip_height;
+				}
+
+				if (context->mask) {
+					pixel_t p = surface_get_pixel(context->mask, _x, _y);
+					masked = p > 0 ? false : true;
+				}
+
+				if (!clipped && !masked) {
+					pixel_t p_src = source_determine_pixel(context->source, _x, _y);
+					pixel_t p_dst = surface_get_pixel(context->surface, _x, _y);
+					pixel_t p_res = context->compose(p_src, p_dst);
+					surface_put_pixel(context->surface, _x, _y, p_res);
+				}
+			}
+		}
+
 	}
 }
Index: uspace/lib/draw/source.c
===================================================================
--- uspace/lib/draw/source.c	(revision ff98ce8df9f54c43b6caa89a9108a3efa35ffcf7)
+++ uspace/lib/draw/source.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -90,4 +90,24 @@
 }
 
+bool source_is_fast(source_t *source)
+{
+	return (source->mask == NULL)
+	    && (source->alpha == (pixel_t) PIXEL(255, 0, 0, 0))
+	    && (source->texture != NULL)
+	    && (source->texture_tile == false)
+	    && transform_is_fast(&source->transform);
+}
+
+pixel_t *source_direct_access(source_t *source, double x, double y)
+{
+	assert(source_is_fast(source));
+
+	long _x = (long) (x + source->transform.m[0][2]);
+	long _y = (long) (y + source->transform.m[1][2]);
+
+	return pixelmap_pixel_at(
+	    surface_pixmap_access(source->texture), (sysarg_t) _x, (sysarg_t) _y);
+}
+
 pixel_t source_determine_pixel(source_t *source, double x, double y)
 {
Index: uspace/lib/draw/source.h
===================================================================
--- uspace/lib/draw/source.h	(revision ff98ce8df9f54c43b6caa89a9108a3efa35ffcf7)
+++ uspace/lib/draw/source.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -71,4 +71,6 @@
 extern void source_set_mask(source_t *, surface_t *, bool);
 
+extern bool source_is_fast(source_t *);
+extern pixel_t *source_direct_access(source_t *, double, double);
 extern pixel_t source_determine_pixel(source_t *, double, double);
 
Index: uspace/lib/draw/surface.c
===================================================================
--- uspace/lib/draw/surface.c	(revision ff98ce8df9f54c43b6caa89a9108a3efa35ffcf7)
+++ uspace/lib/draw/surface.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -143,4 +143,17 @@
 }
 
+void surface_add_damaged_region(surface_t *surface, surface_coord_t x, surface_coord_t y,
+    surface_coord_t width, surface_coord_t height)
+{
+	surface->dirty_x_lo = surface->dirty_x_lo > x ? x : surface->dirty_x_lo;
+	surface->dirty_y_lo = surface->dirty_y_lo > y ? y : surface->dirty_y_lo;
+
+	surface_coord_t x_hi = x + width - 1;
+	surface_coord_t y_hi = y + height - 1;
+
+	surface->dirty_x_hi = surface->dirty_x_hi < x_hi ? x_hi : surface->dirty_x_hi;
+	surface->dirty_y_hi = surface->dirty_y_hi < y_hi ? y_hi : surface->dirty_y_hi;
+}
+
 void surface_reset_damaged_region(surface_t *surface)
 {
@@ -158,16 +171,10 @@
 	surface->dirty_y_hi = surface->dirty_y_hi < y ? y : surface->dirty_y_hi;
 
-	if (x < surface->pixmap.width && y < surface->pixmap.height) {
-		pixelmap_put_pixel(&surface->pixmap, x, y, pixel);
-	}
+	pixelmap_put_pixel(&surface->pixmap, x, y, pixel);
 }
 
 pixel_t surface_get_pixel(surface_t *surface, surface_coord_t x, surface_coord_t y)
 {
-	if (x < surface->pixmap.width && y < surface->pixmap.height) {
-		return pixelmap_get_pixel(&surface->pixmap, x, y);
-	} else {
-		return 0;
-	}
+	return pixelmap_get_pixel(&surface->pixmap, x, y);
 }
 
Index: uspace/lib/draw/surface.h
===================================================================
--- uspace/lib/draw/surface.h	(revision ff98ce8df9f54c43b6caa89a9108a3efa35ffcf7)
+++ uspace/lib/draw/surface.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -61,4 +61,6 @@
 extern void surface_get_damaged_region(surface_t *, surface_coord_t *, surface_coord_t *,
     surface_coord_t *, surface_coord_t *);
+extern void surface_add_damaged_region(surface_t *, surface_coord_t , surface_coord_t ,
+    surface_coord_t , surface_coord_t );
 extern void surface_reset_damaged_region(surface_t *);
 
Index: uspace/lib/gui/terminal.c
===================================================================
--- uspace/lib/gui/terminal.c	(revision ff98ce8df9f54c43b6caa89a9108a3efa35ffcf7)
+++ uspace/lib/gui/terminal.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -196,15 +196,16 @@
 	uint16_t glyph = fb_font_glyph(field->ch);
 	
-	// FIXME: This font drawing routine is shamelessly
-	//        suboptimal. It should be optimized for
-	//        aligned memory transfers, etc.
-	
 	for (unsigned int y = 0; y < FONT_SCANLINES; y++) {
-		for (unsigned int x = 0; x < FONT_WIDTH; x++) {
-			pixel_t pixel =
-			    (fb_font[glyph][y] & (1 << (7 - x))) ? fgcolor : bgcolor;
-			surface_put_pixel(surface, bx + x, by + y, pixel);
+		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);
 }
 
Index: uspace/lib/gui/window.c
===================================================================
--- uspace/lib/gui/window.c	(revision ff98ce8df9f54c43b6caa89a9108a3efa35ffcf7)
+++ uspace/lib/gui/window.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -66,6 +66,8 @@
 
 static pixel_t border_color = PIXEL(255, 0, 0, 0);
-static pixel_t header_bgcolor = PIXEL(255, 25, 25, 112);
-static pixel_t header_fgcolor = PIXEL(255, 255, 255, 255);
+static pixel_t header_bg_focus_color = PIXEL(255, 25, 25, 112);
+static pixel_t header_fg_focus_color = PIXEL(255, 255, 255, 255);
+static pixel_t header_bg_unfocus_color = PIXEL(255, 70, 130, 180);
+static pixel_t header_fg_unfocus_color = PIXEL(255, 255, 255, 255);
 
 static void paint_internal(widget_t *w)
@@ -94,5 +96,6 @@
 	    w->vpos + w->height - border_thickness, w->width, border_thickness);
 
-	source_set_color(&source, header_bgcolor);
+	source_set_color(&source, 
+	    w->window->is_focused ? header_bg_focus_color : header_bg_unfocus_color);
 	drawctx_transfer(&drawctx,
 	    w->hpos + border_thickness, w->vpos + border_thickness,
@@ -106,5 +109,6 @@
 	char cls_pict[] = "x";
 	font_get_box(&font, cls_pict, &cls_width, &cls_height);
-	source_set_color(&source, header_fgcolor);
+	source_set_color(&source, 
+	    w->window->is_focused ? header_fg_focus_color : header_fg_unfocus_color);
 	sysarg_t cls_x = ((close_width - cls_width) / 2) + w->hpos + w->width -
 	    border_thickness - close_width;
@@ -447,4 +451,8 @@
 			break;
 		case ET_POSITION_EVENT:
+			if (!win->is_focused) {
+				win->is_focused = true;
+				handle_refresh(win);
+			}
 			deliver_position_event(win, event->data.pos);
 			break;
@@ -454,4 +462,16 @@
 		case ET_WINDOW_RESIZE:
 			handle_resize(win, event->data.rsz.width, event->data.rsz.height);
+			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:
@@ -514,5 +534,6 @@
 }
 
-window_t *window_open(char *winreg, bool is_main, bool is_decorated, const char *caption)
+window_t *window_open(char *winreg, bool is_main, bool is_decorated, 
+    const char *caption, sysarg_t x_offset, sysarg_t y_offset)
 {
 	int rc;
@@ -525,4 +546,5 @@
 	win->is_main = is_main;
 	win->is_decorated = is_decorated;
+	win->is_focused = true;
 	prodcons_initialize(&win->events);
 	fibril_mutex_initialize(&win->guard);
@@ -557,5 +579,5 @@
 	service_id_t out_dsid;
 	
-	rc = win_register(reg_sess, &in_dsid, &out_dsid);
+	rc = win_register(reg_sess, &in_dsid, &out_dsid, x_offset, y_offset);
 	async_hangup(reg_sess);
 	if (rc != EOK) {
Index: uspace/lib/gui/window.h
===================================================================
--- uspace/lib/gui/window.h	(revision ff98ce8df9f54c43b6caa89a9108a3efa35ffcf7)
+++ uspace/lib/gui/window.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -50,4 +50,5 @@
 	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. */
 	char *caption; /**< Text title of the window header. */
 	async_sess_t *isess; /**< Input events from compositor. */
@@ -65,5 +66,5 @@
  * 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(char *, bool, bool, const char *);
+extern window_t *window_open(char *, bool, bool, const char *, sysarg_t, sysarg_t);
 
 /**
Index: uspace/lib/softrend/filter.c
===================================================================
--- uspace/lib/softrend/filter.c	(revision ff98ce8df9f54c43b6caa89a9108a3efa35ffcf7)
+++ uspace/lib/softrend/filter.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -44,6 +44,4 @@
 		_x %= pixmap->width;
 		_y %= pixmap->height;
-	} else if (_x < 0 || _x >= (long) pixmap->width || _y < 0 || _y >= (long) pixmap->height) {
-		return 0;
 	}
 
Index: uspace/lib/softrend/transform.c
===================================================================
--- uspace/lib/softrend/transform.c	(revision ff98ce8df9f54c43b6caa89a9108a3efa35ffcf7)
+++ uspace/lib/softrend/transform.c	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -136,4 +136,12 @@
 }
 
+bool transform_is_fast(transform_t *t)
+{
+	return (t->m[0][0] == 1) && (t->m[0][1] == 0)
+	    && (t->m[1][0] == 0) && (t->m[1][1] == 1)
+	    && ((t->m[0][2] - ((long) t->m[0][2])) == 0.0)
+	    && ((t->m[1][2] - ((long) t->m[1][2])) == 0.0);
+}
+
 void transform_apply_linear(const transform_t *t, double *x, double *y)
 {
Index: uspace/lib/softrend/transform.h
===================================================================
--- uspace/lib/softrend/transform.h	(revision ff98ce8df9f54c43b6caa89a9108a3efa35ffcf7)
+++ uspace/lib/softrend/transform.h	(revision 3194d83cd48bf0ba94cbc3623cfce9300290003f)
@@ -37,4 +37,6 @@
 #define SOFTREND_TRANSFORM_H_
 
+#include <bool.h>
+
 #ifndef PI
 #define PI 3.141592653589793
@@ -53,4 +55,6 @@
 extern void transform_rotate(transform_t *, double);
 
+extern bool transform_is_fast(transform_t *);
+
 extern void transform_apply_linear(const transform_t *, double *, double *);
 extern void transform_apply_affine(const transform_t *, double *, double *);
