From 257f2086d1e8aee94fb4975603dab5408af015cc Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Thu, 24 Jun 2021 08:57:27 +0400 Subject: [PATCH] Get rid of gtk2 header compatibility --- Telegram/CMakeLists.txt | 2 +- .../platform/linux/linux_gdk_helper.cpp | 23 ++++--------------- .../platform/linux/linux_gtk_integration_p.h | 4 ---- 3 files changed, 6 insertions(+), 23 deletions(-) diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index b29f795a74..e7ffe0af23 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -125,7 +125,7 @@ if (LINUX) target_link_libraries(Telegram PRIVATE PkgConfig::X11) endif() else() - pkg_search_module(GTK REQUIRED gtk+-3.0 gtk+-2.0) + pkg_check_modules(GTK REQUIRED gtk+-3.0) target_include_directories(Telegram PRIVATE ${GTK_INCLUDE_DIRS}) if (NOT DESKTOP_APP_DISABLE_X11_INTEGRATION) diff --git a/Telegram/SourceFiles/platform/linux/linux_gdk_helper.cpp b/Telegram/SourceFiles/platform/linux/linux_gdk_helper.cpp index 3834c8c72e..c19149fc28 100644 --- a/Telegram/SourceFiles/platform/linux/linux_gdk_helper.cpp +++ b/Telegram/SourceFiles/platform/linux/linux_gdk_helper.cpp @@ -20,13 +20,11 @@ extern "C" { } // extern "C" #endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION -// CentOS 7 seem to be too old for needed definitions, -// so don't include until we link to gtk directly. -#if !defined DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION && defined LINK_TO_GTK +#ifndef DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION extern "C" { #include } // extern "C" -#endif // !DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION && LINK_TO_GTK +#endif // !DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION namespace Platform { namespace internal { @@ -36,7 +34,7 @@ using base::Platform::GtkIntegration; using namespace Platform::Gtk; #ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION -// To be able to compile with gtk-3.0 headers as well +// To be able to compile with gtk-3.0 headers #define GdkDrawable GdkWindow // Gtk 2 @@ -50,12 +48,6 @@ f_gdk_x11_drawable_get_xid gdk_x11_drawable_get_xid = nullptr; using f_gdk_x11_window_get_type = GType (*)(void); f_gdk_x11_window_get_type gdk_x11_window_get_type = nullptr; -// To be able to compile with gtk-2.0 headers as well -template -inline bool gdk_is_x11_window_check(Object *obj) { - return g_type_cit_helper(obj, gdk_x11_window_get_type()); -} - using f_gdk_window_get_display = GdkDisplay*(*)(GdkWindow *window); f_gdk_window_get_display gdk_window_get_display = nullptr; @@ -70,11 +62,6 @@ f_gdk_x11_window_get_xid gdk_x11_window_get_xid = nullptr; using f_gdk_wayland_window_get_type = GType (*)(void); f_gdk_wayland_window_get_type gdk_wayland_window_get_type = nullptr; -template -inline bool gdk_is_wayland_window_check(Object *obj) { - return g_type_cit_helper(obj, gdk_wayland_window_get_type()); -} - using f_gdk_wayland_window_set_transient_for_exported = gboolean(*)(GdkWindow *window, char *parent_handle_str); f_gdk_wayland_window_set_transient_for_exported gdk_wayland_window_set_transient_for_exported = nullptr; #endif // !DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION @@ -115,7 +102,7 @@ void GdkSetTransientFor(GdkWindow *window, QWindow *parent) { #ifndef DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION if (gdk_wayland_window_get_type != nullptr && gdk_wayland_window_set_transient_for_exported != nullptr - && gdk_is_wayland_window_check(window)) { + && GDK_IS_WAYLAND_WINDOW(window)) { if (const auto integration = WaylandIntegration::Instance()) { if (const auto handle = integration->nativeHandle(parent) ; !handle.isEmpty()) { @@ -134,7 +121,7 @@ void GdkSetTransientFor(GdkWindow *window, QWindow *parent) { && gdk_x11_display_get_xdisplay != nullptr && gdk_x11_window_get_xid != nullptr && gdk_window_get_display != nullptr - && gdk_is_x11_window_check(window)) { + && GDK_IS_X11_WINDOW(window)) { XSetTransientForHint( gdk_x11_display_get_xdisplay(gdk_window_get_display(window)), gdk_x11_window_get_xid(window), diff --git a/Telegram/SourceFiles/platform/linux/linux_gtk_integration_p.h b/Telegram/SourceFiles/platform/linux/linux_gtk_integration_p.h index 66ace0eb3a..c3544c2ef5 100644 --- a/Telegram/SourceFiles/platform/linux/linux_gtk_integration_p.h +++ b/Telegram/SourceFiles/platform/linux/linux_gtk_integration_p.h @@ -12,10 +12,6 @@ extern "C" { #include } // extern "C" -// To be able to compile with gtk-2.0 headers as well -typedef struct _GdkMonitor GdkMonitor; -typedef struct _GtkAppChooser GtkAppChooser; - namespace Platform { namespace Gtk {