[Libreoffice-commits] core.git: config_host.mk.in configure.ac Repository.mk solenv/gbuild vcl/inc vcl/Library_vclplug_gtk4.mk vcl/Module_vcl.mk vcl/unx

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Mon May 10 08:58:39 UTC 2021


 Repository.mk                               |    1 
 config_host.mk.in                           |    3 
 configure.ac                                |   37 +
 solenv/gbuild/CppunitTest.mk                |    1 
 vcl/Library_vclplug_gtk4.mk                 |  107 ++++
 vcl/Module_vcl.mk                           |    5 
 vcl/inc/unx/gtk/gtkbackend.hxx              |    8 
 vcl/inc/unx/gtk/gtkdata.hxx                 |   12 
 vcl/inc/unx/gtk/gtkframe.hxx                |   33 +
 vcl/inc/unx/gtk/gtkgdi.hxx                  |    9 
 vcl/inc/unx/gtk/gtkinst.hxx                 |   22 
 vcl/inc/unx/gtk/gtkobject.hxx               |    2 
 vcl/inc/unx/gtk/gtksalmenu.hxx              |    2 
 vcl/inc/unx/gtk/gtksys.hxx                  |    4 
 vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx   |   95 +++
 vcl/unx/gtk3/fpicker/SalGtkFolderPicker.cxx |   28 -
 vcl/unx/gtk3/fpicker/SalGtkPicker.cxx       |   36 +
 vcl/unx/gtk3/gtkdata.cxx                    |   50 +
 vcl/unx/gtk3/gtkframe.cxx                   |  292 +++++++++++
 vcl/unx/gtk3/gtkinst.cxx                    |  725 +++++++++++++++++++++++++++-
 vcl/unx/gtk3/gtkobject.cxx                  |   72 ++
 vcl/unx/gtk3/gtksalmenu.cxx                 |  120 ++++
 vcl/unx/gtk3/gtksys.cxx                     |   32 +
 vcl/unx/gtk3/salnativewidgets-gtk.cxx       |   42 +
 vcl/unx/gtk4/fpicker/SalGtkFilePicker.cxx   |   12 
 vcl/unx/gtk4/fpicker/SalGtkFilePicker.hxx   |   12 
 vcl/unx/gtk4/fpicker/SalGtkFolderPicker.cxx |   12 
 vcl/unx/gtk4/fpicker/SalGtkFolderPicker.hxx |   12 
 vcl/unx/gtk4/fpicker/SalGtkPicker.cxx       |   12 
 vcl/unx/gtk4/fpicker/SalGtkPicker.hxx       |   12 
 vcl/unx/gtk4/fpicker/eventnotification.hxx  |   12 
 vcl/unx/gtk4/fpicker/resourceprovider.cxx   |   12 
 vcl/unx/gtk4/gloactiongroup.cxx             |   12 
 vcl/unx/gtk4/glomenu.cxx                    |   12 
 vcl/unx/gtk4/gtkcairo.cxx                   |   12 
 vcl/unx/gtk4/gtkcairo.hxx                   |   12 
 vcl/unx/gtk4/gtkdata.cxx                    |   12 
 vcl/unx/gtk4/gtkframe.cxx                   |   12 
 vcl/unx/gtk4/gtkinst.cxx                    |   12 
 vcl/unx/gtk4/gtkobject.cxx                  |   12 
 vcl/unx/gtk4/gtksalmenu.cxx                 |   12 
 vcl/unx/gtk4/gtksys.cxx                     |   12 
 vcl/unx/gtk4/hudawareness.cxx               |   12 
 vcl/unx/gtk4/salnativewidgets-gtk.cxx       |   12 
 44 files changed, 1918 insertions(+), 60 deletions(-)

New commits:
commit 4c8e2b47cb81a8b582d71db927682753c6d12ad9
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri May 7 12:17:46 2021 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon May 10 10:57:57 2021 +0200

    bodge a gtk4 starting point into existence
    
    this is not supposed to work or anything even close to that
    
    Change-Id: I46b4fed6a1e6cfc885cb4f7c24660bb6438d5101
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115293
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/Repository.mk b/Repository.mk
index db52290e90c7..e95ea304ffda 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -280,6 +280,7 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,onlineupdate, \
 $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,gnome, \
 	$(if $(ENABLE_EVOAB2),evoab) \
 	$(if $(ENABLE_GTK3),vclplug_gtk3) \
+	$(if $(ENABLE_GTK4),vclplug_gtk4) \
 	$(if $(ENABLE_GIO),losessioninstall) \
 	$(if $(ENABLE_GIO),ucpgio1) \
 ))
diff --git a/config_host.mk.in b/config_host.mk.in
index d45511061037..f7fa8ca12f9f 100644
--- a/config_host.mk.in
+++ b/config_host.mk.in
@@ -159,6 +159,7 @@ export ENABLE_GIO=@ENABLE_GIO@
 export ENABLE_GPGMEPP=@ENABLE_GPGMEPP@
 export ENABLE_GSTREAMER_1_0=@ENABLE_GSTREAMER_1_0@
 export ENABLE_GTK3=@ENABLE_GTK3@
+export ENABLE_GTK4=@ENABLE_GTK4@
 export DISABLE_GUI=@DISABLE_GUI@
 export ENABLE_HTMLHELP=@ENABLE_HTMLHELP@
 export ENABLE_JAVA=@ENABLE_JAVA@
@@ -255,6 +256,8 @@ export GSTREAMER_1_0_CFLAGS=$(gb_SPACE)@GSTREAMER_1_0_CFLAGS@
 export GSTREAMER_1_0_LIBS=$(gb_SPACE)@GSTREAMER_1_0_LIBS@
 export GTK3_CFLAGS=$(gb_SPACE)@GTK3_CFLAGS@
 export GTK3_LIBS=$(gb_SPACE)@GTK3_LIBS@
+export GTK4_CFLAGS=$(gb_SPACE)@GTK4_CFLAGS@
+export GTK4_LIBS=$(gb_SPACE)@GTK4_LIBS@
 export USING_X11=@USING_X11@
 export HAMCREST_JAR=@HAMCREST_JAR@
 export HAVE_BROKEN_GCC_WMAYBE_UNINITIALIZED=@HAVE_BROKEN_GCC_WMAYBE_UNINITIALIZED@
diff --git a/configure.ac b/configure.ac
index d802a66a2d8f..f40314d09853 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1564,6 +1564,10 @@ libo_FUZZ_ARG_ENABLE(gtk3,
         [Determines whether to use Gtk+ 3.0 vclplug on platforms where Gtk+ 3.0 is available.]),
 ,test "${enable_gtk3+set}" = set || enable_gtk3=yes)
 
