talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit f6a95827052a4f1e6492509b2b103c877247bc38
parent fef7068386f01f0abf41c6dde8df21becfb92c45
Author: Andrej Kacian <ticho@claws-mail.org>
Date:   Tue,  6 Nov 2018 00:05:17 +0100

Make sure all users of GtkCMCList do not blindly assume that a button-press-event happens inside of the tree view.

If clicking on the header row, the event's x,y coordinates
were pointing to a different spot than what the event handler
code expected, since those coordinates are relative to the
relevant GDK window, and header row has its own. Calls to
gtk_cmclist_get_selection_info() or gtk_sctree_is_hot_spot()
in such cases therefore returned bogus info.

This fixes things like folderview expanding/collapsing
selected folder when double-clicking its header column, or
selecting first row when single-clicking it.

Diffstat:
Msrc/addressbook.c | 4++++
Msrc/editgroup.c | 2++
Msrc/folderview.c | 1+
Msrc/grouplistdialog.c | 1+
Msrc/gtk/gtkcmctree.h | 4++++
Msrc/gtk/gtksctree.h | 4++++
Msrc/summaryview.c | 1+
7 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/src/addressbook.c b/src/addressbook.c @@ -2482,6 +2482,7 @@ static gboolean addressbook_list_button_pressed(GtkWidget *widget, gpointer data) { if( ! event ) return FALSE; + if( event->window != GTK_CMCLIST(widget)->clist_window ) return FALSE; addressbook_list_menu_setup(); @@ -2539,6 +2540,9 @@ static gboolean addressbook_tree_button_pressed(GtkWidget *ctree, if( ! event ) return FALSE; /* if( ! event || event->type != GDK_BUTTON_PRESS) return FALSE;*/ + if( event->window != clist->clist_window ) + return FALSE; + if (event->button == 1) { if (event->type == GDK_2BUTTON_PRESS) { if( gtk_cmclist_get_selection_info( clist, event->x, event->y, &row, &column ) ) { diff --git a/src/editgroup.c b/src/editgroup.c @@ -214,6 +214,7 @@ static void edit_group_to_avail( GtkWidget *widget, gpointer data ) { static gboolean edit_group_list_group_button( GtkCMCList *clist, GdkEventButton *event, gpointer data ) { if( ! event ) return FALSE; + if( event->window != clist->clist_window ) return FALSE; if( event->button == 1 ) { if( event->type == GDK_2BUTTON_PRESS ) { @@ -225,6 +226,7 @@ static gboolean edit_group_list_group_button( GtkCMCList *clist, GdkEventButton static gboolean edit_group_list_avail_button( GtkCMCList *clist, GdkEventButton *event, gpointer data ) { if( ! event ) return FALSE; + if( event->window != clist->clist_window ) return FALSE; if( event->button == 1 ) { if( event->type == GDK_2BUTTON_PRESS ) { diff --git a/src/folderview.c b/src/folderview.c @@ -2020,6 +2020,7 @@ static gboolean folderview_button_pressed(GtkWidget *ctree, GdkEventButton *even gint prev_row = -1, row = -1, column = -1; if (!event) return FALSE; + if (event->window != clist->clist_window) return FALSE; if (event->button == 1 || event->button == 2) { if (!gtk_sctree_is_hot_spot (GTK_SCTREE(clist), event->x, event->y)) diff --git a/src/grouplistdialog.c b/src/grouplistdialog.c @@ -577,6 +577,7 @@ static gboolean button_press_cb(GtkCMCTree *ctree, GdkEventButton *button, if (button->type != GDK_BUTTON_PRESS) return TRUE; if (button->button != 1) return TRUE; + if (button->window != GTK_CMCLIST(ctree)->clist_window) return TRUE; if (!gtk_cmclist_get_selection_info(GTK_CMCLIST(ctree), button->x, button->y, &row, &col)) diff --git a/src/gtk/gtkcmctree.h b/src/gtk/gtkcmctree.h @@ -253,6 +253,10 @@ GList * gtk_cmctree_find_all_by_row_data_custom (GtkCMCTree *ctree, GtkCMCTreeNode *node, gpointer data, GCompareFunc func); + +/* This assumes that x and y coordinates are inside the clist_window. + * Returns true if the coordinates are inside a tree expander on + * one of the rows. */ gboolean gtk_cmctree_is_hot_spot (GtkCMCTree *ctree, gint x, gint y); diff --git a/src/gtk/gtksctree.h b/src/gtk/gtksctree.h @@ -119,6 +119,10 @@ void gtk_sctree_set_column_tooltip (GtkSCTree *sctree, void gtk_sctree_set_use_markup (GtkSCTree *sctree, int column, gboolean markup); + +/* This assumes that x and y coordinates are inside the clist_window. + * Returns true if the coordinates are inside a tree expander on + * one of the rows. */ gboolean gtk_sctree_is_hot_spot (GtkSCTree *ctree, gint x, diff --git a/src/summaryview.c b/src/summaryview.c @@ -6848,6 +6848,7 @@ static gboolean summary_button_pressed(GtkWidget *ctree, GdkEventButton *event, SummaryView *summaryview) { if (!event) return FALSE; + if (event->window != GTK_CMCLIST(ctree)->clist_window) return FALSE; if (event->button == 3) { /* right clicked */