mirror of
https://github.com/labwc/labwc.git
synced 2026-04-12 08:21:13 -04:00
Move magnifier config into rc.xml
This commit is contained in:
parent
8d5bfe1e0e
commit
50066161b0
8 changed files with 86 additions and 58 deletions
|
|
@ -909,6 +909,39 @@ situation.
|
|||
option has been exposed for unusual use-cases. It is equivalent to
|
||||
Openbox's `<hideDelay>`. Default is 250 ms.
|
||||
|
||||
## MAGNIFIER
|
||||
|
||||
```
|
||||
<magnifier>
|
||||
<width>400</width>
|
||||
<height>400</height>
|
||||
<initScale>2</initScale>
|
||||
<increment>0.2</increment>
|
||||
<useFilter>true</useFilter>
|
||||
</magnifier>
|
||||
```
|
||||
|
||||
*<magnifier><width>*
|
||||
Width of magnifier window in pixels. Default is 400.
|
||||
Set to -1 to use fullscreen magnifier.
|
||||
|
||||
*<magnifier><height>*
|
||||
Height of magnifier window in pixels. Default is 400.
|
||||
Set to -1 to use fullscreen magnifier.
|
||||
|
||||
*<magnifier><initScale>*
|
||||
Initial number of times by which magnified image is scaled. Value
|
||||
is the default at boot; can be modified at run-time in a keyboard
|
||||
or mouse binding by calling 'ZoomIn' or 'ZoomOut'. Default is x2.
|
||||
|
||||
*<magnifier><increment>*
|
||||
Step by which magnification changes on each call to 'ZoomIn' or
|
||||
'ZoomOut'. Default is 0.2.
|
||||
|
||||
*<magnifier><useFilter>* [yes|no|default]
|
||||
Whether to apply a bilinear filter to the magnified image, or
|
||||
just to use nearest-neighbour. Default is true - bilinear filtered.
|
||||
|
||||
## ENVIRONMENT VARIABLES
|
||||
|
||||
*XCURSOR_THEME* and *XCURSOR_SIZE* are supported to set cursor theme
|
||||
|
|
|
|||
|
|
@ -277,33 +277,12 @@ elements are not listed here, but are supported.
|
|||
*window.inactive.border.color*. This is obsolete, but supported for
|
||||
backward compatibility as some themes still contain it.
|
||||
|
||||
*magnifier.width*
|
||||
Width of magnifier window in pixels. Default is 400.
|
||||
Set to -1 to use fullscreen magnifier.
|
||||
|
||||
*magnifier.height*
|
||||
Height of magnifier window in pixels. Default is 400.
|
||||
Set to -1 to use fullscreen magnifier.
|
||||
|
||||
*magnifier.border.width*
|
||||
Width of magnifier window border in pixels. Default is 1.
|
||||
|
||||
*magnifier.border.color*
|
||||
Color of the magnfier window border. Default is #ff0000 (red).
|
||||
|
||||
*magnifier.init-scale*
|
||||
Initial number of times by which magnified image is scaled. Value
|
||||
is the default at boot; can be modified at run-time in a keyboard
|
||||
or mouse binding by calling 'ZoomIn' or 'ZoomOut'. Default is x2.
|
||||
|
||||
*magnifier.increment*
|
||||
Step by which magnification changes on each call to 'ZoomIn' or
|
||||
'ZoomOut'. Default is 0.2.
|
||||
|
||||
*magnifier.filter*
|
||||
Set to 1 to apply a bilinear filter to the magnified image.
|
||||
Set to 0 to use nearest-neighbour. Default is 1 - bilinear filtered.
|
||||
|
||||
# BUTTONS
|
||||
|
||||
The images used for the titlebar icons are referred to as buttons.
|
||||
|
|
|
|||
|
|
@ -589,4 +589,23 @@
|
|||
<menu>
|
||||
<ignoreButtonReleasePeriod>250</ignoreButtonReleasePeriod>
|
||||
</menu>
|
||||
|
||||
<!--
|
||||
Magnifier settings
|
||||
'width' sets the width in pixels of the magnifier window.
|
||||
'height' sets the height in pixels of the magnifier window.
|
||||
'initScale' sets the initial magnification factor at boot.
|
||||
'increment' sets the amount by which the magnification factor
|
||||
changes when 'ZoomIn' or 'ZoomOut' are called.
|
||||
'useFilter' sets whether to use a bilinear filter on the magnified
|
||||
output or simply to take nearest pixel.
|
||||
-->
|
||||
<magnifier>
|
||||
<width>400</width>
|
||||
<height>400</height>
|
||||
<initScale>2</initScale>
|
||||
<increment>0.2</increment>
|
||||
<useFilter>true</useFilter>
|
||||
</magnifier>
|
||||
|
||||
</labwc_config>
|
||||
|
|
|
|||
|
|
@ -140,6 +140,13 @@ struct rcxml {
|
|||
|
||||
/* Menu */
|
||||
unsigned int menu_ignore_button_release_period;
|
||||
|
||||
/* Magnifier */
|
||||
int mag_width;
|
||||
int mag_height;
|
||||
int mag_scale;
|
||||
float mag_increment;
|
||||
bool mag_filter;
|
||||
};
|
||||
|
||||
extern struct rcxml rc;
|
||||
|
|
|
|||
|
|
@ -141,13 +141,8 @@ struct theme {
|
|||
int osd_window_switcher_item_height;
|
||||
|
||||
/* magnifier */
|
||||
int mag_scale;
|
||||
int mag_width;
|
||||
int mag_height;
|
||||
float mag_border_color[4];
|
||||
int mag_border_width;
|
||||
int mag_filter;
|
||||
float mag_increment;
|
||||
};
|
||||
|
||||
struct server;
|
||||
|
|
|
|||
|
|
@ -1036,6 +1036,16 @@ entry(xmlNode *node, char *nodename, char *content)
|
|||
}
|
||||
} else if (!strcasecmp(nodename, "ignoreButtonReleasePeriod.menu")) {
|
||||
rc.menu_ignore_button_release_period = atoi(content);
|
||||
} else if (!strcasecmp(nodename, "width.magnifier")) {
|
||||
rc.mag_width = atoi(content);
|
||||
} else if (!strcasecmp(nodename, "height.magnifier")) {
|
||||
rc.mag_height = atoi(content);
|
||||
} else if (!strcasecmp(nodename, "initScale.magnifier")) {
|
||||
rc.mag_scale = atoi(content);
|
||||
} else if (!strcasecmp(nodename, "increment.magnifier")) {
|
||||
set_float(content, &rc.mag_increment);
|
||||
} else if (!strcasecmp(nodename, "useFilter.magnifier")) {
|
||||
set_bool(content, &rc.mag_filter);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1242,6 +1252,12 @@ rcxml_init(void)
|
|||
rc.workspace_config.min_nr_workspaces = 1;
|
||||
|
||||
rc.menu_ignore_button_release_period = 250;
|
||||
|
||||
rc.mag_width = 400;
|
||||
rc.mag_height = 400;
|
||||
rc.mag_scale = 2;
|
||||
rc.mag_increment = 0.2;
|
||||
rc.mag_filter = true;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ magnify(struct output *output, struct wlr_buffer *output_buffer, struct wlr_box
|
|||
wlr_output_layout_output_coords(server->output_layout, output->wlr_output, &ox, &oy);
|
||||
ox *= output->wlr_output->scale;
|
||||
oy *= output->wlr_output->scale;
|
||||
if (theme->mag_width == -1 || theme->mag_height == -1) {
|
||||
if (rc.mag_width == -1 || rc.mag_height == -1) {
|
||||
fullscreen = true;
|
||||
}
|
||||
if ((ox < 0 || oy < 0 || ox >= output_buffer->width || oy >= output_buffer->height)
|
||||
|
|
@ -58,7 +58,7 @@ magnify(struct output *output, struct wlr_buffer *output_buffer, struct wlr_box
|
|||
}
|
||||
|
||||
if (mag_scale == 0.0) {
|
||||
mag_scale = theme->mag_scale;
|
||||
mag_scale = rc.mag_scale;
|
||||
}
|
||||
|
||||
if (fullscreen) {
|
||||
|
|
@ -67,10 +67,10 @@ magnify(struct output *output, struct wlr_buffer *output_buffer, struct wlr_box
|
|||
x = 0;
|
||||
y = 0;
|
||||
} else {
|
||||
width = theme->mag_width + 1;
|
||||
height = theme->mag_height + 1;
|
||||
x = ox - (theme->mag_width / 2.0);
|
||||
y = oy - (theme->mag_height / 2.0);
|
||||
width = rc.mag_width + 1;
|
||||
height = rc.mag_height + 1;
|
||||
x = ox - (rc.mag_width / 2.0);
|
||||
y = oy - (rc.mag_height / 2.0);
|
||||
}
|
||||
double cropped_width = width;
|
||||
double cropped_height = height;
|
||||
|
|
@ -201,7 +201,7 @@ magnify(struct output *output, struct wlr_buffer *output_buffer, struct wlr_box
|
|||
.dst_box = dst_box,
|
||||
.alpha = NULL,
|
||||
.clip = NULL,
|
||||
.filter_mode = theme->mag_filter ? WLR_SCALE_FILTER_BILINEAR
|
||||
.filter_mode = rc.mag_filter ? WLR_SCALE_FILTER_BILINEAR
|
||||
: WLR_SCALE_FILTER_NEAREST,
|
||||
};
|
||||
wlr_render_pass_add_texture(tmp_render_pass, &opts);
|
||||
|
|
@ -266,18 +266,17 @@ void
|
|||
magnify_set_scale(struct server *server, enum magnify_dir dir)
|
||||
{
|
||||
struct output *output = output_nearest_to_cursor(server);
|
||||
struct theme *theme = server->theme;
|
||||
|
||||
if (dir == MAGNIFY_INCREASE) {
|
||||
if (magnify_on) {
|
||||
mag_scale += theme->mag_increment;
|
||||
mag_scale += rc.mag_increment;
|
||||
} else {
|
||||
magnify_on = true;
|
||||
mag_scale = 1.0 + theme->mag_increment;
|
||||
mag_scale = 1.0 + rc.mag_increment;
|
||||
}
|
||||
} else {
|
||||
if (magnify_on && mag_scale > 1.0 + theme->mag_increment) {
|
||||
mag_scale -= theme->mag_increment;
|
||||
if (magnify_on && mag_scale > 1.0 + rc.mag_increment) {
|
||||
mag_scale -= rc.mag_increment;
|
||||
} else {
|
||||
magnify_on = false;
|
||||
}
|
||||
|
|
|
|||
20
src/theme.c
20
src/theme.c
|
|
@ -573,13 +573,8 @@ theme_builtin(struct theme *theme, struct server *server)
|
|||
theme->snapping_overlay_edge.border_color[0][0] = FLT_MIN;
|
||||
|
||||
/* magnifier */
|
||||
theme->mag_scale = 2;
|
||||
theme->mag_width = 400;
|
||||
theme->mag_height = 400;
|
||||
parse_hexstr("#ff0000", theme->mag_border_color);
|
||||
theme->mag_border_width = 1;
|
||||
theme->mag_filter = true;
|
||||
theme->mag_increment = 0.2;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -836,27 +831,12 @@ entry(struct theme *theme, const char *key, const char *value)
|
|||
parse_hexstrs(value, theme->snapping_overlay_edge.border_color);
|
||||
}
|
||||
|
||||
if (match_glob(key, "magnifier.init-scale")) {
|
||||
theme->mag_scale = atoi(value);
|
||||
}
|
||||
if (match_glob(key, "magnifier.width")) {
|
||||
theme->mag_width = atoi(value);
|
||||
}
|
||||
if (match_glob(key, "magnifier.height")) {
|
||||
theme->mag_height = atoi(value);
|
||||
}
|
||||
if (match_glob(key, "magnifier.border.width")) {
|
||||
theme->mag_border_width = atoi(value);
|
||||
}
|
||||
if (match_glob(key, "magnifier.border.color")) {
|
||||
parse_hexstr(value, theme->mag_border_color);
|
||||
}
|
||||
if (match_glob(key, "magnifier.filter")) {
|
||||
theme->mag_filter = atoi(value);
|
||||
}
|
||||
if (match_glob(key, "magnifier.increment")) {
|
||||
set_float(value, &theme->mag_increment);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue