diff options
-rw-r--r-- | CMake/FindGdkPixbuf.cmake | 3 | ||||
-rw-r--r-- | CMakeLists.txt | 61 | ||||
-rw-r--r-- | README.md | 14 | ||||
-rw-r--r-- | include/client/cairo.h | 2 | ||||
-rw-r--r-- | sway/config.c | 6 | ||||
-rw-r--r-- | swaybar/main.c | 49 | ||||
-rw-r--r-- | swaybg/CMakeLists.txt | 11 | ||||
-rw-r--r-- | swaybg/main.c | 4 | ||||
-rw-r--r-- | swaylock/CMakeLists.txt | 11 | ||||
-rw-r--r-- | swaylock/main.c | 4 | ||||
-rw-r--r-- | wayland/CMakeLists.txt | 11 | ||||
-rw-r--r-- | wayland/cairo.c | 5 |
12 files changed, 139 insertions, 42 deletions
diff --git a/CMake/FindGdkPixbuf.cmake b/CMake/FindGdkPixbuf.cmake index 53bb0501..4ea1d5b9 100644 --- a/CMake/FindGdkPixbuf.cmake +++ b/CMake/FindGdkPixbuf.cmake | |||
@@ -29,6 +29,7 @@ IF(NOT GDK_PIXBUF_FOUND AND NOT PKG_CONFIG_FOUND) | |||
29 | # Report results | 29 | # Report results |
30 | IF(GDK_PIXBUF_LIBRARIES AND GDK_PIXBUF_INCLUDE_DIRS) | 30 | IF(GDK_PIXBUF_LIBRARIES AND GDK_PIXBUF_INCLUDE_DIRS) |
31 | SET(GDK_PIXBUF_FOUND 1) | 31 | SET(GDK_PIXBUF_FOUND 1) |
32 | SET(GdkPixbuf_FOUND 1) | ||
32 | IF(NOT GdkPixbuf_FIND_QUIETLY) | 33 | IF(NOT GdkPixbuf_FIND_QUIETLY) |
33 | MESSAGE(STATUS "Found GdkPixbuf: ${GDK_PIXBUF_LIBRARIES}") | 34 | MESSAGE(STATUS "Found GdkPixbuf: ${GDK_PIXBUF_LIBRARIES}") |
34 | ENDIF(NOT GdkPixbuf_FIND_QUIETLY) | 35 | ENDIF(NOT GdkPixbuf_FIND_QUIETLY) |
@@ -41,6 +42,8 @@ IF(NOT GDK_PIXBUF_FOUND AND NOT PKG_CONFIG_FOUND) | |||
41 | ENDIF(NOT GdkPixbuf_FIND_QUIETLY) | 42 | ENDIF(NOT GdkPixbuf_FIND_QUIETLY) |
42 | ENDIF(GdkPixbuf_FIND_REQUIRED) | 43 | ENDIF(GdkPixbuf_FIND_REQUIRED) |
43 | ENDIF(GDK_PIXBUF_LIBRARIES AND GDK_PIXBUF_INCLUDE_DIRS) | 44 | ENDIF(GDK_PIXBUF_LIBRARIES AND GDK_PIXBUF_INCLUDE_DIRS) |
45 | ELSE(NOT GDK_PIXBUF_FOUND AND NOT PKG_CONFIG_FOUND) | ||
46 | SET(GdkPixbuf_FOUND 1) | ||
44 | ENDIF(NOT GDK_PIXBUF_FOUND AND NOT PKG_CONFIG_FOUND) | 47 | ENDIF(NOT GDK_PIXBUF_FOUND AND NOT PKG_CONFIG_FOUND) |
45 | 48 | ||
46 | # Hide advanced variables from CMake GUIs | 49 | # Hide advanced variables from CMake GUIs |
diff --git a/CMakeLists.txt b/CMakeLists.txt index 2a9ffde9..5cd9c67b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -41,18 +41,37 @@ add_definitions(-DSWAY_GIT_BRANCH=\"${GIT_BRANCH}\") | |||
41 | string(TIMESTAMP CURRENT_DATE "%Y-%m-%d" UTC) | 41 | string(TIMESTAMP CURRENT_DATE "%Y-%m-%d" UTC) |
42 | add_definitions(-DSWAY_VERSION_DATE=\"${CURRENT_DATE}\") | 42 | add_definitions(-DSWAY_VERSION_DATE=\"${CURRENT_DATE}\") |
43 | 43 | ||
44 | find_package(Cairo REQUIRED) | 44 | option(enable-swaylock "Enables the swaylock utility" YES) |
45 | option(enable-swaybg "Enables the wallpaper utility" YES) | ||
46 | option(enable-swaybar "Enables the swaybar utility" YES) | ||
47 | option(enable-swaygrab "Enables the swaygrab utility" YES) | ||
48 | option(enable-swaymsg "Enables the swaymsg utility" YES) | ||
49 | option(enable-gdk-pixbuf "Use Pixbuf to support more image formats" YES) | ||
50 | |||
45 | find_package(JsonC REQUIRED) | 51 | find_package(JsonC REQUIRED) |
46 | find_package(PCRE REQUIRED) | 52 | find_package(PCRE REQUIRED) |
47 | find_package(Pango REQUIRED) | ||
48 | find_package(WLC REQUIRED) | 53 | find_package(WLC REQUIRED) |
49 | find_package(Wayland REQUIRED) | 54 | find_package(Wayland REQUIRED) |
50 | find_package(XKBCommon REQUIRED) | 55 | find_package(XKBCommon REQUIRED) |
51 | find_package(GdkPixbuf REQUIRED) | 56 | find_package(Cairo) |
52 | find_package(PAM REQUIRED) | 57 | find_package(Pango) |
58 | find_package(GdkPixbuf) | ||
59 | find_package(PAM) | ||
53 | 60 | ||
61 | include(FeatureSummary) | ||
54 | include(Manpage) | 62 | include(Manpage) |
55 | 63 | ||
64 | if (enable-gdk-pixbuf) | ||
65 | if (GDK_PIXBUF_FOUND) | ||
66 | set(WITH_GDK_PIXBUF YES) | ||
67 | add_definitions(-DWITH_GDK_PIXBUF) | ||
68 | else() | ||
69 | message(WARNING "gdk-pixbuf required but not found, only png images supported.") | ||
70 | endif() | ||
71 | else() | ||
72 | message(STATUS "Building without gdk-pixbuf, only png images supported.") | ||
73 | endif() | ||
74 | |||
56 | include_directories(include) | 75 | include_directories(include) |
57 | 76 | ||
58 | add_subdirectory(protocols) | 77 | add_subdirectory(protocols) |
@@ -60,14 +79,38 @@ add_subdirectory(common) | |||
60 | add_subdirectory(wayland) | 79 | add_subdirectory(wayland) |
61 | 80 | ||
62 | add_subdirectory(sway) | 81 | add_subdirectory(sway) |
63 | add_subdirectory(swaybg) | 82 | if(enable-swaybg) |
64 | add_subdirectory(swaymsg) | 83 | if(CAIRO_FOUND AND PANGO_FOUND) |
65 | add_subdirectory(swaygrab) | 84 | add_subdirectory(swaybg) |
66 | add_subdirectory(swaybar) | 85 | else() |
67 | add_subdirectory(swaylock) | 86 | message(WARNING "Not building swaybg - cairo, and pango are required.") |
87 | endif() | ||
88 | endif() | ||
89 | if(enable-swaymsg) | ||
90 | add_subdirectory(swaymsg) | ||
91 | endif() | ||
92 | if(enable-swaygrab) | ||
93 | add_subdirectory(swaygrab) | ||
94 | endif() | ||
95 | if(enable-swaybar) | ||
96 | if(CAIRO_FOUND AND PANGO_FOUND) | ||
97 | add_subdirectory(swaybar) | ||
98 | else() | ||
99 | message(WARNING "Not building swaybar - cairo, and pango are required.") | ||
100 | endif() | ||
101 | endif() | ||
102 | if(enable-swaylock) | ||
103 | if(CAIRO_FOUND AND PANGO_FOUND AND PAM_FOUND) | ||
104 | add_subdirectory(swaylock) | ||
105 | else() | ||
106 | message(WARNING "Not building swaylock - cairo, pango, and PAM are required.") | ||
107 | endif() | ||
108 | endif() | ||
68 | 109 | ||
69 | install( | 110 | install( |
70 | FILES ${CMAKE_CURRENT_SOURCE_DIR}/sway.desktop | 111 | FILES ${CMAKE_CURRENT_SOURCE_DIR}/sway.desktop |
71 | DESTINATION share/wayland-sessions | 112 | DESTINATION share/wayland-sessions |
72 | COMPONENT data | 113 | COMPONENT data |
73 | ) | 114 | ) |
115 | |||
116 | feature_summary(WHAT ALL) | ||
@@ -6,7 +6,7 @@ Read the [FAQ](https://github.com/SirCmpwn/sway/wiki). Join the | |||
6 | [IRC channel](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway on | 6 | [IRC channel](http://webchat.freenode.net/?channels=sway&uio=d4) (#sway on |
7 | irc.freenode.net). | 7 | irc.freenode.net). |
8 | 8 | ||
9 | ![](https://sr.ht/_qNU.png) | 9 | ![](https://sr.ht/NCx_.png) |
10 | 10 | ||
11 | ## Rationale | 11 | ## Rationale |
12 | 12 | ||
@@ -41,10 +41,14 @@ Install dependencies: | |||
41 | * asciidoc | 41 | * asciidoc |
42 | * pcre | 42 | * pcre |
43 | * json-c | 43 | * json-c |
44 | * pango | 44 | * pango * |
45 | * cairo | 45 | * cairo * |
46 | * gdk-pixbuf2 | 46 | * gdk-pixbuf2 * |
47 | * pam | 47 | * pam ** |
48 | |||
49 | _\*Only required for swaybar, swaybg, and swaylock_ | ||
50 | |||
51 | _\*\*Only required for swaylock_ | ||
48 | 52 | ||
49 | Run these commands: | 53 | Run these commands: |
50 | 54 | ||
diff --git a/include/client/cairo.h b/include/client/cairo.h index 98ced907..ad8390c4 100644 --- a/include/client/cairo.h +++ b/include/client/cairo.h | |||
@@ -1,8 +1,10 @@ | |||
1 | #ifndef _SWAY_CAIRO_H | 1 | #ifndef _SWAY_CAIRO_H |
2 | #define _SWAY_CAIRO_H | 2 | #define _SWAY_CAIRO_H |
3 | 3 | ||
4 | #ifdef WITH_GDK_PIXBUF | ||
4 | #include <gdk-pixbuf/gdk-pixbuf.h> | 5 | #include <gdk-pixbuf/gdk-pixbuf.h> |
5 | 6 | ||
6 | cairo_surface_t* gdk_cairo_image_surface_create_from_pixbuf(const GdkPixbuf *gdkbuf); | 7 | cairo_surface_t* gdk_cairo_image_surface_create_from_pixbuf(const GdkPixbuf *gdkbuf); |
8 | #endif //WITH_GDK_PIXBUF | ||
7 | 9 | ||
8 | #endif | 10 | #endif |
diff --git a/sway/config.c b/sway/config.c index faa3e387..4b1bf01a 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -53,7 +53,9 @@ static void free_bar(struct bar_config *bar) { | |||
53 | } | 53 | } |
54 | list_free(bar->bindings); | 54 | list_free(bar->bindings); |
55 | 55 | ||
56 | free_flat_list(bar->outputs); | 56 | if (bar->outputs) { |
57 | free_flat_list(bar->outputs); | ||
58 | } | ||
57 | free(bar); | 59 | free(bar); |
58 | } | 60 | } |
59 | 61 | ||
@@ -450,7 +452,7 @@ void load_swaybars(swayc_t *output, int output_idx) { | |||
450 | int j; | 452 | int j; |
451 | for (j = 0; j < bar->outputs->length; ++j) { | 453 | for (j = 0; j < bar->outputs->length; ++j) { |
452 | char *o = bar->outputs->items[j]; | 454 | char *o = bar->outputs->items[j]; |
453 | if (strcmp(o, "*") || strcasecmp(o, output->name)) { | 455 | if (!strcmp(o, "*") || !strcasecmp(o, output->name)) { |
454 | apply = true; | 456 | apply = true; |
455 | break; | 457 | break; |
456 | } | 458 | } |
diff --git a/swaybar/main.c b/swaybar/main.c index 243ef2a9..5b8ba45d 100644 --- a/swaybar/main.c +++ b/swaybar/main.c | |||
@@ -18,8 +18,6 @@ | |||
18 | #include "stringop.h" | 18 | #include "stringop.h" |
19 | #include "log.h" | 19 | #include "log.h" |
20 | 20 | ||
21 | #define MARGIN 5 | ||
22 | |||
23 | struct box_colors { | 21 | struct box_colors { |
24 | uint32_t border; | 22 | uint32_t border; |
25 | uint32_t background; | 23 | uint32_t background; |
@@ -188,6 +186,11 @@ uint32_t parse_position(const char *position) { | |||
188 | } | 186 | } |
189 | } | 187 | } |
190 | 188 | ||
189 | static int margin = 3; | ||
190 | static const int ws_hor_padding = 5; | ||
191 | static double ws_ver_padding = 1.5; | ||
192 | static const int ws_spacing = 1; | ||
193 | |||
191 | void bar_ipc_init(int outputi, const char *bar_id) { | 194 | void bar_ipc_init(int outputi, const char *bar_id) { |
192 | uint32_t len = 0; | 195 | uint32_t len = 0; |
193 | char *res = ipc_single_command(socketfd, IPC_GET_OUTPUTS, NULL, &len); | 196 | char *res = ipc_single_command(socketfd, IPC_GET_OUTPUTS, NULL, &len); |
@@ -229,6 +232,17 @@ void bar_ipc_init(int outputi, const char *bar_id) { | |||
229 | desktop_shell_set_panel_position(registry->desktop_shell, parse_position(json_object_get_string(position))); | 232 | desktop_shell_set_panel_position(registry->desktop_shell, parse_position(json_object_get_string(position))); |
230 | } | 233 | } |
231 | 234 | ||
235 | if (bar_height) { | ||
236 | int width, height; | ||
237 | get_text_size(window, &width, &height, "Test string for measuring purposes"); | ||
238 | int bar_height_value = json_object_get_int(bar_height); | ||
239 | if (bar_height_value > 0) { | ||
240 | margin = (bar_height_value - height) / 2; | ||
241 | ws_ver_padding = margin - 1.5; | ||
242 | } | ||
243 | window->height = height + margin * 2; | ||
244 | } | ||
245 | |||
232 | if (_colors) { | 246 | if (_colors) { |
233 | json_object *background, *statusline, *separator; | 247 | json_object *background, *statusline, *separator; |
234 | json_object *focused_workspace_border, *focused_workspace_bg, *focused_workspace_text; | 248 | json_object *focused_workspace_border, *focused_workspace_bg, *focused_workspace_text; |
@@ -321,12 +335,12 @@ void render() { | |||
321 | int width, height; | 335 | int width, height; |
322 | get_text_size(window, &width, &height, "%s", line); | 336 | get_text_size(window, &width, &height, "%s", line); |
323 | 337 | ||
324 | cairo_move_to(window->cairo, window->width - MARGIN - width, MARGIN); | 338 | cairo_move_to(window->cairo, window->width - margin - width, margin); |
325 | pango_printf(window, "%s", line); | 339 | pango_printf(window, "%s", line); |
326 | 340 | ||
327 | // Workspaces | 341 | // Workspaces |
328 | cairo_set_line_width(window->cairo, 2.0); | 342 | cairo_set_line_width(window->cairo, 1.0); |
329 | int x = 1; | 343 | double x = 0.5; |
330 | int i; | 344 | int i; |
331 | for (i = 0; i < workspaces->length; ++i) { | 345 | for (i = 0; i < workspaces->length; ++i) { |
332 | struct workspace *ws = workspaces->items[i]; | 346 | struct workspace *ws = workspaces->items[i]; |
@@ -341,19 +355,20 @@ void render() { | |||
341 | } else { | 355 | } else { |
342 | box_colors = colors.inactive_workspace; | 356 | box_colors = colors.inactive_workspace; |
343 | } | 357 | } |
358 | |||
344 | cairo_set_source_u32(window->cairo, box_colors.background); | 359 | cairo_set_source_u32(window->cairo, box_colors.background); |
345 | cairo_rectangle(window->cairo, x, 0, width + MARGIN * 2, window->height); | 360 | cairo_rectangle(window->cairo, x, 1.5, width + ws_hor_padding * 2 - 1, height + ws_ver_padding * 2); |
346 | cairo_fill(window->cairo); | 361 | cairo_fill(window->cairo); |
347 | 362 | ||
348 | cairo_set_source_u32(window->cairo, box_colors.border); | 363 | cairo_set_source_u32(window->cairo, box_colors.border); |
349 | cairo_rectangle(window->cairo, x, 2, width + MARGIN * 2, window->height - 4); | 364 | cairo_rectangle(window->cairo, x, 1.5, width + ws_hor_padding * 2 - 1, height + ws_ver_padding * 2); |
350 | cairo_stroke(window->cairo); | 365 | cairo_stroke(window->cairo); |
351 | 366 | ||
352 | cairo_set_source_u32(window->cairo, box_colors.text); | 367 | cairo_set_source_u32(window->cairo, box_colors.text); |
353 | cairo_move_to(window->cairo, x + MARGIN, MARGIN); | 368 | cairo_move_to(window->cairo, (int)x + ws_hor_padding, margin); |
354 | pango_printf(window, "%s", ws->name); | 369 | pango_printf(window, "%s", ws->name); |
355 | 370 | ||
356 | x += width + MARGIN * 2 + MARGIN; | 371 | x += width + ws_hor_padding * 2 + ws_spacing; |
357 | } | 372 | } |
358 | } | 373 | } |
359 | 374 | ||
@@ -467,6 +482,12 @@ int main(int argc, char **argv) { | |||
467 | int desired_output = atoi(argv[optind]); | 482 | int desired_output = atoi(argv[optind]); |
468 | struct output_state *output = registry->outputs->items[desired_output]; | 483 | struct output_state *output = registry->outputs->items[desired_output]; |
469 | 484 | ||
485 | window = window_setup(registry, output->width, 30, false); | ||
486 | if (!window) { | ||
487 | sway_abort("Failed to create window."); | ||
488 | } | ||
489 | desktop_shell_set_panel(registry->desktop_shell, output->output, window->surface); | ||
490 | |||
470 | bar_ipc_init(desired_output, bar_id); | 491 | bar_ipc_init(desired_output, bar_id); |
471 | 492 | ||
472 | if (status_command) { | 493 | if (status_command) { |
@@ -491,16 +512,6 @@ int main(int argc, char **argv) { | |||
491 | line[0] = '\0'; | 512 | line[0] = '\0'; |
492 | } | 513 | } |
493 | 514 | ||
494 | window = window_setup(registry, output->width, 30, false); | ||
495 | if (!window) { | ||
496 | sway_abort("Failed to create window."); | ||
497 | } | ||
498 | desktop_shell_set_panel(registry->desktop_shell, output->output, window->surface); | ||
499 | |||
500 | int width, height; | ||
501 | get_text_size(window, &width, &height, "Test string for measuring purposes"); | ||
502 | window->height = height + MARGIN * 2; | ||
503 | |||
504 | poll_for_update(); | 515 | poll_for_update(); |
505 | 516 | ||
506 | window_teardown(window); | 517 | window_teardown(window); |
diff --git a/swaybg/CMakeLists.txt b/swaybg/CMakeLists.txt index 4dc961ff..68098370 100644 --- a/swaybg/CMakeLists.txt +++ b/swaybg/CMakeLists.txt | |||
@@ -3,7 +3,6 @@ include_directories( | |||
3 | ${WAYLAND_CLIENT_INCLUDE_DIR} | 3 | ${WAYLAND_CLIENT_INCLUDE_DIR} |
4 | ${CAIRO_INCLUDE_DIRS} | 4 | ${CAIRO_INCLUDE_DIRS} |
5 | ${PANGO_INCLUDE_DIRS} | 5 | ${PANGO_INCLUDE_DIRS} |
6 | ${GDK_PIXBUF_INCLUDE_DIRS} | ||
7 | ) | 6 | ) |
8 | 7 | ||
9 | add_executable(swaybg | 8 | add_executable(swaybg |
@@ -17,10 +16,18 @@ target_link_libraries(swaybg | |||
17 | ${WAYLAND_CURSOR_LIBRARIES} | 16 | ${WAYLAND_CURSOR_LIBRARIES} |
18 | ${CAIRO_LIBRARIES} | 17 | ${CAIRO_LIBRARIES} |
19 | ${PANGO_LIBRARIES} | 18 | ${PANGO_LIBRARIES} |
20 | ${GDK_PIXBUF_LIBRARIES} | ||
21 | m | 19 | m |
22 | ) | 20 | ) |
23 | 21 | ||
22 | if (WITH_GDK_PIXBUF) | ||
23 | include_directories( | ||
24 | ${GDK_PIXBUF_INCLUDE_DIRS} | ||
25 | ) | ||
26 | target_link_libraries(swaybg | ||
27 | ${GDK_PIXBUF_LIBRARIES} | ||
28 | ) | ||
29 | endif() | ||
30 | |||
24 | install( | 31 | install( |
25 | TARGETS swaybg | 32 | TARGETS swaybg |
26 | RUNTIME | 33 | RUNTIME |
diff --git a/swaybg/main.c b/swaybg/main.c index 2ae06c6f..b936be2b 100644 --- a/swaybg/main.c +++ b/swaybg/main.c | |||
@@ -56,6 +56,7 @@ int main(int argc, const char **argv) { | |||
56 | desktop_shell_set_background(registry->desktop_shell, output->output, window->surface); | 56 | desktop_shell_set_background(registry->desktop_shell, output->output, window->surface); |
57 | list_add(surfaces, window); | 57 | list_add(surfaces, window); |
58 | 58 | ||
59 | #ifdef WITH_GDK_PIXBUF | ||
59 | GError *err = NULL; | 60 | GError *err = NULL; |
60 | GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(argv[2], &err); | 61 | GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(argv[2], &err); |
61 | if (!pixbuf) { | 62 | if (!pixbuf) { |
@@ -63,6 +64,9 @@ int main(int argc, const char **argv) { | |||
63 | } | 64 | } |
64 | cairo_surface_t *image = gdk_cairo_image_surface_create_from_pixbuf(pixbuf); | 65 | cairo_surface_t *image = gdk_cairo_image_surface_create_from_pixbuf(pixbuf); |
65 | g_object_unref(pixbuf); | 66 | g_object_unref(pixbuf); |
67 | #else | ||
68 | cairo_surface_t *image = cairo_image_surface_create_from_png(argv[2]); | ||
69 | #endif //WITH_GDK_PIXBUF | ||
66 | if (!image) { | 70 | if (!image) { |
67 | sway_abort("Failed to read background image."); | 71 | sway_abort("Failed to read background image."); |
68 | } | 72 | } |
diff --git a/swaylock/CMakeLists.txt b/swaylock/CMakeLists.txt index 306be80e..950a170d 100644 --- a/swaylock/CMakeLists.txt +++ b/swaylock/CMakeLists.txt | |||
@@ -2,7 +2,6 @@ include_directories( | |||
2 | ${PROTOCOLS_INCLUDE_DIRS} | 2 | ${PROTOCOLS_INCLUDE_DIRS} |
3 | ${WAYLAND_CLIENT_INCLUDE_DIR} | 3 | ${WAYLAND_CLIENT_INCLUDE_DIR} |
4 | ${CAIRO_INCLUDE_DIRS} | 4 | ${CAIRO_INCLUDE_DIRS} |
5 | ${GDK_PIXBUF_INCLUDE_DIRS} | ||
6 | ${PANGO_INCLUDE_DIRS} | 5 | ${PANGO_INCLUDE_DIRS} |
7 | ${PAM_INCLUDE_DIRS} | 6 | ${PAM_INCLUDE_DIRS} |
8 | ) | 7 | ) |
@@ -17,12 +16,20 @@ target_link_libraries(swaylock | |||
17 | ${WAYLAND_CLIENT_LIBRARIES} | 16 | ${WAYLAND_CLIENT_LIBRARIES} |
18 | ${WAYLAND_CURSOR_LIBRARIES} | 17 | ${WAYLAND_CURSOR_LIBRARIES} |
19 | ${CAIRO_LIBRARIES} | 18 | ${CAIRO_LIBRARIES} |
20 | ${GDK_PIXBUF_LIBRARIES} | ||
21 | ${PANGO_LIBRARIES} | 19 | ${PANGO_LIBRARIES} |
22 | ${PAM_LIBRARIES} | 20 | ${PAM_LIBRARIES} |
23 | m | 21 | m |
24 | ) | 22 | ) |
25 | 23 | ||
24 | if (WITH_GDK_PIXBUF) | ||
25 | include_directories( | ||
26 | ${GDK_PIXBUF_INCLUDE_DIRS} | ||
27 | ) | ||
28 | target_link_libraries(swaylock | ||
29 | ${GDK_PIXBUF_LIBRARIES} | ||
30 | ) | ||
31 | endif() | ||
32 | |||
26 | install( | 33 | install( |
27 | TARGETS swaylock | 34 | TARGETS swaylock |
28 | RUNTIME | 35 | RUNTIME |
diff --git a/swaylock/main.c b/swaylock/main.c index 82b88731..eccb902e 100644 --- a/swaylock/main.c +++ b/swaylock/main.c | |||
@@ -113,6 +113,7 @@ int main(int argc, char **argv) { | |||
113 | 113 | ||
114 | registry->input->notify = notify_key; | 114 | registry->input->notify = notify_key; |
115 | 115 | ||
116 | #ifdef WITH_GDK_PIXBUF | ||
116 | GError *err = NULL; | 117 | GError *err = NULL; |
117 | GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(argv[1], &err); // TODO: Parse i3lock arguments | 118 | GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(argv[1], &err); // TODO: Parse i3lock arguments |
118 | if (!pixbuf) { | 119 | if (!pixbuf) { |
@@ -120,6 +121,9 @@ int main(int argc, char **argv) { | |||
120 | } | 121 | } |
121 | cairo_surface_t *image = gdk_cairo_image_surface_create_from_pixbuf(pixbuf); | 122 | cairo_surface_t *image = gdk_cairo_image_surface_create_from_pixbuf(pixbuf); |
122 | g_object_unref(pixbuf); | 123 | g_object_unref(pixbuf); |
124 | #else | ||
125 | cairo_surface_t *image = cairo_image_surface_create_from_png(argv[1]); | ||
126 | #endif //WITH_GDK_PIXBUF | ||
123 | if (!image) { | 127 | if (!image) { |
124 | sway_abort("Failed to read background image."); | 128 | sway_abort("Failed to read background image."); |
125 | } | 129 | } |
diff --git a/wayland/CMakeLists.txt b/wayland/CMakeLists.txt index 6519cd7d..282ea1aa 100644 --- a/wayland/CMakeLists.txt +++ b/wayland/CMakeLists.txt | |||
@@ -1,7 +1,6 @@ | |||
1 | include_directories( | 1 | include_directories( |
2 | ${PROTOCOLS_INCLUDE_DIRS} | 2 | ${PROTOCOLS_INCLUDE_DIRS} |
3 | ${PANGO_INCLUDE_DIRS} | 3 | ${PANGO_INCLUDE_DIRS} |
4 | ${GDK_PIXBUF_INCLUDE_DIRS} | ||
5 | ${XKBCOMMON_INCLUDE_DIRS} | 4 | ${XKBCOMMON_INCLUDE_DIRS} |
6 | ) | 5 | ) |
7 | 6 | ||
@@ -17,6 +16,14 @@ target_link_libraries(sway-wayland | |||
17 | sway-common | 16 | sway-common |
18 | sway-protocols | 17 | sway-protocols |
19 | ${PANGO_LIBRARIES} | 18 | ${PANGO_LIBRARIES} |
20 | ${GDK_PIXBUF_LIBRARIES} | ||
21 | ${XKBCOMMON_LIBRARIES} | 19 | ${XKBCOMMON_LIBRARIES} |
22 | ) | 20 | ) |
21 | |||
22 | if (WITH_GDK_PIXBUF) | ||
23 | include_directories( | ||
24 | ${GDK_PIXBUF_INCLUDE_DIRS} | ||
25 | ) | ||
26 | target_link_libraries(sway-wayland | ||
27 | ${GDK_PIXBUF_LIBRARIES} | ||
28 | ) | ||
29 | endif() | ||
diff --git a/wayland/cairo.c b/wayland/cairo.c index 10a15f40..7462b10a 100644 --- a/wayland/cairo.c +++ b/wayland/cairo.c | |||
@@ -1,7 +1,9 @@ | |||
1 | #include <gdk-pixbuf/gdk-pixbuf.h> | ||
2 | #include <cairo/cairo.h> | 1 | #include <cairo/cairo.h> |
3 | #include "client/cairo.h" | 2 | #include "client/cairo.h" |
4 | 3 | ||
4 | #ifdef WITH_GDK_PIXBUF | ||
5 | #include <gdk-pixbuf/gdk-pixbuf.h> | ||
6 | |||
5 | #ifndef GDK_PIXBUF_CHECK_VERSION | 7 | #ifndef GDK_PIXBUF_CHECK_VERSION |
6 | #define GDK_PIXBUF_CHECK_VERSION(major,minor,micro) \ | 8 | #define GDK_PIXBUF_CHECK_VERSION(major,minor,micro) \ |
7 | (GDK_PIXBUF_MAJOR > (major) || \ | 9 | (GDK_PIXBUF_MAJOR > (major) || \ |
@@ -103,3 +105,4 @@ cairo_surface_t* gdk_cairo_image_surface_create_from_pixbuf(const GdkPixbuf *gdk | |||
103 | cairo_surface_mark_dirty(cs); | 105 | cairo_surface_mark_dirty(cs); |
104 | return cs; | 106 | return cs; |
105 | } | 107 | } |
108 | #endif //WITH_GDK_PIXBUF | ||