mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-19 07:37:11 +02:00
Perform additional checks for gtk scaling factor
This commit is contained in:
parent
834ee4eae7
commit
7c031a4fb6
2 changed files with 20 additions and 2 deletions
|
@ -328,6 +328,7 @@ void GtkIntegration::load() {
|
|||
|
||||
if (GtkLoaded) {
|
||||
LOAD_GTK_SYMBOL(lib_gtk, "gdk_display_get_default", gdk_display_get_default);
|
||||
LOAD_GTK_SYMBOL(lib_gtk, "gdk_display_get_monitor", gdk_display_get_monitor);
|
||||
LOAD_GTK_SYMBOL(lib_gtk, "gdk_display_get_primary_monitor", gdk_display_get_primary_monitor);
|
||||
LOAD_GTK_SYMBOL(lib_gtk, "gdk_monitor_get_scale_factor", gdk_monitor_get_scale_factor);
|
||||
|
||||
|
@ -440,13 +441,29 @@ std::optional<QString> GtkIntegration::getStringSetting(
|
|||
std::optional<int> GtkIntegration::scaleFactor() const {
|
||||
if (!loaded()
|
||||
|| (gdk_display_get_default == nullptr)
|
||||
|| (gdk_display_get_monitor == nullptr)
|
||||
|| (gdk_display_get_primary_monitor == nullptr)
|
||||
|| (gdk_monitor_get_scale_factor == nullptr)) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return gdk_monitor_get_scale_factor(
|
||||
gdk_display_get_primary_monitor(gdk_display_get_default()));
|
||||
const auto display = gdk_display_get_default();
|
||||
if (!display) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
const auto monitor = [&] {
|
||||
if (const auto primary = gdk_display_get_primary_monitor(display)) {
|
||||
return primary;
|
||||
}
|
||||
return gdk_display_get_monitor(display, 0);
|
||||
}();
|
||||
|
||||
if (!monitor) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return gdk_monitor_get_scale_factor(monitor);
|
||||
}
|
||||
|
||||
bool GtkIntegration::fileDialogSupported() const {
|
||||
|
|
|
@ -149,6 +149,7 @@ inline bool g_type_cit_helper(Object *instance, GType iface_type) {
|
|||
inline gint (*gtk_dialog_run)(GtkDialog *dialog) = nullptr;
|
||||
inline GdkAtom (*gdk_atom_intern)(const gchar *atom_name, gboolean only_if_exists) = nullptr;
|
||||
inline GdkDisplay* (*gdk_display_get_default)(void) = nullptr;
|
||||
inline GdkMonitor* (*gdk_display_get_monitor)(GdkDisplay *display, int monitor_num) = nullptr;
|
||||
inline GdkMonitor* (*gdk_display_get_primary_monitor)(GdkDisplay *display) = nullptr;
|
||||
inline int (*gdk_monitor_get_scale_factor)(GdkMonitor *monitor) = nullptr;
|
||||
inline GdkPixbuf* (*gdk_pixbuf_new_from_file_at_size)(const gchar *filename, int width, int height, GError **error) = nullptr;
|
||||
|
|
Loading…
Add table
Reference in a new issue