diff --git a/gdk/x11/gdkscreen-x11.c b/gdk/x11/gdkscreen-x11.c
index 1faa827..6fd83ad 100644
--- a/gdk/x11/gdkscreen-x11.c
+++ b/gdk/x11/gdkscreen-x11.c
@@ -712,6 +712,7 @@ init_randr13 (GdkScreen *screen)
   GdkScreenX11 *screen_x11 = GDK_SCREEN_X11 (screen);
   Display *dpy = GDK_SCREEN_XDISPLAY (screen);
   XRRScreenResources *resources;
+  RROutput primary_output;
   int i;
   GArray *monitors;
   gboolean randr12_compat = FALSE;
@@ -727,11 +728,19 @@ init_randr13 (GdkScreen *screen)
   monitors = g_array_sized_new (FALSE, TRUE, sizeof (GdkX11Monitor),
                                 resources->noutput);
 
+  primary_output = XRRGetOutputPrimary (screen_x11->xdisplay,
+                                        screen_x11->xroot_window);
+
   for (i = 0; i < resources->noutput; ++i)
     {
       XRROutputInfo *output =
 	XRRGetOutputInfo (dpy, resources, resources->outputs[i]);
 
+      if (resources->outputs[i] == primary_output)
+        {
+          screen_x11->primary = i;
+        }
+
       /* Non RandR1.2 X driver have output name "default" */
       randr12_compat |= !g_strcmp0(output->name, "default");
 
diff --git a/gdk/x11/gdkscreen-x11.h b/gdk/x11/gdkscreen-x11.h
index 0d1548c..fbd1a9e 100644
--- a/gdk/x11/gdkscreen-x11.h
+++ b/gdk/x11/gdkscreen-x11.h
@@ -93,6 +93,7 @@ struct _GdkScreenX11
   /* Xinerama/RandR 1.2 */
   gint		 n_monitors;
   GdkX11Monitor	*monitors;
+  gint           primary;
 
   /* Pango renderer object singleton */
   PangoRenderer *renderer;
