mirror of
https://cagebreak.project-repo.co/cagebreak.git
synced 2026-08-20 20:44:18 +02:00
Fix configure_message command
This commit is contained in:
parent
d7a789d556
commit
d6ce3d66bb
4 changed files with 58 additions and 8 deletions
14
cagebreak.c
14
cagebreak.c
|
|
@ -297,7 +297,18 @@ main(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
server.nws = 1;
|
||||
server.message_timeout = 2;
|
||||
server.message_config.fg_color[0] = 0.0;
|
||||
server.message_config.fg_color[1] = 0.0;
|
||||
server.message_config.fg_color[2] = 0.0;
|
||||
server.message_config.fg_color[3] = 1.0;
|
||||
|
||||
server.message_config.bg_color[0] = 0.9;
|
||||
server.message_config.bg_color[1] = 0.85;
|
||||
server.message_config.bg_color[2] = 0.85;
|
||||
server.message_config.bg_color[3] = 1.0;
|
||||
|
||||
server.message_config.display_time = 2;
|
||||
server.message_config.font = strdup("pango:Monospace 10");
|
||||
|
||||
event_loop = wl_display_get_event_loop(server.wl_display);
|
||||
sigint_source =
|
||||
|
|
@ -626,6 +637,7 @@ end:
|
|||
wlr_output_layout_destroy(server.output_layout);
|
||||
|
||||
free(server.input);
|
||||
free(server.message_config.font);
|
||||
pango_cairo_font_map_set_default(NULL);
|
||||
cairo_debug_reset_static_data();
|
||||
FcFini();
|
||||
|
|
|
|||
33
keybinding.c
33
keybinding.c
|
|
@ -76,6 +76,12 @@ keybinding_free(struct keybinding *keybinding, bool recursive) {
|
|||
free(keybinding->data.i_cfg->mapped_to_output);
|
||||
}
|
||||
free(keybinding->data.o_cfg);
|
||||
break;
|
||||
case KEYBINDING_CONFIGURE_MESSAGE:
|
||||
if(keybinding->data.m_cfg->font != NULL) {
|
||||
free(keybinding->data.m_cfg->font);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
@ -910,6 +916,30 @@ keybinding_configure_input(struct cg_server *server,
|
|||
cg_input_apply_config(cfg, server);
|
||||
}
|
||||
|
||||
void
|
||||
keybinding_configure_message(struct cg_server *server,
|
||||
struct cg_message_config *config) {
|
||||
if(config->font != NULL) {
|
||||
free(server->message_config.font);
|
||||
server->message_config.font = strdup(config->font);
|
||||
}
|
||||
if(config->display_time != -1) {
|
||||
server->message_config.display_time = config->display_time;
|
||||
}
|
||||
if(config->bg_color[0] != -1) {
|
||||
server->message_config.bg_color[0] = config->bg_color[0];
|
||||
server->message_config.bg_color[1] = config->bg_color[1];
|
||||
server->message_config.bg_color[2] = config->bg_color[2];
|
||||
server->message_config.bg_color[3] = config->bg_color[3];
|
||||
}
|
||||
if(config->fg_color[0] != -1) {
|
||||
server->message_config.fg_color[0] = config->fg_color[0];
|
||||
server->message_config.fg_color[1] = config->fg_color[1];
|
||||
server->message_config.fg_color[2] = config->fg_color[2];
|
||||
server->message_config.fg_color[3] = config->fg_color[3];
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
keybinding_configure_input_dev(struct cg_server *server,
|
||||
struct cg_input_config *cfg) {}
|
||||
|
|
@ -1051,6 +1081,9 @@ run_action(enum keybinding_action action, struct cg_server *server,
|
|||
case KEYBINDING_CONFIGURE_OUTPUT:
|
||||
keybinding_configure_output(server, data.o_cfg);
|
||||
break;
|
||||
case KEYBINDING_CONFIGURE_MESSAGE:
|
||||
keybinding_configure_message(server, data.m_cfg);
|
||||
break;
|
||||
case KEYBINDING_CONFIGURE_INPUT:
|
||||
keybinding_configure_input(server, data.i_cfg);
|
||||
break;
|
||||
|
|
|
|||
17
message.c
17
message.c
|
|
@ -35,7 +35,6 @@ struct wlr_texture *
|
|||
create_message_texture(const char *string, const struct cg_output *output) {
|
||||
const int WIDTH_PADDING = 8;
|
||||
const int HEIGHT_PADDING = 2;
|
||||
const char *font = "pango:Monospace 10";
|
||||
|
||||
struct wlr_texture *texture;
|
||||
double scale = output->wlr_output->scale;
|
||||
|
|
@ -60,7 +59,8 @@ create_message_texture(const char *string, const struct cg_output *output) {
|
|||
cairo_font_options_set_subpixel_order(
|
||||
fo, to_cairo_subpixel_order(output->wlr_output->subpixel));
|
||||
cairo_set_font_options(c, fo);
|
||||
get_text_size(c, font, &width, &height, NULL, scale, "%s", string);
|
||||
get_text_size(c, output->server->message_config.font, &width, &height, NULL,
|
||||
scale, "%s", string);
|
||||
width += 2 * WIDTH_PADDING;
|
||||
height += 2 * HEIGHT_PADDING;
|
||||
cairo_surface_destroy(dummy_surface);
|
||||
|
|
@ -72,16 +72,19 @@ create_message_texture(const char *string, const struct cg_output *output) {
|
|||
cairo_set_antialias(cairo, CAIRO_ANTIALIAS_BEST);
|
||||
cairo_set_font_options(cairo, fo);
|
||||
cairo_font_options_destroy(fo);
|
||||
cairo_set_source_rgba(cairo, 0.9, 0.85, 0.85, 1.0);
|
||||
float *bg_col = output->server->message_config.bg_color;
|
||||
cairo_set_source_rgba(cairo, bg_col[0], bg_col[1], bg_col[2], bg_col[3]);
|
||||
cairo_paint(cairo);
|
||||
PangoContext *pango = pango_cairo_create_context(cairo);
|
||||
cairo_set_source_rgba(cairo, 0, 0, 0, 1);
|
||||
float *fg_col = output->server->message_config.fg_color;
|
||||
cairo_set_source_rgba(cairo, fg_col[0], fg_col[1], fg_col[2], fg_col[3]);
|
||||
cairo_set_line_width(cairo, 2);
|
||||
cairo_rectangle(cairo, 0, 0, width, height);
|
||||
cairo_stroke(cairo);
|
||||
cairo_move_to(cairo, WIDTH_PADDING, HEIGHT_PADDING);
|
||||
|
||||
pango_printf(cairo, font, scale, "%s", string);
|
||||
pango_printf(cairo, output->server->message_config.font, scale, "%s",
|
||||
string);
|
||||
|
||||
cairo_surface_flush(surface);
|
||||
unsigned char *data = cairo_image_surface_get_data(surface);
|
||||
|
|
@ -175,7 +178,7 @@ message_printf(struct cg_output *output, const char *fmt, ...) {
|
|||
|
||||
message_set_output(output, buffer, box, CG_MESSAGE_TOP_RIGHT);
|
||||
free(buffer);
|
||||
alarm(output->server->message_timeout);
|
||||
alarm(output->server->message_config.display_time);
|
||||
}
|
||||
#if CG_HAS_FANALYZE
|
||||
#pragma GCC diagnostic pop
|
||||
|
|
@ -194,7 +197,7 @@ message_printf_pos(struct cg_output *output, struct wlr_box *position,
|
|||
|
||||
message_set_output(output, buffer, position, align);
|
||||
free(buffer);
|
||||
alarm(output->server->message_timeout);
|
||||
alarm(output->server->message_config.display_time);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
2
server.h
2
server.h
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "config.h"
|
||||
#include "ipc_server.h"
|
||||
#include "message.h"
|
||||
|
||||
#include <wayland-server-core.h>
|
||||
#include <wlr/types/wlr_xdg_decoration_v1.h>
|
||||
|
|
@ -44,6 +45,7 @@ struct cg_server {
|
|||
struct keybinding_list *keybindings;
|
||||
struct wl_list output_config;
|
||||
struct wl_list input_config;
|
||||
struct cg_message_config message_config;
|
||||
|
||||
enum wl_output_transform output_transform;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue