Index: uspace/lib/display/include/display.h
===================================================================
--- uspace/lib/display/include/display.h	(revision 12dd36c50ddb4a9f3ef61157afc0eaba800ce4ad)
+++ uspace/lib/display/include/display.h	(revision 8279aab04ec4921ce66c9162c2c0a3e0ba480230)
@@ -1,4 +1,4 @@
 /*
- * Copyright (c) 2023 Jiri Svoboda
+ * Copyright (c) 2025 Jiri Svoboda
  * All rights reserved.
  *
@@ -48,4 +48,6 @@
 extern errno_t display_open(const char *, display_t **);
 extern void display_close(display_t *);
+extern void display_lock(display_t *);
+extern void display_unlock(display_t *);
 extern errno_t display_get_info(display_t *, display_info_t *);
 
Index: uspace/lib/display/src/display.c
===================================================================
--- uspace/lib/display/src/display.c	(revision 12dd36c50ddb4a9f3ef61157afc0eaba800ce4ad)
+++ uspace/lib/display/src/display.c	(revision 8279aab04ec4921ce66c9162c2c0a3e0ba480230)
@@ -1,4 +1,4 @@
 /*
- * Copyright (c) 2023 Jiri Svoboda
+ * Copyright (c) 2025 Jiri Svoboda
  * All rights reserved.
  *
@@ -138,4 +138,26 @@
 }
 
+/*
+ * Lock display.
+ *
+ * While display is locked, display event handlers will not be called.
+ *
+ * @param display Display
+ */
+void display_lock(display_t *display)
+{
+	fibril_mutex_lock(&display->lock);
+}
+
+/*
+ * Unlock display.
+ *
+ * @param display Display
+ */
+void display_unlock(display_t *display)
+{
+	fibril_mutex_unlock(&display->lock);
+}
+
 /** Initialize window parameters structure.
  *
@@ -700,13 +722,11 @@
 	display_wnd_ev_t event;
 
+	display_lock(display);
+
 	while (true) {
-		fibril_mutex_lock(&display->lock);
-
 		if (display->sess != NULL)
 			rc = display_get_event(display, &window, &event);
 		else
 			rc = ENOENT;
-
-		fibril_mutex_unlock(&display->lock);
 
 		if (rc != EOK)
@@ -752,4 +772,5 @@
 	}
 
+	display_unlock(display);
 	async_answer_0(icall, EOK);
 }
Index: uspace/lib/ui/src/ui.c
===================================================================
--- uspace/lib/ui/src/ui.c	(revision 12dd36c50ddb4a9f3ef61157afc0eaba800ce4ad)
+++ uspace/lib/ui/src/ui.c	(revision 8279aab04ec4921ce66c9162c2c0a3e0ba480230)
@@ -1,4 +1,4 @@
 /*
- * Copyright (c) 2023 Jiri Svoboda
+ * Copyright (c) 2025 Jiri Svoboda
  * All rights reserved.
  *
@@ -568,4 +568,6 @@
 void ui_lock(ui_t *ui)
 {
+	if (ui->display != NULL)
+		display_lock(ui->display);
 	fibril_mutex_lock(&ui->lock);
 }
@@ -582,4 +584,6 @@
 {
 	fibril_mutex_unlock(&ui->lock);
+	if (ui->display != NULL)
+		display_unlock(ui->display);
 }
 
Index: uspace/lib/ui/src/window.c
===================================================================
--- uspace/lib/ui/src/window.c	(revision 12dd36c50ddb4a9f3ef61157afc0eaba800ce4ad)
+++ uspace/lib/ui/src/window.c	(revision 8279aab04ec4921ce66c9162c2c0a3e0ba480230)
@@ -1,4 +1,4 @@
 /*
- * Copyright (c) 2024 Jiri Svoboda
+ * Copyright (c) 2025 Jiri Svoboda
  * All rights reserved.
  *
@@ -978,7 +978,7 @@
 	ui_t *ui = window->ui;
 
-	ui_lock(ui);
+	fibril_mutex_lock(&ui->lock);
 	ui_window_send_close(window);
-	ui_unlock(ui);
+	fibril_mutex_unlock(&ui->lock);
 }
 
@@ -989,5 +989,5 @@
 	ui_t *ui = window->ui;
 
-	ui_lock(ui);
+	fibril_mutex_lock(&ui->lock);
 	(void)nfocus;
 
@@ -998,5 +998,5 @@
 
 	ui_window_send_focus(window, nfocus);
-	ui_unlock(ui);
+	fibril_mutex_unlock(&ui->lock);
 }
 
@@ -1007,7 +1007,7 @@
 	ui_t *ui = window->ui;
 
-	ui_lock(ui);
+	fibril_mutex_lock(&ui->lock);
 	ui_window_send_kbd(window, kbd_event);
-	ui_unlock(ui);
+	fibril_mutex_unlock(&ui->lock);
 }
 
@@ -1023,14 +1023,14 @@
 		return;
 
-	ui_lock(ui);
+	fibril_mutex_lock(&ui->lock);
 
 	claim = ui_wdecor_pos_event(window->wdecor, event);
 	if (claim == ui_claimed) {
-		ui_unlock(ui);
+		fibril_mutex_unlock(&ui->lock);
 		return;
 	}
 
 	ui_window_send_pos(window, event);
-	ui_unlock(ui);
+	fibril_mutex_unlock(&ui->lock);
 }
 
@@ -1048,8 +1048,8 @@
 		return;
 
-	ui_lock(ui);
+	fibril_mutex_lock(&ui->lock);
 	(void) ui_window_resize(window, rect);
 	ui_window_send_resize(window);
-	ui_unlock(ui);
+	fibril_mutex_unlock(&ui->lock);
 }
 
@@ -1060,5 +1060,5 @@
 	ui_t *ui = window->ui;
 
-	ui_lock(ui);
+	fibril_mutex_lock(&ui->lock);
 
 	if (window->wdecor != NULL && nfocus == 0) {
@@ -1068,5 +1068,5 @@
 
 	ui_window_send_unfocus(window, nfocus);
-	ui_unlock(ui);
+	fibril_mutex_unlock(&ui->lock);
 }
 
