[gtk/kill-primary-monitor] Remove primary monitors



commit 5d9efb56753076507ad635d121c28c933aacd5a6
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Jan 3 18:35:30 2020 -0500

    Remove primary monitors
    
    This is not a very successful concept, and Wayland
    does not have it at all, so lets just remove it.
    
    https://gitlab.gnome.org/GNOME/gtk/issues/982

 gdk/broadway/gdkdisplay-broadway.c |  9 -----
 gdk/broadway/gdksurface-broadway.c |  2 +-
 gdk/gdkdisplay.c                   | 34 -----------------
 gdk/gdkdisplay.h                   |  2 -
 gdk/gdkdisplayprivate.h            |  1 -
 gdk/gdkmonitor.c                   | 20 +---------
 gdk/gdkmonitor.h                   |  2 -
 gdk/win32/gdkdisplay-win32.c       | 13 -------
 gdk/x11/gdkcursor-x11.c            |  2 +-
 gdk/x11/gdkdisplay-x11.c           | 12 ------
 gdk/x11/gdkdisplay-x11.h           |  1 -
 gdk/x11/gdkmonitor-x11.c           |  3 +-
 gdk/x11/gdkscreen-x11.c            | 76 --------------------------------------
 gtk/inspector/general.c            |  2 -
 gtk/inspector/visual.c             |  2 +-
 tests/animated-resizing.c          |  2 +-
 16 files changed, 6 insertions(+), 177 deletions(-)
---
diff --git a/gdk/broadway/gdkdisplay-broadway.c b/gdk/broadway/gdkdisplay-broadway.c
index d02ea887b0..69a2d1085e 100644
--- a/gdk/broadway/gdkdisplay-broadway.c
+++ b/gdk/broadway/gdkdisplay-broadway.c
@@ -329,14 +329,6 @@ gdk_broadway_display_get_monitor (GdkDisplay *display,
   return NULL;
 }
 
-static GdkMonitor *
-gdk_broadway_display_get_primary_monitor (GdkDisplay *display)
-{
-  GdkBroadwayDisplay *broadway_display = GDK_BROADWAY_DISPLAY (display);
-
-  return broadway_display->monitor;
-}
-
 static gboolean
 gdk_broadway_display_get_setting (GdkDisplay *display,
                                   const char *name,
@@ -443,7 +435,6 @@ gdk_broadway_display_class_init (GdkBroadwayDisplayClass * class)
 
   display_class->get_n_monitors = gdk_broadway_display_get_n_monitors;
   display_class->get_monitor = gdk_broadway_display_get_monitor;
-  display_class->get_primary_monitor = gdk_broadway_display_get_primary_monitor;
   display_class->get_setting = gdk_broadway_display_get_setting;
   display_class->get_last_seen_time = gdk_broadway_display_get_last_seen_time;
 }
diff --git a/gdk/broadway/gdksurface-broadway.c b/gdk/broadway/gdksurface-broadway.c
index 6229fa12a7..5d2426b687 100644
--- a/gdk/broadway/gdksurface-broadway.c
+++ b/gdk/broadway/gdksurface-broadway.c
@@ -770,7 +770,7 @@ gdk_broadway_surface_maximize (GdkSurface *surface)
   impl->pre_maximize_height = surface->height;
 
   display = gdk_surface_get_display (surface);
-  monitor = gdk_display_get_primary_monitor (display);
+  monitor = gdk_display_get_monitor (display, 0);
   gdk_monitor_get_geometry (monitor, &geom);
 
   gdk_broadway_surface_move_resize (surface,
diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c
index c2a9e26bf7..5eb928bd0c 100644
--- a/gdk/gdkdisplay.c
+++ b/gdk/gdkdisplay.c
@@ -155,12 +155,6 @@ gdk_display_real_get_default_seat (GdkDisplay *display)
   return display->seats->data;
 }
 
