summaryrefslogtreecommitdiff
path: root/src/bin/e_randr2.h
blob: 70d27c092279384d11c723986eb92cf2f113cb75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#ifdef E_TYPEDEFS

typedef struct _E_Randr2        E_Randr2;
typedef struct _E_Randr2_Screen E_Randr2_Screen;
typedef struct _E_Randr2_Mode   E_Randr2_Mode;

typedef struct _E_Config_Randr2        E_Config_Randr2;
typedef struct _E_Config_Randr2_Screen E_Config_Randr2_Screen;

#else
#ifndef E_RANDR2_H
#define E_RAND2R_H

typedef enum
{
   E_RANDR2_POLICY_NONE,
   E_RANDR2_POLICY_EXTEND,
   E_RANDR2_POLICY_CLONE,
   E_RANDR2_POLICY_ASK,
} E_Randr2_Policy;

typedef enum _E_Randr2_Relative
{
   E_RANDR2_RELATIVE_UNKNOWN,
   E_RANDR2_RELATIVE_NONE,
   E_RANDR2_RELATIVE_CLONE,
   E_RANDR2_RELATIVE_TO_LEFT,
   E_RANDR2_RELATIVE_TO_RIGHT,
   E_RANDR2_RELATIVE_TO_ABOVE,
   E_RANDR2_RELATIVE_TO_BELOW
} E_Randr2_Relative;

typedef enum _E_Randr2_Connector
{
   E_RANDR2_CONNECTOR_UNDEFINED,
   E_RANDR2_CONNECTOR_DVI,
   E_RANDR2_CONNECTOR_HDMI_A,
   E_RANDR2_CONNECTOR_HDMI_B,
   E_RANDR2_CONNECTOR_MDDI,
   E_RANDR2_CONNECTOR_DISPLAY_PORT
} E_Randr2_Connector;

struct _E_Randr2
{
   Eina_List *screens; // available screens
   int        w, h; // virtual resolution needed for screens (calculated)
};

struct _E_Randr2_Mode
{
   int    w, h; // resolution width and height
   double refresh; // refresh in hz
   unsigned int flags; // randr mode flags.
   Eina_Bool preferred E_BITFIELD; // is this the preferred mode for the device?
};

struct _E_Randr2_Screen
{
   char *id; // string id which is "name/edid";
   struct {
      char                 *screen; // name of the screen device attached
      char                 *name; // name of the output itself
      char                 *edid; // full edid data
      E_Randr2_Connector    connector; // the connector type
      unsigned int          subpixel; //ecore_drm2_output_subpixel_get
      Eina_Bool             is_lid E_BITFIELD; // is an internal screen
      Eina_Bool             lid_closed E_BITFIELD; // is lid closed when screen qury'd
      Eina_Bool             connected E_BITFIELD; // some screen is plugged in or not
      Eina_Bool             backlight E_BITFIELD; // does it have backlight controls?
      Eina_Bool             can_rot_0 E_BITFIELD; // can it do this rotation?
      Eina_Bool             can_rot_90 E_BITFIELD; // can it do this rotation?
      Eina_Bool             can_rot_180 E_BITFIELD; // can it do this rotation?
      Eina_Bool             can_rot_270 E_BITFIELD; // can it do this rotation?
      Eina_List            *modes; // available screen modes here
      struct {
         int                w, h; // physical width and height in mm
      } size;
   } info;
   struct {
      struct {
         E_Randr2_Relative  mode; // what relative mode to the screen below
         char              *to; // what screen this one is relative to
         double             align; // alignment along the edge
      } relative;
      Eina_Rectangle        geom; // the geometry that is set (as a result)
      E_Randr2_Mode         mode; // screen res/refresh to use
      int                   rotation; // 0, 90, 180, 270
      int                   priority; // larger num == more important
      Eina_Bool             enabled E_BITFIELD; // should this monitor be enabled?
      Eina_Bool             configured E_BITFIELD; // has screen been configured by e?
      Eina_Bool             ignore_disconnect E_BITFIELD; // ignore disconnects for this screen...

      char                 *profile; // profile name to use on this screen
      double                scale_multiplier; // if 0.0 - then dont multiply scale
   } config;
};

struct _E_Config_Randr2
{
   int            version;
   Eina_List     *screens;
   unsigned char  restore;
   unsigned char  ignore_hotplug_events;
   unsigned char  ignore_acpi_events;
   E_Randr2_Policy default_policy;
   double         hotplug_response;
};

struct _E_Config_Randr2_Screen
{
   const char    *id;
   const char    *rel_to;
   double         rel_align;
   double         mode_refresh;
   int            mode_w;
   int            mode_h;
   int            rotation;
   int            priority;
   unsigned char  rel_mode;
   unsigned char  enabled;
   unsigned char  ignore_disconnect;

   const char    *custom_label_screen; // name of the screen device attached

   const char    *profile;
   double         scale_multiplier;
};

extern E_API E_Config_Randr2 *e_randr2_cfg;
extern E_API E_Randr2        *e_randr2;

extern E_API int              E_EVENT_RANDR_CHANGE;

EINTERN Eina_Bool             e_randr2_init(void);
EINTERN int                   e_randr2_shutdown(void);

E_API    void                 e_randr2_stop(void);

E_API    Eina_Bool            e_randr2_config_save(void);
E_API    void                 e_randr2_config_apply(void);
E_API    void                 e_randr2_screeninfo_update(void);

E_API void                    e_randr2_screen_refresh_queue(Eina_Bool lid_event);
E_API E_Config_Randr2_Screen *e_randr2_config_screen_find(E_Randr2_Screen *s, E_Config_Randr2 *cfg);
E_API void                    e_randr2_screens_setup(int rw, int rh);
E_API E_Randr2_Screen        *e_randr2_screen_id_find(const char *id);
E_API double                  e_randr2_screen_dpi_get(E_Randr2_Screen *s);
E_API void                    e_randr2_screen_modes_sort(E_Randr2_Screen *s);
#endif
#endif