From 5b3b8728e06b515c9ab3cdd2d601445cabd285a8 Mon Sep 17 00:00:00 2001 From: wangxiaoqing Date: Fri, 29 Jul 2022 16:41:14 +0800 Subject: [PATCH 4/4] Not draw icon and text hight light color when icon not get force MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 当图标未获得焦点时,不高亮绘制其图标和文字 Related #I5HRI0 Signed-off-by: wangxiaoqing --- libcaja-private/caja-icon-canvas-item.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/libcaja-private/caja-icon-canvas-item.c b/libcaja-private/caja-icon-canvas-item.c index 7ab2f70..7c56de2 100644 --- a/libcaja-private/caja-icon-canvas-item.c +++ b/libcaja-private/caja-icon-canvas-item.c @@ -1077,7 +1077,9 @@ prepare_pango_layout_for_draw (CajaIconCanvasItem *item, container = CAJA_ICON_CONTAINER (EEL_CANVAS_ITEM (item)->canvas); details = item->details; - needs_highlight = details->is_highlighted_for_selection || details->is_highlighted_for_drop; + needs_highlight = (details->is_highlighted_for_selection && + gtk_widget_has_focus (GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas))) || + details->is_highlighted_for_drop; if (IS_COMPACT_VIEW (container)) { @@ -1278,7 +1280,9 @@ draw_label_text (CajaIconCanvasItem *item, text_rect = compute_text_rectangle (item, icon_rect, TRUE, BOUNDS_USAGE_FOR_DISPLAY); - needs_highlight = details->is_highlighted_for_selection || details->is_highlighted_for_drop; + needs_highlight = (details->is_highlighted_for_selection && + gtk_widget_has_focus (GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas))) || + details->is_highlighted_for_drop; is_rtl_label_beside = caja_icon_container_is_layout_rtl (container) && container->details->label_position == CAJA_ICON_LABEL_POSITION_BESIDE; @@ -1777,22 +1781,17 @@ real_map_surface (CajaIconCanvasItem *icon_item) } } - if (icon_item->details->is_highlighted_for_selection - || icon_item->details->is_highlighted_for_drop) + if ((icon_item->details->is_highlighted_for_selection && + gtk_widget_has_focus (GTK_WIDGET (canvas))) || + icon_item->details->is_highlighted_for_drop) { GtkStyleContext *style; style = gtk_widget_get_style_context (GTK_WIDGET (canvas)); - if (gtk_widget_has_focus (GTK_WIDGET (canvas))) { - gtk_style_context_get (style, GTK_STATE_FLAG_SELECTED, - GTK_STYLE_PROPERTY_BACKGROUND_COLOR, - &c, NULL); - } else { - gtk_style_context_get (style, GTK_STATE_FLAG_ACTIVE, - GTK_STYLE_PROPERTY_BACKGROUND_COLOR, - &c, NULL); - } + gtk_style_context_get (style, GTK_STATE_FLAG_SELECTED, + GTK_STYLE_PROPERTY_BACKGROUND_COLOR, + &c, NULL); color = *c; gdk_rgba_free (c); -- 2.36.1