Act on key press, not release

This commit is contained in:
Rafał Dzięgiel
2021-04-22 14:13:53 +02:00
parent 6f39b3939a
commit c9b2f25192

View File

@@ -608,8 +608,6 @@ class ClapperPlayer extends GstClapper.Clapper
const clapperWidget = this.widget.get_ancestor(Gtk.Grid); const clapperWidget = this.widget.get_ancestor(Gtk.Grid);
let bool = false; let bool = false;
this.keyPressCount++;
switch(keyval) { switch(keyval) {
case Gdk.KEY_Up: case Gdk.KEY_Up:
bool = true; bool = true;
@@ -623,9 +621,27 @@ class ClapperPlayer extends GstClapper.Clapper
if(this.keyPressCount > 1) if(this.keyPressCount > 1)
clapperWidget.revealControls(); clapperWidget.revealControls();
break; break;
default: case Gdk.KEY_space:
this.toggle_play();
break; break;
case Gdk.KEY_Return:
if(clapperWidget.isFullscreenMode)
clapperWidget.revealControls(true);
break;
case Gdk.KEY_F11:
case Gdk.KEY_f:
case Gdk.KEY_F:
clapperWidget.toggleFullscreen();
break;
case Gdk.KEY_q:
case Gdk.KEY_Q:
this.widget.root.emit('close-request');
break;
default:
return;
} }
this.keyPressCount++;
} }
/* Also happens after using controls navigation for selected keys */ /* Also happens after using controls navigation for selected keys */
@@ -637,18 +653,11 @@ class ClapperPlayer extends GstClapper.Clapper
return; return;
const clapperWidget = this.widget.get_ancestor(Gtk.Grid); const clapperWidget = this.widget.get_ancestor(Gtk.Grid);
let value, root; let value;
this.keyPressCount = 0; this.keyPressCount = 0;
switch(keyval) { switch(keyval) {
case Gdk.KEY_space:
this.toggle_play();
break;
case Gdk.KEY_Return:
if(clapperWidget.isFullscreenMode)
clapperWidget.revealControls(true);
break;
case Gdk.KEY_Right: case Gdk.KEY_Right:
case Gdk.KEY_Left: case Gdk.KEY_Left:
value = Math.round( value = Math.round(
@@ -657,16 +666,6 @@ class ClapperPlayer extends GstClapper.Clapper
this.seek_seconds(value); this.seek_seconds(value);
clapperWidget._setHideControlsTimeout(); clapperWidget._setHideControlsTimeout();
break; break;
case Gdk.KEY_F11:
case Gdk.KEY_f:
case Gdk.KEY_F:
clapperWidget.toggleFullscreen();
break;
case Gdk.KEY_q:
case Gdk.KEY_Q:
root = this.widget.get_root();
root.emit('close-request');
break;
default: default:
break; break;
} }