[gnome-flashback] monitor-transform: add function to compute from orientation
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-flashback] monitor-transform: add function to compute from orientation
- Date: Sat, 23 Oct 2021 18:48:45 +0000 (UTC)
commit ddcede1d95170b244a9f8c90b836504c2aafe5dc
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Mon Sep 13 14:43:46 2021 +0300
monitor-transform: add function to compute from orientation
Based on mutter commit:
https://gitlab.gnome.org/GNOME/mutter/-/commit/d0a9dfefc8e9
backends/gf-monitor-config-manager.c | 19 +++----------------
backends/gf-monitor-manager.c | 22 +++-------------------
backends/gf-monitor-transform.c | 23 +++++++++++++++++++++++
backends/gf-monitor-transform.h | 10 +++++++---
4 files changed, 36 insertions(+), 38 deletions(-)
---
diff --git a/backends/gf-monitor-config-manager.c b/backends/gf-monitor-config-manager.c
index 289b653..6cd52b6 100644
--- a/backends/gf-monitor-config-manager.c
+++ b/backends/gf-monitor-config-manager.c
@@ -186,6 +186,7 @@ get_monitor_transform (GfMonitorManager *monitor_manager,
{
GfBackend *backend;
GfOrientationManager *orientation_manager;
+ GfOrientation orientation;
if (!gf_monitor_is_laptop_panel (monitor) ||
!gf_monitor_manager_get_panel_orientation_managed (monitor_manager))
@@ -193,23 +194,9 @@ get_monitor_transform (GfMonitorManager *monitor_manager,
backend = gf_monitor_manager_get_backend (monitor_manager);
orientation_manager = gf_backend_get_orientation_manager (backend);
+ orientation = gf_orientation_manager_get_orientation (orientation_manager);
- switch (gf_orientation_manager_get_orientation (orientation_manager))
- {
- case GF_ORIENTATION_BOTTOM_UP:
- return GF_MONITOR_TRANSFORM_180;
-
- case GF_ORIENTATION_LEFT_UP:
- return GF_MONITOR_TRANSFORM_90;
-
- case GF_ORIENTATION_RIGHT_UP:
- return GF_MONITOR_TRANSFORM_270;
-
- case GF_ORIENTATION_UNDEFINED:
- case GF_ORIENTATION_NORMAL:
- default:
- return GF_MONITOR_TRANSFORM_NORMAL;
- }
+ return gf_monitor_transform_from_orientation (orientation);
}
static GfLogicalMonitorConfig *
diff --git a/backends/gf-monitor-manager.c b/backends/gf-monitor-manager.c
index 3c1b1ca..707eb45 100644
--- a/backends/gf-monitor-manager.c
+++ b/backends/gf-monitor-manager.c
@@ -604,6 +604,7 @@ static void
handle_orientation_change (GfOrientationManager *orientation_manager,
GfMonitorManager *manager)
{
+ GfOrientation orientation;
GfMonitorTransform transform;
GError *error = NULL;
GfMonitorsConfig *config;
@@ -617,25 +618,8 @@ handle_orientation_change (GfOrientationManager *orientation_manager,
if (!gf_monitor_is_active (laptop_panel))
return;
- switch (gf_orientation_manager_get_orientation (orientation_manager))
- {
- case GF_ORIENTATION_NORMAL:
- transform = GF_MONITOR_TRANSFORM_NORMAL;
- break;
- case GF_ORIENTATION_BOTTOM_UP:
- transform = GF_MONITOR_TRANSFORM_180;
- break;
- case GF_ORIENTATION_LEFT_UP:
- transform = GF_MONITOR_TRANSFORM_90;
- break;
- case GF_ORIENTATION_RIGHT_UP:
- transform = GF_MONITOR_TRANSFORM_270;
- break;
-
- case GF_ORIENTATION_UNDEFINED:
- default:
- return;
- }
+ orientation = gf_orientation_manager_get_orientation (orientation_manager);
+ transform = gf_monitor_transform_from_orientation (orientation);
laptop_logical_monitor = gf_monitor_get_logical_monitor (laptop_panel);
if (gf_logical_monitor_get_transform (laptop_logical_monitor) == transform)
diff --git a/backends/gf-monitor-transform.c b/backends/gf-monitor-transform.c
index ee1c1a3..57412e1 100644
--- a/backends/gf-monitor-transform.c
+++ b/backends/gf-monitor-transform.c
@@ -18,6 +18,29 @@
#include "config.h"
#include "gf-monitor-transform.h"
+GfMonitorTransform
+gf_monitor_transform_from_orientation (GfOrientation orientation)
+{
+ switch (orientation)
+ {
+ case GF_ORIENTATION_BOTTOM_UP:
+ return GF_MONITOR_TRANSFORM_180;
+
+ case GF_ORIENTATION_LEFT_UP:
+ return GF_MONITOR_TRANSFORM_90;
+
+ case GF_ORIENTATION_RIGHT_UP:
+ return GF_MONITOR_TRANSFORM_270;
+
+ case GF_ORIENTATION_UNDEFINED:
+ case GF_ORIENTATION_NORMAL:
+ default:
+ break;
+ }
+
+ return GF_MONITOR_TRANSFORM_NORMAL;
+}
+
GfMonitorTransform
gf_monitor_transform_invert (GfMonitorTransform transform)
{
diff --git a/backends/gf-monitor-transform.h b/backends/gf-monitor-transform.h
index bc6aca9..14f02ac 100644
--- a/backends/gf-monitor-transform.h
+++ b/backends/gf-monitor-transform.h
@@ -21,6 +21,8 @@
#include <glib-object.h>
+#include "gf-orientation-manager-private.h"
+
G_BEGIN_DECLS
typedef enum
@@ -50,10 +52,12 @@ gf_monitor_transform_is_flipped (GfMonitorTransform transform)
return (transform >= GF_MONITOR_TRANSFORM_FLIPPED);
}
-GfMonitorTransform gf_monitor_transform_invert (GfMonitorTransform transform);
+GfMonitorTransform gf_monitor_transform_from_orientation (GfOrientation orientation);
+
+GfMonitorTransform gf_monitor_transform_invert (GfMonitorTransform transform);
-GfMonitorTransform gf_monitor_transform_transform (GfMonitorTransform transform,
- GfMonitorTransform other);
+GfMonitorTransform gf_monitor_transform_transform (GfMonitorTransform transform,
+ GfMonitorTransform other);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]