Get rid of gtk2 header compatibility

This commit is contained in:
Ilya Fedin 2021-06-24 08:57:27 +04:00 committed by John Preston
parent f011c84ce8
commit 257f2086d1
3 changed files with 6 additions and 23 deletions

View File

@ -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)

View File

@ -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 <gdk/gdkwayland.h>
} // 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 <typename Object>
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 <typename Object>
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),

View File

@ -12,10 +12,6 @@ extern "C" {
#include <gdk/gdk.h>
} // 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 {