mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-06 23:24:01 +02:00
Move gtk clibpboard to linux_libs
This commit is contained in:
parent
d97880913c
commit
1dcbb103a8
6 changed files with 31 additions and 50 deletions
|
@ -251,6 +251,14 @@ f_gdk_pixbuf_get_rowstride gdk_pixbuf_get_rowstride = nullptr;
|
||||||
bool GtkLoaded() {
|
bool GtkLoaded() {
|
||||||
return gtkLoaded;
|
return gtkLoaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
::GtkClipboard *GtkClipboard() {
|
||||||
|
if (gtk_clipboard_get != nullptr) {
|
||||||
|
return gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION
|
#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||||
|
|
||||||
void start() {
|
void start() {
|
||||||
|
|
|
@ -31,6 +31,7 @@ namespace Libs {
|
||||||
|
|
||||||
#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION
|
#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||||
bool GtkLoaded();
|
bool GtkLoaded();
|
||||||
|
::GtkClipboard *GtkClipboard();
|
||||||
#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION
|
#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||||
|
|
||||||
void start();
|
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);
|
typedef void (*f_gtk_widget_destroy)(GtkWidget *widget);
|
||||||
extern f_gtk_widget_destroy gtk_widget_destroy;
|
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;
|
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;
|
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;
|
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;
|
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);
|
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 "platform/linux/main_window_linux.h"
|
||||||
|
|
||||||
#include "styles/style_window.h"
|
#include "styles/style_window.h"
|
||||||
#include "platform/linux/linux_libs.h"
|
|
||||||
#include "platform/linux/specific_linux.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.h"
|
||||||
#include "history/history_widget.h"
|
#include "history/history_widget.h"
|
||||||
#include "history/history_inner_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)
|
MainWindow::MainWindow(not_null<Window::Controller*> controller)
|
||||||
: Window::MainWindow(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() {
|
void MainWindow::initHook() {
|
||||||
|
|
|
@ -18,11 +18,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include <dbusmenuexporter.h>
|
#include <dbusmenuexporter.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION
|
|
||||||
typedef struct _GtkClipboard GtkClipboard;
|
|
||||||
#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION
|
|
||||||
|
|
||||||
|
|
||||||
namespace Platform {
|
namespace Platform {
|
||||||
|
|
||||||
class MainWindow : public Window::MainWindow {
|
class MainWindow : public Window::MainWindow {
|
||||||
|
@ -75,12 +70,6 @@ public slots:
|
||||||
|
|
||||||
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||||
|
|
||||||
#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION
|
|
||||||
GtkClipboard *gtkClipboard() {
|
|
||||||
return _gtkClipboard;
|
|
||||||
}
|
|
||||||
#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void initHook() override;
|
void initHook() override;
|
||||||
void unreadCounterChangedHook() override;
|
void unreadCounterChangedHook() override;
|
||||||
|
@ -144,10 +133,6 @@ private:
|
||||||
void attachToSNITrayIcon();
|
void attachToSNITrayIcon();
|
||||||
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||||
|
|
||||||
#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION
|
|
||||||
GtkClipboard *_gtkClipboard = nullptr;
|
|
||||||
#endif // !TDESKTOP_DISABLE_GTK_INTEGRATION
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Platform
|
} // 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() {
|
std::optional<crl::time> XCBLastUserInputTime() {
|
||||||
if (const auto native = QGuiApplication::platformNativeInterface()) {
|
if (const auto native = QGuiApplication::platformNativeInterface()) {
|
||||||
const auto connection = reinterpret_cast<xcb_connection_t*>(
|
const auto connection = reinterpret_cast<xcb_connection_t*>(
|
||||||
|
@ -793,40 +808,22 @@ QString GetIconName() {
|
||||||
return Result;
|
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 GetImageFromClipboard() {
|
||||||
QImage data;
|
QImage data;
|
||||||
|
|
||||||
#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION
|
#ifndef TDESKTOP_DISABLE_GTK_INTEGRATION
|
||||||
if (!GtkClipboardSupported() || !App::wnd()->gtkClipboard()) {
|
if (!GetImageFromClipboardSupported() || !Libs::GtkClipboard()) {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto gsel = Libs::gtk_clipboard_wait_for_contents(
|
auto gsel = Libs::gtk_clipboard_wait_for_contents(
|
||||||
App::wnd()->gtkClipboard(),
|
Libs::GtkClipboard(),
|
||||||
Libs::gdk_atom_intern("TARGETS", true));
|
Libs::gdk_atom_intern("TARGETS", true));
|
||||||
|
|
||||||
if (gsel) {
|
if (gsel) {
|
||||||
if (Libs::gtk_selection_data_targets_include_image(gsel, false)) {
|
if (Libs::gtk_selection_data_targets_include_image(gsel, false)) {
|
||||||
auto img = Libs::gtk_clipboard_wait_for_image(
|
auto img = Libs::gtk_clipboard_wait_for_image(
|
||||||
App::wnd()->gtkClipboard());
|
Libs::GtkClipboard());
|
||||||
|
|
||||||
if (img) {
|
if (img) {
|
||||||
data = QImage(
|
data = QImage(
|
||||||
|
|
|
@ -42,7 +42,6 @@ QString GetIconName();
|
||||||
inline void IgnoreApplicationActivationRightNow() {
|
inline void IgnoreApplicationActivationRightNow() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GtkClipboardSupported();
|
|
||||||
void SetTrayIconSupported(bool supported);
|
void SetTrayIconSupported(bool supported);
|
||||||
void InstallMainDesktopFile();
|
void InstallMainDesktopFile();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue