diff --git a/VERSION.cmake b/VERSION.cmake index 1804a58b..456823c1 100644 --- a/VERSION.cmake +++ b/VERSION.cmake @@ -1,5 +1,5 @@ SET( VERSION_MAJOR "2" ) SET( VERSION_MINOR "52" ) -SET( VERSION_PATCH "1" ) +SET( VERSION_PATCH "2" ) SET( VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}${VERSION_SHA1}" ) diff --git a/package/libyui-gtk.changes b/package/libyui-gtk.changes index b1d8b237..7fa3deaa 100644 --- a/package/libyui-gtk.changes +++ b/package/libyui-gtk.changes @@ -1,3 +1,13 @@ +------------------------------------------------------------------- +Sun Sep 25 19:07:11 CEST 2022 - anaselli@linux.it +- Changed displayWidth/displayHeight implementation For GTK3 + suggestion is to get the GdkWindow out of the GtkWindow widget + with gtk_widget_get_window(), and then use + gdk_display_get_monitor_at_window() + This fixes dnfdragora bug https://github.com/manatools/dnfdragora/issues/207 + when it runs on Gnome desktop. +- 2.51.2 + ------------------------------------------------------------------- Sun Jul 11 15:27:20 CET 2021 - anaselli@linux.it - Fixed CMAKE_INSTALL_LIBDIR for pkgconfig diff --git a/package/libyui-gtk.spec b/package/libyui-gtk.spec index d39f8466..158f18d0 100644 --- a/package/libyui-gtk.spec +++ b/package/libyui-gtk.spec @@ -17,7 +17,7 @@ Name: libyui-gtk -Version: 2.52.1 +Version: 2.52.2 Release: 0 Source: %{name}-%{version}.tar.bz2 diff --git a/src/YGDialog.cc b/src/YGDialog.cc index b9a06486..b11a4498 100644 --- a/src/YGDialog.cc +++ b/src/YGDialog.cc @@ -364,18 +364,19 @@ void YGDialog::present() YGDialog *YGDialog::currentDialog() { - YDialog *ydialog = YDialog::currentDialog (false); - if (ydialog) - return static_cast (ydialog); - return NULL; + YDialog *ydialog = YDialog::currentDialog (false); + if (ydialog) + return dynamic_cast (ydialog); + return NULL; } GtkWindow *YGDialog::currentWindow() { - YGDialog *ydialog = YGDialog::currentDialog(); - if (ydialog) - return GTK_WINDOW (ydialog->m_window->getWidget()); - return NULL; + YGDialog *ydialog = YGDialog::currentDialog(); + if (ydialog) + if (ydialog->m_window && GTK_IS_WINDOW(ydialog->m_window->getWidget())) + return GTK_WINDOW (ydialog->m_window->getWidget()); + return NULL; } void YGDialog::setCloseCallback (YGWindowCloseFn canClose, void *canCloseData) diff --git a/src/YGUI.cc b/src/YGUI.cc index 42a7ecb9..2c107116 100644 --- a/src/YGUI.cc +++ b/src/YGUI.cc @@ -639,25 +639,68 @@ float YGApplication::layoutUnits (YUIDimension dim, int units) static inline GdkScreen *getScreen () { return gdk_display_get_default_screen (gdk_display_get_default()); } + // GTK doesn't seem to have some desktopWidth/Height like Qt, so we to report // a reduced display size to compensate for the panel, or the window frame +// +// * For GTK3 get the GdkWindow out of the GtkWindow widget with gtk_widget_get_window(), +// and then use gdk_display_get_monitor_at_window() +// +// The idea was to use YGDialog::currentWindow() but it next function is used in the YGDialog +// constructor and the pointer is not reliable and sometimes crashes (To be investigated more) +// Example of code is the next: +// GdkMonitor * pMonitor = NULL; +// GtkWindow* pWindow = YGDialog::currentWindow(); +// GtkWidget *widget = NULL; +// if (pWindow) +// { +// widget = GTK_WIDGET (pWindow); +// } +// if (widget) { +// pMonitor = gdk_display_get_monitor_at_window ( +// gdk_display_get_default(), +// gtk_widget_get_window(widget) +// ); +// } +static inline GdkMonitor * getGdkMonitor() +{ + GdkMonitor * pMonitor = gdk_display_get_monitor_at_window ( + gdk_display_get_default(), + gdk_get_default_root_window () + ); + + return pMonitor; +} + int YGApplication::displayWidth() { - GdkRectangle monitor; - gdk_monitor_get_geometry ( - gdk_display_get_primary_monitor(gdk_display_get_default()), - &monitor); - return monitor.width; + GdkMonitor * pMonitor = getGdkMonitor(); + + if (pMonitor) + { + GdkRectangle geometry; + gdk_monitor_get_geometry (pMonitor, &geometry); + + return geometry.width; + } + + return 640; } int YGApplication::displayHeight() { - GdkRectangle monitor; - gdk_monitor_get_geometry ( - gdk_display_get_primary_monitor (gdk_display_get_default()), - &monitor); - return monitor.height; + GdkMonitor * pMonitor = getGdkMonitor(); + + if (pMonitor) + { + GdkRectangle geometry; + gdk_monitor_get_geometry (pMonitor, &geometry); + + return geometry.height; + } + + return 480; } int YGApplication::displayDepth() @@ -676,16 +719,20 @@ long YGApplication::displayColors() // Get default size as in Qt as much as possible int YGApplication::defaultWidth() { + GdkMonitor * pMonitor = getGdkMonitor(); + GdkRectangle availableSize = {0}; - gdk_monitor_get_workarea( - gdk_display_get_primary_monitor(gdk_display_get_default()), - &availableSize); + + if (pMonitor) + { + gdk_monitor_get_workarea(pMonitor, &availableSize); + } int width = availableSize.width; if ( displayWidth() >= 1024 ) { // Scale down to 70% of screen size - width = std::max( (int) (availableSize.width * 0.7), 800 ) ; + width = std::max( (int) (availableSize.width * 0.7), 1024 ) ; } return width; @@ -693,16 +740,20 @@ int YGApplication::defaultWidth() int YGApplication::defaultHeight() { - GdkRectangle availableSize = {0}; - gdk_monitor_get_workarea( - gdk_display_get_primary_monitor(gdk_display_get_default()), - &availableSize); + GdkMonitor * pMonitor = getGdkMonitor(); + + GdkRectangle availableSize = {0}; + + if (pMonitor) + { + gdk_monitor_get_workarea(pMonitor, &availableSize); + } int height = availableSize.height; - if ( displayWidth() >= 1024 ) + if ( displayHeight() >= 768 ) { // Scale down to 70% of screen size - height = std::max( (int) (availableSize.height * 0.7), 600 ) ; + height = std::max( (int) (availableSize.height * 0.7), 768 ) ; } return height;