border: clear buffer on fullscreen views
This patch makes sure to clear the border buffer of fullscreen view so the border doesn't get drawn behind a fullscreen view, which would be visible if the view was transparent.
This commit is contained in:
parent
27066c6328
commit
ddd5b69b99
|
@ -3,11 +3,19 @@
|
||||||
#include <wlc/wlc.h>
|
#include <wlc/wlc.h>
|
||||||
#include "container.h"
|
#include "container.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Border pixel buffer and corresponding geometry.
|
||||||
|
*/
|
||||||
struct border {
|
struct border {
|
||||||
unsigned char *buffer;
|
unsigned char *buffer;
|
||||||
struct wlc_geometry geometry;
|
struct wlc_geometry geometry;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear border buffer.
|
||||||
|
*/
|
||||||
|
void border_clear(struct border *border);
|
||||||
|
|
||||||
void render_view_borders(wlc_handle view);
|
void render_view_borders(wlc_handle view);
|
||||||
void update_view_border(swayc_t *view);
|
void update_view_border(swayc_t *view);
|
||||||
void map_update_view_border(swayc_t *view, void *data);
|
void map_update_view_border(swayc_t *view, void *data);
|
||||||
|
|
|
@ -4,12 +4,11 @@
|
||||||
#include <pango/pangocairo.h>
|
#include <pango/pangocairo.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
#include "container.h"
|
#include "container.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "client/pango.h"
|
#include "client/pango.h"
|
||||||
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
|
|
||||||
void cairo_set_source_u32(cairo_t *cairo, uint32_t color) {
|
void cairo_set_source_u32(cairo_t *cairo, uint32_t color) {
|
||||||
color = htonl(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);
|
(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) {
|
static cairo_t *create_border_buffer(swayc_t *view, struct wlc_geometry g, cairo_surface_t **surface) {
|
||||||
if (view->border == NULL) {
|
if (view->border == NULL) {
|
||||||
view->border = malloc(sizeof(struct border));
|
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,
|
*surface = cairo_image_surface_create_for_data(view->border->buffer,
|
||||||
CAIRO_FORMAT_ARGB32, g.size.w, g.size.h, stride);
|
CAIRO_FORMAT_ARGB32, g.size.w, g.size.h, stride);
|
||||||
if (cairo_surface_status(*surface) != CAIRO_STATUS_SUCCESS) {
|
if (cairo_surface_status(*surface) != CAIRO_STATUS_SUCCESS) {
|
||||||
free(view->border);
|
border_clear(view->border);
|
||||||
view->border->buffer = NULL;
|
|
||||||
sway_log(L_DEBUG, "Unable to allocate surface");
|
sway_log(L_DEBUG, "Unable to allocate surface");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
cr = cairo_create(*surface);
|
cr = cairo_create(*surface);
|
||||||
if (cairo_status(cr) != CAIRO_STATUS_SUCCESS) {
|
if (cairo_status(cr) != CAIRO_STATUS_SUCCESS) {
|
||||||
cairo_surface_destroy(*surface);
|
cairo_surface_destroy(*surface);
|
||||||
free(view->border->buffer);
|
border_clear(view->border);
|
||||||
view->border->buffer = NULL;
|
|
||||||
sway_log(L_DEBUG, "Unable to create cairo context");
|
sway_log(L_DEBUG, "Unable to create cairo context");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -295,10 +299,8 @@ void update_view_border(swayc_t *view) {
|
||||||
cairo_t *cr = NULL;
|
cairo_t *cr = NULL;
|
||||||
cairo_surface_t *surface = NULL;
|
cairo_surface_t *surface = NULL;
|
||||||
|
|
||||||
if (view->border && view->border->buffer) {
|
// clear previous border buffer.
|
||||||
free(view->border->buffer);
|
border_clear(view->border);
|
||||||
view->border->buffer = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get focused and focused_inactive views
|
// get focused and focused_inactive views
|
||||||
swayc_t *focused = get_focused_view(&root_container);
|
swayc_t *focused = get_focused_view(&root_container);
|
||||||
|
|
|
@ -555,6 +555,7 @@ void update_geometry(swayc_t *container) {
|
||||||
|
|
||||||
container->border_geometry = wlc_geometry_zero;
|
container->border_geometry = wlc_geometry_zero;
|
||||||
container->title_bar_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
|
} else if (container->is_floating) { // allocate border for floating window
|
||||||
update_border_geometry_floating(container, &geometry);
|
update_border_geometry_floating(container, &geometry);
|
||||||
} else if (!container->is_floating) { // allocate border for titled window
|
} else if (!container->is_floating) { // allocate border for titled window
|
||||||
|
|
Loading…
Reference in a new issue