Make pressing the preview work again

This commit is contained in:
Benjamin Schaaf
2021-04-26 19:07:59 +10:00
parent 1bd975698c
commit d03d4b99e3
4 changed files with 93 additions and 77 deletions

View File

@@ -545,6 +545,7 @@ static void
preview_pressed(GtkGestureClick *gesture, int n_press, double x, double y)
{
GtkWidget *widget = gtk_event_controller_get_widget(GTK_EVENT_CONTROLLER(gesture));
int scale_factor = gtk_widget_get_scale_factor(widget);
// Tapped zbar result
if (zbar_result) {
@@ -552,9 +553,8 @@ preview_pressed(GtkGestureClick *gesture, int n_press, double x, double y)
float offset_x, offset_y, size_x, size_y;
position_preview(&offset_x, &offset_y, &size_x, &size_y);
double scale = preview_buffer_height / size_y;
int zbar_x = (x - offset_x) * scale;
int zbar_y = (y - offset_y) * scale;
int zbar_x = (x - offset_x) * scale_factor / size_x * preview_buffer_width;
int zbar_y = (y - offset_y) * scale_factor / size_y * preview_buffer_height;
for (uint8_t i = 0; i < zbar_result->size; ++i) {
MPZBarCode *code = &zbar_result->codes[i];