+AC_ARG_ENABLE(gtk4,
+    AS_HELP_STRING([--enable-gtk4],
+        [Determines whether to use Gtk+ 4.0 vclplug on platforms where Gtk+ 4.0 is available.]))
+
 AC_ARG_ENABLE(introspection,
     AS_HELP_STRING([--enable-introspection],
         [Generate files for GObject introspection.  Requires --enable-gtk3.  (Typically used by
@@ -11426,6 +11430,14 @@ if test "x$enable_gtk3_kde5" = "xyes"; then
 fi
 AC_SUBST(ENABLE_GTK3_KDE5)
 
+ENABLE_GTK4=""
+if test "x$enable_gtk4" = "xyes"; then
+    ENABLE_GTK4="TRUE"
+    AC_DEFINE(ENABLE_GTK4)
+    R="$R gtk4"
+fi
+AC_SUBST(ENABLE_GTK4)
+
 ENABLE_QT5=""
 if test "x$enable_qt5" = "xyes"; then
     ENABLE_QT5="TRUE"
@@ -11465,6 +11477,29 @@ fi
 AC_SUBST(GTK3_LIBS)
 AC_SUBST(GTK3_CFLAGS)
 
+GTK4_CFLAGS=""
+GTK4_LIBS=""
+if test "x$enable_gtk4" = "xyes"; then
+    if test "$with_system_cairo" = no; then
+        add_warning 'Non-system cairo combined with gtk4 is assumed to cause trouble; proceed at your own risk.'
+    fi
+    : ${with_system_cairo:=yes}
+    PKG_CHECK_MODULES(GTK4, gtk4 gmodule-no-export-2.0 glib-2.0 >= 2.38 cairo atk)
+    GTK4_CFLAGS=$(printf '%s' "$GTK4_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g")
+    GTK4_CFLAGS="$GTK4_CFLAGS -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED"
+    FilterLibs "${GTK4_LIBS}"
+    GTK4_LIBS="${filteredlibs}"
+
+    dnl We require egl only for the gtk4 plugin. Otherwise we use glx.
+    if test "$with_system_epoxy" != "yes"; then
+        AC_CHECK_LIB(EGL, eglMakeCurrent, [:], AC_MSG_ERROR([libEGL required.]))
+        AC_CHECK_HEADER(EGL/eglplatform.h, [],
+                        [AC_MSG_ERROR(EGL headers not found. install mesa-libEGL-devel)], [])
+    fi
+fi
+AC_SUBST(GTK4_LIBS)
+AC_SUBST(GTK4_CFLAGS)
+
 if test "$enable_introspection" = yes; then
     if test "$ENABLE_GTK3" = "TRUE" -o "$ENABLE_GTK3_KDE5" = "TRUE"; then
         GOBJECT_INTROSPECTION_REQUIRE(INTROSPECTION_REQUIRED_VERSION)
@@ -11606,7 +11641,7 @@ AC_SUBST(SYSTEM_BLUEZ)
 dnl ===================================================================
 dnl Check whether to enable GIO support
 dnl ===================================================================
-if test "$ENABLE_GTK3" = "TRUE" -o "$ENABLE_GTK3_KDE5" = "TRUE"; then
+if test "$ENABLE_GTK4" = "TRUE" -o "$ENABLE_GTK3" = "TRUE" -o "$ENABLE_GTK3_KDE5" = "TRUE"; then
     AC_MSG_CHECKING([whether to enable GIO support])
     if test "$_os" != "WINNT" -a "$_os" != "Darwin" -a "$enable_gio" = "yes"; then
         dnl Need at least 2.26 for the dbus support.
diff --git a/solenv/gbuild/CppunitTest.mk b/solenv/gbuild/CppunitTest.mk
index a296ef73a932..53a8831e2ff0 100644
--- a/solenv/gbuild/CppunitTest.mk
+++ b/solenv/gbuild/CppunitTest.mk
@@ -236,6 +236,7 @@ $(call gb_CppunitTest_get_target,$(1)) : $(call gb_Library_get_target,desktop_de
 $(call gb_CppunitTest_get_target,$(1)) : $(if $(filter $(2),$(true)),, \
     $(call gb_Library_get_target,vclplug_gen) \
         $(if $(ENABLE_GTK3),$(call gb_Library_get_target,vclplug_gtk3)) \
+        $(if $(ENABLE_GTK4),$(call gb_Library_get_target,vclplug_gtk4)) \
         $(if $(ENABLE_QT5),$(call gb_Library_get_target,vclplug_qt5)) \
 	 )
 else ifeq ($(OS),MACOSX)
diff --git a/vcl/Library_vclplug_gtk4.mk b/vcl/Library_vclplug_gtk4.mk
new file mode 100644
index 000000000000..3f1c3ebe88a7
--- /dev/null
+++ b/vcl/Library_vclplug_gtk4.mk
@@ -0,0 +1,107 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This file incorporates work covered by the following license notice:
+#
+#   Licensed to the Apache Software Foundation (ASF) under one or more
+#   contributor license agreements. See the NOTICE file distributed
+#   with this work for additional information regarding copyright
+#   ownership. The ASF licenses this file to you under the Apache
+#   License, Version 2.0 (the "License"); you may not use this file
+#   except in compliance with the License. You may obtain a copy of
+#   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+#
+
+$(eval $(call gb_Library_Library,vclplug_gtk4))
+
+# Silence deprecation warnings wholesale as long as vcl/unx/gtk4/*.cxx just
+# forward to vcl/unx/gtk/*.cxx:
+$(eval $(call gb_Library_add_cxxflags,vclplug_gtk4, \
+    -Wno-deprecated-declarations \
+))
+
+$(eval $(call gb_Library_set_include,vclplug_gtk4,\
+    $$(INCLUDE) \
+    $$(GTK4_CFLAGS) \
+    $$(GSTREAMER_1_0_CFLAGS) \
+    -I$(SRCDIR)/vcl/inc \
+    -I$(SRCDIR)/vcl/unx \
+    -I$(SRCDIR)/vcl/unx/gtk4 \
+))
+
+$(eval $(call gb_Library_add_defs,vclplug_gtk4,\
+    -DVCLPLUG_GTK_IMPLEMENTATION \
+    -DVCL_INTERNALS \
+))
+
+$(eval $(call gb_Library_use_custom_headers,vclplug_gtk4,\
+	officecfg/registry \
+))
+
+$(eval $(call gb_Library_use_sdk_api,vclplug_gtk4))
+
+$(eval $(call gb_Library_add_libs,vclplug_gtk4,\
+	$(GTK4_LIBS) \
+	-lX11 \
+	-lXext \
+	-lSM \
+	-lICE \
+))
+
+$(eval $(call gb_Library_use_libraries,vclplug_gtk4,\
+    vcl \
+    svl \
+    tl \
+    utl \
+    sot \
+    ucbhelper \
+    basegfx \
+    comphelper \
+    cppuhelper \
+    i18nlangtag \
+    i18nutil \
+    $(if $(ENABLE_JAVA), \
+        jvmaccess) \
+    cppu \
+    sal \
+))
+
+$(eval $(call gb_Library_use_externals,vclplug_gtk4,\
+	boost_headers \
+	epoxy \
+	dbus \
+	graphite \
+	harfbuzz \
+))
+
+$(eval $(call gb_Library_add_exception_objects,vclplug_gtk4,\
+    vcl/unx/gtk4/fpicker/resourceprovider \
+    vcl/unx/gtk4/fpicker/SalGtkFilePicker \
+    vcl/unx/gtk4/fpicker/SalGtkFolderPicker \
+    vcl/unx/gtk4/fpicker/SalGtkPicker \
+    vcl/unx/gtk4/gtkdata \
+    vcl/unx/gtk4/gtkinst \
+    vcl/unx/gtk4/gtksys \
+    vcl/unx/gtk4/gtkcairo \
+    vcl/unx/gtk4/salnativewidgets-gtk \
+    vcl/unx/gtk4/gtkframe \
+    vcl/unx/gtk4/gtkobject \
+	vcl/unx/gtk4/gtksalmenu \
+	vcl/unx/gtk4/glomenu \
+	vcl/unx/gtk4/gloactiongroup \
+    vcl/unx/gtk4/hudawareness \
+))
+
+ifeq ($(OS),LINUX)
+$(eval $(call gb_Library_add_libs,vclplug_gtk4,\
+	-lm \
+	-ldl \
+))
+endif
+
+# vim: set noet sw=4 ts=4:
diff --git a/vcl/Module_vcl.mk b/vcl/Module_vcl.mk
index 3a3626157b1f..9bb22e09f582 100644
--- a/vcl/Module_vcl.mk
+++ b/vcl/Module_vcl.mk
@@ -72,6 +72,11 @@ $(eval $(call gb_Module_add_targets,vcl,\
     Library_vclplug_gtk3 \
 ))
 endif
+ifneq ($(ENABLE_GTK4),)
+$(eval $(call gb_Module_add_targets,vcl,\
+    Library_vclplug_gtk4 \
+))
+endif
 ifneq ($(ENABLE_KF5),)
 $(eval $(call gb_Module_add_targets,vcl,\
     CustomTarget_kf5_moc \
diff --git a/vcl/inc/unx/gtk/gtkbackend.hxx b/vcl/inc/unx/gtk/gtkbackend.hxx
index 288311b41fca..03b2e021313b 100644
--- a/vcl/inc/unx/gtk/gtkbackend.hxx
+++ b/vcl/inc/unx/gtk/gtkbackend.hxx
@@ -12,11 +12,19 @@
 
 #include <gtk/gtk.h>
 #if defined(GDK_WINDOWING_X11)
+#if GTK_CHECK_VERSION(4, 0, 0)
+#include <gdk/x11/gdkx.h>
+#else
 #include <gdk/gdkx.h>
+#endif
 bool DLSYM_GDK_IS_X11_DISPLAY(GdkDisplay* pDisplay);
 #endif
 #if defined(GDK_WINDOWING_WAYLAND)
+#if GTK_CHECK_VERSION(4, 0, 0)
+#include <gdk/wayland/gdkwayland.h>
+#else
 #include <gdk/gdkwayland.h>
+#endif
 bool DLSYM_GDK_IS_WAYLAND_DISPLAY(GdkDisplay* pDisplay);
 #endif
 
diff --git a/vcl/inc/unx/gtk/gtkdata.hxx b/vcl/inc/unx/gtk/gtkdata.hxx
index 976412cfb6d5..2a741e855b94 100644
--- a/vcl/inc/unx/gtk/gtkdata.hxx
+++ b/vcl/inc/unx/gtk/gtkdata.hxx
@@ -21,9 +21,13 @@
 #define INCLUDED_VCL_INC_UNX_GTK_GTKDATA_HXX
 
 #define GLIB_DISABLE_DEPRECATION_WARNINGS
+#include <gtk/gtk.h>
 #include <gdk/gdk.h>
+#if GTK_CHECK_VERSION(4,0,0)
+#include <gdk/x11/gdkx.h>
+#else
 #include <gdk/gdkx.h>
-#include <gtk/gtk.h>
+#endif
 
 #include <com/sun/star/accessibility/XAccessibleContext.hpp>
 #include <com/sun/star/accessibility/XAccessibleEventListener.hpp>
@@ -42,10 +46,12 @@ namespace com::sun::star::accessibility { class XAccessibleEventListener; }
 class GtkSalDisplay;
 class DocumentFocusListener;
 
+#if !GTK_CHECK_VERSION(4,0,0)
 inline ::Window widget_get_xid(GtkWidget *widget)
 {
     return GDK_WINDOW_XID(gtk_widget_get_window(widget));
 }
+#endif
 
 class GtkSalTimer final : public SalTimer
 {
@@ -182,11 +188,13 @@ public:
     SalX11Screen GetDefaultXScreen() { return m_pSys->GetDisplayDefaultXScreen(); }
     Size         GetScreenSize( int nDisplayScreen );
 
-    GdkFilterReturn filterGdkEvent( GdkXEvent* sys_event );
     void startupNotificationCompleted() { m_bStartupCompleted = true; }
 
+#if !GTK_CHECK_VERSION(4,0,0)
+    GdkFilterReturn filterGdkEvent( GdkXEvent* sys_event );
     void screenSizeChanged( GdkScreen const * );
     void monitorsChanged( GdkScreen const * );
+#endif
 
     virtual void TriggerUserEventProcessing() override;
     virtual void TriggerAllUserEventsProcessed() override;
diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx
index f2e2386f7971..ab54f8fe3254 100644
--- a/vcl/inc/unx/gtk/gtkframe.hxx
+++ b/vcl/inc/unx/gtk/gtkframe.hxx
@@ -22,9 +22,10 @@
 
 #include <cairo.h>
 #include <gdk/gdk.h>
-#include <gdk/gdkx.h>
 #include <gtk/gtk.h>
+#if !GTK_CHECK_VERSION(4,0,0)
 #include <gtk/gtkx.h>
+#endif
 #include <gdk/gdkkeysyms.h>
 
 #include <salframe.hxx>
@@ -63,6 +64,7 @@ class GtkSalFrame final : public SalFrame
     struct IMHandler
     {
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
         // Not all GTK Input Methods swallow key release
         // events.  Since they swallow the key press events and we
         // are left with the key release events, we need to
@@ -125,9 +127,12 @@ class GtkSalFrame final : public SalFrame
                     ;
             }
         };
+#endif
 
         GtkSalFrame*                    m_pFrame;
+#if !GTK_CHECK_VERSION(4, 0, 0)
         std::list< PreviousKeyPress >   m_aPrevKeyPresses;
+#endif
         int                             m_nPrevKeyPresses; // avoid using size()
         GtkIMContext*                   m_pIMContext;
         bool                            m_bFocused;
@@ -142,7 +147,9 @@ class GtkSalFrame final : public SalFrame
         void            deleteIMContext();
         void            updateIMSpotLocation();
         void            endExtTextInput( EndExtTextInputFlags nFlags );
+#if !GTK_CHECK_VERSION(4, 0, 0)
         bool            handleKeyEvent( GdkEventKey* pEvent );
+#endif
         void            focusChanged( bool bFocusIn );
 
         void            doCallEndExtTextInput();
@@ -163,16 +170,22 @@ class GtkSalFrame final : public SalFrame
     GtkWidget*                      m_pWindow;
     GtkHeaderBar*                   m_pHeaderBar;
     GtkGrid*                        m_pTopLevelGrid;
+#if !GTK_CHECK_VERSION(4, 0, 0)
     GtkEventBox*                    m_pEventBox;
+#endif
     GtkFixed*                       m_pFixedContainer;
+#if !GTK_CHECK_VERSION(4, 0, 0)
     GdkWindow*                      m_pForeignParent;
     GdkNativeWindow                 m_aForeignParentWindow;
     GdkWindow*                      m_pForeignTopLevel;
     GdkNativeWindow                 m_aForeignTopLevelWindow;
+#endif
     SalFrameStyleFlags              m_nStyle;
     GtkSalFrame*                    m_pParent;
     std::list< GtkSalFrame* >       m_aChildren;
+#if !GTK_CHECK_VERSION(4, 0, 0)
     GdkWindowState                  m_nState;
+#endif
     SystemEnvData                   m_aSystemData;
     std::unique_ptr<GtkSalGraphics> m_pGraphics;
     bool                            m_bGraphics;
@@ -208,11 +221,13 @@ class GtkSalFrame final : public SalFrame
 
     GtkSalMenu*                     m_pSalMenu;
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
 #if ENABLE_DBUS && ENABLE_GIO
     private:
     friend void ensure_dbus_setup(GdkWindow* gdkWindow, GtkSalFrame* pSalFrame);
     friend void on_registrar_available (GDBusConnection*, const gchar*, const gchar*, gpointer);
     friend void on_registrar_unavailable (GDBusConnection*, const gchar*, gpointer);
+#endif
 #endif
     guint                           m_nWatcherId;
 
@@ -221,6 +236,7 @@ class GtkSalFrame final : public SalFrame
     void InitCommon();
     void InvalidateGraphics();
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
     // signals
     static gboolean     signalButton( GtkWidget*, GdkEventButton*, gpointer );
     static void         signalStyleUpdated(GtkWidget*, gpointer);
@@ -258,6 +274,7 @@ class GtkSalFrame final : public SalFrame
     static gboolean     signalScroll( GtkWidget*, GdkEvent*, gpointer );
     static gboolean     signalCrossing( GtkWidget*, GdkEventCrossing*, gpointer );
     static void         signalDestroy( GtkWidget*, gpointer );
+#endif
 
     void            Center();
     void            SetDefaultSize();
@@ -271,7 +288,9 @@ class GtkSalFrame final : public SalFrame
                                    bool bSendRelease
                                    );
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
     static GdkNativeWindow findTopLevelSystemWindow( GdkNativeWindow aWindow );
+#endif
 
     static int m_nFloats;
 
@@ -338,7 +357,9 @@ public:
     static GdkDisplay*     getGdkDisplay();
     GtkWidget*  getWindow() const { return m_pWindow; }
     GtkFixed*   getFixedContainer() const { return m_pFixedContainer; }
+#if !GTK_CHECK_VERSION(4, 0, 0)
     GtkEventBox* getEventBox() const { return m_pEventBox; }
+#endif
     GtkWidget*  getMouseEventWidget() const;
     GtkGrid*    getTopLevelGridWidget() const { return m_pTopLevelGrid; }
     const SalX11Screen& getXScreenNumber() const { return m_nXScreen; }
@@ -373,15 +394,19 @@ public:
         m_pDragSource = nullptr;
     }
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
     void startDrag(gint nButton, gint nDragOriginX, gint nDragOriginY,
                    GdkDragAction sourceActions, GtkTargetList* pTargetList);
+#endif
 
     void closePopup();
 
     void addGrabLevel();
     void removeGrabLevel();
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
     void nopaint_container_resize_children(GtkContainer*);
+#endif
 
     void LaunchAsyncScroll(GdkEvent const * pEvent);
     DECL_LINK(AsyncScroll, Timer *, void);
@@ -515,12 +540,16 @@ public:
     static void                 UpdateLastInputEventTime(guint32 nUserInputTime);
     static sal_uInt16           GetMouseModCode(guint nState);
     static sal_uInt16           GetKeyCode(guint nKeyVal);
+#if !GTK_CHECK_VERSION(4, 0, 0)
     static guint                GetKeyValFor(GdkKeymap* pKeyMap, guint16 hardware_keycode, guint8 group);
+#endif
     static sal_uInt16           GetKeyModCode(guint nState);
     static GdkEvent*            makeFakeKeyPress(GtkWidget* pWidget);
+#if !GTK_CHECK_VERSION(4, 0, 0)
     static SalWheelMouseEvent   GetWheelEvent(const GdkEventScroll& rEvent);
     static gboolean             NativeWidgetHelpPressed(GtkAccelGroup*, GObject*, guint,
         GdkModifierType, gpointer pFrame);
+#endif
     static OUString             GetPreeditDetails(GtkIMContext* pIMContext, std::vector<ExtTextInputAttr>& rInputFlags, sal_Int32& rCursorPos, sal_uInt8& rCursorFlags);
     static Selection            CalcDeleteSurroundingSelection(const OUString& rSurroundingText, sal_Int32 nCursorIndex, int nOffset, int nChars);
 
@@ -531,12 +560,14 @@ public:
 
 #define OOO_TYPE_FIXED ooo_fixed_get_type()
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
 extern "C" {
 
 GType ooo_fixed_get_type();
 AtkObject* ooo_fixed_get_accessible(GtkWidget *obj);
 
 } // extern "C"
+#endif
 
 #if !GTK_CHECK_VERSION(3, 22, 0)
 enum GdkAnchorHints
diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx
index 5ff7a562af82..44bcec7fd5d6 100644
--- a/vcl/inc/unx/gtk/gtkgdi.hxx
+++ b/vcl/inc/unx/gtk/gtkgdi.hxx
@@ -98,6 +98,7 @@ class GtkSalGraphics : public SvpSalGraphics
     GtkSalFrame * const mpFrame;
 
 protected:
+#if !GTK_CHECK_VERSION(4, 0, 0)
     bool isNativeControlSupported(ControlType, ControlPart) override;
     virtual bool        drawNativeControl( ControlType nType, ControlPart nPart,
                                                const tools::Rectangle& rControlRegion,
@@ -111,6 +112,7 @@ protected:
                                                     const OUString& rCaption,
                                                     tools::Rectangle &rNativeBoundingRegion,
                                                     tools::Rectangle &rNativeContentRegion ) override;
+#endif
     bool updateSettings(AllSettings&) override;
     void handleDamage(const tools::Rectangle&) override;
 
@@ -118,11 +120,9 @@ public:
     GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow );
 
 #if ENABLE_CAIRO_CANVAS
-
     virtual bool        SupportsCairo() const override;
     virtual cairo::SurfaceSharedPtr CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const override;
     virtual cairo::SurfaceSharedPtr CreateSurface(const OutputDevice& rRefDevice, int x, int y, int width, int height) const override;
-
 #endif
 
     void WidgetQueueDraw() const;
@@ -132,7 +132,9 @@ public:
     virtual OUString getRenderBackendName() const override { return "gtk3svp"; }
 
     GtkStyleContext* createStyleContext(GtkControlPart ePart);
+#if !GTK_CHECK_VERSION(4, 0, 0)
     GtkStyleContext* makeContext(GtkWidgetPath *pPath, GtkStyleContext *pParent);
+#endif
 private:
     GtkWidget              *mpWindow;
     static GtkStyleContext *mpWindowStyle;
@@ -201,6 +203,7 @@ private:
     static GtkStyleContext *mpSeparatorMenuItemStyle;
     static GtkStyleContext *mpSeparatorMenuItemSeparatorStyle;
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
     static tools::Rectangle NWGetScrollButtonRect( ControlPart nPart, tools::Rectangle aAreaRect );
     static tools::Rectangle NWGetSpinButtonRect( ControlPart nPart, tools::Rectangle aAreaRect);
     static tools::Rectangle NWGetComboBoxButtonRect(ControlType nType, ControlPart nPart, tools::Rectangle aAreaRect);
@@ -234,7 +237,7 @@ private:
 
     static void PaintRadio(cairo_t *cr, GtkStyleContext *context,
                            const tools::Rectangle& rControlRectangle, bool bInMenu);
-
+#endif
 
     static bool style_loaded;
 };
diff --git a/vcl/inc/unx/gtk/gtkinst.hxx b/vcl/inc/unx/gtk/gtkinst.hxx
index 565a72c90a9d..ce3e1232be6a 100644
--- a/vcl/inc/unx/gtk/gtkinst.hxx
+++ b/vcl/inc/unx/gtk/gtkinst.hxx
@@ -53,6 +53,11 @@ public:
 
 class GtkSalFrame;
 
+#if GTK_CHECK_VERSION(4, 0, 0)
+gint gtk_dialog_run(GtkDialog *dialog);
+#endif
+
+#if !GTK_CHECK_VERSION(4, 0, 0)
 struct VclToGtkHelper
 {
     std::vector<css::datatransfer::DataFlavor> aInfoToFlavor;
@@ -62,13 +67,16 @@ struct VclToGtkHelper
 private:
     GtkTargetEntry makeGtkTargetEntry(const css::datatransfer::DataFlavor& rFlavor);
 };
+#endif
 
 class GtkTransferable : public cppu::WeakImplHelper<css::datatransfer::XTransferable>
 {
+#if !GTK_CHECK_VERSION(4, 0, 0)
 protected:
     std::map<OUString, GdkAtom> m_aMimeTypeToAtom;
 
     std::vector<css::datatransfer::DataFlavor> getTransferDataFlavorsAsVector(GdkAtom *targets, gint n_targets);
+#endif
 
 public:
     virtual css::uno::Any SAL_CALL getTransferData(const css::datatransfer::DataFlavor& rFlavor) override = 0;
@@ -87,7 +95,9 @@ class GtkInstDropTarget final : public cppu::WeakComponentImplHelper<css::datatr
     GtkSalFrame* m_pFrame;
     GtkDnDTransferable* m_pFormatConversionRequest;
     bool m_bActive;
+#if !GTK_CHECK_VERSION(4, 0, 0)
     bool m_bInDrag;
+#endif
     sal_Int8 m_nDefaultActions;
     std::vector<css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>> m_aListeners;
 public:
@@ -122,10 +132,12 @@ public:
         m_pFormatConversionRequest = pRequest;
     }
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
     gboolean signalDragDrop(GtkWidget* pWidget, GdkDragContext* context, gint x, gint y, guint time);
     gboolean signalDragMotion(GtkWidget* pWidget, GdkDragContext* context, gint x, gint y, guint time);
     void signalDragDropReceived(GtkWidget* pWidget, GdkDragContext* context, gint x, gint y, GtkSelectionData* data, guint ttype, guint time);
     void signalDragLeave(GtkWidget* pWidget, GdkDragContext* context, guint time);
+#endif
 };
 
 class GtkInstDragSource final : public cppu::WeakComponentImplHelper<css::datatransfer::dnd::XDragSource,
@@ -136,7 +148,9 @@ class GtkInstDragSource final : public cppu::WeakComponentImplHelper<css::datatr
     GtkSalFrame* m_pFrame;
     css::uno::Reference<css::datatransfer::dnd::XDragSourceListener> m_xListener;
     css::uno::Reference<css::datatransfer::XTransferable> m_xTrans;
+#if !GTK_CHECK_VERSION(4, 0, 0)
     VclToGtkHelper m_aConversionHelper;
+#endif
 public:
     GtkInstDragSource()
         : WeakComponentImplHelper(m_aMutex)
@@ -147,7 +161,9 @@ public:
     void set_datatransfer(const css::uno::Reference<css::datatransfer::XTransferable>& rTrans,
                           const css::uno::Reference<css::datatransfer::dnd::XDragSourceListener>& rListener);
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
     std::vector<GtkTargetEntry> FormatsToGtk(const css::uno::Sequence<css::datatransfer::DataFlavor> &rFormats);
+#endif
 
     void setActiveDragSource();
 
@@ -173,8 +189,10 @@ public:
 
     void dragFailed();
     void dragDelete();
+#if !GTK_CHECK_VERSION(4, 0, 0)
     void dragEnd(GdkDragContext* context);
     void dragDataGet(GtkSelectionData *data, guint info);
+#endif
 
     // For LibreOffice internal D&D we provide the Transferable without Gtk
     // intermediaries as a shortcut, see tdf#100097 for how dbaccess depends on this
@@ -226,9 +244,11 @@ public:
     virtual css::uno::Reference< css::uno::XInterface > CreateDragSource() override;
     virtual css::uno::Reference< css::uno::XInterface > CreateDropTarget() override;
     virtual OpenGLContext* CreateOpenGLContext() override;
+#if !GTK_CHECK_VERSION(4, 0, 0)
     virtual weld::Builder* CreateBuilder(weld::Widget* pParent, const OUString& rUIRoot, const OUString& rUIFile) override;
     virtual weld::Builder* CreateInterimBuilder(vcl::Window* pParent, const OUString& rUIRoot, const OUString& rUIFile,
                                                 bool bAllowCycleFocusOut, sal_uInt64 nLOKWindowId = 0) override;
+#endif
     virtual weld::MessageDialog* CreateMessageDialog(weld::Widget* pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage) override;
     virtual weld::Window* GetFrameWeld(const css::uno::Reference<css::awt::XWindow>& rWindow) override;
 
@@ -242,7 +262,9 @@ public:
 
 private:
     GtkSalTimer *m_pTimer;
+#if !GTK_CHECK_VERSION(4, 0, 0)
     std::unordered_map< GdkAtom, css::uno::Reference<css::uno::XInterface> > m_aClipboards;
+#endif
     bool                        IsTimerExpired();
     bool                        bNeedsInit;
     cairo_font_options_t*       m_pLastCairoFontOptions;
diff --git a/vcl/inc/unx/gtk/gtkobject.hxx b/vcl/inc/unx/gtk/gtkobject.hxx
index 8b37492e61cf..ee063873980a 100644
--- a/vcl/inc/unx/gtk/gtkobject.hxx
+++ b/vcl/inc/unx/gtk/gtkobject.hxx
@@ -50,8 +50,10 @@ public:
 
 private:
     // signals
+#if !GTK_CHECK_VERSION(4, 0, 0)
     static gboolean     signalButton( GtkWidget*, GdkEventButton*, gpointer );
     static gboolean     signalFocus( GtkWidget*, GdkEventFocus*, gpointer );
+#endif
 };
 
 // this attempts to clip the hosted native window using gdk_window_shape_combine_region
diff --git a/vcl/inc/unx/gtk/gtksalmenu.hxx b/vcl/inc/unx/gtk/gtksalmenu.hxx
index 8af690d20a9d..e55cb791e90c 100644
--- a/vcl/inc/unx/gtk/gtksalmenu.hxx
+++ b/vcl/inc/unx/gtk/gtksalmenu.hxx
@@ -125,7 +125,9 @@ public:
 
     void CreateMenuBarWidget();
     void DestroyMenuBarWidget();
+#if !GTK_CHECK_VERSION(4, 0, 0)
     gboolean SignalKey(GdkEventKey const * pEvent);
+#endif
     void ReturnFocus();
 
     virtual bool ShowNativePopupMenu(FloatingWindow * pWin, const tools::Rectangle& rRect, FloatWinPopupFlags nFlags) override;
diff --git a/vcl/inc/unx/gtk/gtksys.hxx b/vcl/inc/unx/gtk/gtksys.hxx
index fa6879c2125b..ef0376bebf86 100644
--- a/vcl/inc/unx/gtk/gtksys.hxx
+++ b/vcl/inc/unx/gtk/gtksys.hxx
@@ -17,8 +17,10 @@
 class GtkSalSystem final : public SalGenericSystem
 {
     GdkDisplay *mpDisplay;
+#if !GTK_CHECK_VERSION(4,0,0)
     // Number of monitors for every active screen.
     std::deque<std::pair<GdkScreen*, int> > maScreenMonitors;
+#endif
 public:
              GtkSalSystem();
     virtual ~GtkSalSystem() override;
@@ -35,10 +37,12 @@ public:
             { return getXScreenFromDisplayScreen( GetDisplayBuiltInScreen() ); }
     SalX11Screen      getXScreenFromDisplayScreen(unsigned int nDisplayScreen);
     void              countScreenMonitors();
+#if !GTK_CHECK_VERSION(4,0,0)
     // We have a 'screen' number that is combined from screen-idx + monitor-idx
     int        getScreenIdxFromPtr     (GdkScreen *pScreen);
     int        getScreenMonitorIdx     (GdkScreen *pScreen, int nX, int nY);
     GdkScreen *getScreenMonitorFromIdx (int nIdx, gint &nMonitor);
+#endif
 };
 
 #endif // INCLUDED_VCL_INC_UNX_GTK_GTKSYS_HXX
diff --git a/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx b/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx
index bf9336f5a51f..66e5670bb0db 100644
--- a/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx
+++ b/vcl/unx/gtk3/fpicker/SalGtkFilePicker.cxx
@@ -73,7 +73,9 @@ void SalGtkFilePicker::InitialMapping()
     if (!mbPreviewState )
     {
         gtk_widget_hide( m_pPreview );
+#if !GTK_CHECK_VERSION(4, 0, 0)
         gtk_file_chooser_set_preview_widget_active( GTK_FILE_CHOOSER( m_pDialog ), false);
+#endif
     }
     gtk_widget_set_size_request (m_pPreview, -1, -1);
 }
