terminology: Improve terminal mouse handling

No mouse interaction when terminal handles it.

SVN revision: 77487
This commit is contained in:
Sebastian Dransfeld 2012-10-04 23:19:09 +00:00
parent 2a03fbbd04
commit 7067a61849
1 changed files with 21 additions and 13 deletions

View File

@ -1331,15 +1331,16 @@ _rep_mouse_down(Evas_Object *obj, Evas_Event_Mouse_Down *ev, int cx, int cy)
return ret; return ret;
} }
static void static Eina_Bool
_rep_mouse_up(Evas_Object *obj, Evas_Event_Mouse_Up *ev, int cx, int cy) _rep_mouse_up(Evas_Object *obj, Evas_Event_Mouse_Up *ev, int cx, int cy)
{ {
Termio *sd; Termio *sd;
char buf[64]; char buf[64];
Eina_Bool ret = EINA_FALSE;
sd = evas_object_smart_data_get(obj); sd = evas_object_smart_data_get(obj);
if (!sd) return; if (!sd) return EINA_FALSE;
if (sd->pty->mouse_rep == MOUSE_OFF) return; if (sd->pty->mouse_rep == MOUSE_OFF) return EINA_FALSE;
switch (sd->pty->mouse_rep) switch (sd->pty->mouse_rep)
{ {
case MOUSE_UTF8: // ESC.[.M.BTN/FLGS.UTF8.YUTF8 case MOUSE_UTF8: // ESC.[.M.BTN/FLGS.UTF8.YUTF8
@ -1372,6 +1373,7 @@ _rep_mouse_up(Evas_Object *obj, Evas_Event_Mouse_Up *ev, int cx, int cy)
} }
buf[i] = 0; buf[i] = 0;
termpty_write(sd->pty, buf, strlen(buf)); termpty_write(sd->pty, buf, strlen(buf));
ret = EINA_TRUE;
} }
break; break;
case MOUSE_SGR: // ESC.[.<.NUM.;.NUM.;.NUM.M case MOUSE_SGR: // ESC.[.<.NUM.;.NUM.;.NUM.M
@ -1384,6 +1386,7 @@ _rep_mouse_up(Evas_Object *obj, Evas_Event_Mouse_Up *ev, int cx, int cy)
snprintf(buf, sizeof(buf), "%c[<%i;%i;%im", 0x1b, snprintf(buf, sizeof(buf), "%c[<%i;%i;%im", 0x1b,
(btn | shift | meta | ctrl), cx + 1, cy + 1); (btn | shift | meta | ctrl), cx + 1, cy + 1);
termpty_write(sd->pty, buf, strlen(buf)); termpty_write(sd->pty, buf, strlen(buf));
ret = EINA_TRUE;
} }
break; break;
case MOUSE_NORMAL: case MOUSE_NORMAL:
@ -1403,22 +1406,26 @@ _rep_mouse_up(Evas_Object *obj, Evas_Event_Mouse_Up *ev, int cx, int cy)
buf[5] = cy + 1 + ' '; buf[5] = cy + 1 + ' ';
buf[6] = 0; buf[6] = 0;
termpty_write(sd->pty, buf, strlen(buf)); termpty_write(sd->pty, buf, strlen(buf));
ret = EINA_TRUE;
} }
break; break;
default: default:
break; break;
} }
return ret;
} }
static void static Eina_Bool
_rep_mouse_move(Evas_Object *obj, Evas_Event_Mouse_Move *ev __UNUSED__, int cx __UNUSED__, int cy __UNUSED__) _rep_mouse_move(Evas_Object *obj, Evas_Event_Mouse_Move *ev __UNUSED__, int cx __UNUSED__, int cy __UNUSED__)
{ {
Termio *sd; Termio *sd;
Eina_Bool ret = EINA_FALSE;
sd = evas_object_smart_data_get(obj); sd = evas_object_smart_data_get(obj);
if (!sd) return; if (!sd) return EINA_FALSE;
if (sd->pty->mouse_rep == MOUSE_OFF) return; if (sd->pty->mouse_rep == MOUSE_OFF) return EINA_FALSE;
// not sure what to d here right now so do nothing. // not sure what to d here right now so do nothing.
return ret;
} }
static void static void
@ -1535,14 +1542,13 @@ static void
_smart_cb_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event) _smart_cb_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event)
{ {
Evas_Event_Mouse_Down *ev = event; Evas_Event_Mouse_Down *ev = event;
Eina_Bool paste;
Termio *sd; Termio *sd;
int cx, cy; int cx, cy;
sd = evas_object_smart_data_get(data); sd = evas_object_smart_data_get(data);
if (!sd) return; if (!sd) return;
_smart_xy_to_cursor(data, ev->canvas.x, ev->canvas.y, &cx, &cy); _smart_xy_to_cursor(data, ev->canvas.x, ev->canvas.y, &cx, &cy);
paste = _rep_mouse_down(data, ev, cx, cy); if (_rep_mouse_down(data, ev, cx, cy)) return;
sd->didclick = EINA_FALSE; sd->didclick = EINA_FALSE;
if (ev->button == 1) if (ev->button == 1)
{ {
@ -1613,11 +1619,13 @@ _smart_cb_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__
} }
else if (ev->button == 2) else if (ev->button == 2)
{ {
if (!paste)
_paste_selection(data, ELM_SEL_TYPE_PRIMARY); _paste_selection(data, ELM_SEL_TYPE_PRIMARY);
} }
else if (ev->button == 3) else if (ev->button == 3)
{
/* TODO: Show options when in terminal mouse mode */
evas_object_smart_callback_call(data, "options", NULL); evas_object_smart_callback_call(data, "options", NULL);
}
} }
static void static void
@ -1630,7 +1638,7 @@ _smart_cb_mouse_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
sd = evas_object_smart_data_get(data); sd = evas_object_smart_data_get(data);
if (!sd) return; if (!sd) return;
_smart_xy_to_cursor(data, ev->canvas.x, ev->canvas.y, &cx, &cy); _smart_xy_to_cursor(data, ev->canvas.x, ev->canvas.y, &cx, &cy);
_rep_mouse_up(data, ev, cx, cy); if (_rep_mouse_up(data, ev, cx, cy)) return;
if (sd->cur.makesel) if (sd->cur.makesel)
{ {
sd->cur.makesel = 0; sd->cur.makesel = 0;
@ -1668,7 +1676,7 @@ _smart_cb_mouse_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__
if ((sd->mouse.cx != cx) || (sd->mouse.cy != cy)) mc_change = EINA_TRUE; if ((sd->mouse.cx != cx) || (sd->mouse.cy != cy)) mc_change = EINA_TRUE;
sd->mouse.cx = cx; sd->mouse.cx = cx;
sd->mouse.cy = cy; sd->mouse.cy = cy;
_rep_mouse_move(data, ev, cx, cy); if (_rep_mouse_move(data, ev, cx, cy)) return;
if (sd->cur.makesel) if (sd->cur.makesel)
{ {
if (!sd->cur.sel) if (!sd->cur.sel)