From 9d27ee89e2698b1851fda79f207018dbec4b14a1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
Date: Thu, 5 Jul 2018 18:29:25 +0200
Subject: [PATCH] phosh: Add method to get the primary monitor

This avoids opencoding it in lot of places (See #20)
---
 src/phosh.c | 13 +++++++++++++
 src/phosh.h |  3 +++
 2 files changed, 16 insertions(+)

diff --git a/src/phosh.c b/src/phosh.c
index 9223e63..bbd9653 100644
--- a/src/phosh.c
+++ b/src/phosh.c
@@ -868,6 +868,19 @@ phosh_shell_get_wl_layer_shell ()
 }
 
 
+PhoshMonitor *
+phosh_shell_get_primary_monitor ()
+{
+  PhoshShellPrivate *priv = phosh_shell_get_instance_private (_phosh);
+  PhoshMonitor *monitor;
+
+  monitor = phosh_monitor_manager_get_monitor (priv->monitor_manager, 0);
+  g_return_val_if_fail (monitor, NULL);
+
+  return monitor;
+}
+
+
 /**
  * Returns the usable area in pixels usable by a client on the phone
  * display
diff --git a/src/phosh.h b/src/phosh.h
index 51c912a..74bfbe5 100644
--- a/src/phosh.h
+++ b/src/phosh.h
@@ -8,6 +8,8 @@
 #ifndef PHOSH_H
 #define PHOSH_H
 
+#include "monitor/monitor.h"
+
 #include <gtk/gtk.h>
 
 #define PHOSH_TYPE_SHELL phosh_shell_get_type()
@@ -25,6 +27,7 @@ void                 phosh_shell_get_usable_area (PhoshShell *self,
 void                 phosh_shell_set_locked      (PhoshShell *self, gboolean locked);
 void                 phosh_shell_lock            (PhoshShell *self);
 void                 phosh_shell_unlock          (PhoshShell *self);
+PhoshMonitor        *phosh_shell_get_primary_monitor ();
 
 /* Phosh keeps track of the wayland globals */
 gpointer             phosh_shell_get_wl_layer_shell  ();
-- 
GitLab