@@ -125,9 +127,12 @@ SalGtkFilePicker::SalGtkFilePicker( const uno::Reference< uno::XComponentContext
 
     gtk_dialog_set_default_response( GTK_DIALOG (m_pDialog), GTK_RESPONSE_ACCEPT );
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
 #if ENABLE_GIO
     gtk_file_chooser_set_local_only( GTK_FILE_CHOOSER( m_pDialog ), false );
 #endif
+#endif
+
     gtk_file_chooser_set_select_multiple( GTK_FILE_CHOOSER( m_pDialog ), false );
 
     m_pVBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
@@ -136,8 +141,13 @@ SalGtkFilePicker::SalGtkFilePicker( const uno::Reference< uno::XComponentContext
     GtkWidget *pHBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
     GtkWidget *pThinVBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
     gtk_box_pack_end (GTK_BOX( m_pVBox ), pHBox, false, false, 0);
     gtk_box_pack_start (GTK_BOX( pHBox ), pThinVBox, false, false, 0);
+#else
+    gtk_box_append(GTK_BOX(m_pVBox), pHBox);
+    gtk_box_prepend(GTK_BOX(m_pVBox), pThinVBox);
+#endif
     gtk_widget_show( pHBox );
     gtk_widget_show( pThinVBox );
 
@@ -167,7 +177,11 @@ SalGtkFilePicker::SalGtkFilePicker( const uno::Reference< uno::XComponentContext
             break;
         }
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
         gtk_box_pack_end( GTK_BOX( pThinVBox ), m_pToggles[i], false, false, 0 );
+#else
+        gtk_box_append(GTK_BOX(pThinVBox), m_pToggles[i]);
+#endif
     }
 
     for( i = 0; i < LIST_LAST; i++ )
@@ -203,26 +217,48 @@ SalGtkFilePicker::SalGtkFilePicker( const uno::Reference< uno::XComponentContext
                 break;
         }
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
         gtk_box_pack_end( GTK_BOX( m_pHBoxs[i] ), m_pLists[i], false, false, 0 );
         gtk_box_pack_end( GTK_BOX( m_pHBoxs[i] ), m_pListLabels[i], false, false, 0 );
+#else
+        gtk_box_append(GTK_BOX(m_pHBoxs[i]), m_pLists[i]);
+        gtk_box_append(GTK_BOX(m_pHBoxs[i]), m_pListLabels[i]);
+#endif
         gtk_label_set_mnemonic_widget( GTK_LABEL(m_pListLabels[i]), m_pLists[i] );
         gtk_box_set_spacing( GTK_BOX( m_pHBoxs[i] ), 12 );
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
         gtk_box_pack_end( GTK_BOX( m_pVBox ), m_pHBoxs[i], false, false, 0 );
+#else
+        gtk_box_append(GTK_BOX(m_pVBox), m_pHBoxs[i]);
+#endif
     }
 
     aLabel = getResString( FILE_PICKER_FILE_TYPE );
     m_pFilterExpander = gtk_expander_new_with_mnemonic(
         OUStringToOString( aLabel, RTL_TEXTENCODING_UTF8 ).getStr());
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
     gtk_box_pack_end( GTK_BOX( m_pVBox ), m_pFilterExpander, false, true, 0 );
+#else
+    gtk_box_append(GTK_BOX(m_pVBox), m_pFilterExpander);
+#endif
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
     GtkWidget *scrolled_window = gtk_scrolled_window_new (nullptr, nullptr);
-    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
-        GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
     gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
         GTK_SHADOW_IN);
+#else
+    GtkWidget *scrolled_window = gtk_scrolled_window_new();
+    gtk_scrolled_window_set_has_frame(GTK_SCROLLED_WINDOW(scrolled_window), true);
+#endif
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
+        GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+#if !GTK_CHECK_VERSION(4, 0, 0)
     gtk_container_add (GTK_CONTAINER (m_pFilterExpander), scrolled_window);
+#else
+    gtk_expander_set_child(GTK_EXPANDER(m_pFilterExpander), scrolled_window);
+#endif
     gtk_widget_show (scrolled_window);
 
     m_pFilterStore = gtk_list_store_new (4, G_TYPE_STRING, G_TYPE_STRING,
@@ -242,13 +278,21 @@ SalGtkFilePicker::SalGtkFilePicker( const uno::Reference< uno::XComponentContext
         gtk_tree_view_append_column (GTK_TREE_VIEW(m_pFilterView), column);
     }
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
     gtk_container_add (GTK_CONTAINER (scrolled_window), m_pFilterView);
+#else
+    gtk_scrolled_window_set_child(GTK_SCROLLED_WINDOW(scrolled_window), m_pFilterView);
+#endif
     gtk_widget_show (m_pFilterView);
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
     gtk_file_chooser_set_extra_widget( GTK_FILE_CHOOSER( m_pDialog ), m_pVBox );
+#endif
 
     m_pPreview = gtk_image_new();
+#if !GTK_CHECK_VERSION(4, 0, 0)
     gtk_file_chooser_set_preview_widget( GTK_FILE_CHOOSER( m_pDialog ), m_pPreview );
+#endif
 
     g_signal_connect( G_OBJECT( m_pToggles[PREVIEW] ), "toggled",
                       G_CALLBACK( preview_toggled_cb ), this );
@@ -275,7 +319,9 @@ SalGtkFilePicker::SalGtkFilePicker( const uno::Reference< uno::XComponentContext
     gtk_widget_set_size_request (m_pFilterView, -1, height);
     gtk_widget_set_size_request (m_pPreview, 1, height);
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
     gtk_file_chooser_set_preview_widget_active( GTK_FILE_CHOOSER( m_pDialog ), true);
+#endif
 }
 
 // XFilePickerNotifier
@@ -407,6 +453,7 @@ shrinkFilterName( const OUString &rFilterName, bool bAllowNoStar = false )
     return aRealName;
 }
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
 static void
 dialog_remove_buttons(GtkWidget *pActionArea)
 {
@@ -437,6 +484,7 @@ dialog_remove_buttons( GtkDialog *pDialog )
     else
         dialog_remove_buttons(gtk_dialog_get_action_area(pDialog));
 }
+#endif
 
 namespace {
 
@@ -721,9 +769,14 @@ uno::Sequence<OUString> SAL_CALL SalGtkFilePicker::getSelectedFiles()
 
     OSL_ASSERT( m_pDialog != nullptr );
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
     GSList* pPathList = gtk_file_chooser_get_uris( GTK_FILE_CHOOSER(m_pDialog) );
-
     int nCount = g_slist_length( pPathList );
+#else
+    GListModel* pPathList = gtk_file_chooser_get_files(GTK_FILE_CHOOSER(m_pDialog));
+    int nCount = g_list_model_get_n_items(pPathList);
+#endif
+
     int nIndex = 0;
 
     // get the current action setting
@@ -733,9 +786,16 @@ uno::Sequence<OUString> SAL_CALL SalGtkFilePicker::getSelectedFiles()
     uno::Sequence< OUString > aSelectedFiles(nCount);
 
     // Convert to OOo
+#if !GTK_CHECK_VERSION(4, 0, 0)
     for( GSList *pElem = pPathList; pElem; pElem = pElem->next)
     {
         gchar *pURI = static_cast<gchar*>(pElem->data);
+#else
+    while (gpointer pElem = g_list_model_get_item(pPathList, nIndex))
+    {
+        gchar *pURI = g_file_get_uri(static_cast<GFile*>(pElem));
+#endif
+
         aSelectedFiles[ nIndex ] = uritounicode(pURI);
 
         if( GTK_FILE_CHOOSER_ACTION_SAVE == eAction )
@@ -854,7 +914,11 @@ uno::Sequence<OUString> SAL_CALL SalGtkFilePicker::getSelectedFiles()
         g_free( pURI );
     }
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
     g_slist_free( pPathList );
+#else
+    g_object_unref(pPathList);
+#endif
 
     return aSelectedFiles;
 }
@@ -998,7 +1062,11 @@ sal_Int16 SAL_CALL SalGtkFilePicker::execute()
                             rtl::Reference<RunDialog> pAnotherDialog = new RunDialog(dlg, xToolkit, xDesktop);
                             btn = pAnotherDialog->run();
 
-                            gtk_widget_destroy( dlg );
+#if !GTK_CHECK_VERSION(4, 0, 0)
+                            gtk_widget_destroy(dlg);
+#else
+                            gtk_window_destroy(GTK_WINDOW(dlg));
+#endif
                         }
                         g_free (gFileName);
 
@@ -1096,7 +1164,9 @@ GtkWidget *SalGtkFilePicker::getWidget( sal_Int16 nControlId, GType *pType )
 static void HackWidthToFirst(GtkComboBox *pWidget)
 {
     GtkRequisition requisition;
+#if !GTK_CHECK_VERSION(4, 0, 0)
     gtk_widget_size_request(GTK_WIDGET(pWidget), &requisition);
+#endif
     gtk_widget_set_size_request(GTK_WIDGET(pWidget), requisition.width, -1);
 }
 
@@ -1461,6 +1531,7 @@ void SalGtkFilePicker::selection_changed_cb( GtkFileChooser *, SalGtkFilePicker
 
 void SalGtkFilePicker::update_preview_cb( GtkFileChooser *file_chooser, SalGtkFilePicker* pobjFP )
 {
+#if !GTK_CHECK_VERSION(4, 0, 0)
     bool have_preview = false;
 
     GtkWidget* preview = pobjFP->m_pPreview;
@@ -1485,6 +1556,10 @@ void SalGtkFilePicker::update_preview_cb( GtkFileChooser *file_chooser, SalGtkFi
 
     if( filename )
         g_free( filename );
+#else
+    (void)file_chooser;
+    (void)pobjFP;
+#endif
 }
 
 sal_Bool SAL_CALL SalGtkFilePicker::setShowState( sal_Bool bShowState )
@@ -1691,7 +1766,9 @@ void SAL_CALL SalGtkFilePicker::initialize( const uno::Sequence<uno::Any>& aArgu
     }
 
     gtk_file_chooser_set_action( GTK_FILE_CHOOSER( m_pDialog ), eAction);
+#if !GTK_CHECK_VERSION(4, 0, 0)
     dialog_remove_buttons( GTK_DIALOG( m_pDialog ) );
+#endif
     gtk_dialog_add_button(GTK_DIALOG( m_pDialog ),
                           getCancelText().getStr(),
                           GTK_RESPONSE_CANCEL);
@@ -1747,6 +1824,7 @@ void SAL_CALL SalGtkFilePicker::cancel()
 
 void SalGtkFilePicker::SetCurFilter( const OUString& rFilter )
 {
+#if !GTK_CHECK_VERSION(4, 0, 0)
     // Get all the filters already added
     GSList *filters = gtk_file_chooser_list_filters ( GTK_FILE_CHOOSER( m_pDialog ) );
     bool bFound = false;
@@ -1767,8 +1845,12 @@ void SalGtkFilePicker::SetCurFilter( const OUString& rFilter )
     }
 
     g_slist_free( filters );
+#else
+    (void)rFilter;
+#endif
 }
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
 extern "C"
 {
 static gboolean
@@ -1796,6 +1878,7 @@ case_insensitive_filter (const GtkFileFilterInfo *filter_info, gpointer data)
     return bRetval;
 }
 }
