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

monitor-manager: Handle panel-orientation-managed



Closes: #540
Signed-off-by: Guido Gunther's avatarGuido Günther <guido.gunther@puri.sm>
parent 59e6b051
......@@ -37,6 +37,7 @@ typedef enum PhoshMonitorMAnagerLayoutMode {
enum {
PROP_0,
PROP_SENSOR_PROXY_MANAGER,
PROP_N_MONITORS,
PROP_LAST_PROP
};
......@@ -56,6 +57,9 @@ typedef struct _PhoshMonitorManager
{
PhoshDisplayDbusDisplayConfigSkeleton parent;
PhoshSensorProxyManager *sensor_proxy_manager;
GBinding *sensor_proxy_binding;
GPtrArray *monitors; /* Currently known monitors */
GPtrArray *heads; /* Currently known heads */
......@@ -1175,6 +1179,18 @@ static const struct zwlr_output_configuration_v1_listener config_listener = {
};
static void
phosh_monitor_manager_dispose (GObject *object)
{
PhoshMonitorManager *self = PHOSH_MONITOR_MANAGER (object);
g_clear_object (&self->sensor_proxy_manager);
g_clear_pointer (&self->sensor_proxy_binding, g_binding_unbind);
G_OBJECT_CLASS (phosh_monitor_manager_parent_class)->dispose (object);
}
static void
phosh_monitor_manager_finalize (GObject *object)
{
......@@ -1190,6 +1206,25 @@ phosh_monitor_manager_finalize (GObject *object)
* PhoshMonitorManager Class
*/
static void
phosh_monitor_manager_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
PhoshMonitorManager *self = PHOSH_MONITOR_MANAGER (object);
switch (property_id) {
case PROP_SENSOR_PROXY_MANAGER:
phosh_monitor_manager_set_sensor_proxy_manager (self, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
phosh_monitor_manager_get_property (GObject *object,
guint property_id,
......@@ -1199,6 +1234,9 @@ phosh_monitor_manager_get_property (GObject *object,
PhoshMonitorManager *self = PHOSH_MONITOR_MANAGER (object);
switch (property_id) {
case PROP_SENSOR_PROXY_MANAGER:
g_value_set_object (value, self->sensor_proxy_manager);
break;
case PROP_N_MONITORS:
g_value_set_int (value, self->monitors->len);
break;
......@@ -1265,8 +1303,18 @@ phosh_monitor_manager_class_init (PhoshMonitorManagerClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->constructed = phosh_monitor_manager_constructed;
object_class->dispose = phosh_monitor_manager_dispose;
object_class->finalize = phosh_monitor_manager_finalize;
object_class->get_property = phosh_monitor_manager_get_property;
object_class->set_property = phosh_monitor_manager_set_property;
props[PROP_SENSOR_PROXY_MANAGER] =
g_param_spec_object ("sensor-proxy-manager",
"Sensor Proxy Manager",
"Sensor Proxy Manager",
PHOSH_TYPE_SENSOR_PROXY_MANAGER,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS);
props[PROP_N_MONITORS] =
g_param_spec_int ("n-monitors",
......@@ -1322,9 +1370,11 @@ phosh_monitor_manager_init (PhoshMonitorManager *self)
PhoshMonitorManager *
phosh_monitor_manager_new (void)
phosh_monitor_manager_new (PhoshSensorProxyManager *proxy)
{
return g_object_new (PHOSH_TYPE_MONITOR_MANAGER, NULL);
return g_object_new (PHOSH_TYPE_MONITOR_MANAGER,
"sensor-proxy-manager", proxy,
NULL);
}
......@@ -1444,3 +1494,24 @@ phosh_monitor_manager_apply_monitor_config (PhoshMonitorManager *self)
zwlr_output_configuration_v1_apply (config);
}
void
phosh_monitor_manager_set_sensor_proxy_manager (PhoshMonitorManager *self,
PhoshSensorProxyManager *manager)
{
g_return_if_fail (PHOSH_IS_MONITOR_MANAGER (self));
g_return_if_fail (PHOSH_IS_SENSOR_PROXY_MANAGER (manager) || manager == NULL);
g_clear_object (&self->sensor_proxy_manager);
g_clear_pointer (&self->sensor_proxy_binding, g_binding_unbind);
if (manager == NULL)
return;
self->sensor_proxy_manager = g_object_ref (manager);
self->sensor_proxy_binding = g_object_bind_property (manager, "has-accelerometer",
self, "panel-orientation-managed",
G_BINDING_SYNC_CREATE);
}
......@@ -9,6 +9,9 @@
#include "monitor/phosh-display-dbus.h"
#include "monitor/monitor.h"
#include "sensor-proxy-manager.h"
#include <glib-object.h>
G_BEGIN_DECLS
......@@ -32,7 +35,7 @@ typedef enum _MetaMonitorsConfigMethod
G_DECLARE_FINAL_TYPE (PhoshMonitorManager, phosh_monitor_manager, PHOSH, MONITOR_MANAGER,
PhoshDisplayDbusDisplayConfigSkeleton)
PhoshMonitorManager * phosh_monitor_manager_new (void);
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,
......@@ -44,5 +47,6 @@ void phosh_monitor_manager_set_monitor_transform (PhoshMoni
PhoshMonitor *monitor,
PhoshMonitorTransform transform);
void phosh_monitor_manager_apply_monitor_config (PhoshMonitorManager *self);
void phosh_monitor_manager_set_sensor_proxy_manager (PhoshMonitorManager *self,
PhoshSensorProxyManager *manager);
G_END_DECLS
......@@ -498,6 +498,8 @@ setup_idle_cb (PhoshShell *self)
if (priv->sensor_proxy_manager) {
priv->proximity = phosh_proximity_new (priv->sensor_proxy_manager,
priv->lockscreen_manager);
phosh_monitor_manager_set_sensor_proxy_manager (priv->monitor_manager,
priv->sensor_proxy_manager);
}
priv->mount_manager = phosh_mount_manager_new ();
......@@ -625,7 +627,7 @@ phosh_shell_constructed (GObject *object)
exising toplevels */
priv->toplevel_manager = phosh_toplevel_manager_new ();
priv->monitor_manager = phosh_monitor_manager_new ();
priv->monitor_manager = phosh_monitor_manager_new (NULL);
g_signal_connect_swapped (priv->monitor_manager,
"monitor-removed",
G_CALLBACK (on_monitor_removed),
......
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