summaryrefslogtreecommitdiff
path: root/gtk/gtktreeviewcolumn.c
diff options
context:
space:
mode:
authorKristian Rietveld <kris@gtk.org>2010-12-15 23:45:04 +0100
committerKristian Rietveld <kris@gtk.org>2010-12-15 23:55:26 +0100
commitc8d130efa7a0d807bdaa50381d12c3f4223e8e2c (patch)
treed8b35e720deef589d6ce7ef7cb4b6558bf639c57 /gtk/gtktreeviewcolumn.c
parent5399f7b6e6a483caa4567537cf7d7c24fd92b2b2 (diff)
downloadgtk+-c8d130efa7a0d807bdaa50381d12c3f4223e8e2c.tar.gz
Revisit "Handle clicks in indentation area"
Check (x, y) is inside background area. If yes, continue processing and clamp the coordinates into cell area. This way we will properly handle getting a cell (which is only used for setting the focus cell) for clicks in the indentation area (in LTR and RTL mode) and clicks in the focus rectangle area in case focus-line-width is large.
Diffstat (limited to 'gtk/gtktreeviewcolumn.c')
-rw-r--r--gtk/gtktreeviewcolumn.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/gtk/gtktreeviewcolumn.c b/gtk/gtktreeviewcolumn.c
index 2621cb360b..905a7bb275 100644
--- a/gtk/gtktreeviewcolumn.c
+++ b/gtk/gtktreeviewcolumn.c
@@ -1473,19 +1473,37 @@ _gtk_tree_view_column_get_edited_cell (GtkTreeViewColumn *column)
GtkCellRenderer *
_gtk_tree_view_column_get_cell_at_pos (GtkTreeViewColumn *column,
GdkRectangle *cell_area,
+ GdkRectangle *background_area,
gint x,
gint y)
{
GtkCellRenderer *match = NULL;
GtkTreeViewColumnPrivate *priv = column->priv;
+ /* If (x, y) is outside of the background area, immediately return */
+ if (x < background_area->x ||
+ x > background_area->x + background_area->width ||
+ y < background_area->y ||
+ y > background_area->y + background_area->height)
+ return NULL;
+
+ /* If (x, y) is inside the background area, clamp it to the cell_area
+ * so that a cell is still returned. The main reason for doing this
+ * (on the x axis) is for handling clicks in the indentation area
+ * (either at the left or right depending on RTL setting). Another
+ * reason is for handling clicks on the area where the focus rectangle
+ * is drawn (this is outside of cell area), this manifests itself
+ * mainly when a large setting is used for focus-line-width.
+ */
if (x < cell_area->x)
- {
- /* This can happen when we click in the "indentation". In this
- * case, we set x to cell_area->x, the start of the first cell.
- */
- x = cell_area->x;
- }
+ x = cell_area->x;
+ else if (x > cell_area->x + cell_area->width)
+ x = cell_area->x + cell_area->width;
+
+ if (y < cell_area->y)
+ y = cell_area->y;
+ else if (y > cell_area->y + cell_area->height)
+ y = cell_area->y + cell_area->height;
match = gtk_cell_area_get_cell_at_position (priv->cell_area,
priv->cell_area_context,