Commit 1367e5e3 authored by Guido Gunther's avatar Guido Gunther Committed by Sebastian Krzyszkowiak
Browse files

monitor-manager: Delay 'monitor-added' until monitor is configured



This makes is simpler for other parts of the shell since they don't
need to track this on their own.

While at that make phosh_monitor_manager_add_monitor private since
this should only happen within monitor-manager.
Signed-off-by: Guido Gunther's avatarGuido Günther <guido.gunther@puri.sm>
parent f2cf3579
......@@ -1037,6 +1037,19 @@ find_monitor_by_wl_output (PhoshMonitorManager *self, struct wl_output *output)
}
static void
on_monitor_configured (PhoshMonitorManager *self, PhoshMonitor *monitor)
{
g_return_if_fail (PHOSH_IS_MONITOR_MANAGER (self));
g_return_if_fail (PHOSH_IS_MONITOR (monitor));
g_signal_emit (self, signals[SIGNAL_MONITOR_ADDED], 0, monitor);
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_N_MONITORS]);
g_signal_handlers_disconnect_by_data (monitor, self);
}
static void
on_monitor_removed (PhoshMonitorManager *self,
PhoshMonitor *monitor,
......@@ -1051,6 +1064,18 @@ on_monitor_removed (PhoshMonitorManager *self,
}
static void
phosh_monitor_manager_add_monitor (PhoshMonitorManager *self, PhoshMonitor *monitor)
{
g_ptr_array_add (self->monitors, monitor);
/* Delay emmission of 'monitor-added' until it's configured */
g_signal_connect_swapped (monitor,
"configured",
G_CALLBACK (on_monitor_configured),
self);
}
static void
on_wl_outputs_changed (PhoshMonitorManager *self, GParamSpec *pspec, PhoshWayland *wl)
{
......@@ -1334,10 +1359,7 @@ phosh_monitor_manager_class_init (PhoshMonitorManagerClass *klass)
* @manager: The #PhoshMonitorManager emitting the signal.
* @monitor: The #PhoshMonitor being added.
*
* Emitted whenever a monitor is about to be added. Note
* that the monitor might not yet be fully initialized. Use
* phosh_monitor_is_configured() to check or listen for
* the #PhoshMonitor::configured signal.
* Emitted whenever a monitor was added.
*/
signals[SIGNAL_MONITOR_ADDED] = g_signal_new (
"monitor-added",
......@@ -1378,15 +1400,6 @@ phosh_monitor_manager_new (PhoshSensorProxyManager *proxy)
}
void
phosh_monitor_manager_add_monitor (PhoshMonitorManager *self, PhoshMonitor *monitor)
{
g_ptr_array_add (self->monitors, monitor);
g_signal_emit (self, signals[SIGNAL_MONITOR_ADDED], 0, monitor);
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_N_MONITORS]);
}
PhoshMonitor *
phosh_monitor_manager_get_monitor (PhoshMonitorManager *self, guint num)
{
......
......@@ -36,8 +36,6 @@ G_DECLARE_FINAL_TYPE (PhoshMonitorManager, phosh_monitor_manager, PHOSH, MONITOR
PhoshDisplayDbusDisplayConfigSkeleton)
PhoshMonitorManager * phosh_monitor_manager_new (PhoshSensorProxyManager *proxy);
void phosh_monitor_manager_add_monitor (PhoshMonitorManager *self,
PhoshMonitor *monitor);
PhoshMonitor * phosh_monitor_manager_get_monitor (PhoshMonitorManager *self,
guint num);
guint phosh_monitor_manager_get_num_monitors (PhoshMonitorManager *self);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment