1 /*
2 * Copyright (C) 2013 Red Hat Inc.
3 * Copyright (C) 2018 Robert Mader
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #ifndef META_MONITOR_TRANSFORM_H
20 #define META_MONITOR_TRANSFORM_H
21
22 #include <glib-object.h>
23
24 #include "backends/meta-backend-types.h"
25 #include "backends/meta-orientation-manager.h"
26 #include "core/util-private.h"
27
28 enum _MetaMonitorTransform
29 {
30 META_MONITOR_TRANSFORM_NORMAL,
31 META_MONITOR_TRANSFORM_90,
32 META_MONITOR_TRANSFORM_180,
33 META_MONITOR_TRANSFORM_270,
34 META_MONITOR_TRANSFORM_FLIPPED,
35 META_MONITOR_TRANSFORM_FLIPPED_90,
36 META_MONITOR_TRANSFORM_FLIPPED_180,
37 META_MONITOR_TRANSFORM_FLIPPED_270,
38 };
39 #define META_MONITOR_N_TRANSFORMS (META_MONITOR_TRANSFORM_FLIPPED_270 + 1)
40 #define META_MONITOR_ALL_TRANSFORMS ((1 << META_MONITOR_N_TRANSFORMS) - 1)
41
42 /* Returns true if transform causes width and height to be inverted
43 This is true for the odd transforms in the enum */
44 static inline gboolean
meta_monitor_transform_is_rotated(MetaMonitorTransform transform)45 meta_monitor_transform_is_rotated (MetaMonitorTransform transform)
46 {
47 return (transform % 2);
48 }
49
50 /* Returns true if transform involves flipping */
51 static inline gboolean
meta_monitor_transform_is_flipped(MetaMonitorTransform transform)52 meta_monitor_transform_is_flipped (MetaMonitorTransform transform)
53 {
54 return (transform >= META_MONITOR_TRANSFORM_FLIPPED);
55 }
56
57 META_EXPORT_TEST
58 MetaMonitorTransform meta_monitor_transform_from_orientation (MetaOrientation orientation);
59
60 META_EXPORT_TEST
61 MetaMonitorTransform meta_monitor_transform_invert (MetaMonitorTransform transform);
62
63 META_EXPORT_TEST
64 MetaMonitorTransform meta_monitor_transform_transform (MetaMonitorTransform transform,
65 MetaMonitorTransform other);
66
67 MetaMonitorTransform meta_monitor_transform_relative_transform (MetaMonitorTransform transform,
68 MetaMonitorTransform other);
69
70 void meta_monitor_transform_transform_point (MetaMonitorTransform transform,
71 int area_width,
72 int area_height,
73 int x,
74 int y,
75 int *out_x,
76 int *out_y);
77
78 #endif /* META_MONITOR_TRANSFORM_H */
79