Index: uspace/app/gfxdemo/gfxdemo.c
===================================================================
--- uspace/app/gfxdemo/gfxdemo.c	(revision c0efb2e9388394d6778c11490e1b62a8fc2faeb3)
+++ uspace/app/gfxdemo/gfxdemo.c	(revision 788c76e3d84d36c0843f4bbd27240fa4735c078a)
@@ -1109,4 +1109,6 @@
 	gfx_rect_t wrect;
 	gfx_coord2_t off;
+	gfx_rect_t ui_rect;
+	gfx_coord2_t dims;
 	errno_t rc;
 
@@ -1114,4 +1116,10 @@
 	if (rc != EOK) {
 		printf("Error initializing UI (%s)\n", display_spec);
+		goto error;
+	}
+
+	rc = ui_get_rect(ui, &ui_rect);
+	if (rc != EOK) {
+		printf("Error getting display size.\n");
 		goto error;
 	}
@@ -1133,4 +1141,12 @@
 	gfx_rect_rtranslate(&off, &wrect, &params.rect);
 
+	gfx_rect_dims(&ui_rect, &dims);
+
+	/* Make sure window is not larger than the entire screen */
+	if (params.rect.p1.x > dims.x)
+		params.rect.p1.x = dims.x;
+	if (params.rect.p1.y > dims.y)
+		params.rect.p1.y = dims.y;
+
 	rc = ui_window_create(ui, &params, &window);
 	if (rc != EOK) {
@@ -1147,7 +1163,11 @@
 	}
 
-	task_retval(0);
-
-	rc = demo_loop(gc, rect.p1.x, rect.p1.y);
+	ui_window_get_app_rect(window, &rect);
+	gfx_rect_dims(&rect, &dims);
+
+	if (!ui_is_fullscreen(ui))
+		task_retval(0);
+
+	rc = demo_loop(gc, dims.x, dims.y);
 	if (rc != EOK)
 		goto error;
