Add possibility to use hardware volume buttons to take a picture
On many mobile operating systems it's possible to take picture using hardware volume buttons. It's easier to hold the phone and take pictures this way. Additionally it makes possible to use selfie stick (at least with jack plug). To be able to handle volume buttons global system shortcuts, that controls audio level has to be disabled. gdk_toplevel_inhibit_system_shortcuts tells compositor to block system keyboard shortcuts, when the camera app has focus. In all other cases system shortcuts are working like before even if camera app is running in background.
This commit is contained in:

committed by
Martijn Braam

parent
4db24ddc5e
commit
17228b1afa
13
src/main.c
13
src/main.c
@@ -1395,7 +1395,12 @@ activate(GtkApplication *app, gpointer data)
|
|||||||
create_simple_action(app, "quit", G_CALLBACK(run_quit_action));
|
create_simple_action(app, "quit", G_CALLBACK(run_quit_action));
|
||||||
|
|
||||||
// Setup shortcuts
|
// Setup shortcuts
|
||||||
const char *capture_accels[] = { "space", NULL };
|
const char *capture_accels[] = {
|
||||||
|
"space",
|
||||||
|
"AudioLowerVolume",
|
||||||
|
"AudioRaiseVolume",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
gtk_application_set_accels_for_action(app, "app.capture", capture_accels);
|
gtk_application_set_accels_for_action(app, "app.capture", capture_accels);
|
||||||
|
|
||||||
const char *quit_accels[] = { "<Ctrl>q", "<Ctrl>w", NULL };
|
const char *quit_accels[] = { "<Ctrl>q", "<Ctrl>w", NULL };
|
||||||
@@ -1496,6 +1501,12 @@ activate(GtkApplication *app, gpointer data)
|
|||||||
|
|
||||||
gtk_application_add_window(app, GTK_WINDOW(window));
|
gtk_application_add_window(app, GTK_WINDOW(window));
|
||||||
gtk_widget_set_visible(window, true);
|
gtk_widget_set_visible(window, true);
|
||||||
|
|
||||||
|
// Inhibit system shortcuts to be able to use
|
||||||
|
// VolumeUp and VolumeDown hardware buttons to take a picture
|
||||||
|
GtkNative *native = gtk_widget_get_native (GTK_WIDGET (window));
|
||||||
|
GdkSurface *surface = gtk_native_get_surface (native);
|
||||||
|
gdk_toplevel_inhibit_system_shortcuts (GDK_TOPLEVEL (surface), NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Reference in New Issue
Block a user