Compare commits

..
4 Commits
Author SHA1 Message Date
deepend-tildeclub ca2456cbc6 Merge pull request #401 from ZoiteChat/fix-ircv3-typing
Fix IRCv3 typing notifications
2026-09-26 05:52:36 -07:00
deepend 222b4868f5 Fix IRCv3 typing notifications 2026-09-26 06:10:20 -06:00
deepend-tildeclub 2cf1f7e833 Merge pull request #398 from ZoiteChat/fix-issue-361
restrict input redraws to the entry widget
2026-09-19 22:33:03 -07:00
deepend 776d24695e keep X11 selection ownership off the chat window 2026-09-18 05:29:03 -06:00
5 changed files with 94 additions and 33 deletions
+8 -6
View File
@@ -2826,6 +2826,7 @@ static gboolean
client_tag_allowed (server *serv, const char *tag)
{
char **deny;
gboolean blocked = FALSE;
int i;
if (!serv->have_message_tags)
@@ -2837,15 +2838,16 @@ client_tag_allowed (server *serv, const char *tag)
deny = g_strsplit (serv->clienttagdeny, ",", 0);
for (i = 0; deny[i]; i++)
{
if (!strcmp (deny[i], "*") || !strcmp (deny[i], tag) || (deny[i][0] == '+' && !strcmp (deny[i] + 1, tag)))
{
g_strfreev (deny);
return FALSE;
}
if (!strcmp (deny[i], "*"))
blocked = TRUE;
else if (deny[i][0] == '-' && !strcmp (deny[i] + 1, tag))
blocked = FALSE;
else if (!strcmp (deny[i], tag) || (deny[i][0] == '+' && !strcmp (deny[i] + 1, tag)))
blocked = TRUE;
}
g_strfreev (deny);
return TRUE;
return !blocked;
}
static char *
+1
View File
@@ -450,6 +450,7 @@ typedef struct session
int mode_timeout_tag;
int typing_timeout_tag;
int typing_status;
gint64 typing_last_sent;
int typing_animation_tag;
int typing_animation_frame;
+26 -13
View File
@@ -778,10 +778,13 @@ mg_inputbox_focus (GtkWidget *widget, GdkEventFocus *event, session_gui *gui)
}
#define TYPING_THROTTLE_USEC (3 * G_USEC_PER_SEC)
static gboolean
mg_client_tag_allowed (server *serv, const char *tag)
{
char **deny;
gboolean blocked = FALSE;
int i;
if (!serv->have_message_tags)
@@ -793,30 +796,42 @@ mg_client_tag_allowed (server *serv, const char *tag)
deny = g_strsplit (serv->clienttagdeny, ",", 0);
for (i = 0; deny[i]; i++)
{
if (!strcmp (deny[i], "*") || !strcmp (deny[i], tag) || (deny[i][0] == '+' && !strcmp (deny[i] + 1, tag)))
{
g_strfreev (deny);
return FALSE;
}
if (!strcmp (deny[i], "*"))
blocked = TRUE;
else if (deny[i][0] == '-' && !strcmp (deny[i] + 1, tag))
blocked = FALSE;
else if (!strcmp (deny[i], tag) || (deny[i][0] == '+' && !strcmp (deny[i] + 1, tag)))
blocked = TRUE;
}
g_strfreev (deny);
return TRUE;
return !blocked;
}
static void
static gboolean
mg_typing_can_send (session *sess)
{
gint64 now = g_get_monotonic_time ();
return sess->typing_last_sent == 0 ||
now - sess->typing_last_sent >= TYPING_THROTTLE_USEC;
}
static gboolean
mg_send_typing (session *sess, const char *state)
{
char tags[32];
if (!sess || !sess->server->connected || !mg_client_tag_allowed (sess->server, "typing") || !sess->channel[0])
return;
return FALSE;
if (sess->type != SESS_CHANNEL && sess->type != SESS_DIALOG)
return;
return FALSE;
g_snprintf (tags, sizeof (tags), "+typing=%s", state);
sess->server->p_tagmsg (sess->server, tags, sess->channel);
sess->typing_last_sent = g_get_monotonic_time ();
return TRUE;
}
static int
@@ -845,17 +860,15 @@ mg_typing_update (session *sess, const char *text)
if (!text || !*text || text[0] == prefs.hex_input_command_char[0])
{
if (sess->typing_status)
if (sess->typing_status && mg_typing_can_send (sess))
mg_send_typing (sess, "done");
sess->typing_status = 0;
return;
}
if (sess->typing_status != 1)
{
if (mg_typing_can_send (sess))
mg_send_typing (sess, "active");
sess->typing_status = 1;
}
sess->typing_timeout_tag = fe_timeout_add_seconds (6, mg_typing_pause_cb, sess);
}
+2 -11
View File
@@ -1266,8 +1266,6 @@ attr_list_has_attrs (PangoAttrList *attrs)
static void
sexy_spell_entry_recheck_all(SexySpellEntry *entry)
{
GdkRectangle rect;
GtkAllocation allocation;
GtkWidget *widget = GTK_WIDGET(entry);
int length, i, text_len;
const char *text;
@@ -1299,15 +1297,8 @@ sexy_spell_entry_recheck_all(SexySpellEntry *entry)
gtk_entry_set_attributes (GTK_ENTRY (entry), attr_list_has_attrs (entry->priv->attr_list) ? entry->priv->attr_list : NULL);
if (gtk_widget_get_realized (GTK_WIDGET(entry)))
{
gtk_widget_get_allocation (GTK_WIDGET(entry), &allocation);
rect.x = 0; rect.y = 0;
rect.width = allocation.width;
rect.height = allocation.height;
gdk_window_invalidate_rect(gtk_widget_get_window (widget), &rect, TRUE);
}
/* GtkEntry shares its parent's GdkWindow in GTK3; redraw the widget area. */
gtk_widget_queue_draw (widget);
}
static gboolean
+56 -2
View File
@@ -273,6 +273,8 @@ 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 void gtk_xtext_clipboard_get (GtkClipboard *, GtkSelectionData *, guint, gpointer);
static void gtk_xtext_clipboard_clear (GtkClipboard *, gpointer);
static textentry *gtk_xtext_nth (GtkXText *xtext, int line, int *subline);
static void gtk_xtext_adjustment_changed (GtkAdjustment * adj,
GtkXText * xtext);
@@ -1082,9 +1084,29 @@ gtk_xtext_new (const XTextColor *palette, int separator)
return GTK_WIDGET (xtext);
}
static void
gtk_xtext_release_selections (GtkXText *xtext)
{
GdkAtom selections[] = { GDK_SELECTION_PRIMARY, GDK_SELECTION_SECONDARY };
guint i;
if (!gtk_widget_has_screen (GTK_WIDGET (xtext)))
return;
for (i = 0; i < G_N_ELEMENTS (selections); i++)
{
GtkClipboard *clipboard = gtk_widget_get_clipboard (GTK_WIDGET (xtext), selections[i]);
if (gtk_clipboard_get_owner (clipboard) == G_OBJECT (xtext))
gtk_clipboard_clear (clipboard);
}
}
static void
gtk_xtext_cleanup (GtkXText *xtext)
{
gtk_xtext_release_selections (xtext);
if (xtext->add_io_tag)
{
g_source_remove (xtext->add_io_tag);
@@ -1179,6 +1201,7 @@ gtk_xtext_finalize (GObject *object)
static void
gtk_xtext_unrealize (GtkWidget * widget)
{
gtk_xtext_release_selections (GTK_XTEXT (widget));
backend_deinit (GTK_XTEXT (widget));
/*
@@ -2743,8 +2766,16 @@ gtk_xtext_set_clip_owner (GtkWidget * xtext, GdkEventButton * event)
{
gtk_clipboard_set_text (gtk_widget_get_clipboard (xtext, GDK_SELECTION_CLIPBOARD), str, len);
gtk_selection_owner_set (xtext, GDK_SELECTION_PRIMARY, event ? event->time : GDK_CURRENT_TIME);
gtk_selection_owner_set (xtext, GDK_SELECTION_SECONDARY, event ? event->time : GDK_CURRENT_TIME);
/* Let GtkClipboard own the X11 selection window. Making xtext
* the selection owner forces its window native and bypasses
* GTK's toplevel backing buffer on subsequent redraws.
*/
gtk_clipboard_set_with_owner (gtk_widget_get_clipboard (xtext, GDK_SELECTION_PRIMARY),
gtk_xtext_selection_targets, G_N_ELEMENTS (gtk_xtext_selection_targets),
gtk_xtext_clipboard_get, gtk_xtext_clipboard_clear, G_OBJECT (xtext));
gtk_clipboard_set_with_owner (gtk_widget_get_clipboard (xtext, GDK_SELECTION_SECONDARY),
gtk_xtext_selection_targets, G_N_ELEMENTS (gtk_xtext_selection_targets),
gtk_xtext_clipboard_get, gtk_xtext_clipboard_clear, G_OBJECT (xtext));
}
g_free (str);
@@ -3197,6 +3228,29 @@ gtk_xtext_selection_get (GtkWidget * widget,
g_free (stripped);
}
static void
gtk_xtext_clipboard_get (GtkClipboard *clipboard, GtkSelectionData *selection_data,
guint info, gpointer owner)
{
int len;
char *text = gtk_xtext_selection_get_text (GTK_XTEXT (owner), &len);
if (text)
{
gtk_selection_data_set_text (selection_data, text, len);
g_free (text);
}
}
static void
gtk_xtext_clipboard_clear (GtkClipboard *clipboard, gpointer owner)
{
GtkXText *xtext = GTK_XTEXT (owner);
if (xtext->orig_buffer)
gtk_xtext_selection_kill (xtext, NULL);
}
static gboolean
gtk_xtext_scroll (GtkWidget *widget, GdkEventScroll *event)
{