|
25 | 25 | This implementation is based off version 1.3 of the XRandR protocol, and may
|
26 | 26 | not be compatible with other versions.
|
27 | 27 |
|
28 |
| -Version 1.2 of the protocol is documented at: |
| 28 | +Version 1.5 of the protocol is documented at: |
29 | 29 | http://cgit.freedesktop.org/xorg/proto/randrproto/tree/randrproto.txt
|
30 | 30 |
|
31 | 31 | Version 1.3.1 here:
|
|
168 | 168 | rq.Card32('matrix33'),
|
169 | 169 | )
|
170 | 170 |
|
| 171 | +MonitorInfo = rq.Struct( |
| 172 | + rq.Card32('name'), |
| 173 | + rq.Bool('primary'), |
| 174 | + rq.Bool('automatic'), |
| 175 | + rq.LengthOf('crtcs', 2), |
| 176 | + rq.Int16('x'), |
| 177 | + rq.Int16('y'), |
| 178 | + rq.Card16('width_in_pixels'), |
| 179 | + rq.Card16('height_in_pixels'), |
| 180 | + rq.Card32('width_in_millimeters'), |
| 181 | + rq.Card32('height_in_millimeters'), |
| 182 | + rq.List('crtcs', rq.Card32Obj) |
| 183 | +) |
171 | 184 |
|
172 | 185 | # Requests #
|
173 | 186 |
|
@@ -197,7 +210,7 @@ def query_version(self):
|
197 | 210 | display=self.display,
|
198 | 211 | opcode=self.display.get_extension_major(extname),
|
199 | 212 | major_version=1,
|
200 |
| - minor_version=3, |
| 213 | + minor_version=5, |
201 | 214 | )
|
202 | 215 |
|
203 | 216 |
|
@@ -1078,6 +1091,76 @@ def get_output_primary(self):
|
1078 | 1091 | )
|
1079 | 1092 |
|
1080 | 1093 |
|
| 1094 | +# Version 1.5 methods |
| 1095 | + |
| 1096 | +class GetMonitors(rq.ReplyRequest): |
| 1097 | + _request = rq.Struct( |
| 1098 | + rq.Card8('opcode'), |
| 1099 | + rq.Opcode(42), |
| 1100 | + rq.RequestLength(), |
| 1101 | + rq.Window('window'), |
| 1102 | + rq.Bool('is_active'), |
| 1103 | + rq.Pad(3) |
| 1104 | + ) |
| 1105 | + |
| 1106 | + _reply = rq.Struct( |
| 1107 | + rq.ReplyCode(), |
| 1108 | + rq.Pad(1), |
| 1109 | + rq.Card16('sequence_number'), |
| 1110 | + rq.ReplyLength(), |
| 1111 | + rq.Card32('timestamp'), |
| 1112 | + rq.LengthOf('monitors', 4), |
| 1113 | + rq.Card32('outputs'), |
| 1114 | + rq.Pad(12), |
| 1115 | + rq.List('monitors', MonitorInfo) |
| 1116 | + ) |
| 1117 | + |
| 1118 | + |
| 1119 | +def get_monitors(self, is_active=True): |
| 1120 | + return GetMonitors( |
| 1121 | + display=self.display, |
| 1122 | + opcode=self.display.get_extension_major(extname), |
| 1123 | + window=self, |
| 1124 | + is_active=is_active |
| 1125 | + ) |
| 1126 | + |
| 1127 | +class SetMonitor(rq.Request): |
| 1128 | + _request = rq.Struct( |
| 1129 | + rq.Card8('opcode'), |
| 1130 | + rq.Opcode(43), |
| 1131 | + rq.RequestLength(), |
| 1132 | + rq.Window('window'), |
| 1133 | + rq.Object('monitor_info', MonitorInfo) |
| 1134 | + ) |
| 1135 | + |
| 1136 | + |
| 1137 | +def set_monitor(self, monitor_info): |
| 1138 | + return SetMonitor( |
| 1139 | + display=self.display, |
| 1140 | + opcode=self.display.get_extension_major(extname), |
| 1141 | + window=self, |
| 1142 | + monitor_info=monitor_info |
| 1143 | + ) |
| 1144 | + |
| 1145 | + |
| 1146 | +class DeleteMonitor(rq.Request): |
| 1147 | + _request = rq.Struct( |
| 1148 | + rq.Card8('opcode'), |
| 1149 | + rq.Opcode(44), |
| 1150 | + rq.RequestLength(), |
| 1151 | + rq.Window('window'), |
| 1152 | + rq.Card32('name') |
| 1153 | + ) |
| 1154 | + |
| 1155 | + |
| 1156 | +def delete_monitor(self, name): |
| 1157 | + return DeleteMonitor( |
| 1158 | + display=self.display, |
| 1159 | + opcode=self.display.get_extension_major(extname), |
| 1160 | + window=self, |
| 1161 | + name=name |
| 1162 | + ) |
| 1163 | + |
1081 | 1164 | # Events #
|
1082 | 1165 |
|
1083 | 1166 | class ScreenChangeNotify(rq.Event):
|
@@ -1149,8 +1232,8 @@ class OutputPropertyNotify(rq.Event):
|
1149 | 1232 | rq.Card8('state'),
|
1150 | 1233 | rq.Pad(11),
|
1151 | 1234 | )
|
1152 |
| - |
1153 |
| - |
| 1235 | + |
| 1236 | + |
1154 | 1237 | # Initialization #
|
1155 | 1238 |
|
1156 | 1239 | def init(disp, info):
|
@@ -1186,6 +1269,11 @@ def init(disp, info):
|
1186 | 1269 | disp.extension_add_method('display', 'xrandr_get_panning', get_panning)
|
1187 | 1270 | disp.extension_add_method('display', 'xrandr_set_panning', set_panning)
|
1188 | 1271 |
|
| 1272 | + # version 1.5 compatible |
| 1273 | + disp.extension_add_method('window', 'xrandr_get_monitors', get_monitors) |
| 1274 | + disp.extension_add_method('window', 'xrandr_set_monitor', set_monitor) |
| 1275 | + disp.extension_add_method('window', 'xrandr_delete_monitor', delete_monitor) |
| 1276 | + |
1189 | 1277 | disp.extension_add_event(info.first_event + RRScreenChangeNotify, ScreenChangeNotify)
|
1190 | 1278 | # add RRNotify events (1 event code with 3 subcodes)
|
1191 | 1279 | disp.extension_add_subevent(info.first_event + RRNotify, RRNotify_CrtcChange, CrtcChangeNotify)
|
|
0 commit comments