aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sway.5.txt22
-rw-r--r--sway/config.c22
-rw-r--r--sway/handlers.c5
-rw-r--r--swaybg/main.c27
-rw-r--r--wayland/window.c2
5 files changed, 59 insertions, 19 deletions
diff --git a/sway.5.txt b/sway.5.txt
index ab2bdedb..5e9dbb1e 100644
--- a/sway.5.txt
+++ b/sway.5.txt
@@ -115,14 +115,28 @@ Commands
When _output_: place mouse at center of newly focused window when changing
output. When _none_: don't move mouse.
-**output** <name> <resolution|res WIDTHxHEIGHT> <position|pos X,Y>::
- Configures the specified output. It will use the given resolution and be
- arranged at the given position in the layout tree. You may omit either of
- these parameters if you only want to set one of them.
+**output** <name> <resolution|res> <WIDTHxHEIGHT>::
+ Configures the specified output to use the given resolution.
+
+**output** <name> <position|pos> <X,Y>::
+ Configures the specified output to be arranged at the given position.
+
+**output** <name> <background|bg> <file> <mode>::
+ Sets the wallpaper for the given output to the specified file, using the given
+ scaling mode (one of "stretch", "fill", "center", "tile").
**output** <name> disable::
Disables the specified output.
+**NOTES FOR THE OUTPUT COMMAND**::
+ You may combine output commands into one, like so:
+ +
+ output HDMI-A-1 res 1920x1080 pos 1920,0 bg ~/wallpaper.png stretch
+ +
+ You can get a list of output names like so:
+ +
+ swaymsg -t get_outputs
+
**reload**::
Reloads the sway config file without restarting sway.
diff --git a/sway/config.c b/sway/config.c
index ce6d8baf..2c9cc290 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -314,6 +314,28 @@ void apply_output_config(struct output_config *oc, swayc_t *output) {
}
output->x = x;
}
+
+ if (oc->background) {
+ int i;
+ for (i = 0; i < root_container.children->length; ++i) {
+ if (root_container.children->items[i] == output) {
+ break;
+ }
+ }
+
+ sway_log(L_DEBUG, "Setting background for output %d to %s", i, oc->background);
+ char *cmd = malloc(
+ strlen("swaybg ") +
+ (i >= 10 ? 2 : 1) +
+ strlen(oc->background) + 3 +
+ strlen(oc->background_option) + 3 +
+ 1);
+ sprintf(cmd, "swaybg %d '%s' '%s'", i, oc->background, oc->background_option);
+ if (fork() == 0) {
+ execl("/bin/sh", "/bin/sh", "-c", cmd, (void *)NULL);
+ }
+ free(cmd);
+ }
}
char *do_var_replacement(char *str) {
diff --git a/sway/handlers.c b/sway/handlers.c
index dde9b88b..28fa9564 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -43,6 +43,11 @@ static bool handle_output_created(wlc_handle output) {
swayc_t *ws = op->children->items[0];
workspace_switch(ws);
}
+
+ // Fixes issues with backgrounds and wlc
+ wlc_handle prev = wlc_get_focused_output();
+ wlc_output_focus(output);
+ wlc_output_focus(prev);
return true;
}
diff --git a/swaybg/main.c b/swaybg/main.c
index 080422e5..5a12eec6 100644
--- a/swaybg/main.c
+++ b/swaybg/main.c
@@ -28,28 +28,29 @@ int main(int argc, char **argv) {
surfaces = create_list();
registry = registry_poll();
- if (argc < 2) {
- sway_abort("Usage: swaybg path/to/file.png");
+ if (argc < 4) {
+ sway_abort("Do not run this program manually. See man 5 sway and look for output options.");
}
if (!registry->desktop_shell) {
sway_abort("swaybg requires the compositor to support the desktop-shell extension.");
}
+ int desired_output = atoi(argv[1]);
+ sway_log(L_INFO, "Using output %d of %d", desired_output, registry->outputs->length);
int i;
- for (i = 0; i < registry->outputs->length; ++i) {
- struct output_state *output = registry->outputs->items[i];
- struct window *window = window_setup(registry, 100, 100, false);
- if (!window) {
- sway_abort("Failed to create surfaces.");
- }
- window->width = output->width;
- window->height = output->height;
- desktop_shell_set_background(registry->desktop_shell, output->output, window->surface);
- list_add(surfaces, window);
+ struct output_state *output = registry->outputs->items[desired_output];
+ struct window *window = window_setup(registry, 100, 100, false);
+ if (!window) {
+ sway_abort("Failed to create surfaces.");
}
+ window->width = output->width;
+ window->height = output->height;
+ desktop_shell_set_background(registry->desktop_shell, output->output, window->surface);
+ list_add(surfaces, window);
- cairo_surface_t *image = cairo_image_surface_create_from_png(argv[1]);
+ char *scaling_mode = argv[3];
+ cairo_surface_t *image = cairo_image_surface_create_from_png(argv[2]);
double width = cairo_image_surface_get_width(image);
double height = cairo_image_surface_get_height(image);
diff --git a/wayland/window.c b/wayland/window.c
index af50c04c..13d4c7b2 100644
--- a/wayland/window.c
+++ b/wayland/window.c
@@ -17,7 +17,6 @@
static void pointer_handle_enter(void *data, struct wl_pointer *pointer,
uint32_t serial, struct wl_surface *surface, wl_fixed_t sx_w, wl_fixed_t sy_w) {
- sway_log(L_INFO, "Set cursor");
struct window *window = data;
struct wl_cursor_image *image = window->cursor.cursor->images[0];
wl_pointer_set_cursor(pointer, serial, window->cursor.surface, image->hotspot_x, image->hotspot_y);
@@ -72,7 +71,6 @@ struct window *window_setup(struct registry *registry, uint32_t width, uint32_t
wl_shell_surface_set_toplevel(window->shell_surface);
}
if (registry->pointer) {
- sway_log(L_INFO, "Register pointer");
wl_pointer_add_listener(registry->pointer, &pointer_listener, window);
}