diff options
author | Drew DeVault <sir@cmpwn.com> | 2016-01-28 08:39:51 -0500 |
---|---|---|
committer | Mikkel Oscar Lyderik <mikkeloscar@gmail.com> | 2016-03-30 00:47:58 +0200 |
commit | 4611bba3dbf63a5ef67bf90d5ebd192eeb07742e (patch) | |
tree | a57320e5a6d463c020986c324a4671aaeed0e415 | |
parent | Merge pull request #553 from Hummer12007/master (diff) | |
download | sway-4611bba3dbf63a5ef67bf90d5ebd192eeb07742e.tar.gz sway-4611bba3dbf63a5ef67bf90d5ebd192eeb07742e.tar.zst sway-4611bba3dbf63a5ef67bf90d5ebd192eeb07742e.zip |
Initial setup of window border rendering
Please don't complain to me about the performance of this
-rw-r--r-- | include/render.h | 7 | ||||
-rw-r--r-- | sway/CMakeLists.txt | 5 | ||||
-rw-r--r-- | sway/handlers.c | 6 | ||||
-rw-r--r-- | sway/render.c | 35 |
4 files changed, 53 insertions, 0 deletions
diff --git a/include/render.h b/include/render.h new file mode 100644 index 00000000..19d3a52e --- /dev/null +++ b/include/render.h | |||
@@ -0,0 +1,7 @@ | |||
1 | #ifndef _SWAY_RENDER_H | ||
2 | #define _SWAY_RENDER_H | ||
3 | #include <wlc/wlc.h> | ||
4 | |||
5 | void render_view_borders(wlc_handle view); | ||
6 | |||
7 | #endif | ||
diff --git a/sway/CMakeLists.txt b/sway/CMakeLists.txt index 5b6104f3..6c62d676 100644 --- a/sway/CMakeLists.txt +++ b/sway/CMakeLists.txt | |||
@@ -5,6 +5,8 @@ include_directories( | |||
5 | ${JSONC_INCLUDE_DIRS} | 5 | ${JSONC_INCLUDE_DIRS} |
6 | ${XKBCOMMON_INCLUDE_DIRS} | 6 | ${XKBCOMMON_INCLUDE_DIRS} |
7 | ${LIBINPUT_INCLUDE_DIRS} | 7 | ${LIBINPUT_INCLUDE_DIRS} |
8 | ${CAIRO_INCLUDE_DIRS} | ||
9 | ${PANGO_INCLUDE_DIRS} | ||
8 | ) | 10 | ) |
9 | 11 | ||
10 | add_executable(sway | 12 | add_executable(sway |
@@ -24,6 +26,7 @@ add_executable(sway | |||
24 | output.c | 26 | output.c |
25 | resize.c | 27 | resize.c |
26 | workspace.c | 28 | workspace.c |
29 | render.c | ||
27 | ) | 30 | ) |
28 | 31 | ||
29 | add_definitions( | 32 | add_definitions( |
@@ -39,6 +42,8 @@ target_link_libraries(sway | |||
39 | ${JSONC_LIBRARIES} | 42 | ${JSONC_LIBRARIES} |
40 | ${WAYLAND_SERVER_LIBRARIES} | 43 | ${WAYLAND_SERVER_LIBRARIES} |
41 | ${LIBINPUT_LIBRARIES} | 44 | ${LIBINPUT_LIBRARIES} |
45 | ${PANGO_LIBRARIES} | ||
46 | ${JSONC_LIBRARIES} | ||
42 | m | 47 | m |
43 | ) | 48 | ) |
44 | 49 | ||
diff --git a/sway/handlers.c b/sway/handlers.c index 7d4ea263..dff682f5 100644 --- a/sway/handlers.c +++ b/sway/handlers.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <ctype.h> | 9 | #include <ctype.h> |
10 | 10 | ||
11 | #include "handlers.h" | 11 | #include "handlers.h" |
12 | #include "render.h" | ||
12 | #include "log.h" | 13 | #include "log.h" |
13 | #include "layout.h" | 14 | #include "layout.h" |
14 | #include "config.h" | 15 | #include "config.h" |
@@ -150,6 +151,10 @@ static void handle_output_post_render(wlc_handle output) { | |||
150 | ipc_get_pixels(output); | 151 | ipc_get_pixels(output); |
151 | } | 152 | } |
152 | 153 | ||
154 | static void handle_view_pre_render(wlc_handle view) { | ||
155 | render_view_borders(view); | ||
156 | } | ||
157 | |||
153 | static void handle_output_resolution_change(wlc_handle output, const struct wlc_size *from, const struct wlc_size *to) { | 158 | static void handle_output_resolution_change(wlc_handle output, const struct wlc_size *from, const struct wlc_size *to) { |
154 | sway_log(L_DEBUG, "Output %u resolution changed to %d x %d", (unsigned int)output, to->w, to->h); | 159 | sway_log(L_DEBUG, "Output %u resolution changed to %d x %d", (unsigned int)output, to->w, to->h); |
155 | swayc_t *c = swayc_by_handle(output); | 160 | swayc_t *c = swayc_by_handle(output); |
@@ -716,6 +721,7 @@ void register_wlc_handlers() { | |||
716 | wlc_set_view_created_cb(handle_view_created); | 721 | wlc_set_view_created_cb(handle_view_created); |
717 | wlc_set_view_destroyed_cb(handle_view_destroyed); | 722 | wlc_set_view_destroyed_cb(handle_view_destroyed); |
718 | wlc_set_view_focus_cb(handle_view_focus); | 723 | wlc_set_view_focus_cb(handle_view_focus); |
724 | wlc_set_view_render_pre_cb(handle_view_pre_render); | ||
719 | wlc_set_view_request_geometry_cb(handle_view_geometry_request); | 725 | wlc_set_view_request_geometry_cb(handle_view_geometry_request); |
720 | wlc_set_view_request_state_cb(handle_view_state_request); | 726 | wlc_set_view_request_state_cb(handle_view_state_request); |
721 | wlc_set_keyboard_key_cb(handle_key); | 727 | wlc_set_keyboard_key_cb(handle_key); |
diff --git a/sway/render.c b/sway/render.c new file mode 100644 index 00000000..66d2e5f0 --- /dev/null +++ b/sway/render.c | |||
@@ -0,0 +1,35 @@ | |||
1 | #include "render.h" | ||
2 | #include <cairo.h> | ||
3 | #include <stdlib.h> | ||
4 | |||
5 | cairo_t *create_cairo_context(int width, int height, int channels, | ||
6 | cairo_surface_t **surf, unsigned char **buf) { | ||
7 | cairo_t *cr; | ||
8 | *buf = calloc(channels * width * height, sizeof(unsigned char)); | ||
9 | if (!*buf) { | ||
10 | return NULL; | ||
11 | } | ||
12 | *surf = cairo_image_surface_create_for_data(*buf, CAIRO_FORMAT_ARGB32, | ||
13 | width, height, channels * width); | ||
14 | if (cairo_surface_status(*surf) != CAIRO_STATUS_SUCCESS) { | ||
15 | free(*buf); | ||
16 | return NULL; | ||
17 | } | ||
18 | cr = cairo_create(*surf); | ||
19 | if (cairo_status(cr) != CAIRO_STATUS_SUCCESS) { | ||
20 | free(*buf); | ||
21 | return NULL; | ||
22 | } | ||
23 | return cr; | ||
24 | } | ||
25 | |||
26 | void render_view_borders(wlc_handle view) { | ||
27 | unsigned char *surf_data; | ||
28 | cairo_surface_t *surf; | ||
29 | int texture_id; | ||
30 | const struct wlc_geometry *geo = wlc_view_get_geometry(view); | ||
31 | cairo_t *cr = create_cairo_context(geo->size.w, geo->size.h, 4, &surf, &surf_data); | ||
32 | // TODO | ||
33 | cairo_destroy(cr); | ||
34 | free(surf_data); | ||
35 | } | ||