Commit 3de17848 authored by Guido Gunther's avatar Guido Gunther

Add rotation-manager

The rotation manager listens to device orientation changes
and adjusts the primary display accordingly.

This interfaces with lockscreen, iio-sensor-proxy and
gsettings to figure out the correct screen orientation.

The manager has two modes: off (don't rotate any output) and sensor
(adjust due to sensor values).
Signed-off-by: Guido Gunther's avatarGuido Günther <guido.gunther@puri.sm>
parent 2d2e3721
......@@ -95,6 +95,7 @@
<xi:include href="xml/proximity.xml"/>
<xi:include href="xml/quick-setting.xml"/>
<xi:include href="xml/rotateinfo.xml"/>
<xi:include href="xml/rotation-manager.xml"/>
<xi:include href="xml/screen-saver-manager.xml"/>
<xi:include href="xml/sensor-proxy-manager.xml"/>
<xi:include href="xml/session-manager.xml"/>
......
......@@ -21,6 +21,7 @@ phosh_enum_headers = [
'notifications/notification.h',
'notifications/notify-manager.h',
'phosh-wayland.h',
'rotation-manager.h',
] + schema_enum_headers
phosh_enums = gnome.mkenums('phosh-enums',
......@@ -140,6 +141,8 @@ libphosh_sources = [
'polkit-auth-prompt.h',
'proximity.h',
'proximity.c',
'rotation-manager.h',
'rotation-manager.c',
'sensor-proxy-manager.c',
'sensor-proxy-manager.h',
'rotateinfo.c',
......@@ -227,4 +230,3 @@ phosh = executable('phosh', ['main.c', libphosh_sources],
dependencies: phosh_tool_dep,
install: true,
install_dir: libexecdir)
......@@ -9,6 +9,7 @@
#include "notifications/notification.h"
#include "notifications/notify-manager.h"
#include "phosh-wayland.h"
#include "rotation-manager.h"
#include "wwan/phosh-wwan-backend.h"
#include "phosh-enums.h"
......
This diff is collapsed.
/*
* Copyright (C) 2021 Purism SPC
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#pragma once
#include "lockscreen-manager.h"
#include "sensor-proxy-manager.h"
G_BEGIN_DECLS
/**
* PhoshRotationManagerMode:
* @PHOSH_ROTATION_MANAGER_MODE_OFF: automatic rotation off
* @PHOSH_ROTATION_MANAGER_MODE_SENSOR: rotation driven by sensor orientation
*
* The mode of a #PhoshRotationManager
*/
typedef enum {
PHOSH_ROTATION_MANAGER_MODE_OFF,
PHOSH_ROTATION_MANAGER_MODE_SENSOR,
} PhoshRotationManagerMode;
#define PHOSH_TYPE_ROTATION_MANAGER (phosh_rotation_manager_get_type ())
G_DECLARE_FINAL_TYPE (PhoshRotationManager, phosh_rotation_manager, PHOSH, ROTATION_MANAGER, GObject);
PhoshRotationManager *phosh_rotation_manager_new (PhoshSensorProxyManager *sensor_proxy_manager,
PhoshLockscreenManager *lockscreen_manager);
void phosh_rotation_manager_set_orientation_locked (PhoshRotationManager *self,
gboolean locked);
gboolean phosh_rotation_manager_get_orientation_locked (PhoshRotationManager *self);
PhoshRotationManagerMode phosh_rotation_manager_get_mode (PhoshRotationManager *self);
void phosh_rotation_manager_set_mode (PhoshRotationManager *self, PhoshRotationManagerMode mode);
G_END_DECLS
......@@ -55,6 +55,7 @@
#include "proximity.h"
#include "quick-setting.h"
#include "rotateinfo.h"
#include "rotation-manager.h"
#include "sensor-proxy-manager.h"
#include "screen-saver-manager.h"
#include "session-manager.h"
......@@ -122,6 +123,7 @@ typedef struct
/* sensors */
PhoshSensorProxyManager *sensor_proxy_manager;
PhoshProximity *proximity;
PhoshRotationManager *rotation_manager;
gboolean startup_finished;
PhoshMonitorTransform transform; /* current rotation of primary monitor */
......@@ -356,7 +358,9 @@ phosh_shell_dispose (GObject *object)
/* sensors */
g_clear_object (&priv->proximity);
g_clear_object (&priv->rotation_manager);
g_clear_object (&priv->sensor_proxy_manager);
phosh_system_prompter_unregister ();
g_clear_object (&priv->session_manager);
......@@ -1011,6 +1015,23 @@ phosh_shell_get_session_manager (PhoshShell *self)
}
PhoshRotationManager *
phosh_shell_get_rotation_manager (PhoshShell *self)
{
PhoshShellPrivate *priv;
g_return_val_if_fail (PHOSH_IS_SHELL (self), NULL);
priv = phosh_shell_get_instance_private (self);
if (!priv->rotation_manager)
priv->rotation_manager = phosh_rotation_manager_new (priv->sensor_proxy_manager,
priv->lockscreen_manager);
g_return_val_if_fail (PHOSH_IS_ROTATION_MANAGER (priv->rotation_manager), NULL);
return priv->rotation_manager;
}
/**
* Returns the usable area in pixels usable by a client on the phone
* display
......
......@@ -15,6 +15,7 @@
#include "monitor-manager.h"
#include "monitor/monitor.h"
#include "osk-manager.h"
#include "rotation-manager.h"
#include "session-manager.h"
#include "toplevel-manager.h"
#include "torch-manager.h"
......@@ -56,6 +57,7 @@ PhoshWifiManager *phosh_shell_get_wifi_manager (PhoshShell *self);
PhoshFeedbackManager *phosh_shell_get_feedback_manager (PhoshShell *self);
PhoshBtManager *phosh_shell_get_bt_manager (PhoshShell *self);
PhoshWWan *phosh_shell_get_wwan (PhoshShell *self);
PhoshRotationManager *phosh_shell_get_rotation_manager (PhoshShell *self);
PhoshTorchManager *phosh_shell_get_torch_manager (PhoshShell *self);
PhoshDockedManager *phosh_shell_get_docked_manager (PhoshShell *self);
PhoshSessionManager *phosh_shell_get_session_manager (PhoshShell *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