theme: create hover button fallbacks

...by copying the non-hover variant and adding a transparent overlay.

Co-authored-by: @johanmalm
This commit is contained in:
Consolatis 2023-12-17 02:16:49 +01:00
parent d207e97992
commit 27de4e6398
6 changed files with 150 additions and 0 deletions

View file

@ -3,8 +3,10 @@
#include <assert.h>
#include <cairo.h>
#include <stdlib.h>
#include <string.h>
#include <wlr/types/wlr_scene.h>
#include <wlr/util/box.h>
#include "buffer.h"
#include "common/graphic-helpers.h"
#include "common/mem.h"
@ -85,3 +87,32 @@ set_cairo_color(cairo_t *cairo, float *c)
{
cairo_set_source_rgba(cairo, c[0], c[1], c[2], c[3]);
}
struct surface_context
get_cairo_surface_from_lab_data_buffer(struct lab_data_buffer *buffer)
{
/* Handle CAIRO_FORMAT_ARGB32 buffers */
if (buffer->cairo) {
return (struct surface_context){
.is_duplicate = false,
.surface = cairo_get_target(buffer->cairo),
};
}
/* Handle DRM_FORMAT_ARGB8888 buffers */
int w = buffer->unscaled_width;
int h = buffer->unscaled_height;
cairo_surface_t *surface =
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h);
if (!surface) {
return (struct surface_context){0};
}
unsigned char *data = cairo_image_surface_get_data(surface);
cairo_surface_flush(surface);
memcpy(data, buffer->data, h * buffer->stride);
cairo_surface_mark_dirty(surface);
return (struct surface_context){
.is_duplicate = true,
.surface = surface,
};
}

View file

@ -6,6 +6,15 @@
#include "common/mem.h"
#include "common/string-helpers.h"
void
trim_last_field(char *buf, char delim)
{
char *p = strrchr(buf, delim);
if (p) {
*p = '\0';
}
}
static void
rtrim(char **s)
{