From 14e95e765eeb1fd103ee8821656b43bf69c5519d Mon Sep 17 00:00:00 2001
From: Tony Crisci <tony@dubstepdish.com>
Date: Thu, 23 Apr 2015 18:21:15 -0400
Subject: [PATCH] Check if output is disabled in handle_output()

Check if the `connection` of the randr output is
XCB_RANDR_CONNECTION_DISONNECTED and disable the output if it is.

This fixes an issue where the output would not be disabled if the output was
physically unplugged from the machine.
---
 src/randr.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/randr.c b/src/randr.c
index 29183695..9e236dcb 100644
--- a/src/randr.c
+++ b/src/randr.c
@@ -555,6 +555,12 @@ static void handle_output(xcb_connection_t *conn, xcb_randr_output_t id,
         return;
     }
 
+    if (output->connection == XCB_RANDR_CONNECTION_DISCONNECTED) {
+        DLOG("Disabling output %s: it is disconnected\n", new->name);
+        new->to_be_disabled = true;
+        return;
+    }
+
     bool updated = update_if_necessary(&(new->rect.x), crtc->x) |
                    update_if_necessary(&(new->rect.y), crtc->y) |
                    update_if_necessary(&(new->rect.width), crtc->width) |