Pause frame processing when window is not active
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "camera.h"
|
#include "camera.h"
|
||||||
#include "flash.h"
|
#include "flash.h"
|
||||||
|
#include "main.h"
|
||||||
#include "pipeline.h"
|
#include "pipeline.h"
|
||||||
#include "process_pipeline.h"
|
#include "process_pipeline.h"
|
||||||
#include "state.h"
|
#include "state.h"
|
||||||
@@ -240,6 +241,11 @@ update_controls()
|
|||||||
static void
|
static void
|
||||||
on_frame(MPBuffer buffer, void *_data)
|
on_frame(MPBuffer buffer, void *_data)
|
||||||
{
|
{
|
||||||
|
// Don't process frame when the window is not active
|
||||||
|
if (!check_window_active()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Only update controls right after a frame was captured
|
// Only update controls right after a frame was captured
|
||||||
update_controls();
|
update_controls();
|
||||||
|
|
||||||
|
@@ -55,6 +55,7 @@ static char last_path[260] = "";
|
|||||||
static MPZBarScanResult *zbar_result = NULL;
|
static MPZBarScanResult *zbar_result = NULL;
|
||||||
|
|
||||||
// Widgets
|
// Widgets
|
||||||
|
GtkWidget *window;
|
||||||
GtkWidget *preview;
|
GtkWidget *preview;
|
||||||
GtkWidget *main_stack;
|
GtkWidget *main_stack;
|
||||||
GtkWidget *open_last_stack;
|
GtkWidget *open_last_stack;
|
||||||
@@ -90,6 +91,12 @@ remap(int value, int input_min, int input_max, int output_min, int output_max)
|
|||||||
return (int)result;
|
return (int)result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
check_window_active()
|
||||||
|
{
|
||||||
|
return gtk_window_is_active(GTK_WINDOW(window));
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_io_pipeline()
|
update_io_pipeline()
|
||||||
{
|
{
|
||||||
@@ -1126,7 +1133,7 @@ activate(GtkApplication *app, gpointer data)
|
|||||||
GtkBuilder *builder = gtk_builder_new_from_resource(
|
GtkBuilder *builder = gtk_builder_new_from_resource(
|
||||||
"/org/postmarketos/Megapixels/camera.ui");
|
"/org/postmarketos/Megapixels/camera.ui");
|
||||||
|
|
||||||
GtkWidget *window = GTK_WIDGET(gtk_builder_get_object(builder, "window"));
|
window = GTK_WIDGET(gtk_builder_get_object(builder, "window"));
|
||||||
iso_button =
|
iso_button =
|
||||||
GTK_WIDGET(gtk_builder_get_object(builder, "iso-controls-button"));
|
GTK_WIDGET(gtk_builder_get_object(builder, "iso-controls-button"));
|
||||||
shutter_button = GTK_WIDGET(
|
shutter_button = GTK_WIDGET(
|
||||||
|
@@ -31,3 +31,5 @@ void mp_main_capture_completed(GdkTexture *thumb, const char *fname);
|
|||||||
void mp_main_set_zbar_result(MPZBarScanResult *result);
|
void mp_main_set_zbar_result(MPZBarScanResult *result);
|
||||||
|
|
||||||
int remap(int value, int input_min, int input_max, int output_min, int output_max);
|
int remap(int value, int input_min, int input_max, int output_min, int output_max);
|
||||||
|
|
||||||
|
bool check_window_active();
|
Reference in New Issue
Block a user