Magnifier on/off just a global flag; not in XML

This commit is contained in:
Simon Long 2024-05-02 18:12:28 +01:00
parent f76dffa01a
commit 789e7f9331
3 changed files with 13 additions and 13 deletions

View file

@ -142,7 +142,6 @@ struct rcxml {
unsigned int menu_ignore_button_release_period; unsigned int menu_ignore_button_release_period;
/* magnifier */ /* magnifier */
bool magnify;
int mag_scale; int mag_scale;
int mag_size; int mag_size;
}; };

View file

@ -12,6 +12,8 @@
#include <wlr/render/drm_format_set.h> #include <wlr/render/drm_format_set.h>
#include "common/macros.h" #include "common/macros.h"
static bool magnify_on;
struct wlr_surface * struct wlr_surface *
lab_wlr_surface_from_node(struct wlr_scene_node *node) lab_wlr_surface_from_node(struct wlr_scene_node *node)
{ {
@ -208,7 +210,7 @@ output_wants_magnification(struct output *output)
static double x = -1; static double x = -1;
static double y = -1; static double y = -1;
struct wlr_cursor *cursor = output->server->seat.cursor; struct wlr_cursor *cursor = output->server->seat.cursor;
if (!rc.magnify) { if (!magnify_on) {
x = -1; x = -1;
y = -1; y = -1;
return false; return false;
@ -227,10 +229,10 @@ output_wants_magnification(struct output *output)
void magnify_toggle (void) void magnify_toggle (void)
{ {
if (rc.magnify) { if (magnify_on) {
rc.magnify = false; magnify_on = false;
} else { } else {
rc.magnify = true; magnify_on = true;
} }
} }
@ -241,17 +243,17 @@ void magnify_toggle (void)
void magnify_set_scale (enum magnify_dir dir) void magnify_set_scale (enum magnify_dir dir)
{ {
if (dir == MAGNIFY_INCREASE) { if (dir == MAGNIFY_INCREASE) {
if (rc.magnify) { if (magnify_on) {
rc.mag_scale++; rc.mag_scale++;
} else { } else {
rc.magnify = true; magnify_on = true;
rc.mag_scale = 2; rc.mag_scale = 2;
} }
} else { } else {
if (rc.magnify && rc.mag_scale > 2) { if (magnify_on && rc.mag_scale > 2) {
rc.mag_scale--; rc.mag_scale--;
} else { } else {
rc.magnify = false; magnify_on = false;
} }
} }
} }
@ -273,11 +275,11 @@ lab_wlr_scene_output_commit(struct wlr_scene_output *scene_output)
if (!wlr_output->needs_frame && !pixman_region32_not_empty( if (!wlr_output->needs_frame && !pixman_region32_not_empty(
&scene_output->damage_ring.current) && !wants_magnification &scene_output->damage_ring.current) && !wants_magnification
&& last_mag != rc.magnify && last_scale != rc.mag_scale) { && last_mag != magnify_on && last_scale != rc.mag_scale) {
return false; return false;
} }
last_mag = rc.magnify; last_mag = magnify_on;
last_scale = rc.mag_scale; last_scale = rc.mag_scale;
if (!wlr_scene_output_build_state(scene_output, state, NULL)) { if (!wlr_scene_output_build_state(scene_output, state, NULL)) {
@ -287,7 +289,7 @@ lab_wlr_scene_output_commit(struct wlr_scene_output *scene_output)
} }
struct wlr_box additional_damage = {0}; struct wlr_box additional_damage = {0};
if (state->buffer && rc.magnify) { if (state->buffer && magnify_on) {
magnify(output, state->buffer, &additional_damage); magnify(output, state->buffer, &additional_damage);
} }

View file

@ -1243,7 +1243,6 @@ rcxml_init(void)
rc.menu_ignore_button_release_period = 250; rc.menu_ignore_button_release_period = 250;
rc.magnify = false;
rc.mag_scale = 2; rc.mag_scale = 2;
rc.mag_size = 400; rc.mag_size = 400;
} }