diff options
-rw-r--r-- | include/sway/output.h | 3 | ||||
-rw-r--r-- | include/sway/server.h | 4 | ||||
-rw-r--r-- | protocols/meson.build | 1 | ||||
-rw-r--r-- | protocols/wlr-output-power-management-unstable-v1.xml | 128 | ||||
-rw-r--r-- | sway/desktop/output.c | 18 | ||||
-rw-r--r-- | sway/server.c | 7 |
6 files changed, 161 insertions, 0 deletions
diff --git a/include/sway/output.h b/include/sway/output.h index 01c32e0b..9117f350 100644 --- a/include/sway/output.h +++ b/include/sway/output.h | |||
@@ -171,4 +171,7 @@ void handle_output_manager_apply(struct wl_listener *listener, void *data); | |||
171 | 171 | ||
172 | void handle_output_manager_test(struct wl_listener *listener, void *data); | 172 | void handle_output_manager_test(struct wl_listener *listener, void *data); |
173 | 173 | ||
174 | void handle_output_power_manager_set_mode(struct wl_listener *listener, | ||
175 | void *data); | ||
176 | |||
174 | #endif | 177 | #endif |
diff --git a/include/sway/server.h b/include/sway/server.h index 2e8e4633..65bd6429 100644 --- a/include/sway/server.h +++ b/include/sway/server.h | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <wlr/types/wlr_data_device.h> | 9 | #include <wlr/types/wlr_data_device.h> |
10 | #include <wlr/types/wlr_layer_shell_v1.h> | 10 | #include <wlr/types/wlr_layer_shell_v1.h> |
11 | #include <wlr/types/wlr_output_management_v1.h> | 11 | #include <wlr/types/wlr_output_management_v1.h> |
12 | #include <wlr/types/wlr_output_power_management_v1.h> | ||
12 | #include <wlr/types/wlr_presentation_time.h> | 13 | #include <wlr/types/wlr_presentation_time.h> |
13 | #include <wlr/types/wlr_relative_pointer_v1.h> | 14 | #include <wlr/types/wlr_relative_pointer_v1.h> |
14 | #include <wlr/types/wlr_server_decoration.h> | 15 | #include <wlr/types/wlr_server_decoration.h> |
@@ -73,6 +74,9 @@ struct sway_server { | |||
73 | struct wl_listener output_manager_apply; | 74 | struct wl_listener output_manager_apply; |
74 | struct wl_listener output_manager_test; | 75 | struct wl_listener output_manager_test; |
75 | 76 | ||
77 | struct wlr_output_power_manager_v1 *output_power_manager_v1; | ||
78 | struct wl_listener output_power_manager_set_mode; | ||
79 | |||
76 | size_t txn_timeout_ms; | 80 | size_t txn_timeout_ms; |
77 | list_t *transactions; | 81 | list_t *transactions; |
78 | list_t *dirty_nodes; | 82 | list_t *dirty_nodes; |
diff --git a/protocols/meson.build b/protocols/meson.build index f2f90dad..124e9777 100644 --- a/protocols/meson.build +++ b/protocols/meson.build | |||
@@ -18,6 +18,7 @@ protocols = [ | |||
18 | ['wlr-layer-shell-unstable-v1.xml'], | 18 | ['wlr-layer-shell-unstable-v1.xml'], |
19 | ['idle.xml'], | 19 | ['idle.xml'], |
20 | ['wlr-input-inhibitor-unstable-v1.xml'], | 20 | ['wlr-input-inhibitor-unstable-v1.xml'], |
21 | ['wlr-output-power-management-unstable-v1.xml'], | ||
21 | ] | 22 | ] |
22 | 23 | ||
23 | client_protocols = [ | 24 | client_protocols = [ |
diff --git a/protocols/wlr-output-power-management-unstable-v1.xml b/protocols/wlr-output-power-management-unstable-v1.xml new file mode 100644 index 00000000..a9778399 --- /dev/null +++ b/protocols/wlr-output-power-management-unstable-v1.xml | |||
@@ -0,0 +1,128 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <protocol name="wlr_output_power_management_unstable_v1"> | ||
3 | <copyright> | ||
4 | Copyright © 2019 Purism SPC | ||
5 | |||
6 | Permission is hereby granted, free of charge, to any person obtaining a | ||
7 | copy of this software and associated documentation files (the "Software"), | ||
8 | to deal in the Software without restriction, including without limitation | ||
9 | the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
10 | and/or sell copies of the Software, and to permit persons to whom the | ||
11 | Software is furnished to do so, subject to the following conditions: | ||
12 | |||
13 | The above copyright notice and this permission notice (including the next | ||
14 | paragraph) shall be included in all copies or substantial portions of the | ||
15 | Software. | ||
16 | |||
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
20 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
22 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
23 | DEALINGS IN THE SOFTWARE. | ||
24 | </copyright> | ||
25 | |||
26 | <description summary="Control power management modes of outputs"> | ||
27 | This protocol allows clients to control power management modes | ||
28 | of outputs that are currently part of the compositor space. The | ||
29 | intent is to allow special clients like desktop shells to power | ||
30 | down outputs when the system is idle. | ||
31 | |||
32 | To modify outputs not currently part of the compositor space see | ||
33 | wlr-output-management. | ||
34 | |||
35 | Warning! The protocol described in this file is experimental and | ||
36 | backward incompatible changes may be made. Backward compatible changes | ||
37 | may be added together with the corresponding interface version bump. | ||
38 | Backward incompatible changes are done by bumping the version number in | ||
39 | the protocol and interface names and resetting the interface version. | ||
40 | Once the protocol is to be declared stable, the 'z' prefix and the | ||
41 | version number in the protocol and interface names are removed and the | ||
42 | interface version number is reset. | ||
43 | </description> | ||
44 | |||
45 | <interface name="zwlr_output_power_manager_v1" version="1"> | ||
46 | <description summary="manager to create per-output power management"> | ||
47 | This interface is a manager that allows creating per-output power | ||
48 | management mode controls. | ||
49 | </description> | ||
50 | |||
51 | <request name="get_output_power"> | ||
52 | <description summary="get a power management for an output"> | ||
53 | Create a output power management mode control that can be used to | ||
54 | adjust the power management mode for a given output. | ||
55 | </description> | ||
56 | <arg name="id" type="new_id" interface="zwlr_output_power_v1"/> | ||
57 | <arg name="output" type="object" interface="wl_output"/> | ||
58 | </request> | ||
59 | |||
60 | <request name="destroy" type="destructor"> | ||
61 | <description summary="destroy the manager"> | ||
62 | All objects created by the manager will still remain valid, until their | ||
63 | appropriate destroy request has been called. | ||
64 | </description> | ||
65 | </request> | ||
66 | </interface> | ||
67 | |||
68 | <interface name="zwlr_output_power_v1" version="1"> | ||
69 | <description summary="adjust power management mode for an output"> | ||
70 | This object offers requests to set the power management mode of | ||
71 | an output. | ||
72 | </description> | ||
73 | |||
74 | <enum name="mode"> | ||
75 | <entry name="off" value="0" | ||
76 | summary="Output is turned off."/> | ||
77 | <entry name="on" value="1" | ||
78 | summary="Output is turned on, no power saving"/> | ||
79 | </enum> | ||
80 | |||
81 | <enum name="error"> | ||
82 | <entry name="invalid_mode" value="1" summary="inexistent power save mode"/> | ||
83 | </enum> | ||
84 | |||
85 | <request name="set_mode"> | ||
86 | <description summary="Set an outputs power save mode"> | ||
87 | Set an output's power save mode to the given mode. The mode change | ||
88 | is effective immediately. If the output does not support the given | ||
89 | mode a failed event is sent. | ||
90 | </description> | ||
91 | <arg name="mode" type="uint" enum="mode" summary="the power save mode to set"/> | ||
92 | </request> | ||
93 | |||
94 | <event name="mode"> | ||
95 | <description summary="Report a power management mode change"> | ||
96 | Report the power management mode change of an output. | ||
97 | |||
98 | The mode event is sent after an output changed its power | ||
99 | management mode. The reason can be a client using set_mode or the | ||
100 | compositor deciding to change an output's mode. | ||
101 | This event is also sent immediately when the object is created | ||
102 | so the client is informed about the current power management mode. | ||
103 | </description> | ||
104 | <arg name="mode" type="uint" enum="mode" | ||
105 | summary="the output's new power management mode"/> | ||
106 | </event> | ||
107 | |||
108 | <event name="failed"> | ||
109 | <description summary="object no longer valid"> | ||
110 | This event indicates that the output power management mode control | ||
111 | is no longer valid. This can happen for a number of reasons, | ||
112 | including: | ||
113 | - The output doesn't support power management | ||
114 | - Another client already has exclusive power management mode control | ||
115 | for this output | ||
116 | - The output disappeared | ||
117 | |||
118 | Upon receiving this event, the client should destroy this object. | ||
119 | </description> | ||
120 | </event> | ||
121 | |||
122 | <request name="destroy" type="destructor"> | ||
123 | <description summary="destroy this power management"> | ||
124 | Destroys the output power management mode control object. | ||
125 | </description> | ||
126 | </request> | ||
127 | </interface> | ||
128 | </protocol> | ||
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index ec662a8c..f5c84d96 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -977,3 +977,21 @@ void handle_output_manager_test(struct wl_listener *listener, void *data) { | |||
977 | wlr_output_configuration_v1_send_succeeded(config); | 977 | wlr_output_configuration_v1_send_succeeded(config); |
978 | wlr_output_configuration_v1_destroy(config); | 978 | wlr_output_configuration_v1_destroy(config); |
979 | } | 979 | } |
980 | |||
981 | void handle_output_power_manager_set_mode(struct wl_listener *listener, | ||
982 | void *data) { | ||
983 | struct wlr_output_power_v1_set_mode_event *event = data; | ||
984 | struct sway_output *output = event->output->data; | ||
985 | |||
986 | struct output_config *oc = new_output_config(output->wlr_output->name); | ||
987 | switch (event->mode) { | ||
988 | case ZWLR_OUTPUT_POWER_V1_MODE_OFF: | ||
989 | oc->dpms_state = DPMS_OFF; | ||
990 | break; | ||
991 | case ZWLR_OUTPUT_POWER_V1_MODE_ON: | ||
992 | oc->dpms_state = DPMS_ON; | ||
993 | break; | ||
994 | } | ||
995 | oc = store_output_config(oc); | ||
996 | apply_output_config(oc, output); | ||
997 | } | ||
diff --git a/sway/server.c b/sway/server.c index c97d098a..9be073a0 100644 --- a/sway/server.c +++ b/sway/server.c | |||
@@ -132,6 +132,13 @@ bool server_init(struct sway_server *server) { | |||
132 | wl_signal_add(&server->output_manager_v1->events.test, | 132 | wl_signal_add(&server->output_manager_v1->events.test, |
133 | &server->output_manager_test); | 133 | &server->output_manager_test); |
134 | 134 | ||
135 | server->output_power_manager_v1 = | ||
136 | wlr_output_power_manager_v1_create(server->wl_display); | ||
137 | server->output_power_manager_set_mode.notify = | ||
138 | handle_output_power_manager_set_mode; | ||
139 | wl_signal_add(&server->output_power_manager_v1->events.set_mode, | ||
140 | &server->output_power_manager_set_mode); | ||
141 | |||
135 | wlr_export_dmabuf_manager_v1_create(server->wl_display); | 142 | wlr_export_dmabuf_manager_v1_create(server->wl_display); |
136 | wlr_screencopy_manager_v1_create(server->wl_display); | 143 | wlr_screencopy_manager_v1_create(server->wl_display); |
137 | wlr_data_control_manager_v1_create(server->wl_display); | 144 | wlr_data_control_manager_v1_create(server->wl_display); |