+#endif
 
 GtkFileFilter* SalGtkFilePicker::implAddFilter( const OUString& rFilter, const OUString& rType )
 {
@@ -1825,10 +1908,12 @@ GtkFileFilter* SalGtkFilePicker::implAddFilter( const OUString& rFilter, const O
                 if (!aTokens.isEmpty())
                     aTokens.append(",");
                 aTokens.append(aToken);
+#if !GTK_CHECK_VERSION(4, 0, 0)
                 gtk_file_filter_add_custom (filter, GTK_FILE_FILTER_URI,
                     case_insensitive_filter,
                     g_strdup( OUStringToOString(aToken, RTL_TEXTENCODING_UTF8).getStr() ),
                     g_free );
+#endif
 
                 SAL_INFO( "vcl.gtk", "fustering with " << aToken );
             }
@@ -1942,6 +2027,7 @@ void SalGtkFilePicker::SetFilters()
 
 SalGtkFilePicker::~SalGtkFilePicker()
 {
+#if !GTK_CHECK_VERSION(4, 0, 0)
     SolarMutexGuard g;
 
     int i;
@@ -1959,6 +2045,7 @@ SalGtkFilePicker::~SalGtkFilePicker()
     m_pFilterVector.reset();
 
     gtk_widget_destroy( m_pVBox );
+#endif
 }
 
 uno::Reference< ui::dialogs::XFilePicker2 >
diff --git a/vcl/unx/gtk3/fpicker/SalGtkFolderPicker.cxx b/vcl/unx/gtk3/fpicker/SalGtkFolderPicker.cxx
index 24bf857544d0..2f79e3d8ba59 100644
--- a/vcl/unx/gtk3/fpicker/SalGtkFolderPicker.cxx
+++ b/vcl/unx/gtk3/fpicker/SalGtkFolderPicker.cxx
@@ -49,8 +49,10 @@ SalGtkFolderPicker::SalGtkFolderPicker( const uno::Reference< uno::XComponentCon
         getOKText().getStr(), GTK_RESPONSE_ACCEPT, nullptr );
 
     gtk_dialog_set_default_response( GTK_DIALOG (m_pDialog), GTK_RESPONSE_ACCEPT );
+#if !GTK_CHECK_VERSION(4, 0, 0)
 #if ENABLE_GIO
     gtk_file_chooser_set_local_only( GTK_FILE_CHOOSER( m_pDialog ), false );
+#endif
 #endif
     gtk_file_chooser_set_select_multiple( GTK_FILE_CHOOSER( m_pDialog ), false );
 }
@@ -71,8 +73,13 @@ void SAL_CALL SalGtkFolderPicker::setDisplayDirectory( const OUString& aDirector
 
     SAL_INFO( "vcl", "setting path to " << aTxt );
 
-    gtk_file_chooser_set_current_folder_uri( GTK_FILE_CHOOSER( m_pDialog ),
-        aTxt.getStr() );
+#if GTK_CHECK_VERSION(4, 0, 0)
+    GFile* pPath = g_file_new_for_uri(aTxt.getStr());
+    gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_pDialog), pPath, nullptr);
+    g_object_unref(pPath);
+#else
+    gtk_file_chooser_set_current_folder_uri(GTK_FILE_CHOOSER(m_pDialog), aTxt.getStr());
+#endif
 }
 
 OUString SAL_CALL SalGtkFolderPicker::getDisplayDirectory()
@@ -81,8 +88,16 @@ OUString SAL_CALL SalGtkFolderPicker::getDisplayDirectory()
 
     assert( m_pDialog != nullptr );
 
+#if GTK_CHECK_VERSION(4, 0, 0)
+    GFile* pPath =
+        gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(m_pDialog));
+    gchar* pCurrentFolder = g_file_get_uri(pPath);
+    g_object_unref(pPath);
+#else
     gchar* pCurrentFolder =
-        gtk_file_chooser_get_current_folder_uri( GTK_FILE_CHOOSER( m_pDialog ) );
+        gtk_file_chooser_get_current_folder_uri(GTK_FILE_CHOOSER(m_pDialog));
+#endif
+
     OUString aCurrentFolderName = uritounicode(pCurrentFolder);
     g_free( pCurrentFolder );
 
@@ -95,8 +110,15 @@ OUString SAL_CALL SalGtkFolderPicker::getDirectory()
 
     assert( m_pDialog != nullptr );
 
+#if GTK_CHECK_VERSION(4, 0, 0)
+    GFile* pPath =
+        gtk_file_chooser_get_file(GTK_FILE_CHOOSER(m_pDialog));
+    gchar* pSelectedFolder = g_file_get_uri(pPath);
+    g_object_unref(pPath);
+#else
     gchar* pSelectedFolder =
         gtk_file_chooser_get_uri( GTK_FILE_CHOOSER( m_pDialog ) );
+#endif
     OUString aSelectedFolderName = uritounicode(pSelectedFolder);
     g_free( pSelectedFolder );
 
diff --git a/vcl/unx/gtk3/fpicker/SalGtkPicker.cxx b/vcl/unx/gtk3/fpicker/SalGtkPicker.cxx
index 7502d5af290b..76c7739b723a 100644
--- a/vcl/unx/gtk3/fpicker/SalGtkPicker.cxx
+++ b/vcl/unx/gtk3/fpicker/SalGtkPicker.cxx
@@ -35,6 +35,7 @@
 
 #include <vcl/window.hxx>
 #include <unx/gtk/gtkframe.hxx>
+#include <unx/gtk/gtkinst.hxx>
 #include "SalGtkPicker.hxx"
 
 using namespace ::rtl;
@@ -100,7 +101,13 @@ GtkWindow* RunDialog::GetTransientFor()
     {
         GtkSalFrame *pFrame = dynamic_cast<GtkSalFrame *>( pWindow->ImplGetFrame() );
         if( pFrame )
+        {
+#if !GTK_CHECK_VERSION(4, 0, 0)
             pParent = GTK_WINDOW(gtk_widget_get_toplevel(pFrame->getWindow()));
+#else
+            pParent = GTK_WINDOW(gtk_widget_get_root(pFrame->getWindow()));
+#endif
+        }
     }
 
     return pParent;
@@ -181,6 +188,13 @@ namespace
     };
 }
 
+#if GTK_CHECK_VERSION(4, 0, 0)
+gint gtk_dialog_run(GtkDialog*)
+{
+    return 0;
+}
+#endif
+
 gint RunDialog::run()
 {
     if (mxToolkit.is())
@@ -238,7 +252,11 @@ SalGtkPicker::~SalGtkPicker()
 
     if (m_pDialog)
     {
+#if !GTK_CHECK_VERSION(4, 0, 0)
         gtk_widget_destroy(m_pDialog);
+#else
+        gtk_window_destroy(GTK_WINDOW(m_pDialog));
+#endif
     }
 }
 
@@ -256,16 +274,28 @@ void SalGtkPicker::implsetDisplayDirectory( const OUString& aDirectory )
 
     SAL_INFO( "vcl", "setting path to " << aTxt );
 
-    gtk_file_chooser_set_current_folder_uri( GTK_FILE_CHOOSER( m_pDialog ),
-        aTxt.getStr() );
+#if GTK_CHECK_VERSION(4, 0, 0)
+    GFile* pPath = g_file_new_for_uri(aTxt.getStr());
+    gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_pDialog), pPath, nullptr);
+    g_object_unref(pPath);
+#else
+    gtk_file_chooser_set_current_folder_uri(GTK_FILE_CHOOSER(m_pDialog), aTxt.getStr());
+#endif
 }
 
 OUString SalGtkPicker::implgetDisplayDirectory()
 {
     OSL_ASSERT( m_pDialog != nullptr );
 
+#if GTK_CHECK_VERSION(4, 0, 0)
+    GFile* pPath =
+        gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(m_pDialog));
+    gchar* pCurrentFolder = g_file_get_uri(pPath);
+    g_object_unref(pPath);
+#else
     gchar* pCurrentFolder =
-        gtk_file_chooser_get_current_folder_uri( GTK_FILE_CHOOSER( m_pDialog ) );
+        gtk_file_chooser_get_current_folder_uri(GTK_FILE_CHOOSER(m_pDialog));
+#endif
     OUString aCurrentFolderName = uritounicode(pCurrentFolder);
     g_free( pCurrentFolder );
 
diff --git a/vcl/unx/gtk3/gtkdata.cxx b/vcl/unx/gtk3/gtkdata.cxx
index 8626252f40e6..f515d93ac1eb 100644
--- a/vcl/unx/gtk3/gtkdata.cxx
+++ b/vcl/unx/gtk3/gtkdata.cxx
@@ -44,6 +44,7 @@
 
 using namespace vcl_sal;
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
 /***************************************************************
  * class GtkSalDisplay                                         *
  ***************************************************************/
@@ -56,6 +57,7 @@ static GdkFilterReturn call_filterGdkEvent( GdkXEvent* sys_event,
     return pDisplay->filterGdkEvent( sys_event );
 }
 }
+#endif
 
 GtkSalDisplay::GtkSalDisplay( GdkDisplay* pDisplay ) :
             m_pSys( GtkSalSystem::GetSingleton() ),
@@ -65,8 +67,10 @@ GtkSalDisplay::GtkSalDisplay( GdkDisplay* pDisplay ) :
     for(GdkCursor* & rpCsr : m_aCursors)
         rpCsr = nullptr;
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
     // FIXME: unify this with SalInst's filter too ?
     gdk_window_add_filter( nullptr, call_filterGdkEvent, this );
+#endif
 
     if ( getenv( "SAL_IGNOREXERRORS" ) )
         GetGenericUnixSalData()->ErrorTrapPush(); // and leak the trap
@@ -78,6 +82,7 @@ GtkSalDisplay::GtkSalDisplay( GdkDisplay* pDisplay ) :
 
 GtkSalDisplay::~GtkSalDisplay()
 {
+#if !GTK_CHECK_VERSION(4, 0, 0)
     gdk_window_remove_filter( nullptr, call_filterGdkEvent, this );
 
     if( !m_bStartupCompleted )
@@ -86,8 +91,10 @@ GtkSalDisplay::~GtkSalDisplay()
     for(GdkCursor* & rpCsr : m_aCursors)
         if( rpCsr )
             gdk_cursor_unref( rpCsr );
+#endif
 }
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
 extern "C" {
 
 static void signalScreenSizeChanged( GdkScreen* pScreen, gpointer data )
@@ -124,14 +131,21 @@ void GtkSalDisplay::monitorsChanged( GdkScreen const * pScreen )
     if (pScreen)
         emitDisplayChanged();
 }
+#endif
 
 GdkCursor* GtkSalDisplay::getFromSvg(OUString const & name, int nXHot, int nYHot)
 {
+#if !GTK_CHECK_VERSION(4, 0, 0)
     GdkPixbuf* pPixBuf = load_icon_by_name(name);
+#else
+    (void)name;
+    GdkPixbuf* pPixBuf = nullptr;
+#endif
     assert(pPixBuf && "missing image?");
     if (!pPixBuf)
         return nullptr;
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
     guint nDefaultCursorSize = gdk_display_get_default_cursor_size( m_pGdkDisplay );
     int nPixWidth = gdk_pixbuf_get_width(pPixBuf);
     int nPixHeight = gdk_pixbuf_get_height(pPixBuf);
@@ -141,19 +155,32 @@ GdkCursor* GtkSalDisplay::getFromSvg(OUString const & name, int nXHot, int nYHot
                                                        nPixHeight * fScalefactor,
                                                        GDK_INTERP_HYPER);
     g_object_unref(pPixBuf);
-    GdkCursor* pCursor = gdk_cursor_new_from_pixbuf(m_pGdkDisplay, pScaledPixBuf,
-                                                    nXHot * fScalefactor, nYHot * fScalefactor);
-    return pCursor;
+    return gdk_cursor_new_from_pixbuf(m_pGdkDisplay, pScaledPixBuf,
+                                      nXHot * fScalefactor, nYHot * fScalefactor);
+#else
+    GdkTexture* pTexture = gdk_texture_new_for_pixbuf(pPixBuf);
+    g_object_unref(pPixBuf);
+    return gdk_cursor_new_from_texture(pTexture, nXHot, nYHot, nullptr);
+#endif
 }
 
 #define MAKE_CURSOR( vcl_name, name, name2 ) \
     case vcl_name: \
         pCursor = getFromSvg(name2, name##curs_x_hot, name##curs_y_hot); \
         break
+
+#if !GTK_CHECK_VERSION(4, 0, 0)
 #define MAP_BUILTIN( vcl_name, gdk_name ) \
     case vcl_name: \
         pCursor = gdk_cursor_new_for_display( m_pGdkDisplay, gdk_name ); \
         break
+#else
+// TODO, the rest of these
+#define MAP_BUILTIN( vcl_name, gdk_name ) \
+    case vcl_name: \
+        pCursor = gdk_cursor_new_from_name("normal", nullptr); \
+        break
+#endif
 
 GdkCursor *GtkSalDisplay::getCursor( PointerStyle ePointerStyle )
 {
@@ -273,7 +300,13 @@ GdkCursor *GtkSalDisplay::getCursor( PointerStyle ePointerStyle )
             break;
         }
         if( !pCursor )
+        {
+#if !GTK_CHECK_VERSION(4, 0, 0)
             pCursor = gdk_cursor_new_for_display( m_pGdkDisplay, GDK_LEFT_PTR );
+#else
+            pCursor = gdk_cursor_new_from_name("normal", nullptr);
+#endif
+        }
 
         m_aCursors[ ePointerStyle ] = pCursor;
     }
@@ -466,8 +499,10 @@ void GtkSalData::Init()
     }
 
     // init gtk/gdk
+#if !GTK_CHECK_VERSION(4, 0, 0)
     gtk_init_check( &nParams, &pCmdLineAry );
     gdk_error_trap_push();
+#endif
 
     for (int i = 0; i < nParams; ++i)
         g_free( pCmdLineAry[i] );
@@ -505,6 +540,7 @@ void GtkSalData::Init()
     GtkSalDisplay *pDisplay = new GtkSalDisplay( pGdkDisp );
     SetDisplay( pDisplay );
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
     int nScreens = gdk_display_get_n_screens( pGdkDisp );
     for( int n = 0; n < nScreens; n++ )
     {
@@ -545,21 +581,29 @@ void GtkSalData::Init()
         gtk_style_context_add_provider_for_screen(pScreen, GTK_STYLE_PROVIDER(pSmallButtonProvider),
             GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
     }
+#endif
 }
 
 void GtkSalData::ErrorTrapPush()
 {
+#if !GTK_CHECK_VERSION(4, 0, 0)
     gdk_error_trap_push ();
+#endif
 }
 
 bool GtkSalData::ErrorTrapPop( bool bIgnoreError )
 {
+#if !GTK_CHECK_VERSION(4, 0, 0)
     if (bIgnoreError)
     {
         gdk_error_trap_pop_ignored (); // faster
         return false;
     }
     return gdk_error_trap_pop () != 0;
+#else
+    (void)bIgnoreError;
+    return false;
+#endif
 }
 
 #if !GLIB_CHECK_VERSION(2,32,0)
diff --git a/vcl/unx/gtk3/gtkframe.cxx b/vcl/unx/gtk3/gtkframe.cxx
index 79f2f73641bf..fb2c2554531e 100644
--- a/vcl/unx/gtk3/gtkframe.cxx
+++ b/vcl/unx/gtk3/gtkframe.cxx
@@ -74,8 +74,13 @@ sal_uInt16 GtkSalFrame::GetKeyModCode( guint state )
         nCode |= KEY_SHIFT;
     if( state & GDK_CONTROL_MASK )
         nCode |= KEY_MOD1;
