Emit word_click even as long as user is not selecting any text when releasing button

This fixes the need to do pixel-perfect clicks to open links in chat
This commit is contained in:
Pavel Djundik 2016-01-10 12:37:30 -08:00 committed by Arnavion
parent edd57fdc86
commit 971e5cf4fe
2 changed files with 24 additions and 6 deletions

View File

@ -113,6 +113,7 @@ char *nocasestrstr (const char *text, const char *tofind); /* util.c */
int xtext_get_stamp_str (time_t, char **);
static void gtk_xtext_render_page (GtkXText * xtext);
static void gtk_xtext_calc_lines (xtext_buffer *buf, int);
static gboolean gtk_xtext_is_selecting (GtkXText *xtext);
static char *gtk_xtext_selection_get_text (GtkXText *xtext, int *len_ret);
static textentry *gtk_xtext_nth (GtkXText *xtext, int line, int *subline);
static void gtk_xtext_adjustment_changed (GtkAdjustment * adj,
@ -1772,7 +1773,6 @@ gtk_xtext_motion_notify (GtkWidget * widget, GdkEventMotion * event)
xtext->select_end_x = x;
xtext->select_end_y = y;
gtk_xtext_selection_update (xtext, event, y, !redraw);
xtext->hilighting = TRUE;
/* user has pressed or released SHIFT, must redraw entire selection */
if (redraw)
@ -1973,13 +1973,10 @@ gtk_xtext_button_release (GtkWidget * widget, GdkEventButton * event)
return FALSE;
}
if (!xtext->hilighting)
if (!gtk_xtext_is_selecting (xtext))
{
word = gtk_xtext_get_word (xtext, event->x, event->y, 0, 0, 0, 0);
g_signal_emit (G_OBJECT (xtext), xtext_signals[WORD_CLICK], 0, word ? word : NULL, event);
} else
{
xtext->hilighting = FALSE;
}
}
@ -2078,6 +2075,28 @@ gtk_xtext_selection_kill (GtkXText *xtext, GdkEventSelection *event)
return TRUE;
}
static gboolean
gtk_xtext_is_selecting (GtkXText *xtext)
{
textentry *ent;
xtext_buffer *buf;
buf = xtext->selection_buffer;
if (!buf)
return FALSE;
for (ent = buf->last_ent_start; ent; ent = ent->next)
{
if (ent->mark_start != -1 && ent->mark_end - ent->mark_start > 0)
return TRUE;
if (ent == buf->last_ent_end)
break;
}
return FALSE;
}
static char *
gtk_xtext_selection_get_text (GtkXText *xtext, int *len_ret)
{

View File

@ -219,7 +219,6 @@ struct _GtkXText
unsigned int word_select:1;
unsigned int line_select:1;
unsigned int button_down:1;
unsigned int hilighting:1;
unsigned int dont_render:1;
unsigned int dont_render2:1;
unsigned int cursor_hand:1;