gtk3: Require GTK >= 3.24

AlmaLinux 9 has GTK 3 3.24.31 [1].

Therefore, require GTK 3.24 as new minimum version
after

    commit 09208d0e6e
    Date:   Mon Jul 28 15:06:09 2025 +0200

        prep Linux baseline bump to Almalinux 9

and drop now obsolete code for older GTK versions.

The new minimum version might also help to further
unify the gtk3 and gtk4 code paths in some places
in the future, s.a. [2].

(`git show --ignore-space-change` can be helpful
to more easily see the "actual changes".)

[1] https://pkgs.org/download/gtk3
[2] https://docs.gtk.org/gtk4/migrating-3to4.html#preparation-in-gtk-3x

Change-Id: Ib2b0d83b1a40b121660ffe04baf3eeb0bebe0da1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193477
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
This commit is contained in:
Michael Weghorn
2025-11-05 23:30:47 +01:00
parent 5392680f0e
commit c392f7b8a6
4 changed files with 51 additions and 151 deletions
+1 -1
View File
@@ -12537,7 +12537,7 @@ if test "$test_gtk3" = yes -a "x$enable_gtk3" = "xyes" -o "x$enable_gtk3_kde5" =
add_warning 'Non-system cairo combined with gtk3 is known to cause trouble (eg. broken image in the splashscreen). Use --with-system-cairo unless you know what you are doing.'
fi
: ${with_system_cairo:=yes}
PKG_CHECK_MODULES(GTK3, gtk+-3.0 >= 3.20 gmodule-no-export-2.0 glib-2.0 >= 2.38 atk >= 2.36 cairo)
PKG_CHECK_MODULES(GTK3, gtk+-3.0 >= 3.24 gmodule-no-export-2.0 glib-2.0 >= 2.38 atk >= 2.36 cairo)
GTK3_CFLAGS=$(printf '%s' "$GTK3_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
GTK3_CFLAGS="$GTK3_CFLAGS -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED"
FilterLibs "${GTK3_LIBS}"
-16
View File
@@ -675,20 +675,4 @@ AtkObject* ooo_fixed_get_accessible(GtkWidget *obj);
} // extern "C"
#if !GTK_CHECK_VERSION(3, 22, 0)
enum GdkAnchorHints
{
GDK_ANCHOR_FLIP_X = 1 << 0,
GDK_ANCHOR_FLIP_Y = 1 << 1,
GDK_ANCHOR_SLIDE_X = 1 << 2,
GDK_ANCHOR_SLIDE_Y = 1 << 3,
GDK_ANCHOR_RESIZE_X = 1 << 4,
GDK_ANCHOR_RESIZE_Y = 1 << 5,
GDK_ANCHOR_FLIP = GDK_ANCHOR_FLIP_X | GDK_ANCHOR_FLIP_Y,
GDK_ANCHOR_SLIDE = GDK_ANCHOR_SLIDE_X | GDK_ANCHOR_SLIDE_Y,
GDK_ANCHOR_RESIZE = GDK_ANCHOR_RESIZE_X | GDK_ANCHOR_RESIZE_Y
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+30 -63
View File
@@ -11295,78 +11295,45 @@ public:
#else
gulong nSignalId = g_signal_connect_swapped(G_OBJECT(m_pMenu), "deactivate", G_CALLBACK(g_main_loop_quit), pLoop);
#if GTK_CHECK_VERSION(3,22,0)
if (gtk_check_version(3, 22, 0) == nullptr)
GdkRectangle aRect;
pWidget = getPopupRect(pWidget, rRect, aRect);
gtk_menu_attach_to_widget(m_pMenu, pWidget, nullptr);
// Send a keyboard event through gtk_main_do_event to toggle any active tooltip offs
// before trying to launch the menu
// https://gitlab.gnome.org/GNOME/gtk/issues/1785
// Fixed in GTK 3.24
GdkEvent *pKeyEvent = GtkSalFrame::makeFakeKeyPress(pWidget);
gtk_main_do_event(pKeyEvent);
GdkEvent *pTriggerEvent = gtk_get_current_event();
bool bEventOwnership = true;
if (!pTriggerEvent)
{
GdkRectangle aRect;
pWidget = getPopupRect(pWidget, rRect, aRect);
gtk_menu_attach_to_widget(m_pMenu, pWidget, nullptr);
pTriggerEvent = pKeyEvent;
bEventOwnership = false;
}
// Send a keyboard event through gtk_main_do_event to toggle any active tooltip offs
// before trying to launch the menu
// https://gitlab.gnome.org/GNOME/gtk/issues/1785
// Fixed in GTK 3.24
GdkEvent *pKeyEvent = GtkSalFrame::makeFakeKeyPress(pWidget);
gtk_main_do_event(pKeyEvent);
bool bSwapForRTL = SwapForRTL(pWidget);
GdkEvent *pTriggerEvent = gtk_get_current_event();
bool bEventOwnership = true;
if (!pTriggerEvent)
{
pTriggerEvent = pKeyEvent;
bEventOwnership = false;
}
bool bSwapForRTL = SwapForRTL(pWidget);
if (ePlace == weld::Placement::Under)
{
if (bSwapForRTL)
gtk_menu_popup_at_rect(m_pMenu, widget_get_surface(pWidget), &aRect, GDK_GRAVITY_SOUTH_EAST, GDK_GRAVITY_NORTH_EAST, pTriggerEvent);
else
gtk_menu_popup_at_rect(m_pMenu, widget_get_surface(pWidget), &aRect, GDK_GRAVITY_SOUTH_WEST, GDK_GRAVITY_NORTH_WEST, pTriggerEvent);
}
if (ePlace == weld::Placement::Under)
{
if (bSwapForRTL)
gtk_menu_popup_at_rect(m_pMenu, widget_get_surface(pWidget), &aRect, GDK_GRAVITY_SOUTH_EAST, GDK_GRAVITY_NORTH_EAST, pTriggerEvent);
else
{
if (bSwapForRTL)
gtk_menu_popup_at_rect(m_pMenu, widget_get_surface(pWidget), &aRect, GDK_GRAVITY_NORTH_WEST, GDK_GRAVITY_NORTH_EAST, pTriggerEvent);
else
gtk_menu_popup_at_rect(m_pMenu, widget_get_surface(pWidget), &aRect, GDK_GRAVITY_NORTH_EAST, GDK_GRAVITY_NORTH_WEST, pTriggerEvent);
}
if (bEventOwnership)
gdk_event_free(pTriggerEvent);
gdk_event_free(pKeyEvent);
gtk_menu_popup_at_rect(m_pMenu, widget_get_surface(pWidget), &aRect, GDK_GRAVITY_SOUTH_WEST, GDK_GRAVITY_NORTH_WEST, pTriggerEvent);
}
else
#else
(void) rRect;
#endif
{
gtk_menu_attach_to_widget(m_pMenu, pWidget, nullptr);
guint nButton;
guint32 nTime;
//typically there is an event, and we can then distinguish if this was
//launched from the keyboard (gets auto-mnemoniced) or the mouse (which
//doesn't)
GdkEvent *pEvent = gtk_get_current_event();
if (pEvent)
{
if (!gdk_event_get_button(pEvent, &nButton))
nButton = 0;
nTime = gdk_event_get_time(pEvent);
gdk_event_free(pEvent);
}
if (bSwapForRTL)
gtk_menu_popup_at_rect(m_pMenu, widget_get_surface(pWidget), &aRect, GDK_GRAVITY_NORTH_WEST, GDK_GRAVITY_NORTH_EAST, pTriggerEvent);
else
{
nButton = 0;
nTime = GtkSalFrame::GetLastInputEventTime();
}
gtk_menu_popup(m_pMenu, nullptr, nullptr, nullptr, nullptr, nButton, nTime);
gtk_menu_popup_at_rect(m_pMenu, widget_get_surface(pWidget), &aRect, GDK_GRAVITY_NORTH_EAST, GDK_GRAVITY_NORTH_WEST, pTriggerEvent);
}
if (bEventOwnership)
gdk_event_free(pTriggerEvent);
gdk_event_free(pKeyEvent);
#endif
if (g_main_loop_is_running(pLoop))
+20 -71
View File
@@ -398,22 +398,6 @@ void GtkSalMenu::Update()
ImplUpdate(false, !bAlwaysShowDisabledEntries);
}
#if !GTK_CHECK_VERSION(4, 0, 0)
static void MenuPositionFunc(GtkMenu* menu, gint* x, gint* y, gboolean* push_in, gpointer user_data)
{
Point *pPos = static_cast<Point*>(user_data);
*x = pPos->X();
if (gtk_widget_get_default_direction() == GTK_TEXT_DIR_RTL)
{
GtkRequisition natural_size;
gtk_widget_get_preferred_size(GTK_WIDGET(menu), nullptr, &natural_size);
*x -= natural_size.width;
}
*y = pPos->Y();
*push_in = false;
}
#endif
static void MenuClosed(GtkPopover* pWidget, GMainLoop* pLoop)
{
// gtk4 4.4.0: click on an entry in a submenu of a menu crashes without this workaround
@@ -483,65 +467,30 @@ bool GtkSalMenu::ShowNativePopupMenu(FloatingWindow* pWin, const tools::Rectangl
gtk_popover_popup(GTK_POPOVER(mpMenuWidget));
#else
#if GTK_CHECK_VERSION(3,22,0)
if (gtk_check_version(3, 22, 0) == nullptr)
AbsoluteScreenPixelRectangle aFloatRect = FloatingWindow::ImplConvertToAbsPos(xParent, rRect);
aFloatRect.Move(-mpFrame->GetUnmirroredGeometry().x(), -mpFrame->GetUnmirroredGeometry().y());
GdkRectangle rect {static_cast<int>(aFloatRect.Left()), static_cast<int>(aFloatRect.Top()),
static_cast<int>(aFloatRect.GetWidth()), static_cast<int>(aFloatRect.GetHeight())};
GdkGravity rect_anchor = GDK_GRAVITY_SOUTH_WEST, menu_anchor = GDK_GRAVITY_NORTH_WEST;
if (nFlags & FloatWinPopupFlags::Left)
{
AbsoluteScreenPixelRectangle aFloatRect = FloatingWindow::ImplConvertToAbsPos(xParent, rRect);
aFloatRect.Move(-mpFrame->GetUnmirroredGeometry().x(), -mpFrame->GetUnmirroredGeometry().y());
GdkRectangle rect {static_cast<int>(aFloatRect.Left()), static_cast<int>(aFloatRect.Top()),
static_cast<int>(aFloatRect.GetWidth()), static_cast<int>(aFloatRect.GetHeight())};
GdkGravity rect_anchor = GDK_GRAVITY_SOUTH_WEST, menu_anchor = GDK_GRAVITY_NORTH_WEST;
if (nFlags & FloatWinPopupFlags::Left)
{
rect_anchor = GDK_GRAVITY_NORTH_WEST;
menu_anchor = GDK_GRAVITY_NORTH_EAST;
}
else if (nFlags & FloatWinPopupFlags::Up)
{
rect_anchor = GDK_GRAVITY_NORTH_WEST;
menu_anchor = GDK_GRAVITY_SOUTH_WEST;
}
else if (nFlags & FloatWinPopupFlags::Right)
{
rect_anchor = GDK_GRAVITY_NORTH_EAST;
}
GdkSurface* gdkWindow = widget_get_surface(mpFrame->getMouseEventWidget());
gtk_menu_popup_at_rect(GTK_MENU(mpMenuWidget), gdkWindow, &rect, rect_anchor, menu_anchor, nullptr);
rect_anchor = GDK_GRAVITY_NORTH_WEST;
menu_anchor = GDK_GRAVITY_NORTH_EAST;
}
else
#endif
else if (nFlags & FloatWinPopupFlags::Up)
{
guint nButton;
guint32 nTime;
//typically there is an event, and we can then distinguish if this was
//launched from the keyboard (gets auto-mnemoniced) or the mouse (which
//doesn't)
GdkEvent *pEvent = gtk_get_current_event();
if (pEvent)
{
gdk_event_get_button(pEvent, &nButton);
nTime = gdk_event_get_time(pEvent);
}
else
{
nButton = 0;
nTime = GtkSalFrame::GetLastInputEventTime();
}
// Do the same strange semantics as vcl popup windows to arrive at a frame geometry
// in mirrored UI case; best done by actually executing the same code.
// (see code in FloatingWindow::StartPopupMode)
sal_uInt16 nArrangeIndex;
Point aPos = FloatingWindow::ImplCalcPos(pWin, rRect, nFlags, nArrangeIndex);
AbsoluteScreenPixelPoint aPosAbs = FloatingWindow::ImplConvertToAbsPos(xParent, aPos);
gtk_menu_popup(GTK_MENU(mpMenuWidget), nullptr, nullptr, MenuPositionFunc,
&aPosAbs, nButton, nTime);
rect_anchor = GDK_GRAVITY_NORTH_WEST;
menu_anchor = GDK_GRAVITY_SOUTH_WEST;
}
else if (nFlags & FloatWinPopupFlags::Right)
{
rect_anchor = GDK_GRAVITY_NORTH_EAST;
}
GdkSurface* gdkWindow = widget_get_surface(mpFrame->getMouseEventWidget());
gtk_menu_popup_at_rect(GTK_MENU(mpMenuWidget), gdkWindow, &rect, rect_anchor, menu_anchor, nullptr);
#endif
if (g_main_loop_is_running(pLoop))