+#if !GTK_CHECK_VERSION(4, 0, 0)
     if( state & GDK_MOD1_MASK )
         nCode |= KEY_MOD2;
+#else
+    if (state & GDK_ALT_MASK)
+        nCode |= KEY_MOD2;
+#endif
     if( state & GDK_SUPER_MASK )
         nCode |= KEY_MOD3;
     return nCode;
@@ -295,6 +300,7 @@ sal_uInt16 GtkSalFrame::GetKeyCode(guint keyval)
     return nCode;
 }
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
 guint GtkSalFrame::GetKeyValFor(GdkKeymap* pKeyMap, guint16 hardware_keycode, guint8 group)
 {
     guint updated_keyval = 0;
@@ -302,6 +308,7 @@ guint GtkSalFrame::GetKeyValFor(GdkKeymap* pKeyMap, guint16 hardware_keycode, gu
         GdkModifierType(0), group, &updated_keyval, nullptr, nullptr, nullptr);
     return updated_keyval;
 }
+#endif
 
 namespace {
 
@@ -393,6 +400,7 @@ bool GtkSalFrame::doKeyCallback( guint state,
      *  be used to input Latin text and use that if possible
      */
     aEvent.mnCode = GetKeyCode( keyval );
+#if !GTK_CHECK_VERSION(4, 0, 0)
     if( aEvent.mnCode == 0 )
     {
         gint best_group = SAL_MAX_INT32;
@@ -422,6 +430,10 @@ bool GtkSalFrame::doKeyCallback( guint state,
         guint updated_keyval = GetKeyValFor(keymap, hardware_keycode, best_group);
         aEvent.mnCode = GetKeyCode(updated_keyval);
     }
+#else
+    (void)hardware_keycode;
+    (void)group;
+#endif
 
     aEvent.mnCode   |= GetKeyModCode( state );
 
@@ -479,6 +491,7 @@ GtkSalFrame::GtkSalFrame( SystemParentData* pSysData )
 
 // AppMenu watch functions.
 
+#if !GTK_CHECK_VERSION(4,0,0)
 static void ObjectDestroyedNotify( gpointer data )
 {
     if ( data ) {
@@ -528,6 +541,7 @@ static bool ensure_dbus_setup( gpointer data )
         g_object_set_data_full( G_OBJECT( gdkWindow ), "g-lo-action-group", pActionGroup, ObjectDestroyedNotify );
 
         GdkDisplay *pDisplay = GtkSalFrame::getGdkDisplay();
+#if !GTK_CHECK_VERSION(4,0,0)
 #if defined(GDK_WINDOWING_X11)
         if (DLSYM_GDK_IS_X11_DISPLAY(pDisplay))
         {
@@ -538,6 +552,7 @@ static bool ensure_dbus_setup( gpointer data )
             gdk_x11_window_set_utf8_property( gdkWindow, "_GTK_UNIQUE_BUS_NAME", g_dbus_connection_get_unique_name( pSessionBus ) );
         }
 #endif
+#endif
 #if defined(GDK_WINDOWING_WAYLAND)
         if (DLSYM_GDK_IS_WAYLAND_DISPLAY(pDisplay))
         {
@@ -559,9 +574,9 @@ static bool ensure_dbus_setup( gpointer data )
         g_free( aDBusWindowPath );
         g_free( aDBusMenubarPath );
     }
-
     return false;
 }
+#endif
 
 void on_registrar_available( GDBusConnection * /*connection*/,
                              const gchar     * /*name*/,
@@ -674,12 +689,14 @@ GtkSalFrame::~GtkSalFrame()
     GtkWidget *pEventWidget = getMouseEventWidget();
     for (auto handler_id : m_aMouseSignalIds)
         g_signal_handler_disconnect(G_OBJECT(pEventWidget), handler_id);
+#if !GTK_CHECK_VERSION(4, 0, 0)
     if( m_pFixedContainer )
         gtk_widget_destroy( GTK_WIDGET( m_pFixedContainer ) );
     if( m_pEventBox )
         gtk_widget_destroy( GTK_WIDGET(m_pEventBox) );
     if( m_pTopLevelGrid )
         gtk_widget_destroy( GTK_WIDGET(m_pTopLevelGrid) );
+#endif
     {
         SolarMutexGuard aGuard;
 
@@ -699,13 +716,20 @@ GtkSalFrame::~GtkSalFrame()
                 if ( m_nActionGroupExportId )
                     g_dbus_connection_unexport_action_group( pSessionBus, m_nActionGroupExportId );
             }
+#if !GTK_CHECK_VERSION(4,0,0)
             gtk_widget_destroy( m_pWindow );
+#else
+            gtk_window_destroy(GTK_WINDOW(m_pWindow));
+#endif
         }
     }
+
+#if !GTK_CHECK_VERSION(4,0,0)
     if( m_pForeignParent )
         g_object_unref( G_OBJECT( m_pForeignParent ) );
     if( m_pForeignTopLevel )
         g_object_unref( G_OBJECT( m_pForeignTopLevel) );
+#endif
 
     m_pGraphics.reset();
 
@@ -727,8 +751,10 @@ void GtkSalFrame::moveWindow( tools::Long nX, tools::Long nY )
                             nX - m_pParent->maGeometry.nX, nY - m_pParent->maGeometry.nY );
         }
     }
+#if !GTK_CHECK_VERSION(4,0,0)
     else
         gtk_window_move( GTK_WINDOW(m_pWindow), nX, nY );
+#endif
 }
 
 void GtkSalFrame::widget_set_size_request(tools::Long nWidth, tools::Long nHeight)
@@ -741,8 +767,10 @@ void GtkSalFrame::window_resize(tools::Long nWidth, tools::Long nHeight)
     m_nWidthRequest = nWidth;
     m_nHeightRequest = nHeight;
     gtk_window_set_default_size(GTK_WINDOW(m_pWindow), nWidth, nHeight);
+#if !GTK_CHECK_VERSION(4,0,0)
     if (gtk_widget_get_visible(m_pWindow))
         gtk_window_resize(GTK_WINDOW(m_pWindow), nWidth, nHeight);
+#endif
 }
 
 void GtkSalFrame::resizeWindow( tools::Long nWidth, tools::Long nHeight )
@@ -755,6 +783,7 @@ void GtkSalFrame::resizeWindow( tools::Long nWidth, tools::Long nHeight )
         window_resize(nWidth, nHeight);
 }
 
+#if !GTK_CHECK_VERSION(4,0,0)
 // tdf#124694 GtkFixed takes the max size of all its children as its
 // preferred size, causing it to not clip its child, but grow instead.
 
@@ -771,14 +800,19 @@ ooo_fixed_get_preferred_width(GtkWidget*, gint *minimum, gint *natural)
     *minimum = 0;
     *natural = 0;
 }
