mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-23 16:56:55 +00:00
Move gtk clibpboard to linux_libs
This commit is contained in:
parent
d97880913c
commit
1dcbb103a8
@ -251,6 +251,14 @@ f_gdk_pixbuf_get_rowstride gdk_pixbuf_get_rowstride = nullptr;
|
||||
bool GtkLoaded() {
|
||||
return gtkLoaded;
|
||||
}
|
||||
|
||||
::GtkClipboard *GtkClipboard() {
|
||||
if (gtk_clipboard_get != nullptr) {
|
||||
return gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||
|
||||
void start() {
|
||||
|
@ -31,6 +31,7 @@ namespace Libs {
|
||||
|
||||
#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||
bool GtkLoaded();
|
||||
::GtkClipboard *GtkClipboard();
|
||||
#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||
|
||||
void start();
|
||||
@ -78,16 +79,16 @@ extern f_gtk_widget_hide_on_delete gtk_widget_hide_on_delete;
|
||||
typedef void (*f_gtk_widget_destroy)(GtkWidget *widget);
|
||||
extern f_gtk_widget_destroy gtk_widget_destroy;
|
||||
|
||||
typedef GtkClipboard* (*f_gtk_clipboard_get)(GdkAtom selection);
|
||||
typedef ::GtkClipboard* (*f_gtk_clipboard_get)(GdkAtom selection);
|
||||
extern f_gtk_clipboard_get gtk_clipboard_get;
|
||||
|
||||
typedef void (*f_gtk_clipboard_store)(GtkClipboard *clipboard);
|
||||
typedef void (*f_gtk_clipboard_store)(::GtkClipboard *clipboard);
|
||||
extern f_gtk_clipboard_store gtk_clipboard_store;
|
||||
|
||||
typedef GtkSelectionData* (*f_gtk_clipboard_wait_for_contents)(GtkClipboard *clipboard, GdkAtom target);
|
||||
typedef GtkSelectionData* (*f_gtk_clipboard_wait_for_contents)(::GtkClipboard *clipboard, GdkAtom target);
|
||||
extern f_gtk_clipboard_wait_for_contents gtk_clipboard_wait_for_contents;
|
||||
|
||||
typedef GdkPixbuf* (*f_gtk_clipboard_wait_for_image)(GtkClipboard *clipboard);
|
||||
typedef GdkPixbuf* (*f_gtk_clipboard_wait_for_image)(::GtkClipboard *clipboard);
|
||||
extern f_gtk_clipboard_wait_for_image gtk_clipboard_wait_for_image;
|
||||
|
||||
typedef gboolean (*f_gtk_selection_data_targets_include_image)(const GtkSelectionData *selection_data, gboolean writable);
|
||||
|
@ -8,10 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "platform/linux/main_window_linux.h"
|
||||
|
||||
#include "styles/style_window.h"
|
||||
#include "platform/linux/linux_libs.h"
|
||||
#include "platform/linux/specific_linux.h"
|
||||
#include "platform/linux/linux_desktop_environment.h"
|
||||
#include "platform/platform_notifications_manager.h"
|
||||
#include "history/history.h"
|
||||
#include "history/history_widget.h"
|
||||
#include "history/history_inner_widget.h"
|
||||
@ -416,12 +413,6 @@ void ForceDisabled(QAction *action, bool disabled) {
|
||||
|
||||
MainWindow::MainWindow(not_null<Window::Controller*> controller)
|
||||
: Window::MainWindow(controller) {
|
||||
#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||
if (GtkClipboardSupported()) {
|
||||
_gtkClipboard = Libs::gtk_clipboard_get(
|
||||
Libs::gdk_atom_intern("CLIPBOARD", true));
|
||||
}
|
||||
#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||
}
|
||||
|
||||
void MainWindow::initHook() {
|
||||
|
@ -18,11 +18,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include <dbusmenuexporter.h>
|
||||
#endif
|
||||
|
||||
#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||
typedef struct _GtkClipboard GtkClipboard;
|
||||
#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||
|
||||
|
||||
namespace Platform {
|
||||
|
||||
class MainWindow : public Window::MainWindow {
|
||||
@ -75,12 +70,6 @@ public slots:
|
||||
|
||||
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||
|
||||
#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||
GtkClipboard *gtkClipboard() {
|
||||
return _gtkClipboard;
|
||||
}
|
||||
#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||
|
||||
protected:
|
||||
void initHook() override;
|
||||
void unreadCounterChangedHook() override;
|
||||
@ -144,10 +133,6 @@ private:
|
||||
void attachToSNITrayIcon();
|
||||
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||
|
||||
#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||
GtkClipboard *_gtkClipboard = nullptr;
|
||||
#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||
|
||||
};
|
||||
|
||||
} // namespace Platform
|
||||
|
@ -283,6 +283,21 @@ bool GenerateDesktopFile(
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||
bool GetImageFromClipboardSupported() {
|
||||
return (Libs::gtk_clipboard_wait_for_contents != nullptr)
|
||||
&& (Libs::gtk_clipboard_wait_for_image != nullptr)
|
||||
&& (Libs::gtk_selection_data_targets_include_image != nullptr)
|
||||
&& (Libs::gtk_selection_data_free != nullptr)
|
||||
&& (Libs::gdk_pixbuf_get_pixels != nullptr)
|
||||
&& (Libs::gdk_pixbuf_get_width != nullptr)
|
||||
&& (Libs::gdk_pixbuf_get_height != nullptr)
|
||||
&& (Libs::gdk_pixbuf_get_rowstride != nullptr)
|
||||
&& (Libs::gdk_pixbuf_get_has_alpha != nullptr)
|
||||
&& (Libs::gdk_atom_intern != nullptr);
|
||||
}
|
||||
#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||
|
||||
std::optional<crl::time> XCBLastUserInputTime() {
|
||||
if (const auto native = QGuiApplication::platformNativeInterface()) {
|
||||
const auto connection = reinterpret_cast<xcb_connection_t*>(
|
||||
@ -793,40 +808,22 @@ QString GetIconName() {
|
||||
return Result;
|
||||
}
|
||||
|
||||
bool GtkClipboardSupported() {
|
||||
#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||
return (Libs::gtk_clipboard_get != nullptr)
|
||||
&& (Libs::gtk_clipboard_wait_for_contents != nullptr)
|
||||
&& (Libs::gtk_clipboard_wait_for_image != nullptr)
|
||||
&& (Libs::gtk_selection_data_targets_include_image != nullptr)
|
||||
&& (Libs::gtk_selection_data_free != nullptr)
|
||||
&& (Libs::gdk_pixbuf_get_pixels != nullptr)
|
||||
&& (Libs::gdk_pixbuf_get_width != nullptr)
|
||||
&& (Libs::gdk_pixbuf_get_height != nullptr)
|
||||
&& (Libs::gdk_pixbuf_get_rowstride != nullptr)
|
||||
&& (Libs::gdk_pixbuf_get_has_alpha != nullptr)
|
||||
&& (Libs::gdk_atom_intern != nullptr);
|
||||
#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
QImage GetImageFromClipboard() {
|
||||
QImage data;
|
||||
|
||||
#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||
if (!GtkClipboardSupported() || !App::wnd()->gtkClipboard()) {
|
||||
if (!GetImageFromClipboardSupported() || !Libs::GtkClipboard()) {
|
||||
return data;
|
||||
}
|
||||
|
||||
auto gsel = Libs::gtk_clipboard_wait_for_contents(
|
||||
App::wnd()->gtkClipboard(),
|
||||
Libs::GtkClipboard(),
|
||||
Libs::gdk_atom_intern("TARGETS", true));
|
||||
|
||||
if (gsel) {
|
||||
if (Libs::gtk_selection_data_targets_include_image(gsel, false)) {
|
||||
auto img = Libs::gtk_clipboard_wait_for_image(
|
||||
App::wnd()->gtkClipboard());
|
||||
Libs::GtkClipboard());
|
||||
|
||||
if (img) {
|
||||
data = QImage(
|
||||
|
@ -42,7 +42,6 @@ QString GetIconName();
|
||||
inline void IgnoreApplicationActivationRightNow() {
|
||||
}
|
||||
|
||||
bool GtkClipboardSupported();
|
||||
void SetTrayIconSupported(bool supported);
|
||||
void InstallMainDesktopFile();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user