summaryrefslogtreecommitdiffstats
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
115 When _output_: place mouse at center of newly focused window when changing 115 When _output_: place mouse at center of newly focused window when changing
116 output. When _none_: don't move mouse. 116 output. When _none_: don't move mouse.
117 117
118**output** <name> <resolution|res WIDTHxHEIGHT> <position|pos X,Y>:: 118**output** <name> <resolution|res> <WIDTHxHEIGHT>::
119 Configures the specified output. It will use the given resolution and be 119 Configures the specified output to use the given resolution.
120 arranged at the given position in the layout tree. You may omit either of 120
121 these parameters if you only want to set one of them. 121**output** <name> <position|pos> <X,Y>::
122 Configures the specified output to be arranged at the given position.
123
124**output** <name> <background|bg> <file> <mode>::
125 Sets the wallpaper for the given output to the specified file, using the given
126 scaling mode (one of "stretch", "fill", "center", "tile").
122 127
123**output** <name> disable:: 128**output** <name> disable::
124 Disables the specified output. 129 Disables the specified output.
125 130
131**NOTES FOR THE OUTPUT COMMAND**::
132 You may combine output commands into one, like so:
133 +
134 output HDMI-A-1 res 1920x1080 pos 1920,0 bg ~/wallpaper.png stretch
135 +
136 You can get a list of output names like so:
137 +
138 swaymsg -t get_outputs
139
126**reload**:: 140**reload**::
127 Reloads the sway config file without restarting sway. 141 Reloads the sway config file without restarting sway.
128 142
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) {
314 } 314 }
315 output->x = x; 315 output->x = x;
316 } 316 }
317
318 if (oc->background) {
319 int i;
320 for (i = 0; i < root_container.children->length; ++i) {
321 if (root_container.children->items[i] == output) {
322 break;
323 }
324 }
325
326 sway_log(L_DEBUG, "Setting background for output %d to %s", i, oc->background);
327 char *cmd = malloc(
328 strlen("swaybg ") +
329 (i >= 10 ? 2 : 1) +
330 strlen(oc->background) + 3 +
331 strlen(oc->background_option) + 3 +
332 1);
333 sprintf(cmd, "swaybg %d '%s' '%s'", i, oc->background, oc->background_option);
334 if (fork() == 0) {
335 execl("/bin/sh", "/bin/sh", "-c", cmd, (void *)NULL);
336 }
337 free(cmd);
338 }
317} 339}
318 340
319char *do_var_replacement(char *str) { 341char *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) {
43 swayc_t *ws = op->children->items[0]; 43 swayc_t *ws = op->children->items[0];
44 workspace_switch(ws); 44 workspace_switch(ws);
45 } 45 }
46
47 // Fixes issues with backgrounds and wlc
48 wlc_handle prev = wlc_get_focused_output();
49 wlc_output_focus(output);
50 wlc_output_focus(prev);
46 return true; 51 return true;
47} 52}
48 53
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) {
28 surfaces = create_list(); 28 surfaces = create_list();
29 registry = registry_poll(); 29 registry = registry_poll();
30 30
31 if (argc < 2) { 31 if (argc < 4) {
32 sway_abort("Usage: swaybg path/to/file.png"); 32 sway_abort("Do not run this program manually. See man 5 sway and look for output options.");
33 } 33 }
34 34
35 if (!registry->desktop_shell) { 35 if (!registry->desktop_shell) {
36 sway_abort("swaybg requires the compositor to support the desktop-shell extension."); 36 sway_abort("swaybg requires the compositor to support the desktop-shell extension.");
37 } 37 }
38 38
39 int desired_output = atoi(argv[1]);
40 sway_log(L_INFO, "Using output %d of %d", desired_output, registry->outputs->length);
39 int i; 41 int i;
40 for (i = 0; i < registry->outputs->length; ++i) { 42 struct output_state *output = registry->outputs->items[desired_output];
41 struct output_state *output = registry->outputs->items[i]; 43 struct window *window = window_setup(registry, 100, 100, false);
42 struct window *window = window_setup(registry, 100, 100, false); 44 if (!window) {
43 if (!window) { 45 sway_abort("Failed to create surfaces.");
44 sway_abort("Failed to create surfaces.");
45 }
46 window->width = output->width;
47 window->height = output->height;
48 desktop_shell_set_background(registry->desktop_shell, output->output, window->surface);
49 list_add(surfaces, window);
50 } 46 }
47 window->width = output->width;
48 window->height = output->height;
49 desktop_shell_set_background(registry->desktop_shell, output->output, window->surface);
50 list_add(surfaces, window);
51 51
52 cairo_surface_t *image = cairo_image_surface_create_from_png(argv[1]); 52 char *scaling_mode = argv[3];
53 cairo_surface_t *image = cairo_image_surface_create_from_png(argv[2]);
53 double width = cairo_image_surface_get_width(image); 54 double width = cairo_image_surface_get_width(image);
54 double height = cairo_image_surface_get_height(image); 55 double height = cairo_image_surface_get_height(image);
55 56
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 @@
17 17
18static void pointer_handle_enter(void *data, struct wl_pointer *pointer, 18static void pointer_handle_enter(void *data, struct wl_pointer *pointer,
19 uint32_t serial, struct wl_surface *surface, wl_fixed_t sx_w, wl_fixed_t sy_w) { 19 uint32_t serial, struct wl_surface *surface, wl_fixed_t sx_w, wl_fixed_t sy_w) {
20 sway_log(L_INFO, "Set cursor");
21 struct window *window = data; 20 struct window *window = data;
22 struct wl_cursor_image *image = window->cursor.cursor->images[0]; 21 struct wl_cursor_image *image = window->cursor.cursor->images[0];
23 wl_pointer_set_cursor(pointer, serial, window->cursor.surface, image->hotspot_x, image->hotspot_y); 22 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
72 wl_shell_surface_set_toplevel(window->shell_surface); 71 wl_shell_surface_set_toplevel(window->shell_surface);
73 } 72 }
74 if (registry->pointer) { 73 if (registry->pointer) {
75 sway_log(L_INFO, "Register pointer");
76 wl_pointer_add_listener(registry->pointer, &pointer_listener, window); 74 wl_pointer_add_listener(registry->pointer, &pointer_listener, window);
77 } 75 }
78 76