+#endif
 
 static void
 ooo_fixed_class_init(GtkFixedClass *klass)
 {
+#if !GTK_CHECK_VERSION(4,0,0)
     GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
     widget_class->get_accessible = ooo_fixed_get_accessible;
     widget_class->get_preferred_height = ooo_fixed_get_preferred_height;
     widget_class->get_preferred_width = ooo_fixed_get_preferred_width;
+#else
+    (void)klass;
+#endif
 }
 
 /*
@@ -816,16 +850,22 @@ ooo_fixed_get_type()
 
 void GtkSalFrame::updateScreenNumber()
 {
+#if !GTK_CHECK_VERSION(4,0,0)
     int nScreen = 0;
     GdkScreen *pScreen = gtk_widget_get_screen( m_pWindow );
     if( pScreen )
         nScreen = getDisplay()->getSystem()->getScreenMonitorIdx( pScreen, maGeometry.nX, maGeometry.nY );
     maGeometry.nDisplayScreenNumber = nScreen;
+#endif
 }
 
 GtkWidget *GtkSalFrame::getMouseEventWidget() const
 {
+#if !GTK_CHECK_VERSION(4,0,0)
     return GTK_WIDGET(m_pEventBox);
+#else
+    return GTK_WIDGET(m_pFixedContainer);
+#endif
 }
 
 static void damaged(void *handle,
@@ -848,6 +888,7 @@ void GtkSalFrame::InitCommon()
     m_aSmoothScrollIdle.SetInvokeHandler(LINK(this, GtkSalFrame, AsyncScroll));
 
     m_pTopLevelGrid = GTK_GRID(gtk_grid_new());
+#if !GTK_CHECK_VERSION(4,0,0)
     gtk_container_add(GTK_CONTAINER(m_pWindow), GTK_WIDGET(m_pTopLevelGrid));
 
     m_pEventBox = GTK_EVENT_BOX(gtk_event_box_new());
@@ -856,19 +897,30 @@ void GtkSalFrame::InitCommon()
     gtk_widget_set_vexpand(GTK_WIDGET(m_pEventBox), true);
     gtk_widget_set_hexpand(GTK_WIDGET(m_pEventBox), true);
     gtk_grid_attach(m_pTopLevelGrid, GTK_WIDGET(m_pEventBox), 0, 0, 1, 1);
+#else
+    gtk_window_set_child(GTK_WINDOW(m_pWindow),  GTK_WIDGET(m_pTopLevelGrid));
+#endif
 
     // add the fixed container child,
     // fixed is needed since we have to position plugin windows
     m_pFixedContainer = GTK_FIXED(g_object_new( ooo_fixed_get_type(), nullptr ));
     gtk_widget_set_can_focus(GTK_WIDGET(m_pFixedContainer), true);
     gtk_widget_set_size_request(GTK_WIDGET(m_pFixedContainer), 1, 1);
+#if !GTK_CHECK_VERSION(4,0,0)
     gtk_container_add( GTK_CONTAINER(m_pEventBox), GTK_WIDGET(m_pFixedContainer) );
+#else
+    gtk_widget_set_vexpand(GTK_WIDGET(m_pFixedContainer), true);
+    gtk_widget_set_hexpand(GTK_WIDGET(m_pFixedContainer), true);
+    gtk_grid_attach(m_pTopLevelGrid, GTK_WIDGET(m_pFixedContainer), 0, 0, 1, 1);
+#endif
 
+#if !GTK_CHECK_VERSION(4,0,0)
     GtkWidget *pEventWidget = getMouseEventWidget();
-
     gtk_widget_set_app_paintable(GTK_WIDGET(m_pFixedContainer), true);
     gtk_widget_set_redraw_on_allocate(GTK_WIDGET(m_pFixedContainer), false);
+#endif
 
+#if !GTK_CHECK_VERSION(4,0,0)
     // connect signals
     // use pEventWidget instead of m_pWindow to avoid infinite event loop under Linux Mint Mate 18.3
     g_signal_connect( G_OBJECT(pEventWidget), "style-updated", G_CALLBACK(signalStyleUpdated), this );
@@ -923,11 +975,15 @@ void GtkSalFrame::InitCommon()
     g_signal_connect( G_OBJECT(m_pWindow), "window-state-event", G_CALLBACK(signalWindowState), this );
     g_signal_connect( G_OBJECT(m_pWindow), "destroy", G_CALLBACK(signalDestroy), this );
 
+#endif
+
     // init members
     m_nKeyModifiers     = ModKeyFlags::NONE;
     m_bFullscreen       = false;
     m_bSpanMonitorsWhenFullscreen = false;
+#if !GTK_CHECK_VERSION(4,0,0)
     m_nState            = GDK_WINDOW_STATE_WITHDRAWN;
+#endif
     m_pIMHandler        = nullptr;
     m_pRegion           = nullptr;
     m_pDropTarget       = nullptr;
@@ -942,14 +998,20 @@ void GtkSalFrame::InitCommon()
     m_nActionGroupExportId = 0;
     m_nHudAwarenessId   = 0;
 
+#if !GTK_CHECK_VERSION(4,0,0)
     gtk_widget_add_events( m_pWindow,
                            GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
                            GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
                            GDK_SCROLL_MASK
                            );
+#endif
 
     // show the widgets
+#if !GTK_CHECK_VERSION(4,0,0)
     gtk_widget_show_all(GTK_WIDGET(m_pTopLevelGrid));
+#else
+    gtk_widget_show(GTK_WIDGET(m_pTopLevelGrid));
+#endif
 
     // realize the window, we need an XWindow id
     gtk_widget_realize( m_pWindow );
@@ -968,9 +1030,11 @@ void GtkSalFrame::InitCommon()
     {
         m_aSystemData.pDisplay = gdk_x11_display_get_xdisplay(pDisplay);
         m_aSystemData.platform = SystemEnvData::Platform::Xcb;
+#if !GTK_CHECK_VERSION(4,0,0)
         GdkScreen* pScreen = gtk_widget_get_screen(m_pWindow);
         GdkVisual* pVisual = gdk_screen_get_system_visual(pScreen);
         m_aSystemData.pVisual = gdk_x11_visual_get_xvisual(pVisual);
+#endif
     }
 #endif
 #if defined(GDK_WINDOWING_WAYLAND)
@@ -1037,9 +1101,11 @@ void GtkSalFrame::AllowCycleFocusOut()
 {
     if (m_nSetFocusSignalId)
         return;
+#if !GTK_CHECK_VERSION(4,0,0)
     // enable/disable can-focus as control enters and leaves
     // embedded native gtk widgets
     m_nSetFocusSignalId = g_signal_connect(G_OBJECT(m_pWindow), "set-focus", G_CALLBACK(signalSetFocus), this);
+#endif
 
     // set container without can-focus and focus will tab between
     // the native embedded widgets using the default gtk handling for
@@ -1057,19 +1123,24 @@ void GtkSalFrame::Init( SalFrame* pParent, SalFrameStyleFlags nStyle )
     }
 
     m_pParent = static_cast<GtkSalFrame*>(pParent);
+#if !GTK_CHECK_VERSION(4,0,0)
     m_pForeignParent = nullptr;
     m_aForeignParentWindow = None;
     m_pForeignTopLevel = nullptr;
     m_aForeignTopLevelWindow = None;
+#endif
     m_nStyle = nStyle;
 
+#if !GTK_CHECK_VERSION(4,0,0)
     GtkWindowType eWinType = (  (nStyle & SalFrameStyleFlags::FLOAT) &&
                               ! (nStyle & SalFrameStyleFlags::OWNERDRAWDECORATION)
                               )
         ? GTK_WINDOW_POPUP : GTK_WINDOW_TOPLEVEL;
+#endif
 
     if( nStyle & SalFrameStyleFlags::SYSTEMCHILD )
     {
+#if !GTK_CHECK_VERSION(4,0,0)
         m_pWindow = gtk_event_box_new();
         if( m_pParent )
         {
@@ -1077,16 +1148,23 @@ void GtkSalFrame::Init( SalFrame* pParent, SalFrameStyleFlags nStyle )
             gtk_fixed_put( m_pParent->getFixedContainer(),
                            m_pWindow, 0, 0 );
         }
+#endif
     }
     else
     {
+#if !GTK_CHECK_VERSION(4,0,0)
         m_pWindow = gtk_window_new(eWinType);
+#else
+        m_pWindow = gtk_window_new();
+#endif
 
+#if !GTK_CHECK_VERSION(4,0,0)
         // hook up F1 to show help for embedded native gtk widgets
         GtkAccelGroup *pGroup = gtk_accel_group_new();
         GClosure* closure = g_cclosure_new(G_CALLBACK(GtkSalFrame::NativeWidgetHelpPressed), GTK_WINDOW(m_pWindow), nullptr);
         gtk_accel_group_connect(pGroup, GDK_KEY_F1, static_cast<GdkModifierType>(0), GTK_ACCEL_LOCKED, closure);
         gtk_window_add_accel_group(GTK_WINDOW(m_pWindow), pGroup);
+#endif
     }
 
     g_object_set_data( G_OBJECT( m_pWindow ), "SalFrame", this );
@@ -1104,9 +1182,13 @@ void GtkSalFrame::Init( SalFrame* pParent, SalFrameStyleFlags nStyle )
     {
         if (m_pParent)
         {
+#if !GTK_CHECK_VERSION(4,0,0)
             GtkWidget* pTopLevel = gtk_widget_get_toplevel(m_pParent->m_pWindow);
             if (!isChild())
                 gtk_window_set_screen(GTK_WINDOW(m_pWindow), gtk_widget_get_screen(pTopLevel));
+#else
+            GtkWidget* pTopLevel = GTK_WIDGET(gtk_widget_get_root(m_pParent->m_pWindow));
+#endif
 
             if (!(m_pParent->m_nStyle & SalFrameStyleFlags::PLUG))
                 gtk_window_set_transient_for(GTK_WINDOW(m_pWindow), GTK_WINDOW(pTopLevel));
@@ -1128,29 +1210,40 @@ void GtkSalFrame::Init( SalFrame* pParent, SalFrameStyleFlags nStyle )
 
     if( bDecoHandling )
     {
+#if !GTK_CHECK_VERSION(4,0,0)
         GdkWindowTypeHint eType = GDK_WINDOW_TYPE_HINT_NORMAL;
         if( (nStyle & SalFrameStyleFlags::DIALOG) && m_pParent != nullptr )
             eType = GDK_WINDOW_TYPE_HINT_DIALOG;
+#endif
         if( nStyle & SalFrameStyleFlags::INTRO )
         {
+#if !GTK_CHECK_VERSION(4,0,0)
             gtk_window_set_role( GTK_WINDOW(m_pWindow), "splashscreen" );
             eType = GDK_WINDOW_TYPE_HINT_SPLASHSCREEN;
+#endif
         }
         else if( nStyle & SalFrameStyleFlags::TOOLWINDOW )
         {
+#if !GTK_CHECK_VERSION(4,0,0)
             eType = GDK_WINDOW_TYPE_HINT_DIALOG;
             gtk_window_set_skip_taskbar_hint( GTK_WINDOW(m_pWindow), true );
+#endif
         }
         else if( nStyle & SalFrameStyleFlags::OWNERDRAWDECORATION )
         {
+#if !GTK_CHECK_VERSION(4,0,0)
             eType = GDK_WINDOW_TYPE_HINT_TOOLBAR;
             gtk_window_set_focus_on_map(GTK_WINDOW(m_pWindow), false);
+#endif
             gtk_window_set_decorated(GTK_WINDOW(m_pWindow), false);
         }
+#if !GTK_CHECK_VERSION(4,0,0)
         gtk_window_set_type_hint( GTK_WINDOW(m_pWindow), eType );
         gtk_window_set_gravity( GTK_WINDOW(m_pWindow), GDK_GRAVITY_STATIC );
+#endif
         gtk_window_set_resizable( GTK_WINDOW(m_pWindow), bool(nStyle & SalFrameStyleFlags::SIZEABLE) );
 
+#if !GTK_CHECK_VERSION(4,0,0)
 #if defined(GDK_WINDOWING_WAYLAND)
         //rhbz#1392145 under wayland/csd if we've overridden the default widget direction in order to set LibreOffice's
         //UI to the configured ui language but the system ui locale is a different text direction, then the toplevel
@@ -1170,30 +1263,37 @@ void GtkSalFrame::Init( SalFrame* pParent, SalFrameStyleFlags nStyle )
                 gtk_widget_show(GTK_WIDGET(m_pHeaderBar));
             }
         }
+#endif
 #endif
     }
+#if !GTK_CHECK_VERSION(4,0,0)
     else if( nStyle & SalFrameStyleFlags::FLOAT )
         gtk_window_set_type_hint( GTK_WINDOW(m_pWindow), GDK_WINDOW_TYPE_HINT_POPUP_MENU );
+#endif
 
     InitCommon();
 
+#if !GTK_CHECK_VERSION(4,0,0)
     if( eWinType == GTK_WINDOW_TOPLEVEL )
     {
         // Enable DBus native menu if available.
         ensure_dbus_setup( this );
-
     }
+#endif
 }
 
+#if !GTK_CHECK_VERSION(4,0,0)
 GdkNativeWindow GtkSalFrame::findTopLevelSystemWindow( GdkNativeWindow )
 {
     //FIXME: no findToplevelSystemWindow
     return 0;
 }
+#endif
 
 void GtkSalFrame::Init( SystemParentData* pSysData )
 {
     m_pParent = nullptr;
+#if !GTK_CHECK_VERSION(4,0,0)
     m_aForeignParentWindow = pSysData->aWindow;
     m_pForeignParent = nullptr;
     m_aForeignTopLevelWindow = findTopLevelSystemWindow(pSysData->aWindow);
@@ -1211,11 +1311,16 @@ void GtkSalFrame::Init( SystemParentData* pSysData )
     {
         m_pWindow = gtk_window_new( GTK_WINDOW_POPUP );
     }
+#endif
     m_nStyle = SalFrameStyleFlags::PLUG;
     InitCommon();
 
+#if !GTK_CHECK_VERSION(4,0,0)
     m_pForeignParent = gdk_x11_window_foreign_new_for_display( getGdkDisplay(), m_aForeignParentWindow );
     gdk_window_set_events( m_pForeignParent, GDK_STRUCTURE_MASK );
+#else
+    (void)pSysData;
+#endif
 
     //FIXME: Handling embedded windows, is going to be fun ...
 }
@@ -1262,8 +1367,10 @@ void GtkSalFrame::SetTitle( const OUString& rTitle )
     {
         OString sTitle(OUStringToOString(rTitle, RTL_TEXTENCODING_UTF8));
         gtk_window_set_title(GTK_WINDOW(m_pWindow), sTitle.getStr());
+#if !GTK_CHECK_VERSION(4,0,0)
         if (m_pHeaderBar)
             gtk_header_bar_set_title(m_pHeaderBar, sTitle.getStr());
+#endif
     }
 }
 
@@ -1271,6 +1378,7 @@ void GtkSalFrame::SetIcon(const char* appicon)
 {
     gtk_window_set_icon_name(GTK_WINDOW(m_pWindow), appicon);
 
+#if !GTK_CHECK_VERSION(4,0,0)
 #if defined(GDK_WINDOWING_WAYLAND)
     if (DLSYM_GDK_IS_WAYLAND_DISPLAY(getGdkDisplay()))
     {
@@ -1287,6 +1395,7 @@ void GtkSalFrame::SetIcon(const char* appicon)
         }
     }
 #endif
+#endif
 }
 
 void GtkSalFrame::SetIcon( sal_uInt16 nIcon )
@@ -1335,10 +1444,12 @@ void GtkSalFrame::Center()
 {
     if (!GTK_IS_WINDOW(m_pWindow))
         return;
+#if !GTK_CHECK_VERSION(4,0,0)
     if (m_pParent)
         gtk_window_set_position(GTK_WINDOW(m_pWindow), GTK_WIN_POS_CENTER_ON_PARENT);
     else
         gtk_window_set_position(GTK_WINDOW(m_pWindow), GTK_WIN_POS_CENTER);
+#endif
 }
 
 Size GtkSalFrame::calcDefaultSize()
@@ -1452,6 +1563,7 @@ void GtkSalFrame::setMinMaxSize()
     if( !m_pWindow || isChild() )
         return;
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
     GdkGeometry aGeo;
     int aHints = 0;
     if( m_nStyle & SalFrameStyleFlags::SIZEABLE )
@@ -1496,6 +1608,7 @@ void GtkSalFrame::setMinMaxSize()
                                        &aGeo,
                                        GdkWindowHints( aHints ) );
     }
+#endif
 }
 
 void GtkSalFrame::SetMaxClientSize( tools::Long nWidth, tools::Long nHeight )
@@ -1534,10 +1647,17 @@ void GtkSalFrame::AllocateFrame()
     if (m_pSurface)
         cairo_surface_destroy(m_pSurface);
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
     m_pSurface = gdk_window_create_similar_surface(gtk_widget_get_window(m_pWindow),
                                                    CAIRO_CONTENT_COLOR_ALPHA,
                                                    aFrameSize.getX(),
                                                    aFrameSize.getY());
+#else
+    m_pSurface = gdk_surface_create_similar_surface(gtk_native_get_surface(gtk_widget_get_native(m_pWindow)),
+                                                    CAIRO_CONTENT_COLOR_ALPHA,
+                                                    aFrameSize.getX(),
+                                                    aFrameSize.getY());
+#endif
     m_aFrameSize = aFrameSize;
 
     cairo_surface_set_user_data(m_pSurface, SvpSalGraphics::getDamageKey(), &m_aDamageHandler, nullptr);
@@ -1568,8 +1688,10 @@ void GtkSalFrame::SetPosSize( tools::Long nX, tools::Long nY, tools::Long nWidth
 
         if( isChild( false ) )
             widget_set_size_request(nWidth, nHeight);
+#if !GTK_CHECK_VERSION(4, 0, 0)
         else if( ! ( m_nState & GDK_WINDOW_STATE_MAXIMIZED ) )
             window_resize(nWidth, nHeight);
+#endif
 
         setMinMaxSize();
     }
@@ -1608,6 +1730,7 @@ void GtkSalFrame::SetPosSize( tools::Long nX, tools::Long nY, tools::Long nWidth
 
 void GtkSalFrame::GetClientSize( tools::Long& rWidth, tools::Long& rHeight )
 {
+#if !GTK_CHECK_VERSION(4, 0, 0)
     if( m_pWindow && !(m_nState & GDK_WINDOW_STATE_ICONIFIED) )
     {
         rWidth = maGeometry.nWidth;
@@ -1615,10 +1738,15 @@ void GtkSalFrame::GetClientSize( tools::Long& rWidth, tools::Long& rHeight )
     }
     else
         rWidth = rHeight = 0;
+#else
+    rWidth = maGeometry.nWidth;
+    rHeight = maGeometry.nHeight;
+#endif
 }
 
 void GtkSalFrame::GetWorkArea( tools::Rectangle& rRect )
 {
+#if !GTK_CHECK_VERSION(4, 0, 0)
     GdkScreen  *pScreen = gtk_widget_get_screen(m_pWindow);
     tools::Rectangle aRetRect;
     int max = gdk_screen_get_n_monitors (pScreen);
@@ -1630,6 +1758,9 @@ void GtkSalFrame::GetWorkArea( tools::Rectangle& rRect )
         aRetRect.Union(aMonitorRect);
     }
     rRect = aRetRect;
+#else
+    (void)rRect;
+#endif
 }
 
 SalFrame* GtkSalFrame::GetParent() const
@@ -1642,6 +1773,7 @@ void GtkSalFrame::SetWindowState( const SalFrameState* pState )
     if( ! m_pWindow || ! pState || isChild( true, false ) )
         return;
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
     const WindowStateMask nMaxGeometryMask =
         WindowStateMask::X | WindowStateMask::Y |
         WindowStateMask::Width | WindowStateMask::Height |
@@ -1683,12 +1815,14 @@ void GtkSalFrame::SetWindowState( const SalFrameState* pState )
             nPosSizeFlags |= SAL_FRAME_POSSIZE_HEIGHT;
         SetPosSize( nX, nY, pState->mnWidth, pState->mnHeight, nPosSizeFlags );
     }
+#endif
     if( pState->mnMask & WindowStateMask::State && ! isChild() )
     {
         if( pState->mnState & WindowStateState::Maximized )
             gtk_window_maximize( GTK_WINDOW(m_pWindow) );
         else
             gtk_window_unmaximize( GTK_WINDOW(m_pWindow) );
+#if !GTK_CHECK_VERSION(4, 0, 0)
         /* #i42379# there is no rollup state in GDK; and rolled up windows are
         *  (probably depending on the WM) reported as iconified. If we iconify a
         *  window here that was e.g. a dialog, then it will be unmapped but still
@@ -1702,10 +1836,12 @@ void GtkSalFrame::SetWindowState( const SalFrameState* pState )
             gtk_window_iconify( GTK_WINDOW(m_pWindow) );
         else
             gtk_window_deiconify( GTK_WINDOW(m_pWindow) );
+#endif
     }
     TriggerPaintEvent();
 }
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
 namespace
 {
     void GetPosAndSize(GtkWindow *pWindow, tools::Long& rX, tools::Long &rY, tools::Long &rWidth, tools::Long &rHeight)
@@ -1727,11 +1863,13 @@ namespace
         return tools::Rectangle(nX, nY, nX + nWidth, nY + nHeight);
     }
 }
+#endif
 
 bool GtkSalFrame::GetWindowState( SalFrameState* pState )
 {
     pState->mnState = WindowStateState::Normal;
     pState->mnMask  = WindowStateMask::State;
+#if !GTK_CHECK_VERSION(4, 0, 0)
     // rollup ? gtk 2.2 does not seem to support the shaded state
     if( m_nState & GDK_WINDOW_STATE_ICONIFIED )
         pState->mnState |= WindowStateState::Minimized;
@@ -1754,6 +1892,7 @@ bool GtkSalFrame::GetWindowState( SalFrameState* pState )
         GetPosAndSize(GTK_WINDOW(m_pWindow), pState->mnX, pState->mnY,
                                              pState->mnWidth, pState->mnHeight);
     }
+#endif
     pState->mnMask  |= WindowStateMask::X            |
                        WindowStateMask::Y            |
                        WindowStateMask::Width        |
@@ -1764,6 +1903,7 @@ bool GtkSalFrame::GetWindowState( SalFrameState* pState )
 
 void GtkSalFrame::SetScreen( unsigned int nNewScreen, SetType eType, tools::Rectangle const *pSize )
 {
+#if !GTK_CHECK_VERSION(4, 0, 0)
     if( !m_pWindow )
         return;
 
@@ -1907,6 +2047,11 @@ void GtkSalFrame::SetScreen( unsigned int nNewScreen, SetType eType, tools::Rect
 
     if( bVisible )
         Show( true );
+#else
+    (void)nNewScreen;
+    (void)eType;
+    (void)pSize;
+#endif
 }
 
 void GtkSalFrame::SetScreenNumber( unsigned int nNewScreen )
@@ -1916,6 +2061,7 @@ void GtkSalFrame::SetScreenNumber( unsigned int nNewScreen )
 
 void GtkSalFrame::updateWMClass()
 {
+#if !GTK_CHECK_VERSION(4, 0, 0)
     OString aResClass = OUStringToOString(m_sWMClass, RTL_TEXTENCODING_ASCII_US);
     const char *pResClass = !aResClass.isEmpty() ? aResClass.getStr() :
                                                     SalGenericSystem::getFrameClassName();
@@ -1937,6 +2083,7 @@ void GtkSalFrame::updateWMClass()
                        pClass );
         XFree( pClass );
     }
+#endif
 }
 
 void GtkSalFrame::SetApplicationID( const OUString &rWMClass )
@@ -1960,7 +2107,9 @@ void GtkSalFrame::ShowFullScreen( bool bFullScreen, sal_Int32 nScreen )
 
     if( bFullScreen )
     {
+#if !GTK_CHECK_VERSION(4, 0, 0)
         m_aRestorePosSize = GetPosAndSize(GTK_WINDOW(m_pWindow));
+#endif
         SetScreen( nScreen, SetType::Fullscreen );
     }
     else
@@ -1975,11 +2124,13 @@ void GtkSalFrame::StartPresentation( bool bStart )
 {
     std::optional<guint> aWindow;
     std::optional<Display*> aDisplay;
+#if !GTK_CHECK_VERSION(4, 0, 0)
     if( getDisplay()->IsX11Display() )
     {
         aWindow = widget_get_xid(m_pWindow);
         aDisplay = GDK_DISPLAY_XDISPLAY( getGdkDisplay() );
     }
+#endif
 
     m_ScreenSaverInhibitor.inhibit( bStart,
                                     u"presentation",
@@ -1990,8 +2141,12 @@ void GtkSalFrame::StartPresentation( bool bStart )
 
 void GtkSalFrame::SetAlwaysOnTop( bool bOnTop )
 {
+#if !GTK_CHECK_VERSION(4, 0, 0)
     if( m_pWindow )
         gtk_window_set_keep_above( GTK_WINDOW( m_pWindow ), bOnTop );
+#else
+    (void)bOnTop;
+#endif
 }
 
 static guint32 nLastUserInputTime = GDK_CURRENT_TIME;
@@ -2028,8 +2183,10 @@ void GtkSalFrame::ToTop( SalFrameToTop nFlags )
 #endif
         if (!(nFlags & SalFrameToTop::GrabFocusOnly))
             gtk_window_present_with_time(GTK_WINDOW(m_pWindow), nTimestamp);
+#if !GTK_CHECK_VERSION(4, 0, 0)
         else
             gdk_window_focus(gtk_widget_get_window(m_pWindow), nTimestamp);
+#endif
         GrabFocus();
     }
     else
@@ -2046,7 +2203,11 @@ void GtkSalFrame::SetPointer( PointerStyle ePointerStyle )
 
     m_ePointerStyle = ePointerStyle;
     GdkCursor *pCursor = getDisplay()->getCursor( ePointerStyle );
+#if !GTK_CHECK_VERSION(4, 0, 0)
     gdk_window_set_cursor( gtk_widget_get_window(m_pWindow), pCursor );
+#else
+    gtk_widget_set_cursor(GTK_WIDGET(m_pWindow), pCursor);
+#endif
 
     // #i80791# use grabPointer the same way as CaptureMouse, respective float grab
     if( getDisplay()->MouseCaptured( this ) )
@@ -2071,6 +2232,7 @@ void GtkSalFrame::grabPointer( bool bGrab, bool bKeyboardAlso, bool bOwnerEvents
     if (!m_pWindow)
         return;
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
     GdkSeat* pSeat = gdk_display_get_default_seat(getGdkDisplay());
     if (bGrab)
     {
@@ -2082,6 +2244,10 @@ void GtkSalFrame::grabPointer( bool bGrab, bool bKeyboardAlso, bool bOwnerEvents
     {
         gdk_seat_ungrab(pSeat);
     }
+#else
+    (void)bKeyboardAlso;
+    (void)bOwnerEvents;
+#endif
 }
 
 void GtkSalFrame::CaptureMouse( bool bCapture )
@@ -2097,6 +2263,7 @@ void GtkSalFrame::SetPointerPos( tools::Long nX, tools::Long nY )
     if( ! pFrame )
         return;
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
     GdkScreen *pScreen = gtk_widget_get_screen(pFrame->m_pWindow);
     GdkDisplay *pDisplay = gdk_screen_get_display( pScreen );
 
@@ -2113,6 +2280,10 @@ void GtkSalFrame::SetPointerPos( tools::Long nX, tools::Long nY )
     gint x, y;
     GdkModifierType mask;
     gdk_window_get_pointer( gtk_widget_get_window(pFrame->m_pWindow) , &x, &y, &mask );
+#else
+    (void)nX;
+    (void)nY;
+#endif
 }
 
 void GtkSalFrame::Flush()
@@ -2136,7 +2307,13 @@ void GtkSalFrame::KeyCodeToGdkKey(const vcl::KeyCode& rKeyCode,
         nModifiers = static_cast<GdkModifierType>( nModifiers | GDK_CONTROL_MASK );
 
     if ( rKeyCode.IsMod2() )
+    {
+#if !GTK_CHECK_VERSION(4, 0, 0)
         nModifiers = static_cast<GdkModifierType>( nModifiers | GDK_MOD1_MASK );
+#else
+        nModifiers = static_cast<GdkModifierType>( nModifiers | GDK_ALT_MASK );
+#endif
+    }
 
     *pGdkModifiers = nModifiers;
 
@@ -2228,12 +2405,14 @@ GtkSalDisplay *GtkSalFrame::getDisplay()
 SalFrame::SalPointerState GtkSalFrame::GetPointerState()
 {
     SalPointerState aState;
+#if !GTK_CHECK_VERSION(4, 0, 0)
     GdkScreen* pScreen;
     gint x, y;
     GdkModifierType aMask;
     gdk_display_get_pointer( getGdkDisplay(), &pScreen, &x, &y, &aMask );
     aState.maPos = Point( x - maGeometry.nX, y - maGeometry.nY );
     aState.mnState = GetMouseModCode( aMask );
+#endif
     return aState;
 }
 
@@ -2241,6 +2420,7 @@ KeyIndicatorState GtkSalFrame::GetIndicatorState()
 {
     KeyIndicatorState nState = KeyIndicatorState::NONE;
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
     GdkKeymap *pKeyMap = gdk_keymap_get_for_display(getGdkDisplay());
 
     if (gdk_keymap_get_caps_lock_state(pKeyMap))
@@ -2249,6 +2429,7 @@ KeyIndicatorState GtkSalFrame::GetIndicatorState()
         nState |= KeyIndicatorState::NUMLOCK;
     if (gdk_keymap_get_scroll_lock_state(pKeyMap))
         nState |= KeyIndicatorState::SCROLLLOCK;
+#endif
 
     return nState;
 }
@@ -2360,8 +2541,10 @@ bool GtkSalFrame::SetPluginParent( SystemParentData* )
 
 void GtkSalFrame::ResetClipRegion()
 {
+#if !GTK_CHECK_VERSION(4, 0, 0)
     if( m_pWindow )
         gdk_window_shape_combine_region( gtk_widget_get_window( m_pWindow ), nullptr, 0, 0 );
+#endif
 }
 
 void GtkSalFrame::BeginSetClipRegion( sal_uInt32 )
@@ -2386,8 +2569,10 @@ void GtkSalFrame::UnionClipRegion( tools::Long nX, tools::Long nY, tools::Long n
 
 void GtkSalFrame::EndSetClipRegion()
 {
+#if !GTK_CHECK_VERSION(4, 0, 0)
     if( m_pWindow && m_pRegion )
         gdk_window_shape_combine_region( gtk_widget_get_window(m_pWindow), m_pRegion, 0, 0 );
+#endif
 }
 
 void GtkSalFrame::PositionByToolkit(const tools::Rectangle& rRect, FloatWinPopupFlags nFlags)
@@ -2414,6 +2599,7 @@ bool GtkSalFrame::GetModal() const
     return gtk_window_get_modal(GTK_WINDOW(m_pWindow));
 }
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
 gboolean GtkSalFrame::signalTooltipQuery(GtkWidget*, gint /*x*/, gint /*y*/,
                                      gboolean /*keyboard_mode*/, GtkTooltip *tooltip,
                                      gpointer frame)