-static GdkMonitor *
-gdk_display_real_get_primary_monitor (GdkDisplay *display)
-{
-  return gdk_display_get_monitor (display, 0);
-}
-
 static void
 gdk_display_class_init (GdkDisplayClass *class)
 {
@@ -177,8 +171,6 @@ gdk_display_class_init (GdkDisplayClass *class)
   class->event_data_free = gdk_display_real_event_data_free;
   class->get_default_seat = gdk_display_real_get_default_seat;
 
-  class->get_primary_monitor = gdk_display_real_get_primary_monitor;
-
   /**
    * GdkDisplay:composited:
    *
@@ -1588,32 +1580,6 @@ gdk_display_get_monitor (GdkDisplay *display,
   return GDK_DISPLAY_GET_CLASS (display)->get_monitor (display, monitor_num);
 }
 
-/**
- * gdk_display_get_primary_monitor:
- * @display: a #GdkDisplay
- *
- * Gets the primary monitor for the display.
- *
- * The primary monitor is considered the monitor where the “main desktop”
- * lives. While normal application surfaces typically allow the window
- * manager to place the surfaces, specialized desktop applications
- * such as panels should place themselves on the primary monitor.
- *
- * If no monitor is the designated primary monitor, any monitor
- * (usually the first) may be returned. To make sure there is a dedicated
- * primary monitor, use gdk_monitor_is_primary() on the returned monitor.
- *
- * Returns: (transfer none): the primary monitor, or any monitor if no
- *     primary monitor is configured by the user
- */
-GdkMonitor *
-gdk_display_get_primary_monitor (GdkDisplay *display)
-{
-  g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
-
-  return GDK_DISPLAY_GET_CLASS (display)->get_primary_monitor (display);
-}
-
 /**
  * gdk_display_get_monitor_at_surface:
  * @display: a #GdkDisplay
diff --git a/gdk/gdkdisplay.h b/gdk/gdkdisplay.h
index fed7d86da2..34610aa51b 100644
--- a/gdk/gdkdisplay.h
+++ b/gdk/gdkdisplay.h
@@ -112,8 +112,6 @@ GDK_AVAILABLE_IN_ALL
 GdkMonitor * gdk_display_get_monitor           (GdkDisplay *display,
                                                 int         monitor_num);
 GDK_AVAILABLE_IN_ALL
-GdkMonitor * gdk_display_get_primary_monitor   (GdkDisplay *display);
-GDK_AVAILABLE_IN_ALL
 GdkMonitor * gdk_display_get_monitor_at_surface (GdkDisplay *display,
                                                 GdkSurface  *surface);
 
diff --git a/gdk/gdkdisplayprivate.h b/gdk/gdkdisplayprivate.h
index 8c8b76a8bc..dca4d0fc2d 100644
--- a/gdk/gdkdisplayprivate.h
+++ b/gdk/gdkdisplayprivate.h
@@ -167,7 +167,6 @@ struct _GdkDisplayClass
   int                    (*get_n_monitors)             (GdkDisplay     *display);
   GdkMonitor *           (*get_monitor)                (GdkDisplay     *display,
                                                         int             index);
-  GdkMonitor *           (*get_primary_monitor)        (GdkDisplay     *display);
   GdkMonitor *           (*get_monitor_at_surface)      (GdkDisplay     *display,
                                                         GdkSurface      *surface);
   gboolean               (*get_setting)                (GdkDisplay     *display,
diff --git a/gdk/gdkmonitor.c b/gdk/gdkmonitor.c
index 37e2c872eb..7df2ac3266 100644
--- a/gdk/gdkmonitor.c
+++ b/gdk/gdkmonitor.c
@@ -33,8 +33,7 @@
  * GdkMonitor objects represent the individual outputs that are
  * associated with a #GdkDisplay. GdkDisplay has APIs to enumerate
  * monitors with gdk_display_get_n_monitors() and gdk_display_get_monitor(), and
- * to find particular monitors with gdk_display_get_primary_monitor() or
- * gdk_display_get_monitor_at_surface().
+ * to find particular monitors with gdk_display_get_monitor_at_surface().
  */
 
 /**
@@ -492,23 +491,6 @@ gdk_monitor_get_subpixel_layout (GdkMonitor *monitor)
   return monitor->subpixel_layout;
 }
 
-/**
- * gdk_monitor_is_primary:
- * @monitor: a #GdkMonitor
- *
- * Gets whether this monitor should be considered primary
- * (see gdk_display_get_primary_monitor()).
- *
- * Returns: %TRUE if @monitor is primary
- */
-gboolean
-gdk_monitor_is_primary (GdkMonitor *monitor)
-{
-  g_return_val_if_fail (GDK_IS_MONITOR (monitor), FALSE);
-
-  return monitor == gdk_display_get_primary_monitor (monitor->display);
-}
-
 GdkMonitor *
 gdk_monitor_new (GdkDisplay *display)
 {
diff --git a/gdk/gdkmonitor.h b/gdk/gdkmonitor.h
index 832f7010e9..58592a5c32 100644
--- a/gdk/gdkmonitor.h
+++ b/gdk/gdkmonitor.h
@@ -88,8 +88,6 @@ int               gdk_monitor_get_refresh_rate    (GdkMonitor   *monitor);
 GDK_AVAILABLE_IN_ALL
 GdkSubpixelLayout gdk_monitor_get_subpixel_layout (GdkMonitor   *monitor);
 GDK_AVAILABLE_IN_ALL
-gboolean          gdk_monitor_is_primary          (GdkMonitor   *monitor);
-GDK_AVAILABLE_IN_ALL
 gboolean          gdk_monitor_is_valid            (GdkMonitor   *monitor);
 
 G_END_DECLS
diff --git a/gdk/win32/gdkdisplay-win32.c b/gdk/win32/gdkdisplay-win32.c
index 9cd080012c..b948c3a703 100644
--- a/gdk/win32/gdkdisplay-win32.c
+++ b/gdk/win32/gdkdisplay-win32.c
@@ -980,18 +980,6 @@ gdk_win32_display_get_monitor (GdkDisplay *display,
   return (GdkMonitor *) g_ptr_array_index (win32_display->monitors, monitor_num);
 }
 
-static GdkMonitor *
-gdk_win32_display_get_primary_monitor (GdkDisplay *display)
-{
-  GdkWin32Display *win32_display = GDK_WIN32_DISPLAY (display);
-
-  /* We arrange for the first monitor in the array to also be the primiary monitor */
-  if (win32_display->monitors->len > 0)
-    return (GdkMonitor *) g_ptr_array_index (win32_display->monitors, 0);
-
-  return NULL;
-}
-
 guint
 _gdk_win32_display_get_monitor_scale_factor (GdkWin32Display *win32_display,
                                              HMONITOR         hmonitor,
@@ -1124,7 +1112,6 @@ gdk_win32_display_class_init (GdkWin32DisplayClass *klass)
 
   display_class->get_n_monitors = gdk_win32_display_get_n_monitors;
   display_class->get_monitor = gdk_win32_display_get_monitor;
-  display_class->get_primary_monitor = gdk_win32_display_get_primary_monitor;
 
 #ifdef GDK_RENDERING_VULKAN
   display_class->vk_context_type = GDK_TYPE_WIN32_VULKAN_CONTEXT;
diff --git a/gdk/x11/gdkcursor-x11.c b/gdk/x11/gdkcursor-x11.c
index 6f2682dc40..1f0f37e346 100644
--- a/gdk/x11/gdkcursor-x11.c
+++ b/gdk/x11/gdkcursor-x11.c
@@ -176,7 +176,7 @@ gdk_x11_cursor_create_for_texture (GdkDisplay *display,
   int target_scale;
 
   target_scale =
-    gdk_monitor_get_scale_factor (gdk_display_get_primary_monitor (display));
+    gdk_monitor_get_scale_factor (gdk_display_get_monitor (display, 0));
   xcimage = create_cursor_image (texture, x, y, target_scale);
   xcursor = XcursorImageLoadCursor (GDK_DISPLAY_XDISPLAY (display), xcimage);
   XcursorImageDestroy (xcimage);
diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c
index fdfbecbf7c..9ab67045fb 100644
--- a/gdk/x11/gdkdisplay-x11.c
+++ b/gdk/x11/gdkdisplay-x11.c
@@ -2956,17 +2956,6 @@ gdk_x11_display_get_monitor (GdkDisplay *display,
   return NULL;
 }
 
-static GdkMonitor *
-gdk_x11_display_get_primary_monitor (GdkDisplay *display)
-{
-  GdkX11Display *x11_display = GDK_X11_DISPLAY (display);
-
-  if (0 <= x11_display->primary_monitor && x11_display->primary_monitor < x11_display->monitors->len)
-    return x11_display->monitors->pdata[x11_display->primary_monitor];
-
-  return NULL;
-}
-
 int
 gdk_x11_display_get_window_depth (GdkX11Display *display)
 {
@@ -3062,7 +3051,6 @@ gdk_x11_display_class_init (GdkX11DisplayClass * class)
 
   display_class->get_n_monitors = gdk_x11_display_get_n_monitors;
   display_class->get_monitor = gdk_x11_display_get_monitor;
-  display_class->get_primary_monitor = gdk_x11_display_get_primary_monitor;
   display_class->get_setting = gdk_x11_display_get_setting;
   display_class->get_last_seen_time = gdk_x11_display_get_last_seen_time;
   display_class->set_cursor_theme = gdk_x11_display_set_cursor_theme;
diff --git a/gdk/x11/gdkdisplay-x11.h b/gdk/x11/gdkdisplay-x11.h
index c326b6a23e..a2e4ab08e0 100644
--- a/gdk/x11/gdkdisplay-x11.h
+++ b/gdk/x11/gdkdisplay-x11.h
@@ -115,7 +115,6 @@ struct _GdkX11Display
   GHashTable *cursors;
 
   GPtrArray *monitors;
-  int primary_monitor;
 
   /* Startup notification */
   gchar *startup_notification_id;
diff --git a/gdk/x11/gdkmonitor-x11.c b/gdk/x11/gdkmonitor-x11.c
index 34d88e98f8..9b75297132 100644
--- a/gdk/x11/gdkmonitor-x11.c
+++ b/gdk/x11/gdkmonitor-x11.c
@@ -73,8 +73,7 @@ gdk_x11_monitor_get_workarea (GdkMonitor   *monitor,
    * but the primary monitor. Since that is where the 'desktop
    * chrome' usually lives, this works ok in practice.
    */
-  if (gdk_monitor_is_primary (monitor) &&
-      !gdk_monitor_has_fullscreen_window (monitor))
+  if (!gdk_monitor_has_fullscreen_window (monitor))
     {
       gdk_x11_screen_get_work_area (screen, &workarea);
       if (gdk_rectangle_intersect (dest, &workarea, &workarea))
diff --git a/gdk/x11/gdkscreen-x11.c b/gdk/x11/gdkscreen-x11.c
index ffba0708f7..9960c252b6 100644
--- a/gdk/x11/gdkscreen-x11.c
+++ b/gdk/x11/gdkscreen-x11.c
@@ -317,12 +317,9 @@ init_randr15 (GdkX11Screen *x11_screen, gboolean *changed)
   GdkDisplay *display = GDK_SCREEN_DISPLAY (x11_screen);
   GdkX11Display *x11_display = GDK_X11_DISPLAY (display);
   XRRScreenResources *resources;
-  RROutput primary_output = None;
-  RROutput first_output = None;
   int i;
   XRRMonitorInfo *rr_monitors;
   int num_rr_monitors;
-  int old_primary;
 
   if (!x11_display->have_randr15)
     return FALSE;
@@ -371,9 +368,6 @@ init_randr15 (GdkX11Screen *x11_screen, gboolean *changed)
           continue;
         }
 
-      if (first_output == None)
-        first_output = output;
-
       if (output_info->crtc)
         {
           XRRCrtcInfo *crtc = XRRGetCrtcInfo (x11_screen->xdisplay, resources, output_info->crtc);
@@ -482,9 +476,6 @@ init_randr15 (GdkX11Screen *x11_screen, gboolean *changed)
       g_free (manufacturer);
       g_free (name);
 
-      if (rr_monitors[i].primary)
-        primary_output = monitor->output;
-
       XRRFreeOutputInfo (output_info);
     }
 
@@ -509,33 +500,6 @@ init_randr15 (GdkX11Screen *x11_screen, gboolean *changed)
         }
     }
 
-  old_primary = x11_display->primary_monitor;
-  x11_display->primary_monitor = 0;
-  for (i = 0; i < x11_display->monitors->len; ++i)
-    {
-      GdkX11Monitor *monitor = x11_display->monitors->pdata[i];
-      if (monitor->output == primary_output)
-        {
-          x11_display->primary_monitor = i;
-          break;
-        }
-
-      /* No RandR1.3+ available or no primary set, fall back to prefer LVDS as primary if present */
-      if (primary_output == None &&
-          g_ascii_strncasecmp (gdk_monitor_get_model (GDK_MONITOR (monitor)), "LVDS", 4) == 0)
-        {
-          x11_display->primary_monitor = i;
-          break;
-        }
-
-      /* No primary specified and no LVDS found */
-      if (monitor->output == first_output)
-        x11_display->primary_monitor = i;
-    }
-
-  if (x11_display->primary_monitor != old_primary)
-    *changed = TRUE;
-
   return x11_display->monitors->len > 0;
 #endif
 
@@ -549,10 +513,7 @@ init_randr13 (GdkX11Screen *x11_screen, gboolean *changed)
   GdkDisplay *display = GDK_SCREEN_DISPLAY (x11_screen);
   GdkX11Display *x11_display = GDK_X11_DISPLAY (display);
   XRRScreenResources *resources;
-  RROutput primary_output = None;
-  RROutput first_output = None;
   int i;
-  int old_primary;
 
   if (!x11_display->have_randr13)
       return FALSE;
@@ -651,9 +612,6 @@ init_randr13 (GdkX11Screen *x11_screen, gboolean *changed)
       XRRFreeOutputInfo (output_info);
     }
 
-  if (resources->noutput > 0)
-    first_output = resources->outputs[0];
-
   XRRFreeScreenResources (resources);
 
   /* Which usable multihead data is not returned in non RandR 1.2+ X driver? */
@@ -676,36 +634,6 @@ init_randr13 (GdkX11Screen *x11_screen, gboolean *changed)
         }
     }
 
-  old_primary = x11_display->primary_monitor;
-  x11_display->primary_monitor = 0;
-  primary_output = XRRGetOutputPrimary (x11_screen->xdisplay,
-                                        x11_screen->xroot_window);
-
-  for (i = 0; i < x11_display->monitors->len; ++i)
-    {
-      GdkX11Monitor *monitor = x11_display->monitors->pdata[i];
-      if (monitor->output == primary_output)
-        {
-          x11_display->primary_monitor = i;
-          break;
-        }
-
-      /* No RandR1.3+ available or no primary set, fall back to prefer LVDS as primary if present */
-      if (primary_output == None &&
-          g_ascii_strncasecmp (gdk_monitor_get_model (GDK_MONITOR (monitor)), "LVDS", 4) == 0)
-        {
-          x11_display->primary_monitor = i;
-          break;
-        }
-
-      /* No primary specified and no LVDS found */
-      if (monitor->output == first_output)
-        x11_display->primary_monitor = i;
-    }
-
-  if (x11_display->primary_monitor != old_primary)
-    *changed = TRUE;
-
   return x11_display->monitors->len > 0;
 #endif
 
@@ -762,10 +690,6 @@ init_no_multihead (GdkX11Screen *x11_screen, gboolean *changed)
   gdk_monitor_set_physical_size (GDK_MONITOR (monitor), width_mm, height_mm);
   gdk_monitor_set_scale_factor (GDK_MONITOR (monitor), x11_screen->surface_scale);
 
-  if (x11_display->primary_monitor != 0)
-    *changed = TRUE;
-  x11_display->primary_monitor = 0;
-
   for (i = x11_display->monitors->len - 1; i >= 0; i--)
     {
       monitor = x11_display->monitors->pdata[i];
diff --git a/gtk/inspector/general.c b/gtk/inspector/general.c
index 4f575de4a9..0bf95670b9 100644
--- a/gtk/inspector/general.c
+++ b/gtk/inspector/general.c
@@ -577,8 +577,6 @@ populate_display (GdkDisplay *display, GtkInspectorGeneral *gen)
       add_label_row (gen, list, "Size", value, 10);
       g_free (value);
 
-      add_check_row (gen, list, "Primary", gdk_monitor_is_primary (monitor), 10);
-
       if (gdk_monitor_get_refresh_rate (monitor) != 0)
         value = g_strdup_printf ("%.2f Hz",
                                  0.001 * gdk_monitor_get_refresh_rate (monitor));
diff --git a/gtk/inspector/visual.c b/gtk/inspector/visual.c
index 5787f12756..5c708821a5 100644
--- a/gtk/inspector/visual.c
+++ b/gtk/inspector/visual.c
@@ -771,7 +771,7 @@ init_scale (GtkInspectorVisual *vis)
     {
       gdouble scale;
 
-      scale = gdk_monitor_get_scale_factor (gdk_display_get_primary_monitor (vis->priv->display));
+      scale = gdk_monitor_get_scale_factor (gdk_display_get_monitor (vis->priv->display, 0));
       gtk_adjustment_set_value (vis->priv->scale_adjustment, scale);
       g_signal_connect (vis->priv->scale_adjustment, "value-changed",
                         G_CALLBACK (scale_changed), vis);
diff --git a/tests/animated-resizing.c b/tests/animated-resizing.c
index 1984aace2d..0301820d92 100644
--- a/tests/animated-resizing.c
+++ b/tests/animated-resizing.c
@@ -201,7 +201,7 @@ main(int argc, char **argv)
   on_frame (0.);
 
   display = gtk_widget_get_display (window);
-  monitor = gdk_display_get_primary_monitor (display);
+  monitor = gdk_display_get_monitor (display, 0);
   gdk_monitor_get_geometry (monitor, &monitor_bounds);
 
   gtk_widget_show (window);


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