aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client/meson.build23
-rw-r--r--client/pool-buffer.c (renamed from client/buffer-pool.c)3
-rw-r--r--common/cairo.c6
-rw-r--r--include/cairo.h3
-rw-r--r--include/meson.build1
-rw-r--r--include/pool-buffer.h (renamed from include/buffer_pool.h)0
-rw-r--r--meson.build5
-rw-r--r--swaybg/main.c44
-rw-r--r--swaybg/meson.build36
9 files changed, 50 insertions, 71 deletions
diff --git a/client/meson.build b/client/meson.build
index 597899ce..2bdda457 100644
--- a/client/meson.build
+++ b/client/meson.build
@@ -1,21 +1,16 @@
1deps = [
2 cairo,
3 pango,
4 pangocairo,
5 wlroots,
6 wayland_client,
7]
8
9if gdk_pixbuf.found()
10 deps += [gdk_pixbuf]
11endif
12
13lib_sway_client = static_library( 1lib_sway_client = static_library(
14 'sway-client', 2 'sway-client',
15 files( 3 files(
16 'buffer-pool.c', 4 'pool-buffer.c',
17 ), 5 ),
18 dependencies: deps, 6 dependencies: [
7 cairo,
8 gdk_pixbuf,
9 pango,
10 pangocairo,
11 wlroots,
12 wayland_client,
13 ],
19 link_with: [lib_sway_common], 14 link_with: [lib_sway_common],
20 include_directories: sway_inc 15 include_directories: sway_inc
21) 16)
diff --git a/client/buffer-pool.c b/client/pool-buffer.c
index 7f673ae9..93cfcfc5 100644
--- a/client/buffer-pool.c
+++ b/client/pool-buffer.c
@@ -8,7 +8,8 @@
8#include <pango/pangocairo.h> 8#include <pango/pangocairo.h>
9#include <unistd.h> 9#include <unistd.h>
10#include <wayland-client.h> 10#include <wayland-client.h>
11#include "buffer_pool.h" 11#include "config.h"
12#include "pool-buffer.h"
12 13
13static int create_pool_file(size_t size, char **name) { 14static int create_pool_file(size_t size, char **name) {
14 static const char template[] = "sway-client-XXXXXX"; 15 static const char template[] = "sway-client-XXXXXX";
diff --git a/common/cairo.c b/common/cairo.c
index c6bd0da9..c267c77c 100644
--- a/common/cairo.c
+++ b/common/cairo.c
@@ -1,7 +1,7 @@
1#include <stdint.h> 1#include <stdint.h>
2#include <cairo/cairo.h> 2#include <cairo/cairo.h>
3#include "cairo.h" 3#include "cairo.h"
4#ifdef WITH_GDK_PIXBUF 4#ifdef HAVE_GDK_PIXBUF
5#include <gdk-pixbuf/gdk-pixbuf.h> 5#include <gdk-pixbuf/gdk-pixbuf.h>
6#endif 6#endif
7 7
@@ -30,7 +30,7 @@ cairo_surface_t *cairo_image_surface_scale(cairo_surface_t *image,
30 return new; 30 return new;
31} 31}
32 32
33#ifdef WITH_GDK_PIXBUF 33#ifdef HAVE_GDK_PIXBUF
34cairo_surface_t* gdk_cairo_image_surface_create_from_pixbuf(const GdkPixbuf *gdkbuf) { 34cairo_surface_t* gdk_cairo_image_surface_create_from_pixbuf(const GdkPixbuf *gdkbuf) {
35 int chan = gdk_pixbuf_get_n_channels(gdkbuf); 35 int chan = gdk_pixbuf_get_n_channels(gdkbuf);
36 if (chan < 3) { 36 if (chan < 3) {
@@ -124,4 +124,4 @@ cairo_surface_t* gdk_cairo_image_surface_create_from_pixbuf(const GdkPixbuf *gdk
124 cairo_surface_mark_dirty(cs); 124 cairo_surface_mark_dirty(cs);
125 return cs; 125 return cs;
126} 126}
127#endif //WITH_GDK_PIXBUF 127#endif //HAVE_GDK_PIXBUF
diff --git a/include/cairo.h b/include/cairo.h
index f5f474d7..31672705 100644
--- a/include/cairo.h
+++ b/include/cairo.h
@@ -8,7 +8,8 @@ void cairo_set_source_u32(cairo_t *cairo, uint32_t color);
8cairo_surface_t *cairo_image_surface_scale(cairo_surface_t *image, 8cairo_surface_t *cairo_image_surface_scale(cairo_surface_t *image,
9 int width, int height); 9 int width, int height);
10 10
11#ifdef WITH_GDK_PIXBUF 11#include "config.h"
12#ifdef HAVE_GDK_PIXBUF
12#include <gdk-pixbuf/gdk-pixbuf.h> 13#include <gdk-pixbuf/gdk-pixbuf.h>
13 14
14cairo_surface_t* gdk_cairo_image_surface_create_from_pixbuf( 15cairo_surface_t* gdk_cairo_image_surface_create_from_pixbuf(
diff --git a/include/meson.build b/include/meson.build
new file mode 100644
index 00000000..65ed027a
--- /dev/null
+++ b/include/meson.build
@@ -0,0 +1 @@
configure_file(output: 'config.h', configuration: conf_data)
diff --git a/include/buffer_pool.h b/include/pool-buffer.h
index cdebd64d..cdebd64d 100644
--- a/include/buffer_pool.h
+++ b/include/pool-buffer.h
diff --git a/meson.build b/meson.build
index 0c35b0e5..b681f43a 100644
--- a/meson.build
+++ b/meson.build
@@ -38,8 +38,10 @@ math = cc.find_library('m')
38git = find_program('git', required: false) 38git = find_program('git', required: false)
39a2x = find_program('a2x', required: false) 39a2x = find_program('a2x', required: false)
40 40
41conf_data = configuration_data()
42
41if gdk_pixbuf.found() 43if gdk_pixbuf.found()
42 add_project_arguments('-DWITH_GDK_PIXBUF', language : 'c') 44 conf_data.set('HAVE_GDK_PIXBUF', true)
43endif 45endif
44 46
45if a2x.found() 47if a2x.found()
@@ -92,6 +94,7 @@ add_project_arguments('-DSWAY_VERSION=@0@'.format(version), language: 'c')
92 94
93sway_inc = include_directories('include') 95sway_inc = include_directories('include')
94 96
97subdir('include')
95subdir('protocols') 98subdir('protocols')
96subdir('common') 99subdir('common')
97subdir('sway') 100subdir('sway')
diff --git a/swaybg/main.c b/swaybg/main.c
index 62ddec6c..f431526c 100644
--- a/swaybg/main.c
+++ b/swaybg/main.c
@@ -1,3 +1,4 @@
1#include <assert.h>
1#include <ctype.h> 2#include <ctype.h>
2#include <stdbool.h> 3#include <stdbool.h>
3#include <stdio.h> 4#include <stdio.h>
@@ -6,7 +7,7 @@
6#include <time.h> 7#include <time.h>
7#include <wayland-client.h> 8#include <wayland-client.h>
8#include <wlr/util/log.h> 9#include <wlr/util/log.h>
9#include "buffer_pool.h" 10#include "pool-buffer.h"
10#include "cairo.h" 11#include "cairo.h"
11#include "util.h" 12#include "util.h"
12#include "wlr-layer-shell-unstable-v1-client-protocol.h" 13#include "wlr-layer-shell-unstable-v1-client-protocol.h"
@@ -127,7 +128,7 @@ static void render_image(struct swaybg_state *state) {
127 break; 128 break;
128 } 129 }
129 case BACKGROUND_MODE_SOLID_COLOR: 130 case BACKGROUND_MODE_SOLID_COLOR:
130 // Should never happen 131 assert(0);
131 break; 132 break;
132 } 133 }
133 cairo_paint(cairo); 134 cairo_paint(cairo);
@@ -158,7 +159,7 @@ static bool prepare_context(struct swaybg_state *state) {
158 state->context.color = parse_color(state->args->path); 159 state->context.color = parse_color(state->args->path);
159 return is_valid_color(state->args->path); 160 return is_valid_color(state->args->path);
160 } 161 }
161#ifdef WITH_GDK_PIXBUF 162#ifdef HAVE_GDK_PIXBUF
162 GError *err = NULL; 163 GError *err = NULL;
163 GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(state->args->path, &err); 164 GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(state->args->path, &err);
164 if (!pixbuf) { 165 if (!pixbuf) {
@@ -170,17 +171,17 @@ static bool prepare_context(struct swaybg_state *state) {
170#else 171#else
171 state->context.image = cairo_image_surface_create_from_png( 172 state->context.image = cairo_image_surface_create_from_png(
172 state->args->path); 173 state->args->path);
173#endif //WITH_GDK_PIXBUF 174#endif //HAVE_GDK_PIXBUF
174 if (!state->context.image) { 175 if (!state->context.image) {
175 wlr_log(L_ERROR, "Failed to read background image."); 176 wlr_log(L_ERROR, "Failed to read background image.");
176 return false; 177 return false;
177 } 178 }
178 if (cairo_surface_status(state->context.image) != CAIRO_STATUS_SUCCESS) { 179 if (cairo_surface_status(state->context.image) != CAIRO_STATUS_SUCCESS) {
179 wlr_log(L_ERROR, "Failed to read background image: %s." 180 wlr_log(L_ERROR, "Failed to read background image: %s."
180#ifndef WITH_GDK_PIXBUF 181#ifndef HAVE_GDK_PIXBUF
181 "\nSway was compiled without gdk_pixbuf support, so only" 182 "\nSway was compiled without gdk_pixbuf support, so only"
182 "\nPNG images can be loaded. This is the likely cause." 183 "\nPNG images can be loaded. This is the likely cause."
183#endif //WITH_GDK_PIXBUF 184#endif //HAVE_GDK_PIXBUF
184 , cairo_status_to_string( 185 , cairo_status_to_string(
185 cairo_surface_status(state->context.image))); 186 cairo_surface_status(state->context.image)));
186 return false; 187 return false;
@@ -256,7 +257,6 @@ int main(int argc, const char **argv) {
256 } 257 }
257 args.output_idx = atoi(argv[1]); 258 args.output_idx = atoi(argv[1]);
258 args.path = argv[2]; 259 args.path = argv[2];
259 args.mode = atoi(argv[3]);
260 260
261 args.mode = BACKGROUND_MODE_STRETCH; 261 args.mode = BACKGROUND_MODE_STRETCH;
262 if (strcmp(argv[3], "stretch") == 0) { 262 if (strcmp(argv[3], "stretch") == 0) {
@@ -280,38 +280,20 @@ int main(int argc, const char **argv) {
280 return 1; 280 return 1;
281 } 281 }
282 282
283 state.display = wl_display_connect(NULL); 283 assert(state.display = wl_display_connect(NULL));
284 if (!state.display) {
285 wlr_log(L_ERROR, "Failed to create display\n");
286 return 1;
287 }
288 284
289 struct wl_registry *registry = wl_display_get_registry(state.display); 285 struct wl_registry *registry = wl_display_get_registry(state.display);
290 wl_registry_add_listener(registry, &registry_listener, &state); 286 wl_registry_add_listener(registry, &registry_listener, &state);
291 wl_display_roundtrip(state.display); 287 wl_display_roundtrip(state.display);
288 assert(state.compositor && state.layer_shell && state.output && state.shm);
292 289
293 if (!state.compositor) { 290 assert(state.surface = wl_compositor_create_surface(state.compositor));
294 wlr_log(L_DEBUG, "wl-compositor not available");
295 return 1;
296 }
297 if (!state.layer_shell) {
298 wlr_log(L_ERROR, "layer-shell not available");
299 return 1;
300 }
301
302 state.surface = wl_compositor_create_surface(state.compositor);
303 if (!state.surface) {
304 wlr_log(L_ERROR, "failed to create wl_surface");
305 return 1;
306 }
307 291
308 state.layer_surface = zwlr_layer_shell_v1_get_layer_surface( 292 state.layer_surface = zwlr_layer_shell_v1_get_layer_surface(
309 state.layer_shell, state.surface, state.output, 293 state.layer_shell, state.surface, state.output,
310 ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND, "wallpaper"); 294 ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND, "wallpaper");
311 if (!state.layer_surface) { 295 assert(state.layer_surface);
312 wlr_log(L_ERROR, "failed to create zwlr_layer_surface"); 296
313 return 1;
314 }
315 zwlr_layer_surface_v1_set_size(state.layer_surface, 0, 0); 297 zwlr_layer_surface_v1_set_size(state.layer_surface, 0, 0);
316 zwlr_layer_surface_v1_set_anchor(state.layer_surface, 298 zwlr_layer_surface_v1_set_anchor(state.layer_surface,
317 ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | 299 ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP |
@@ -320,10 +302,10 @@ int main(int argc, const char **argv) {
320 ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT); 302 ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT);
321 zwlr_layer_surface_v1_add_listener(state.layer_surface, 303 zwlr_layer_surface_v1_add_listener(state.layer_surface,
322 &layer_surface_listener, &state); 304 &layer_surface_listener, &state);
305 state.run_display = true;
323 wl_surface_commit(state.surface); 306 wl_surface_commit(state.surface);
324 wl_display_roundtrip(state.display); 307 wl_display_roundtrip(state.display);
325 308
326 state.run_display = true;
327 while (wl_display_dispatch(state.display) != -1 && state.run_display) { 309 while (wl_display_dispatch(state.display) != -1 && state.run_display) {
328 // This space intentionally left blank 310 // This space intentionally left blank
329 } 311 }
diff --git a/swaybg/meson.build b/swaybg/meson.build
index 7f5d6bd1..5e10f3c7 100644
--- a/swaybg/meson.build
+++ b/swaybg/meson.build
@@ -1,22 +1,18 @@
1deps = [
2 cairo,
3 jsonc,
4 math,
5 pango,
6 pangocairo,
7 sway_protos,
8 wayland_client,
9]
10
11if gdk_pixbuf.found()
12 deps += [gdk_pixbuf]
13endif
14
15executable( 1executable(
16 'swaybg', 2 'swaybg',
17 'main.c', 3 'main.c',
18 include_directories: [sway_inc], 4 include_directories: [sway_inc],
19 dependencies: deps, 5 dependencies: [
20 link_with: [lib_sway_common, lib_sway_client], 6 cairo,
21 install: true 7 gdk_pixbuf,
8 jsonc,
9 math,
10 pango,
11 pangocairo,
12 sway_protos,
13 wayland_client,
14 wlroots,
15 ],
16 link_with: [lib_sway_common, lib_sway_client],
17 install: true
22) 18)