@@ -2433,6 +2619,7 @@ gboolean GtkSalFrame::signalTooltipQuery(GtkWidget*, gint /*x*/, gint /*y*/,
     gtk_tooltip_set_tip_area(tooltip, &aHelpArea);
     return true;
 }
+#endif
 
 bool GtkSalFrame::ShowTooltip(const OUString& rHelpText, const tools::Rectangle& rHelpArea)
 {
@@ -2488,10 +2675,19 @@ namespace
 
 void* GtkSalFrame::ShowPopover(const OUString& rHelpText, vcl::Window* pParent, const tools::Rectangle& rHelpArea, QuickHelpFlags nFlags)
 {
+#if !GTK_CHECK_VERSION(4, 0, 0)
     GtkWidget *pWidget = gtk_popover_new(getMouseEventWidget());
+#else
+    GtkWidget *pWidget = gtk_popover_new();
+    gtk_widget_set_parent(pWidget, getMouseEventWidget());
+#endif
     OString sUTF = OUStringToOString(rHelpText, RTL_TEXTENCODING_UTF8);
     GtkWidget *pLabel =  gtk_label_new(sUTF.getStr());
+#if !GTK_CHECK_VERSION(4, 0, 0)
     gtk_container_add(GTK_CONTAINER(pWidget), pLabel);
+#else
+    gtk_popover_set_child(GTK_POPOVER(pWidget), pLabel);
+#endif
 
     if (nFlags & QuickHelpFlags::Top)
         gtk_popover_set_position(GTK_POPOVER(pWidget), GTK_POS_BOTTOM);
@@ -2504,9 +2700,17 @@ void* GtkSalFrame::ShowPopover(const OUString& rHelpText, vcl::Window* pParent,
 
     set_pointing_to(GTK_POPOVER(pWidget), pParent, rHelpArea, maGeometry);
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
     gtk_popover_set_modal(GTK_POPOVER(pWidget), false);
+#else
+    gtk_popover_set_autohide(GTK_POPOVER(pWidget), false);
+#endif
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
     gtk_widget_show_all(pWidget);
+#else
+    gtk_widget_show(pWidget);
+#endif
 
     return pWidget;
 }
@@ -2517,7 +2721,11 @@ bool GtkSalFrame::UpdatePopover(void* nId, const OUString& rHelpText, vcl::Windo
 
     set_pointing_to(GTK_POPOVER(pWidget), pParent, rHelpArea, maGeometry);
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
     GtkWidget *pLabel = gtk_bin_get_child(GTK_BIN(pWidget));
+#else
+    GtkWidget *pLabel = gtk_popover_get_child(GTK_POPOVER(pWidget));
+#endif
     OString sUTF = OUStringToOString(rHelpText, RTL_TEXTENCODING_UTF8);
     gtk_label_set_text(GTK_LABEL(pLabel), sUTF.getStr());
 
@@ -2527,14 +2735,20 @@ bool GtkSalFrame::UpdatePopover(void* nId, const OUString& rHelpText, vcl::Windo
 bool GtkSalFrame::HidePopover(void* nId)
 {
     GtkWidget *pWidget = static_cast<GtkWidget*>(nId);
+#if !GTK_CHECK_VERSION(4, 0, 0)
     gtk_widget_destroy(pWidget);
+#else
+    g_clear_pointer(&pWidget, gtk_widget_unparent);
+#endif
     return true;
 }
 
 void GtkSalFrame::addGrabLevel()
 {
+#if !GTK_CHECK_VERSION(4, 0, 0)
     if (m_nGrabLevel == 0)
         gtk_grab_add(getMouseEventWidget());
+#endif
     ++m_nGrabLevel;
 }
 
@@ -2543,8 +2757,10 @@ void GtkSalFrame::removeGrabLevel()
     if (m_nGrabLevel > 0)
     {
         --m_nGrabLevel;
+#if !GTK_CHECK_VERSION(4, 0, 0)
         if (m_nGrabLevel == 0)
             gtk_grab_remove(getMouseEventWidget());
+#endif
     }
 }
 
@@ -2560,6 +2776,7 @@ void GtkSalFrame::closePopup()
     pSVData->mpWinData->mpFirstFloat->EndPopupMode(FloatWinPopupEndFlags::Cancel | FloatWinPopupEndFlags::CloseAll);
 }
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
 namespace
 {
     //tdf#117981 translate embedded video window mouse events to parent coordinates
@@ -2574,14 +2791,19 @@ namespace
         }
     }
 }
+#endif
 
 void GtkSalFrame::GrabFocus()
 {
     GtkWidget* pGrabWidget;
+#if !GTK_CHECK_VERSION(4, 0, 0)
     if (GTK_IS_EVENT_BOX(m_pWindow))
         pGrabWidget = GTK_WIDGET(m_pWindow);
     else
         pGrabWidget = GTK_WIDGET(m_pFixedContainer);
+#else
+    pGrabWidget = GTK_WIDGET(m_pFixedContainer);
+#endif
     // m_nSetFocusSignalId is 0 for the DisallowCycleFocusOut case where
     // we don't allow focus to enter the toplevel, but expect it to
     // stay in some embedded native gtk widget
@@ -2595,6 +2817,7 @@ void GtkSalFrame::GrabFocus()
     }
 }
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
 gboolean GtkSalFrame::signalButton(GtkWidget*, GdkEventButton* pEvent, gpointer frame)
 {
     UpdateLastInputEventTime(pEvent->time);
@@ -2706,9 +2929,11 @@ void GtkSalFrame::LaunchAsyncScroll(GdkEvent const * pEvent)
     if (!m_aSmoothScrollIdle.IsActive())
         m_aSmoothScrollIdle.Start();
 }
+#endif
 
 IMPL_LINK_NOARG(GtkSalFrame, AsyncScroll, Timer *, void)
 {
+#if !GTK_CHECK_VERSION(4, 0, 0)
     assert(!m_aPendingScrollEvents.empty());
 
     SalWheelMouseEvent aEvent;
@@ -2757,8 +2982,10 @@ IMPL_LINK_NOARG(GtkSalFrame, AsyncScroll, Timer *, void)
         aEvent.mnScrollLines = std::abs(aEvent.mnDelta) / 40.0;
         CallCallbackExc(SalEvent::WheelMouse, &aEvent);
     }
+#endif
 }
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
 SalWheelMouseEvent GtkSalFrame::GetWheelEvent(const GdkEventScroll& rEvent)
 {
     SalWheelMouseEvent aEvent;
@@ -2954,6 +3181,7 @@ gboolean GtkSalFrame::signalCrossing( GtkWidget*, GdkEventCrossing* pEvent, gpoi
 
     return true;
 }
+#endif
 
 cairo_t* GtkSalFrame::getCairoContext() const
 {
@@ -2980,11 +3208,18 @@ void GtkSalFrame::damaged(sal_Int32 nExtentsX, sal_Int32 nExtentsY,
     if (nExtentsWidth <= 0 || nExtentsHeight <= 0)
         return;
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
     gtk_widget_queue_draw_area(GTK_WIDGET(m_pFixedContainer),
                                nExtentsX, nExtentsY,
                                nExtentsWidth, nExtentsHeight);
+#else
+    gtk_widget_queue_draw(GTK_WIDGET(m_pFixedContainer));
+    (void)nExtentsX;
+    (void)nExtentsY;
+#endif
 }
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
 // blit our backing cairo surface to the target cairo context
 gboolean GtkSalFrame::signalDraw(GtkWidget*, cairo_t *cr, gpointer frame)
 {
@@ -3118,6 +3353,7 @@ gboolean GtkSalFrame::signalConfigure(GtkWidget*, GdkEventConfigure* pEvent, gpo
 
     return false;
 }
+#endif
 
 void GtkSalFrame::TriggerPaintEvent()
 {
@@ -3139,6 +3375,7 @@ void GtkSalFrame::TriggerPaintEvent()
     gtk_widget_queue_draw(GTK_WIDGET(m_pFixedContainer));
 }
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
 gboolean GtkSalFrame::signalFocus( GtkWidget*, GdkEventFocus* pEvent, gpointer frame )
 {
     GtkSalFrame* pThis = static_cast<GtkSalFrame*>(frame);
@@ -3514,7 +3751,9 @@ gboolean GtkSalFrame::signalWindowState( GtkWidget*, GdkEvent* pEvent, gpointer
 
     return false;
 }
+#endif
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
 namespace
 {
     GdkDragAction VclToGdk(sal_Int8 dragOperation)
@@ -3558,10 +3797,12 @@ namespace
         return eAct;
     }
 }
+#endif
 
 static bool g_DropSuccessSet = false;
 static bool g_DropSuccess = false;
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
 namespace {
 
 class GtkDropTargetDropContext : public cppu::WeakImplHelper<css::datatransfer::dnd::XDropTargetDropContext>
@@ -3598,7 +3839,9 @@ public:
 };
 
 }
+#endif
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
 class GtkDnDTransferable : public GtkTransferable
 {
     GdkDragContext *m_pContext;
@@ -3640,9 +3883,13 @@ public:
 
             if (g_main_loop_is_running(m_pLoop))
             {
+#if !GTK_CHECK_VERSION(4, 0, 0)
                 gdk_threads_leave();
+#endif
                 g_main_loop_run(m_pLoop);
+#if !GTK_CHECK_VERSION(4, 0, 0)
                 gdk_threads_enter();
+#endif
             }
 
             g_main_loop_unref(m_pLoop);
@@ -3693,11 +3940,13 @@ public:
         g_main_loop_quit(m_pLoop);
     }
 };
+#endif
 
 // For LibreOffice internal D&D we provide the Transferable without Gtk
 // intermediaries as a shortcut, see tdf#100097 for how dbaccess depends on this
 GtkInstDragSource* GtkInstDragSource::g_ActiveDragSource;
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
 gboolean GtkSalFrame::signalDragDrop(GtkWidget* pWidget, GdkDragContext* context, gint x, gint y, guint time, gpointer frame)
 {
     GtkSalFrame* pThis = static_cast<GtkSalFrame*>(frame);
@@ -3747,7 +3996,9 @@ gboolean GtkInstDropTarget::signalDragDrop(GtkWidget* pWidget, GdkDragContext* c
 
     return true;
 }
+#endif
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
 namespace {
 
 class GtkDropTargetDragContext : public cppu::WeakImplHelper<css::datatransfer::dnd::XDropTargetDragContext>
@@ -3773,7 +4024,9 @@ public:
 };
 
 }
+#endif
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
 void GtkSalFrame::signalDragDropReceived(GtkWidget* pWidget, GdkDragContext* context, gint x, gint y, GtkSelectionData* data, guint ttype, guint time, gpointer frame)
 {
     GtkSalFrame* pThis = static_cast<GtkSalFrame*>(frame);
@@ -3923,6 +4176,7 @@ void GtkSalFrame::signalDestroy( GtkWidget* pObj, gpointer frame )
     pThis->m_xFrameWeld.reset();
     pThis->InvalidateGraphics();
 }
+#endif
 
 // GtkSalFrame::IMHandler
 
@@ -3964,7 +4218,9 @@ void GtkSalFrame::IMHandler::createIMContext()
                       G_CALLBACK (signalIMPreeditEnd), this );
 
     GetGenericUnixSalData()->ErrorTrapPush();
