diff options
author | Drew DeVault <sir@cmpwn.com> | 2016-04-27 07:19:47 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2016-04-27 07:19:47 -0400 |
commit | 89af3f78b2cce23953d4c67603bbc1d09b980bcc (patch) | |
tree | 8e185c6a180f62ccf3a2fd55164a6b449bbceb1e | |
parent | 70f0099918587483ca523bd11c309c046fea037c (diff) | |
parent | ddd5b69b998a8f413ad3b7ec5ff4d54221dfc0b6 (diff) | |
download | sway-89af3f78b2cce23953d4c67603bbc1d09b980bcc.tar.xz |
Merge pull request #606 from mikkeloscar/tabbed-stacking-layout
border: clear buffer on fullscreen views
-rw-r--r-- | include/border.h | 8 | ||||
-rw-r--r-- | sway/border.c | 26 | ||||
-rw-r--r-- | sway/layout.c | 1 |
3 files changed, 23 insertions, 12 deletions
diff --git a/include/border.h b/include/border.h index c99c02ea..eb7fc656 100644 --- a/include/border.h +++ b/include/border.h @@ -3,11 +3,19 @@ #include <wlc/wlc.h> #include "container.h" +/** + * Border pixel buffer and corresponding geometry. + */ struct border { unsigned char *buffer; struct wlc_geometry geometry; }; +/** + * Clear border buffer. + */ +void border_clear(struct border *border); + void render_view_borders(wlc_handle view); void update_view_border(swayc_t *view); void map_update_view_border(swayc_t *view, void *data); diff --git a/sway/border.c b/sway/border.c index cec443f4..d261d006 100644 --- a/sway/border.c +++ b/sway/border.c @@ -4,12 +4,11 @@ #include <pango/pangocairo.h> #include <stdlib.h> #include <stdio.h> +#include <arpa/inet.h> #include "container.h" #include "config.h" #include "client/pango.h" -#include <arpa/inet.h> - void cairo_set_source_u32(cairo_t *cairo, uint32_t color) { color = htonl(color); @@ -20,6 +19,13 @@ void cairo_set_source_u32(cairo_t *cairo, uint32_t color) { (color >> (3*8) & 0xFF) / 255.0); } +void border_clear(struct border *border) { + if (border && border->buffer) { + free(border->buffer); + border->buffer = NULL; + } +} + static cairo_t *create_border_buffer(swayc_t *view, struct wlc_geometry g, cairo_surface_t **surface) { if (view->border == NULL) { view->border = malloc(sizeof(struct border)); @@ -35,16 +41,14 @@ static cairo_t *create_border_buffer(swayc_t *view, struct wlc_geometry g, cairo *surface = cairo_image_surface_create_for_data(view->border->buffer, CAIRO_FORMAT_ARGB32, g.size.w, g.size.h, stride); if (cairo_surface_status(*surface) != CAIRO_STATUS_SUCCESS) { - free(view->border); - view->border->buffer = NULL; + border_clear(view->border); sway_log(L_DEBUG, "Unable to allocate surface"); return NULL; } cr = cairo_create(*surface); if (cairo_status(cr) != CAIRO_STATUS_SUCCESS) { cairo_surface_destroy(*surface); - free(view->border->buffer); - view->border->buffer = NULL; + border_clear(view->border); sway_log(L_DEBUG, "Unable to create cairo context"); return NULL; } @@ -295,10 +299,8 @@ void update_view_border(swayc_t *view) { cairo_t *cr = NULL; cairo_surface_t *surface = NULL; - if (view->border && view->border->buffer) { - free(view->border->buffer); - view->border->buffer = NULL; - } + // clear previous border buffer. + border_clear(view->border); // get focused and focused_inactive views swayc_t *focused = get_focused_view(&root_container); @@ -315,8 +317,8 @@ void update_view_border(swayc_t *view) { // for tabbed/stacked layouts the focused view has to draw all the // titlebars of the hidden views. - swayc_t *p = swayc_tabbed_stacked_parent(view); - if (p && view->parent->focused == view) { + swayc_t *p = NULL; + if (view->parent->focused == view && (p = swayc_tabbed_stacked_parent(view))) { struct wlc_geometry g = { .origin = { .x = p->x, diff --git a/sway/layout.c b/sway/layout.c index 3e550927..902a521b 100644 --- a/sway/layout.c +++ b/sway/layout.c @@ -555,6 +555,7 @@ void update_geometry(swayc_t *container) { container->border_geometry = wlc_geometry_zero; container->title_bar_geometry = wlc_geometry_zero; + border_clear(container->border); } else if (container->is_floating) { // allocate border for floating window update_border_geometry_floating(container, &geometry); } else if (!container->is_floating) { // allocate border for titled window |