[gnome-software: 49/110] Adapt to GdkMonitor API changes




commit 398720b467aff9d47429a65c9d04d18021a745c4
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Tue Aug 24 10:51:12 2021 -0300

    Adapt to GdkMonitor API changes

 src/gs-hardware-support-context-dialog.c | 15 ++++++++-------
 src/gs-shell.c                           | 15 +++++++++------
 2 files changed, 17 insertions(+), 13 deletions(-)
---
diff --git a/src/gs-hardware-support-context-dialog.c b/src/gs-hardware-support-context-dialog.c
index 849787a7b..f4a049803 100644
--- a/src/gs-hardware-support-context-dialog.c
+++ b/src/gs-hardware-support-context-dialog.c
@@ -161,17 +161,20 @@ add_relation_row (GtkListBox                   *list_box,
 GdkMonitor *
 gs_hardware_support_context_dialog_get_largest_monitor (GdkDisplay *display)
 {
+       GListModel *monitors;  /* (unowned) */
        GdkMonitor *monitor;  /* (unowned) */
-       int n_monitors, monitor_max_dimension;
+       int monitor_max_dimension;
+       guint n_monitors;
 
        g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
 
-       n_monitors = gdk_display_get_n_monitors (display);
+       monitors = gdk_display_get_monitors (display);
+       n_monitors = g_list_model_get_n_items (monitors);
        monitor_max_dimension = 0;
        monitor = NULL;
 
-       for (int i = 0; i < n_monitors; i++) {
-               GdkMonitor *monitor2 = gdk_display_get_monitor (display, i);
+       for (guint i = 0; i < n_monitors; i++) {
+               g_autoptr(GdkMonitor) monitor2 = g_list_model_get_item (monitors, i);
                GdkRectangle monitor_geometry;
                int monitor2_max_dimension;
 
@@ -181,9 +184,7 @@ gs_hardware_support_context_dialog_get_largest_monitor (GdkDisplay *display)
                gdk_monitor_get_geometry (monitor2, &monitor_geometry);
                monitor2_max_dimension = MAX (monitor_geometry.width, monitor_geometry.height);
 
-               if (monitor2_max_dimension > monitor_max_dimension ||
-                   (gdk_monitor_is_primary (monitor2) &&
-                    monitor2_max_dimension == monitor_max_dimension)) {
+               if (monitor2_max_dimension > monitor_max_dimension) {
                        monitor = monitor2;
                        monitor_max_dimension = monitor2_max_dimension;
                        continue;
diff --git a/src/gs-shell.c b/src/gs-shell.c
index 077760b7f..4d1ae4c19 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -1065,18 +1065,21 @@ static void
 gs_shell_main_window_realized_cb (GtkWidget *widget, GsShell *shell)
 {
        GdkRectangle geometry;
+       GdkSurface *surface;
        GdkDisplay *display;
        GdkMonitor *monitor;
 
        display = gtk_widget_get_display (GTK_WIDGET (shell));
-       monitor = gdk_display_get_monitor_at_window (display,
-                                                    gtk_widget_get_window (GTK_WIDGET (shell)));
+       surface = gtk_native_get_surface (GTK_NATIVE (shell));
+       monitor = gdk_display_get_monitor_at_surface (display, surface);
 
        /* adapt the window for low and medium resolution screens */
-       gdk_monitor_get_geometry (monitor, &geometry);
-       if (geometry.width < 800 || geometry.height < 600) {
-       } else if (geometry.width < 1366 || geometry.height < 768) {
-               gtk_window_set_default_size (GTK_WINDOW (shell), 1050, 600);
+       if (monitor != NULL) {
+               gdk_monitor_get_geometry (monitor, &geometry);
+               if (geometry.width < 800 || geometry.height < 600) {
+               } else if (geometry.width < 1366 || geometry.height < 768) {
+                       gtk_window_set_default_size (GTK_WINDOW (shell), 1050, 600);
+               }
        }
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]