diff --git a/src/backends/meta-cursor-renderer.c b/src/backends/meta-cursor-renderer.c index 48cd239a9..a76241b9e 100644 --- a/src/backends/meta-cursor-renderer.c +++ b/src/backends/meta-cursor-renderer.c @@ -27,6 +27,8 @@ #include "meta-cursor-renderer.h" #include +#include +#include #include #include @@ -116,6 +118,14 @@ meta_cursor_renderer_calculate_rect (MetaCursorRenderer *renderer, }; } +static gboolean +is_cursor_in_monitors_area (int x, int y) +{ + MetaMonitorManager *monitor_manager = meta_backend_get_monitor_manager (meta_get_backend ()); + return meta_monitor_manager_get_monitor_at_point (monitor_manager, + (gfloat) x, (gfloat) y) >= 0; +} + static void update_cursor (MetaCursorRenderer *renderer, MetaCursorSprite *cursor_sprite) @@ -124,6 +134,11 @@ update_cursor (MetaCursorRenderer *renderer, gboolean handled_by_backend; gboolean should_redraw = FALSE; + /* do not render cursor if it is not on any monitor. Such situation + * can occur e. g. after monitor hot-plug */ + if (!is_cursor_in_monitors_area (priv->current_x, priv->current_y)) + return; + if (cursor_sprite) meta_cursor_sprite_prepare_at (cursor_sprite, priv->current_x,