-
Notifications
You must be signed in to change notification settings - Fork 113
Provides support for version 1.5 of RANDR protocol #224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,7 +25,7 @@ | |
| This implementation is based off version 1.3 of the XRandR protocol, and may | ||
| not be compatible with other versions. | ||
|
|
||
| Version 1.2 of the protocol is documented at: | ||
| Version 1.5 of the protocol is documented at: | ||
| http://cgit.freedesktop.org/xorg/proto/randrproto/tree/randrproto.txt | ||
|
|
||
| Version 1.3.1 here: | ||
|
|
@@ -168,6 +168,19 @@ | |
| rq.Card32('matrix33'), | ||
| ) | ||
|
|
||
| MonitorInfo = rq.Struct( | ||
| rq.Card32('name'), | ||
| rq.Bool('primary'), | ||
| rq.Bool('automatic'), | ||
| rq.LengthOf('crtcs', 2), | ||
| rq.Int16('x'), | ||
| rq.Int16('y'), | ||
| rq.Card16('width_in_pixels'), | ||
| rq.Card16('height_in_pixels'), | ||
| rq.Card32('width_in_millimeters'), | ||
| rq.Card32('height_in_millimeters'), | ||
| rq.List('crtcs', rq.Card32Obj) | ||
| ) | ||
|
|
||
| # Requests # | ||
|
|
||
|
|
@@ -197,7 +210,7 @@ def query_version(self): | |
| display=self.display, | ||
| opcode=self.display.get_extension_major(extname), | ||
| major_version=1, | ||
| minor_version=3, | ||
| minor_version=5, | ||
| ) | ||
|
|
||
|
|
||
|
|
@@ -1078,6 +1091,76 @@ def get_output_primary(self): | |
| ) | ||
|
|
||
|
|
||
| # Version 1.5 methods | ||
|
|
||
| class GetMonitors(rq.ReplyRequest): | ||
| _request = rq.Struct( | ||
| rq.Card8('opcode'), | ||
| rq.Opcode(42), | ||
| rq.RequestLength(), | ||
| rq.Window('window'), | ||
| rq.Bool('is_active'), | ||
| rq.Pad(3) | ||
| ) | ||
|
|
||
| _reply = rq.Struct( | ||
| rq.ReplyCode(), | ||
| rq.Pad(1), | ||
| rq.Card16('sequence_number'), | ||
| rq.ReplyLength(), | ||
| rq.Card32('timestamp'), | ||
| rq.LengthOf('monitors', 4), | ||
| rq.Card32('outputs'), | ||
| rq.Pad(12), | ||
| rq.List('monitors', MonitorInfo) | ||
| ) | ||
|
|
||
|
|
||
| def get_monitors(self, is_active=True): | ||
| return GetMonitors( | ||
| display=self.display, | ||
| opcode=self.display.get_extension_major(extname), | ||
| window=self, | ||
| is_active=is_active | ||
| ) | ||
|
|
||
| class SetMonitor(rq.Request): | ||
| _request = rq.Struct( | ||
| rq.Card8('opcode'), | ||
| rq.Opcode(43), | ||
| rq.RequestLength(), | ||
| rq.Window('window'), | ||
| rq.Object('monitor_info', MonitorInfo) | ||
| ) | ||
|
|
||
|
|
||
| def set_monitor(self, monitor_info): | ||
| return SetMonitor( | ||
| display=self.display, | ||
| opcode=self.display.get_extension_major(extname), | ||
| window=self, | ||
| monitor_info=monitor_info | ||
| ) | ||
|
|
||
|
|
||
| class DeleteMonitor(rq.Request): | ||
| _request = rq.Struct( | ||
| rq.Card8('opcode'), | ||
| rq.Opcode(44), | ||
| rq.RequestLength(), | ||
| rq.Window('window'), | ||
| rq.Card32('name') | ||
| ) | ||
|
|
||
|
|
||
| def delete_monitor(self, name): | ||
| return DeleteMonitor( | ||
| display=self.display, | ||
| opcode=self.display.get_extension_major(extname), | ||
| window=self, | ||
| name=name | ||
| ) | ||
|
|
||
| # Events # | ||
|
|
||
| class ScreenChangeNotify(rq.Event): | ||
|
|
@@ -1149,8 +1232,8 @@ class OutputPropertyNotify(rq.Event): | |
| rq.Card8('state'), | ||
| rq.Pad(11), | ||
| ) | ||
|
|
||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like unnecessary extra spaces were added here. |
||
| # Initialization # | ||
|
|
||
| def init(disp, info): | ||
|
|
@@ -1186,6 +1269,11 @@ def init(disp, info): | |
| disp.extension_add_method('display', 'xrandr_get_panning', get_panning) | ||
| disp.extension_add_method('display', 'xrandr_set_panning', set_panning) | ||
|
|
||
| # version 1.5 compatible | ||
| disp.extension_add_method('window', 'xrandr_get_monitors', get_monitors) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if version 1.5 is present almost everywhere for now. Does it make sense to check version of the extension? So that we can support both 1.3 and 1.5+. |
||
| disp.extension_add_method('window', 'xrandr_set_monitor', set_monitor) | ||
| disp.extension_add_method('window', 'xrandr_delete_monitor', delete_monitor) | ||
|
|
||
| disp.extension_add_event(info.first_event + RRScreenChangeNotify, ScreenChangeNotify) | ||
| # add RRNotify events (1 event code with 3 subcodes) | ||
| disp.extension_add_subevent(info.first_event + RRNotify, RRNotify_CrtcChange, CrtcChangeNotify) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -604,7 +604,8 @@ def parse_value(self, val, display): | |
| return self.type.parse_value(val, display) | ||
|
|
||
| def pack_value(self, val): | ||
| return self.type.pack_value(val) | ||
| val = self.type.pack_value(val) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The suggestion to fix underlying functions is also applicable here. |
||
| return val, len(val), None | ||
|
|
||
| def check_value(self, val): | ||
| if isinstance(val, tuple): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1.3->1.5