gtk+3.0: fix position for tooltip in gtk3 (lxde/trisquel-mini)

This commit is contained in:
Ark74 2025-08-13 01:24:49 -06:00
parent d2b3ecfbd6
commit 8dd4361d9f
2 changed files with 66 additions and 0 deletions

View file

@ -0,0 +1,36 @@
From baa351f7e2d8cb92e94ce122bf8b96cfe88f9a5a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ingo=20Br=C3=BCckl?= <ib@oddnet.de>
Date: Mon, 17 Feb 2025 18:04:20 +0100
Subject: [PATCH] Fix position of child tooltips in custom windows
Unlike a GTK_TOPLEVEL_WINDOW, a custom toplevel window derived from
GtkWindow can have non-zero x/y allocations (like a panel at the bottom
of the screen).
Since the allocation of such a toplevel window is relative to the screen
origin, the position of the child must also be relative to the screen
origin so that we get the correct coordinates relative to each other.
diff --git a/gtk/gtktooltip.c b/gtk/gtktooltip.c
index 1bf72f19..3d6a99f1 100644
--- a/gtk/gtktooltip.c
+++ b/gtk/gtktooltip.c
@@ -875,6 +875,7 @@ gtk_tooltip_position (GtkTooltip *tooltip,
GdkWindow *widget_window;
GdkWindow *effective_toplevel;
GtkWidget *toplevel;
+ GtkAllocation toplevel_allocation;
int rect_anchor_dx = 0;
int cursor_size;
int anchor_rect_padding;
@@ -886,8 +887,9 @@ gtk_tooltip_position (GtkTooltip *tooltip,
tooltip->tooltip_widget = new_tooltip_widget;
toplevel = _gtk_widget_get_toplevel (new_tooltip_widget);
+ _gtk_widget_get_allocation (toplevel, &toplevel_allocation);
gtk_widget_translate_coordinates (new_tooltip_widget, toplevel,
- 0, 0,
+ toplevel_allocation.x, toplevel_allocation.y,
&anchor_rect.x, &anchor_rect.y);
anchor_rect.width = gtk_widget_get_allocated_width (new_tooltip_widget);

30
helpers/make-gtk+3.0 Normal file
View file

@ -0,0 +1,30 @@
#!/bin/sh
#
# Copyright (C) 2025 Luis Guzman <ark@switnet.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
VERSION=1
. ./config
# TODO: Keep an eye on this final fix to match changes accordingly.
# https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/8216
patch_p1 $DATA/000-fix_tooltip_gtk+3.0_lxde.patch
changelog "Apply fix for tooltip on lxde / trisquel-mini."
package