aboutsummaryrefslogtreecommitdiff
path: root/termo.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2014-11-19 02:41:36 +0100
committerPřemysl Janouch <p.janouch@gmail.com>2014-11-19 03:19:13 +0100
commit2d777dd67e9be3c5bfd36660ade94710de0f4a0d (patch)
tree046b13365164eb2ac437804a6eca90131183380b /termo.c
parent5a80bceec9c3fcc304d8dde1c10f16a9adde8598 (diff)
downloadtermo-2d777dd67e9be3c5bfd36660ade94710de0f4a0d.tar.gz
termo-2d777dd67e9be3c5bfd36660ade94710de0f4a0d.tar.xz
termo-2d777dd67e9be3c5bfd36660ade94710de0f4a0d.zip
Rewrite the mouse API
I wasn't aware of the fact that 1000, 1002 and 1003 are mutually exclusive and turn each other off. Also now it's not needed to set the protocol, it gets set by default.
Diffstat (limited to 'termo.c')
-rw-r--r--termo.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/termo.c b/termo.c
index 063a5a7..e88e74d 100644
--- a/termo.c
+++ b/termo.c
@@ -315,7 +315,7 @@ termo_alloc (void)
tk->method.peekkey_mouse = &peekkey_mouse;
tk->mouse_proto = TERMO_MOUSE_PROTO_NONE;
- tk->mouse_tracking = TERMO_MOUSE_TRACKING_NORMAL;
+ tk->mouse_tracking = TERMO_MOUSE_TRACKING_CLICK;
tk->guessed_mouse_proto = TERMO_MOUSE_PROTO_NONE;
tk->ti_data = NULL;
@@ -638,28 +638,35 @@ termo_get_buffer_remaining (termo_t *tk)
return tk->buffsize - tk->buffcount;
}
-int
-termo_get_mouse_proto (termo_t *tk)
+termo_mouse_proto_t
+termo_get_mouse_proto(termo_t *tk)
{
return tk->mouse_proto;
}
-int
-termo_guess_mouse_proto (termo_t *tk)
+termo_mouse_proto_t
+termo_guess_mouse_proto(termo_t *tk)
{
return tk->guessed_mouse_proto;
}
int
-termo_set_mouse_proto (termo_t *tk, int proto)
+termo_set_mouse_proto (termo_t *tk, termo_mouse_proto_t proto)
{
- int old_proto = tk->mouse_proto;
+ termo_mouse_proto_t old_proto = tk->mouse_proto;
tk->mouse_proto = proto;
// Call the TI driver to apply the change if needed
- if (!tk->is_started
+ if (proto == old_proto
+ || !tk->is_started
|| !tk->ti_method.set_mouse_proto)
return true;
+
+ // Unsetting the protocol disables tracking; this is a bit hackish
+ if (!tk->ti_method.set_mouse_tracking_mode (tk->ti_data,
+ tk->mouse_tracking, proto != TERMO_MOUSE_PROTO_NONE))
+ return false;
+
return tk->ti_method.set_mouse_proto (tk->ti_data, old_proto, false)
&& tk->ti_method.set_mouse_proto (tk->ti_data, proto, true);
}
@@ -677,9 +684,11 @@ termo_set_mouse_tracking_mode (termo_t *tk, termo_mouse_tracking_t mode)
tk->mouse_tracking = mode;
// Call the TI driver to apply the change if needed
- if (!tk->is_started
+ if (mode == old_mode
+ || !tk->is_started
|| !tk->ti_method.set_mouse_tracking_mode)
return true;
+
return tk->ti_method.set_mouse_tracking_mode (tk->ti_data, old_mode, false)
&& tk->ti_method.set_mouse_tracking_mode (tk->ti_data, mode, true);
}