From 24c91d95de97a3313591703c61297da4ca7dc6d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Wed, 12 Apr 2017 14:24:25 +0800 Subject: core/screen: Make logical monitor getters handle being headless Don't crash or return invalid indices when we are headless. https://bugzilla.gnome.org/show_bug.cgi?id=730551 --- src/core/screen.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/screen.c b/src/core/screen.c index 503c20195..98c5538e3 100644 --- a/src/core/screen.c +++ b/src/core/screen.c @@ -1515,6 +1515,9 @@ meta_screen_get_monitor_index_for_rect (MetaScreen *screen, logical_monitor = meta_monitor_manager_get_logical_monitor_from_rect (monitor_manager, rect); + if (!logical_monitor) + return -1; + return logical_monitor->number; } @@ -1604,7 +1607,7 @@ meta_screen_get_primary_monitor (MetaScreen *screen) if (logical_monitor) return logical_monitor->number; else - return 0; + return -1; } /** -- cgit v1.2.1