2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +00:00

Add DESKTOP_APP_DISABLE_X11_INTEGRATION

This commit is contained in:
Ilya Fedin
2021-02-22 17:41:25 +04:00
committed by John Preston
parent a40a8ac7ee
commit 14b09e88d6
4 changed files with 51 additions and 11 deletions

View File

@@ -10,11 +10,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/platform/linux/base_linux_gtk_integration_p.h"
#include "platform/linux/linux_gtk_integration_p.h"
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
extern "C" {
#undef signals
#include <gdk/gdkx.h>
#define signals public
} // extern "C"
#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION
namespace Platform {
namespace internal {
@@ -29,6 +31,7 @@ enum class GtkLoaded {
GtkLoaded gdk_helper_loaded = GtkLoaded::GtkNone;
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
// To be able to compile with gtk-3.0 headers as well
#define GdkDrawable GdkWindow
@@ -57,8 +60,10 @@ f_gdk_x11_display_get_xdisplay gdk_x11_display_get_xdisplay = nullptr;
using f_gdk_x11_window_get_xid = Window(*)(GdkWindow *window);
f_gdk_x11_window_get_xid gdk_x11_window_get_xid = nullptr;
#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION
bool GdkHelperLoadGtk2(QLibrary &lib) {
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
#ifdef LINK_TO_GTK
return false;
#else // LINK_TO_GTK
@@ -66,14 +71,21 @@ bool GdkHelperLoadGtk2(QLibrary &lib) {
if (!LOAD_GTK_SYMBOL(lib, "gdk_x11_drawable_get_xid", gdk_x11_drawable_get_xid)) return false;
return true;
#endif // !LINK_TO_GTK
#else // !DESKTOP_APP_DISABLE_X11_INTEGRATION
return false;
#endif // DESKTOP_APP_DISABLE_X11_INTEGRATION
}
bool GdkHelperLoadGtk3(QLibrary &lib) {
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
if (!LOAD_GTK_SYMBOL(lib, "gdk_x11_window_get_type", gdk_x11_window_get_type)) return false;
if (!LOAD_GTK_SYMBOL(lib, "gdk_window_get_display", gdk_window_get_display)) return false;
if (!LOAD_GTK_SYMBOL(lib, "gdk_x11_display_get_xdisplay", gdk_x11_display_get_xdisplay)) return false;
if (!LOAD_GTK_SYMBOL(lib, "gdk_x11_window_get_xid", gdk_x11_window_get_xid)) return false;
return true;
#else // !DESKTOP_APP_DISABLE_X11_INTEGRATION
return false;
#endif // DESKTOP_APP_DISABLE_X11_INTEGRATION
}
void GdkHelperLoad(QLibrary &lib) {
@@ -86,10 +98,15 @@ void GdkHelperLoad(QLibrary &lib) {
}
bool GdkHelperLoaded() {
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
return gdk_helper_loaded != GtkLoaded::GtkNone;
#else // !DESKTOP_APP_DISABLE_X11_INTEGRATION
return true;
#endif // DESKTOP_APP_DISABLE_X11_INTEGRATION
}
void XSetTransientForHint(GdkWindow *window, quintptr winId) {
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
if (gdk_helper_loaded == GtkLoaded::Gtk2) {
::XSetTransientForHint(gdk_x11_drawable_get_xdisplay(window),
gdk_x11_drawable_get_xid(window),
@@ -101,6 +118,7 @@ void XSetTransientForHint(GdkWindow *window, quintptr winId) {
winId);
}
}
#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION
}
} // namespace internal

View File

@@ -24,18 +24,21 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "window/window_controller.h"
#include "window/window_session_controller.h"
#include "base/platform/base_platform_info.h"
#include "base/platform/linux/base_linux_xcb_utilities.h"
#include "base/call_delayed.h"
#include "ui/widgets/popup_menu.h"
#include "ui/widgets/input_fields.h"
#include "facades.h"
#include "app.h"
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
#include "base/platform/linux/base_linux_xcb_utilities.h"
#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION
#include <QtCore/QSize>
#include <QtCore/QTemporaryFile>
#include <QtGui/QWindow>
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
#include <QtCore/QTemporaryFile>
#include <QtDBus/QDBusInterface>
#include <QtDBus/QDBusConnection>
#include <QtDBus/QDBusConnectionInterface>
@@ -82,6 +85,7 @@ base::flat_map<int, QImage> TrayIconImageBack;
QIcon TrayIcon;
QString TrayIconThemeName, TrayIconName;
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
bool XCBSkipTaskbar(QWindow *window, bool set) {
const auto connection = base::Platform::XCB::GetConnectionFromQt();
if (!connection) {
@@ -131,11 +135,14 @@ bool XCBSkipTaskbar(QWindow *window, bool set) {
return true;
}
#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION
bool SkipTaskbar(QWindow *window, bool set) {
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
if (!IsWayland()) {
return XCBSkipTaskbar(window, set);
}
#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION
return false;
}

View File

@@ -8,7 +8,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "platform/linux/specific_linux.h"
#include "base/platform/base_platform_info.h"
#include "base/platform/linux/base_linux_xcb_utilities.h"
#include "base/platform/linux/base_linux_gtk_integration.h"
#include "ui/platform/ui_platform_utility.h"
#include "platform/linux/linux_desktop_environment.h"
@@ -24,6 +23,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/update_checker.h"
#include "window/window_controller.h"
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
#include "base/platform/linux/base_linux_xcb_utilities.h"
#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
#include "platform/linux/linux_notification_service_watcher.h"
#include "platform/linux/linux_gsd_media_keys.h"
@@ -577,8 +580,12 @@ bool TrayIconSupported() {
}
bool SkipTaskbarSupported() {
#ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION
return !IsWayland()
&& base::Platform::XCB::IsSupportedByWM("_NET_WM_STATE_SKIP_TASKBAR");
#endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION
return false;
}
} // namespace Platform