aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sway/ipc-json.c14
-rw-r--r--swaymsg/main.c26
2 files changed, 38 insertions, 2 deletions
diff --git a/sway/ipc-json.c b/sway/ipc-json.c
index 213c8fb6..977f1ecb 100644
--- a/sway/ipc-json.c
+++ b/sway/ipc-json.c
@@ -78,6 +78,20 @@ static void ipc_json_describe_output(swayc_t *container, json_object *object) {
78 json_object_new_string(ipc_json_get_output_transform(wlr_output->transform))); 78 json_object_new_string(ipc_json_get_output_transform(wlr_output->transform)));
79 // TODO WLR need to set "current_workspace" to the currently focused 79 // TODO WLR need to set "current_workspace" to the currently focused
80 // workspace in a way that makes sense with multiseat 80 // workspace in a way that makes sense with multiseat
81
82 json_object *modes_array = json_object_new_array();
83 struct wlr_output_mode *mode;
84 wl_list_for_each(mode, &wlr_output->modes, link) {
85 json_object *mode_object = json_object_new_object();
86 json_object_object_add(mode_object, "width",
87 json_object_new_int(mode->width));
88 json_object_object_add(mode_object, "height",
89 json_object_new_int(mode->height));
90 json_object_object_add(mode_object, "refresh",
91 json_object_new_int(mode->refresh));
92 json_object_array_add(modes_array, mode_object);
93 }
94 json_object_object_add(object, "modes", modes_array);
81} 95}
82 96
83static void ipc_json_describe_workspace(swayc_t *workspace, json_object *object) { 97static void ipc_json_describe_workspace(swayc_t *workspace, json_object *object) {
diff --git a/swaymsg/main.c b/swaymsg/main.c
index 88b14813..c9be3a86 100644
--- a/swaymsg/main.c
+++ b/swaymsg/main.c
@@ -125,13 +125,16 @@ static void pretty_print_output(json_object *o) {
125 json_object_object_get_ex(rect, "y", &y); 125 json_object_object_get_ex(rect, "y", &y);
126 json_object_object_get_ex(rect, "width", &width); 126 json_object_object_get_ex(rect, "width", &width);
127 json_object_object_get_ex(rect, "height", &height); 127 json_object_object_get_ex(rect, "height", &height);
128 json_object *modes;
129 json_object_object_get_ex(o, "modes", &modes);
130
128 printf( 131 printf(
129 "Output %s '%s %s %s'%s%s\n" 132 "Output %s '%s %s %s'%s%s\n"
130 " Mode: %dx%d @ %f Hz\n" 133 " Current mode: %dx%d @ %f Hz\n"
131 " Position: %d,%d\n" 134 " Position: %d,%d\n"
132 " Scale factor: %dx\n" 135 " Scale factor: %dx\n"
133 " Transform: %s\n" 136 " Transform: %s\n"
134 " Workspace: %s\n\n", 137 " Workspace: %s\n",
135 json_object_get_string(name), 138 json_object_get_string(name),
136 json_object_get_string(make), 139 json_object_get_string(make),
137 json_object_get_string(model), 140 json_object_get_string(model),
@@ -145,6 +148,25 @@ static void pretty_print_output(json_object *o) {
145 json_object_get_string(transform), 148 json_object_get_string(transform),
146 json_object_get_string(ws) 149 json_object_get_string(ws)
147 ); 150 );
151
152 size_t modes_len = json_object_array_length(modes);
153 if (modes_len > 0) {
154 printf(" Available modes:\n");
155 for (size_t i = 0; i < modes_len; ++i) {
156 json_object *mode = json_object_array_get_idx(modes, i);
157
158 json_object *mode_width, *mode_height, *mode_refresh;
159 json_object_object_get_ex(mode, "width", &mode_width);
160 json_object_object_get_ex(mode, "height", &mode_height);
161 json_object_object_get_ex(mode, "refresh", &mode_refresh);
162
163 printf(" %dx%d @ %f Hz\n", json_object_get_int(mode_width),
164 json_object_get_int(mode_height),
165 (float)json_object_get_int(mode_refresh) / 1000);
166 }
167 }
168
169 printf("\n");
148} 170}
149 171
150static void pretty_print_version(json_object *v) { 172static void pretty_print_version(json_object *v) {