aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sway/config.h1
-rw-r--r--sway/commands/output/mode.c8
-rw-r--r--sway/config/output.c16
-rw-r--r--sway/sway-output.5.scd6
4 files changed, 25 insertions, 6 deletions
diff --git a/include/sway/config.h b/include/sway/config.h
index 632027ea..3dedbec8 100644
--- a/include/sway/config.h
+++ b/include/sway/config.h
@@ -198,6 +198,7 @@ struct output_config {
198 int enabled; 198 int enabled;
199 int width, height; 199 int width, height;
200 float refresh_rate; 200 float refresh_rate;
201 int custom_mode;
201 int x, y; 202 int x, y;
202 float scale; 203 float scale;
203 int32_t transform; 204 int32_t transform;
diff --git a/sway/commands/output/mode.c b/sway/commands/output/mode.c
index bcfce372..5b710713 100644
--- a/sway/commands/output/mode.c
+++ b/sway/commands/output/mode.c
@@ -12,6 +12,14 @@ struct cmd_results *output_cmd_mode(int argc, char **argv) {
12 12
13 struct output_config *output = config->handler_context.output_config; 13 struct output_config *output = config->handler_context.output_config;
14 14
15 if (strcmp(argv[0], "--custom") == 0) {
16 argv++;
17 argc--;
18 output->custom_mode = 1;
19 } else {
20 output->custom_mode = 0;
21 }
22
15 char *end; 23 char *end;
16 output->width = strtol(*argv, &end, 10); 24 output->width = strtol(*argv, &end, 10);
17 if (*end) { 25 if (*end) {
diff --git a/sway/config/output.c b/sway/config/output.c
index 42deec67..1d21e52f 100644
--- a/sway/config/output.c
+++ b/sway/config/output.c
@@ -42,6 +42,7 @@ struct output_config *new_output_config(const char *name) {
42 oc->enabled = -1; 42 oc->enabled = -1;
43 oc->width = oc->height = -1; 43 oc->width = oc->height = -1;
44 oc->refresh_rate = -1; 44 oc->refresh_rate = -1;
45 oc->custom_mode = -1;
45 oc->x = oc->y = -1; 46 oc->x = oc->y = -1;
46 oc->scale = -1; 47 oc->scale = -1;
47 oc->transform = -1; 48 oc->transform = -1;
@@ -74,6 +75,9 @@ void merge_output_config(struct output_config *dst, struct output_config *src) {
74 if (src->refresh_rate != -1) { 75 if (src->refresh_rate != -1) {
75 dst->refresh_rate = src->refresh_rate; 76 dst->refresh_rate = src->refresh_rate;
76 } 77 }
78 if (src->custom_mode != -1) {
79 dst->custom_mode = src->custom_mode;
80 }
77 if (src->transform != -1) { 81 if (src->transform != -1) {
78 dst->transform = src->transform; 82 dst->transform = src->transform;
79 } 83 }
@@ -202,11 +206,13 @@ struct output_config *store_output_config(struct output_config *oc) {
202} 206}
203 207
204static bool set_mode(struct wlr_output *output, int width, int height, 208static bool set_mode(struct wlr_output *output, int width, int height,
205 float refresh_rate) { 209 float refresh_rate, bool custom) {
206 int mhz = (int)(refresh_rate * 1000); 210 int mhz = (int)(refresh_rate * 1000);
207 if (wl_list_empty(&output->modes)) { 211
212 if (wl_list_empty(&output->modes) || custom) {
208 sway_log(SWAY_DEBUG, "Assigning custom mode to %s", output->name); 213 sway_log(SWAY_DEBUG, "Assigning custom mode to %s", output->name);
209 return wlr_output_set_custom_mode(output, width, height, mhz); 214 return wlr_output_set_custom_mode(output, width, height,
215 refresh_rate > 0 ? mhz : 0);
210 } 216 }
211 217
212 struct wlr_output_mode *mode, *best = NULL; 218 struct wlr_output_mode *mode, *best = NULL;
@@ -261,8 +267,8 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) {
261 if (oc && oc->width > 0 && oc->height > 0) { 267 if (oc && oc->width > 0 && oc->height > 0) {
262 sway_log(SWAY_DEBUG, "Set %s mode to %dx%d (%f Hz)", oc->name, oc->width, 268 sway_log(SWAY_DEBUG, "Set %s mode to %dx%d (%f Hz)", oc->name, oc->width,
263 oc->height, oc->refresh_rate); 269 oc->height, oc->refresh_rate);
264 modeset_success = 270 modeset_success = set_mode(wlr_output, oc->width, oc->height,
265 set_mode(wlr_output, oc->width, oc->height, oc->refresh_rate); 271 oc->refresh_rate, oc->custom_mode == 1);
266 } else if (!wl_list_empty(&wlr_output->modes)) { 272 } else if (!wl_list_empty(&wlr_output->modes)) {
267 struct wlr_output_mode *mode = 273 struct wlr_output_mode *mode =
268 wl_container_of(wlr_output->modes.prev, mode, link); 274 wl_container_of(wlr_output->modes.prev, mode, link);
diff --git a/sway/sway-output.5.scd b/sway/sway-output.5.scd
index da17e1c1..ae6ced24 100644
--- a/sway/sway-output.5.scd
+++ b/sway/sway-output.5.scd
@@ -24,12 +24,16 @@ must be separated by one space. For example:
24 24
25# COMMANDS 25# COMMANDS
26 26
27*output* <name> mode|resolution|res <WIDTHxHEIGHT>[@<RATE>[Hz]] 27*output* <name> mode|resolution|res [--custom] <WIDTHxHEIGHT>[@<RATE>[Hz]]
28 Configures the specified output to use the given mode. Modes are a 28 Configures the specified output to use the given mode. Modes are a
29 combination of width and height (in pixels) and a refresh rate that your 29 combination of width and height (in pixels) and a refresh rate that your
30 display can be configured to use. For a list of available modes for each 30 display can be configured to use. For a list of available modes for each
31 output, use *swaymsg -t get_outputs*. 31 output, use *swaymsg -t get_outputs*.
32 32
33 To set a custom mode not listed in the list of available modes, use
34 *--custom*. You should probably only use this if you know what you're
35 doing.
36
33 Examples: 37 Examples:
34 38
35 output HDMI-A-1 mode 1920x1080 39 output HDMI-A-1 mode 1920x1080