+#if !GTK_CHECK_VERSION(4, 0, 0)
     gtk_im_context_set_client_window(m_pIMContext, gtk_widget_get_window(m_pFrame->getMouseEventWidget()));
+#endif
     gtk_im_context_focus_in( m_pIMContext );
     GetGenericUnixSalData()->ErrorTrapPop();
     m_bFocused = true;
@@ -3977,7 +4233,9 @@ void GtkSalFrame::IMHandler::deleteIMContext()
     {
         // first give IC a chance to deinitialize
         GetGenericUnixSalData()->ErrorTrapPush();
+#if !GTK_CHECK_VERSION(4, 0, 0)
         gtk_im_context_set_client_window( m_pIMContext, nullptr );
+#endif
         GetGenericUnixSalData()->ErrorTrapPop();
         // destroy old IC
         g_object_unref( m_pIMContext );
@@ -4066,6 +4324,7 @@ void GtkSalFrame::IMHandler::focusChanged( bool bFocusIn )
     }
 }
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
 bool GtkSalFrame::IMHandler::handleKeyEvent( GdkEventKey* pEvent )
 {
     vcl::DeletionListener aDel( m_pFrame );
@@ -4239,6 +4498,11 @@ void GtkSalFrame::IMHandler::signalIMCommit( GtkIMContext* /*pContext*/, gchar*
         }
     }
 }
+#else
+void GtkSalFrame::IMHandler::signalIMCommit( GtkIMContext* /*pContext*/, gchar* /*pText*/, gpointer /*im_handler*/ )
+{
+}
+#endif
 
 OUString GtkSalFrame::GetPreeditDetails(GtkIMContext* pIMContext, std::vector<ExtTextInputAttr>& rInputFlags, sal_Int32& rCursorPos, sal_uInt8& rCursorFlags)
 {
@@ -4515,6 +4779,7 @@ Size GtkSalDisplay::GetScreenSize( int nDisplayScreen )
 
 sal_uIntPtr GtkSalFrame::GetNativeWindowHandle(GtkWidget *pWidget) const
 {
+#if !GTK_CHECK_VERSION(4, 0, 0)
     (void) this;                // Silence loplugin:staticmethods
     GdkDisplay *pDisplay = getGdkDisplay();
     GdkWindow *pWindow = gtk_widget_get_window(pWidget);
@@ -4530,6 +4795,9 @@ sal_uIntPtr GtkSalFrame::GetNativeWindowHandle(GtkWidget *pWidget) const
     {
         return reinterpret_cast<sal_uIntPtr>(gdk_wayland_window_get_wl_surface(pWindow));
     }
+#endif
+#else
+    (void)pWidget;
 #endif
     return 0;
 }
@@ -4550,16 +4818,19 @@ void GtkInstDragSource::setActiveDragSource()
    g_DropSuccess = false;
 }
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
 std::vector<GtkTargetEntry> GtkInstDragSource::FormatsToGtk(const css::uno::Sequence<css::datatransfer::DataFlavor> &rFormats)
 {
     return m_aConversionHelper.FormatsToGtk(rFormats);
 }
+#endif
 
 void GtkInstDragSource::startDrag(const datatransfer::dnd::DragGestureEvent& rEvent,
                               sal_Int8 sourceActions, sal_Int32 /*cursor*/, sal_Int32 /*image*/,
                               const css::uno::Reference<css::datatransfer::XTransferable>& rTrans,
                               const css::uno::Reference<css::datatransfer::dnd::XDragSourceListener>& rListener)
 {
+#if !GTK_CHECK_VERSION(4, 0, 0)
     set_datatransfer(rTrans, rListener);
 
     if (m_pFrame)
@@ -4591,8 +4862,15 @@ void GtkInstDragSource::startDrag(const datatransfer::dnd::DragGestureEvent& rEv
     }
     else
         dragFailed();
+#else
+    (void)rEvent;
+    (void)sourceActions;
+    (void)rTrans;
+    (void)rListener;
+#endif
 }
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
 void GtkSalFrame::startDrag(gint nButton, gint nDragOriginX, gint nDragOriginY,
                             GdkDragAction sourceActions, GtkTargetList* pTargetList)
 {
@@ -4703,6 +4981,7 @@ void GtkSalFrame::signalDragDataGet(GtkWidget* /*widget*/, GdkDragContext* /*con
         return;
     pThis->m_pDragSource->dragDataGet(data, info);
 }
+#endif
 
 bool GtkSalFrame::CallCallbackExc(SalEvent nEvent, const void* pEvent) const
 {
@@ -4719,6 +4998,7 @@ bool GtkSalFrame::CallCallbackExc(SalEvent nEvent, const void* pEvent) const
     return nRet;
 }
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
 void GtkSalFrame::nopaint_container_resize_children(GtkContainer *pContainer)
 {
     bool bOrigSalObjectSetPosSize = m_bSalObjectSetPosSize;
@@ -4726,9 +5006,11 @@ void GtkSalFrame::nopaint_container_resize_children(GtkContainer *pContainer)
     gtk_container_resize_children(pContainer);
     m_bSalObjectSetPosSize = bOrigSalObjectSetPosSize;
 }
+#endif
 
 GdkEvent* GtkSalFrame::makeFakeKeyPress(GtkWidget* pWidget)
 {
+#if !GTK_CHECK_VERSION(4, 0, 0)
     GdkEvent *event = gdk_event_new(GDK_KEY_PRESS);
     event->key.window = GDK_WINDOW(g_object_ref(gtk_widget_get_window(pWidget)));
 
@@ -4745,6 +5027,10 @@ GdkEvent* GtkSalFrame::makeFakeKeyPress(GtkWidget* pWidget)
     event->key.group = 0;
     event->key.is_modifier = false;
     return event;
+#else
+    (void)pWidget;
+    return nullptr;
+#endif
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index 485ed1d8c387..c696627af246 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -41,7 +41,9 @@
 #include <fcntl.h>
 #include <unistd.h>
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
 #include "a11y/atkwrapper.hxx"
+#endif
 #include <com/sun/star/lang/IllegalArgumentException.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
@@ -97,6 +99,7 @@ using namespace com::sun::star::lang;
 extern "C"
 {
     #define GET_YIELD_MUTEX() static_cast<GtkYieldMutex*>(GetSalData()->m_pInstance->GetYieldMutex())
+#if !GTK_CHECK_VERSION(4, 0, 0)
     static void GdkThreadsEnter()
     {
         GtkYieldMutex *pYieldMutex = GET_YIELD_MUTEX();
@@ -107,15 +110,16 @@ extern "C"
         GtkYieldMutex *pYieldMutex = GET_YIELD_MUTEX();
         pYieldMutex->ThreadsLeave();
     }
+#endif
 
     VCLPLUG_GTK_PUBLIC SalInstance* create_SalInstance()
     {
         SAL_INFO(
             "vcl.gtk",
-            "create vcl plugin instance with gtk version " << gtk_major_version
-                << " " << gtk_minor_version << " " << gtk_micro_version);
+            "create vcl plugin instance with gtk version " << gtk_get_major_version()
+                << " " << gtk_get_minor_version() << " " << gtk_get_micro_version());
 
-        if (gtk_major_version == 3 && gtk_minor_version < 18)
+        if (gtk_get_major_version() == 3 && gtk_get_minor_version() < 18)
         {
             g_warning("require gtk >= 3.18 for theme expectations");
             return nullptr;
@@ -145,12 +149,16 @@ extern "C"
         if ( !sup )
             g_thread_init( nullptr );
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
         gdk_threads_set_lock_functions (GdkThreadsEnter, GdkThreadsLeave);
+#endif
         SAL_INFO("vcl.gtk", "Hooked gdk threads locks");
 
         auto pYieldMutex = std::make_unique<GtkYieldMutex>();
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
         gdk_threads_init();
+#endif
 
         GtkInstance* pInstance = new GtkInstance( std::move(pYieldMutex) );
         SAL_INFO("vcl.gtk", "creating GtkInstance " << pInstance);
@@ -162,15 +170,18 @@ extern "C"
     }
 }
 
-static VclInputFlags categorizeEvent(const GdkEvent *pEvent)
+#if !GTK_CHECK_VERSION(4, 0, 0)
+static VclInputFlags categorizeEvent(GdkEvent *pEvent)
 {
     VclInputFlags nType = VclInputFlags::NONE;
-    switch( pEvent->type )
+    switch (gdk_event_get_event_type(pEvent))
     {
     case GDK_MOTION_NOTIFY:
     case GDK_BUTTON_PRESS:
+#if !GTK_CHECK_VERSION(4, 0, 0)
     case GDK_2BUTTON_PRESS:
     case GDK_3BUTTON_PRESS:
+#endif
     case GDK_BUTTON_RELEASE:
     case GDK_ENTER_NOTIFY:
     case GDK_LEAVE_NOTIFY:
@@ -181,15 +192,18 @@ static VclInputFlags categorizeEvent(const GdkEvent *pEvent)
     // case GDK_KEY_RELEASE: //similar to the X11SalInstance one
         nType = VclInputFlags::KEYBOARD;
         break;
+#if !GTK_CHECK_VERSION(4, 0, 0)
     case GDK_EXPOSE:
         nType = VclInputFlags::PAINT;
         break;
+#endif
     default:
         nType = VclInputFlags::OTHER;
         break;
     }
     return nType;
 }
+#endif
 
 GtkInstance::GtkInstance( std::unique_ptr<SalYieldMutex> pMutex )
     : SvpSalInstance( std::move(pMutex) )
@@ -217,7 +231,9 @@ void GtkInstance::EnsureInit()
     pSalData->Init();
     GtkSalData::initNWF();
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
     InitAtkBridge();
+#endif
 
     ImplSVData* pSVData = ImplGetSVData();
 #ifdef GTK_TOOLKIT_NAME
@@ -232,7 +248,9 @@ void GtkInstance::EnsureInit()
 GtkInstance::~GtkInstance()
 {
     assert( nullptr == m_pTimer );
+#if !GTK_CHECK_VERSION(4, 0, 0)
     DeInitAtkBridge();
+#endif
     ResetLastSeenCairoFontOptions(nullptr);
 }
 
@@ -400,13 +418,16 @@ bool GtkInstance::AnyInput( VclInputFlags nType )
     EnsureInit();
     if( (nType & VclInputFlags::TIMER) && IsTimerExpired() )
         return true;
+#if !GTK_CHECK_VERSION(4, 0, 0)
     if (!gdk_events_pending())
         return false;
+#endif
 
     if (nType == VCL_INPUT_ANY)
         return true;
 
     bool bRet = false;
+#if !GTK_CHECK_VERSION(4, 0, 0)
     std::deque<GdkEvent*> aEvents;
     GdkEvent *pEvent = nullptr;
     while ((pEvent = gdk_event_get()))
@@ -426,6 +447,7 @@ bool GtkInstance::AnyInput( VclInputFlags nType )
         gdk_event_free(pEvent);
         aEvents.pop_front();
     }
+#endif
     return bRet;
 }
 
@@ -437,10 +459,14 @@ std::unique_ptr<GenPspGraphics> GtkInstance::CreatePrintGraphics()
 
 const cairo_font_options_t* GtkInstance::GetCairoFontOptions()
 {
+#if !GTK_CHECK_VERSION(4, 0, 0)
     const cairo_font_options_t* pCairoFontOptions = gdk_screen_get_font_options(gdk_screen_get_default());
     if (!m_pLastCairoFontOptions && pCairoFontOptions)
         m_pLastCairoFontOptions = cairo_font_options_copy(pCairoFontOptions);
     return pCairoFontOptions;
+#else
+    return nullptr;
+#endif
 }
 
 const cairo_font_options_t* GtkInstance::GetLastSeenCairoFontOptions() const
@@ -519,6 +545,7 @@ namespace
     };
 }
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
 std::vector<css::datatransfer::DataFlavor> GtkTransferable::getTransferDataFlavorsAsVector(GdkAtom *targets, gint n_targets)
 {
     std::vector<css::datatransfer::DataFlavor> aVector;
@@ -560,7 +587,9 @@ std::vector<css::datatransfer::DataFlavor> GtkTransferable::getTransferDataFlavo
                                     strlen(pFinalName),
                                     RTL_TEXTENCODING_UTF8);
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
         m_aMimeTypeToAtom[aFlavor.MimeType] = targets[i];
+#endif
 
         aFlavor.DataType = cppu::UnoType<Sequence< sal_Int8 >>::get();
 
@@ -592,7 +621,7 @@ std::vector<css::datatransfer::DataFlavor> GtkTransferable::getTransferDataFlavo
 
     return aVector;
 }
-
+#endif
 
 css::uno::Sequence<css::datatransfer::DataFlavor> SAL_CALL GtkTransferable::getTransferDataFlavors()
 {
@@ -609,6 +638,7 @@ sal_Bool SAL_CALL GtkTransferable::isDataFlavorSupported(const css::datatransfer
 
 namespace {
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
 class GtkClipboardTransferable : public GtkTransferable
 {
 private:
@@ -626,6 +656,8 @@ public:
 
     virtual css::uno::Any SAL_CALL getTransferData(const css::datatransfer::DataFlavor& rFlavor) override
     {
+        css::uno::Any aRet;
+#if !GTK_CHECK_VERSION(4, 0, 0)
         GtkClipboard* clipboard = gtk_clipboard_get(m_nSelection);
         if (rFlavor.MimeType == "text/plain;charset=utf-16")
         {
@@ -634,7 +666,6 @@ public:
             if (pText)
                 aStr = OUString(pText, strlen(pText), RTL_TEXTENCODING_UTF8);
             g_free(pText);
-            css::uno::Any aRet;
             aRet <<= aStr.replaceAll("\r\n", "\n");
             return aRet;
         }
@@ -643,7 +674,6 @@ public:
         if (it == m_aMimeTypeToAtom.end())
             return css::uno::Any();
 
-        css::uno::Any aRet;
         GtkSelectionData* data = gtk_clipboard_wait_for_contents(clipboard,
                                                                  it->second);
         if (!data)
@@ -657,6 +687,7 @@ public:
         gtk_selection_data_free(data);
         aRet <<= aSeq;
         return aRet;
+#endif
     }
 
     std::vector<css::datatransfer::DataFlavor> getTransferDataFlavorsAsVector()
@@ -664,6 +695,7 @@ public:
     {
         std::vector<css::datatransfer::DataFlavor> aVector;
 
+#if !GTK_CHECK_VERSION(4, 0, 0)
         GtkClipboard* clipboard = gtk_clipboard_get(m_nSelection);
 
         GdkAtom *targets;
@@ -673,10 +705,12 @@ public:
             aVector = GtkTransferable::getTransferDataFlavorsAsVector(targets, n_targets);
             g_free(targets);
         }
+#endif
 
         return aVector;
     }
 };
+#endif
 
 class VclGtkClipboard :
         public cppu::WeakComponentImplHelper<
@@ -684,20 +718,30 @@ class VclGtkClipboard :
         datatransfer::clipboard::XFlushableClipboard,
         XServiceInfo>
 {
+#if !GTK_CHECK_VERSION(4, 0, 0)
     GdkAtom                                                  m_nSelection;
+#endif
     osl::Mutex                                               m_aMutex;
+#if !GTK_CHECK_VERSION(4, 0, 0)
     gulong                                                   m_nOwnerChangedSignalId;
+#endif
     ImplSVEvent*                                             m_pSetClipboardEvent;
     Reference<css::datatransfer::XTransferable>              m_aContents;
     Reference<css::datatransfer::clipboard::XClipboardOwner> m_aOwner;
     std::vector< Reference<css::datatransfer::clipboard::XClipboardListener> > m_aListeners;

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list