mirror of
https://github.com/labwc/labwc.git
synced 2026-04-12 08:21:13 -04:00
Add setting of border width and colour
This commit is contained in:
parent
68acb89d26
commit
05c89f18fb
4 changed files with 50 additions and 12 deletions
|
|
@ -589,12 +589,18 @@
|
|||
<!--
|
||||
Magnifier settings
|
||||
|
||||
'scale' sets the initial magnification factor when first booted.
|
||||
'size' sets the width and height in pixels of the magnifier window.
|
||||
'initScale' sets the initial magnification factor when first booted.
|
||||
'borderColour' is an XML RGB string with a leading # which sets the
|
||||
colour of the border for the magnifier window.
|
||||
'borderWidth' sets the width in pixels of the border for the
|
||||
magnifier window.
|
||||
-->
|
||||
<magnifier>
|
||||
<scale>2</scale>
|
||||
<size>400</size>
|
||||
<initScale>2</initScale>
|
||||
<borderColour>#ff0000</borderColour>
|
||||
<borderWidth>1</borderWidth>
|
||||
</magnifier>
|
||||
|
||||
</labwc_config>
|
||||
|
|
|
|||
|
|
@ -41,6 +41,12 @@ struct usable_area_override {
|
|||
struct wl_list link; /* struct rcxml.usable_area_overrides */
|
||||
};
|
||||
|
||||
struct rgb_colour {
|
||||
int r;
|
||||
int g;
|
||||
int b;
|
||||
};
|
||||
|
||||
struct rcxml {
|
||||
/* from command line */
|
||||
char *config_dir;
|
||||
|
|
@ -141,6 +147,8 @@ struct rcxml {
|
|||
/* magnifier */
|
||||
int mag_scale;
|
||||
int mag_size;
|
||||
struct rgb_colour mag_border_col;
|
||||
int mag_border_width;
|
||||
};
|
||||
|
||||
extern struct rcxml rc;
|
||||
|
|
|
|||
|
|
@ -43,9 +43,6 @@ lab_wlr_scene_get_prev_node(struct wlr_scene_node *node)
|
|||
}
|
||||
|
||||
|
||||
/* TODO: move to rc. (or theme?) settings */
|
||||
#define magnifier_border 1 /* in pixels */
|
||||
|
||||
static void
|
||||
magnify(struct output *output, struct wlr_buffer *output_buffer, struct wlr_box *damage)
|
||||
{
|
||||
|
|
@ -152,15 +149,20 @@ magnify(struct output *output, struct wlr_buffer *output_buffer, struct wlr_box
|
|||
|
||||
/* Borders */
|
||||
struct wlr_box border_box = {
|
||||
.x = ox - (width / 2 + magnifier_border),
|
||||
.y = oy - (height / 2 + magnifier_border),
|
||||
.width = (width + magnifier_border * 2),
|
||||
.height = (height + magnifier_border * 2),
|
||||
.x = ox - (width / 2 + rc.mag_border_width),
|
||||
.y = oy - (height / 2 + rc.mag_border_width),
|
||||
.width = (width + rc.mag_border_width * 2),
|
||||
.height = (height + rc.mag_border_width * 2),
|
||||
};
|
||||
struct wlr_render_rect_options bg_opts = {
|
||||
.box = border_box,
|
||||
/* TODO: make this a rc. setting */
|
||||
.color = (struct wlr_render_color) { 1, 0, 0, 1 },
|
||||
.color = (struct wlr_render_color) {
|
||||
.r = rc.mag_border_col.r / 255.0,
|
||||
.g = rc.mag_border_col.g / 255.0,
|
||||
.b = rc.mag_border_col.b / 255.0,
|
||||
.a = 1
|
||||
},
|
||||
.clip = NULL,
|
||||
};
|
||||
wlr_render_pass_add_rect(tmp_render_pass, &bg_opts);
|
||||
|
|
|
|||
|
|
@ -746,6 +746,19 @@ set_adaptive_sync_mode(const char *str, enum adaptive_sync_mode *variable)
|
|||
}
|
||||
}
|
||||
|
||||
static bool parse_rgb(const char *str, int *r, int *g, int *b)
|
||||
{
|
||||
int rr, rg, rb;
|
||||
if (!str) return false;
|
||||
if (strlen(str) != 7) return false;
|
||||
if (str[0] != '#') return false;
|
||||
if (sscanf(str, "#%2X%2X%2X", &rr, &rg, &rb) != 3) return false;
|
||||
*r = rr;
|
||||
*g = rg;
|
||||
*b = rb;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
entry(xmlNode *node, char *nodename, char *content)
|
||||
{
|
||||
|
|
@ -1034,10 +1047,15 @@ entry(xmlNode *node, char *nodename, char *content)
|
|||
} else {
|
||||
wlr_log(WLR_ERROR, "Missing 'button' argument for tablet button mapping");
|
||||
}
|
||||
} else if (!strcasecmp(nodename, "scale.magnifier")) {
|
||||
rc.mag_scale = atoi(content);
|
||||
} else if (!strcasecmp(nodename, "size.magnifier")) {
|
||||
rc.mag_size = atoi(content);
|
||||
} else if (!strcasecmp(nodename, "initScale.magnifier")) {
|
||||
rc.mag_scale = atoi(content);
|
||||
} else if (!strcasecmp(nodename, "borderColour.magnifier")) {
|
||||
parse_rgb(content, &rc.mag_border_col.r, &rc.mag_border_col.g,
|
||||
&rc.mag_border_col.b);
|
||||
} else if (!strcasecmp(nodename, "borderWidth.magnifier")) {
|
||||
rc.mag_border_width = atoi(content);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1245,6 +1263,10 @@ rcxml_init(void)
|
|||
|
||||
rc.mag_scale = 2;
|
||||
rc.mag_size = 400;
|
||||
rc.mag_border_col.r = 255;
|
||||
rc.mag_border_col.g = 0;
|
||||
rc.mag_border_col.b = 0;
|
||||
rc.mag_border_width = 1;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue