From 9ae126da1e56487bc4a5b69962f76555a00a4b3e Mon Sep 17 00:00:00 2001
From: "James E. Blair" <jeblair@linux.vnet.ibm.com>
Date: Thu, 14 Jan 2016 14:01:27 -0800
Subject: [PATCH] Add option to disable mouse support

Change-Id: Icb075699441774989810671e48106a9de3926b92
---
 examples/reference-gertty.yaml | 4 ++++
 gertty/app.py                  | 1 +
 gertty/config.py               | 2 ++
 3 files changed, 7 insertions(+)

diff --git a/examples/reference-gertty.yaml b/examples/reference-gertty.yaml
index e621f52..264b64a 100644
--- a/examples/reference-gertty.yaml
+++ b/examples/reference-gertty.yaml
@@ -166,6 +166,10 @@ commentlinks:
 # them in UTC instead, uncomment the following line:
 # display-times-in-utc: true
 
+# Gertty handles mouse input by default.  If you don't want it messing
+# with your terminal's mouse handling, uncomment the following line:
+# handle-mouse: false
+
 # Closed changes that are older than two months are removed from the
 # local database (and their refs are removed from the local git repos
 # so that git may garbage collect them).  If you would like to change
diff --git a/gertty/app.py b/gertty/app.py
index c47a31f..73af729 100644
--- a/gertty/app.py
+++ b/gertty/app.py
@@ -251,6 +251,7 @@ class App(object):
         self.status.update(title=screen.title)
         self.updateStatusQueries()
         self.loop = urwid.MainLoop(screen, palette=self.config.palette.getPalette(),
+                                   handle_mouse=self.config.handle_mouse,
                                    unhandled_input=self.unhandledInput)
 
         self.sync_pipe = self.loop.watch_pipe(self.refresh)
diff --git a/gertty/config.py b/gertty/config.py
index 42089b8..5056a29 100644
--- a/gertty/config.py
+++ b/gertty/config.py
@@ -117,6 +117,7 @@ class ConfigSchema(object):
                            'hide-comments': self.hide_comments,
                            'thread-changes': bool,
                            'display-times-in-utc': bool,
+                           'handle-mouse': bool,
                            'change-list-options': self.change_list_options,
                            'expire-age': str,
                            })
@@ -226,6 +227,7 @@ class Config(object):
 
         self.thread_changes = self.config.get('thread-changes', True)
         self.utc = self.config.get('display-times-in-utc', False)
+        self.handle_mouse = self.config.get('handle-mouse', True)
 
         change_list_options = self.config.get('change-list-options', {})
         self.change_list_options = {