Index: uspace/lib/ui/src/window.c
===================================================================
--- uspace/lib/ui/src/window.c	(revision 1af103e4973625ad986fb43b4eea1bcd9414c3c1)
+++ uspace/lib/ui/src/window.c	(revision 8a6ebbb5ac39f92e3b6f2a64d07c67e15440ed5a)
@@ -109,4 +109,7 @@
 };
 
+static void wnd_sysmenu_erestore(ui_menu_entry_t *, void *);
+static void wnd_sysmenu_eminimize(ui_menu_entry_t *, void *);
+static void wnd_sysmenu_emaximize(ui_menu_entry_t *, void *);
 static void wnd_sysmenu_eclose(ui_menu_entry_t *, void *);
 
@@ -208,4 +211,78 @@
 }
 
+/** Create window's system menu.
+ *
+ * @param window Window
+ * @return EOK on success or an error code
+ */
+static errno_t ui_window_sysmenu_create(ui_window_t *window)
+{
+	errno_t rc;
+	ui_menu_entry_t *mrestore;
+	ui_menu_entry_t *mmin;
+	ui_menu_entry_t *mmax;
+	ui_menu_entry_t *msep;
+	ui_menu_entry_t *mclose;
+
+	rc = ui_menu_create(window, &window->sysmenu);
+	if (rc != EOK)
+		goto error;
+
+	ui_menu_set_cb(window->sysmenu, &wnd_sysmenu_cb, (void *)window);
+
+	rc = ui_menu_entry_create(window->sysmenu, "~R~estore",
+	    "", &mrestore);
+	if (rc != EOK)
+		goto error;
+
+	if (!window->wdecor->maximized)
+		ui_menu_entry_set_disabled(mrestore, true);
+
+	ui_menu_entry_set_cb(mrestore, wnd_sysmenu_erestore, (void *)window);
+
+	rc = ui_menu_entry_create(window->sysmenu, "Mi~n~imize",
+	    "", &mmin);
+	if (rc != EOK)
+		goto error;
+
+	if ((window->wdecor->style & ui_wds_minimize_btn) == 0)
+		ui_menu_entry_set_disabled(mmin, true);
+
+	ui_menu_entry_set_cb(mmin, wnd_sysmenu_eminimize, (void *)window);
+
+	rc = ui_menu_entry_create(window->sysmenu, "Ma~x~imize",
+	    "", &mmax);
+	if (rc != EOK)
+		goto error;
+
+	if ((window->wdecor->style & ui_wds_maximize_btn) == 0 ||
+	    window->wdecor->maximized)
+		ui_menu_entry_set_disabled(mmax, true);
+
+	ui_menu_entry_set_cb(mmax, wnd_sysmenu_emaximize, (void *)window);
+
+	rc = ui_menu_entry_sep_create(window->sysmenu, &msep);
+	if (rc != EOK)
+		goto error;
+
+	rc = ui_menu_entry_create(window->sysmenu, "~C~lose", "Alt-F4",
+	    &mclose);
+	if (rc != EOK)
+		goto error;
+
+	if ((window->wdecor->style & ui_wds_close_btn) == 0)
+		ui_menu_entry_set_disabled(mclose, true);
+
+	ui_menu_entry_set_cb(mclose, wnd_sysmenu_eclose, (void *)window);
+
+	window->sysmenu_restore = mrestore;
+	window->sysmenu_minimize = mmin;
+	window->sysmenu_maximize = mmax;
+
+	return EOK;
+error:
+	return rc;
+}
+
 /** Create new window.
  *
@@ -399,4 +476,9 @@
 	window->cursor = ui_curs_arrow;
 	window->placement = params->placement;
+
+	rc = ui_window_sysmenu_create(window);
+	if (rc != EOK)
+		goto error;
+
 	*rwindow = window;
 
@@ -1230,23 +1312,5 @@
 {
 	errno_t rc;
-	ui_menu_entry_t *mclose;
 	ui_wdecor_geom_t geom;
-
-	if (window->sysmenu == NULL) {
-		rc = ui_menu_create(window, &window->sysmenu);
-		if (rc != EOK)
-			goto error;
-
-		ui_menu_set_cb(window->sysmenu, &wnd_sysmenu_cb,
-		    (void *)window);
-
-		rc = ui_menu_entry_create(window->sysmenu, "~C~lose", "Alt-F4",
-		    &mclose);
-		if (rc != EOK)
-			goto error;
-
-		ui_menu_entry_set_cb(mclose, wnd_sysmenu_eclose,
-		    (void *)window);
-	}
 
 	if (ui_menu_is_open(window->sysmenu)) {
@@ -1308,4 +1372,6 @@
 
 	ui_wdecor_set_maximized(window->wdecor, true);
+	ui_menu_entry_set_disabled(window->sysmenu_restore, false);
+	ui_menu_entry_set_disabled(window->sysmenu_maximize, true);
 
 	rc = ui_window_size_change(window, &rect, ui_wsc_maximize);
@@ -1330,4 +1396,6 @@
 
 	ui_wdecor_set_maximized(window->wdecor, false);
+	ui_menu_entry_set_disabled(window->sysmenu_restore, true);
+	ui_menu_entry_set_disabled(window->sysmenu_maximize, false);
 
 	rc = ui_window_size_change(window, &window->normal_rect,
@@ -1452,4 +1520,40 @@
 
 	ui_menu_close(sysmenu);
+}
+
+/** Handle system menu Restore entry activation.
+ *
+ * @param mentry Menu entry
+ * @param arg Argument (ui_window_t *)
+ */
+static void wnd_sysmenu_erestore(ui_menu_entry_t *mentry, void *arg)
+{
+	ui_window_t *window = (ui_window_t *)arg;
+
+	ui_window_send_unmaximize(window);
+}
+
+/** Handle system menu Minimize entry activation.
+ *
+ * @param mentry Menu entry
+ * @param arg Argument (ui_window_t *)
+ */
+static void wnd_sysmenu_eminimize(ui_menu_entry_t *mentry, void *arg)
+{
+	ui_window_t *window = (ui_window_t *)arg;
+
+	ui_window_send_minimize(window);
+}
+
+/** Handle system menu Maximize entry activation.
+ *
+ * @param mentry Menu entry
+ * @param arg Argument (ui_window_t *)
+ */
+static void wnd_sysmenu_emaximize(ui_menu_entry_t *mentry, void *arg)
+{
+	ui_window_t *window = (ui_window_t *)arg;
+
+	ui_window_send_maximize(window);
 }
 
