Move magnfier size into XML

This commit is contained in:
Simon Long 2024-05-02 18:08:24 +01:00
parent 483a92368e
commit f76dffa01a
3 changed files with 22 additions and 19 deletions

View file

@ -60,9 +60,6 @@ struct rcxml {
bool focus_follow_mouse_requires_movement;
bool raise_on_focus;
bool magnify;
int magnification;
/* theme */
char *theme_name;
int corner_radius;
@ -143,6 +140,11 @@ struct rcxml {
/* Menu */
unsigned int menu_ignore_button_release_period;
/* magnifier */
bool magnify;
int mag_scale;
int mag_size;
};
extern struct rcxml rc;

View file

@ -43,7 +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 */
#define magnifier_crop_size 200 /* how many pixels in each direction of the cursor */
static void
magnify(struct output *output, struct wlr_buffer *output_buffer, struct wlr_box *damage)
@ -77,10 +76,10 @@ magnify(struct output *output, struct wlr_buffer *output_buffer, struct wlr_box
oy *= output->wlr_output->scale;
/* TODO: refactor, to use rc. settings */
int width = magnifier_crop_size * 2 + 1;
int width = rc.mag_size + 1;
int height = width;
double x = ox - magnifier_crop_size;
double y = oy - magnifier_crop_size;
double x = ox - (rc.mag_size / 2.0);
double y = oy - (rc.mag_size / 2.0);
double cropped_width = width;
double cropped_height = height;
double dst_x = 0;
@ -172,10 +171,10 @@ magnify(struct output *output, struct wlr_buffer *output_buffer, struct wlr_box
opts = (struct wlr_render_texture_options) {
.texture = tmp_texture,
.src_box = (struct wlr_fbox) {
.x = width * (rc.magnification - 1) / (2 * rc.magnification),
.y = height * (rc.magnification - 1) / (2 * rc.magnification),
.width = width / rc.magnification,
.height = height / rc.magnification,
.x = width * (rc.mag_scale - 1) / (2 * rc.mag_scale),
.y = height * (rc.mag_scale - 1) / (2 * rc.mag_scale),
.width = width / rc.mag_scale,
.height = height / rc.mag_scale,
},
.dst_box = (struct wlr_box) {
.x = ox - (width / 2),
@ -243,14 +242,14 @@ void magnify_set_scale (enum magnify_dir dir)
{
if (dir == MAGNIFY_INCREASE) {
if (rc.magnify) {
rc.magnification++;
rc.mag_scale++;
} else {
rc.magnify = true;
rc.magnification = 2;
rc.mag_scale = 2;
}
} else {
if (rc.magnify && rc.magnification > 2) {
rc.magnification--;
if (rc.magnify && rc.mag_scale > 2) {
rc.mag_scale--;
} else {
rc.magnify = false;
}
@ -274,12 +273,12 @@ lab_wlr_scene_output_commit(struct wlr_scene_output *scene_output)
if (!wlr_output->needs_frame && !pixman_region32_not_empty(
&scene_output->damage_ring.current) && !wants_magnification
&& last_mag != rc.magnify && last_scale != rc.magnification) {
&& last_mag != rc.magnify && last_scale != rc.mag_scale) {
return false;
}
last_mag = rc.magnify;
last_scale = rc.magnification;
last_scale = rc.mag_scale;
if (!wlr_scene_output_build_state(scene_output, state, NULL)) {
wlr_log(WLR_ERROR, "Failed to build output state for %s",

View file

@ -1206,8 +1206,6 @@ rcxml_init(void)
rc.focus_follow_mouse = false;
rc.focus_follow_mouse_requires_movement = true;
rc.raise_on_focus = false;
rc.magnify = false;
rc.magnification = 2;
rc.doubleclick_time = 500;
rc.scroll_factor = 1.0;
@ -1244,6 +1242,10 @@ rcxml_init(void)
rc.workspace_config.min_nr_workspaces = 1;
rc.menu_ignore_button_release_period = 250;
rc.magnify = false;
rc.mag_scale = 2;
rc.mag_size = 400;
}
static void