mirror of
				https://github.com/Rafostar/clapper.git
				synced 2025-10-31 02:15:36 +01:00 
			
		
		
		
	Restore button presses
This commit is contained in:
		| @@ -38,6 +38,7 @@ var App = GObject.registerClass({ | |||||||
|         this.window = null; |         this.window = null; | ||||||
|         this.interface = null; |         this.interface = null; | ||||||
|         this.player = null; |         this.player = null; | ||||||
|  |         this.dragAllowed = false; | ||||||
|  |  | ||||||
|         this.posX = 0; |         this.posX = 0; | ||||||
|         this.posY = 0; |         this.posY = 0; | ||||||
| @@ -69,10 +70,10 @@ var App = GObject.registerClass({ | |||||||
|         this.interface.addHeaderBar(headerBar, APP_NAME); |         this.interface.addHeaderBar(headerBar, APP_NAME); | ||||||
|  |  | ||||||
|         this.interface.controls.fullscreenButton.connect( |         this.interface.controls.fullscreenButton.connect( | ||||||
|             'clicked', () => this._onInterfaceToggleFullscreenClicked(true) |             'clicked', () => this.activeWindow.fullscreen() | ||||||
|         ); |         ); | ||||||
|         this.interface.controls.unfullscreenButton.connect( |         this.interface.controls.unfullscreenButton.connect( | ||||||
|             'clicked', () => this._onInterfaceToggleFullscreenClicked(false) |             'clicked', () => this.activeWindow.unfullscreen() | ||||||
|         ); |         ); | ||||||
|  |  | ||||||
|         this.window.set_titlebar(this.interface.headerBar); |         this.window.set_titlebar(this.interface.headerBar); | ||||||
| @@ -171,10 +172,11 @@ var App = GObject.registerClass({ | |||||||
| */ | */ | ||||||
|         this.interface.addPlayer(this.player); |         this.interface.addPlayer(this.player); | ||||||
|         this.player.connect('state-changed', this._onPlayerStateChanged.bind(this)); |         this.player.connect('state-changed', this._onPlayerStateChanged.bind(this)); | ||||||
| /* |  | ||||||
|         this.player.connectWidget( |         this.player.clickGesture.connect( | ||||||
|             'button-press-event', this._onPlayerButtonPressEvent.bind(this) |             'pressed', this._onPlayerPressed.bind(this) | ||||||
|         ); |         ); | ||||||
|  | /* | ||||||
|         this.player.connectWidget( |         this.player.connectWidget( | ||||||
|             'enter-notify-event', this._onPlayerEnterNotifyEvent.bind(this) |             'enter-notify-event', this._onPlayerEnterNotifyEvent.bind(this) | ||||||
|         ); |         ); | ||||||
| @@ -183,7 +185,7 @@ var App = GObject.registerClass({ | |||||||
|         ); |         ); | ||||||
| */ | */ | ||||||
|         this.player.keyController.connect( |         this.player.keyController.connect( | ||||||
|             'key-pressed', this._onPlayerKeyPress.bind(this) |             'key-pressed', this._onPlayerKeyPressed.bind(this) | ||||||
|         ); |         ); | ||||||
|         this.player.motionController.connect( |         this.player.motionController.connect( | ||||||
|             'motion', this._onPlayerMotion.bind(this) |             'motion', this._onPlayerMotion.bind(this) | ||||||
| @@ -214,7 +216,7 @@ var App = GObject.registerClass({ | |||||||
|         this.interface.setFullscreenMode(isFullscreen); |         this.interface.setFullscreenMode(isFullscreen); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     _onPlayerKeyPress(self, keyval, keycode, state) |     _onPlayerKeyPressed(self, keyval, keycode, state) | ||||||
|     { |     { | ||||||
|         let bool = false; |         let bool = false; | ||||||
|  |  | ||||||
| @@ -250,14 +252,6 @@ var App = GObject.registerClass({ | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     _onInterfaceToggleFullscreenClicked(isFsRequested) |  | ||||||
|     { |  | ||||||
|         if(this.window.isFullscreen === isFsRequested) |  | ||||||
|             return; |  | ||||||
|  |  | ||||||
|         this.window.toggleFullscreen(); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     _onPlayerRealize() |     _onPlayerRealize() | ||||||
|     { |     { | ||||||
|         this.player.widget.disconnect(this._playerRealizeSignal); |         this.player.widget.disconnect(this._playerRealizeSignal); | ||||||
| @@ -314,31 +308,19 @@ var App = GObject.registerClass({ | |||||||
|         debug(`set prevent suspend to: ${isInhibited}`); |         debug(`set prevent suspend to: ${isInhibited}`); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     _onPlayerButtonPressEvent(self, event) |     _onPlayerPressed(gesture, nPress, x, y) | ||||||
|     { |     { | ||||||
|         let [res, button] = event.get_button(); |         let button = gesture.get_current_button(); | ||||||
|         if(!res) return; |         let isDouble = (nPress % 2 == 0); | ||||||
|  |         this.dragAllowed = !isDouble; | ||||||
|  |  | ||||||
|         switch(button) { |         switch(button) { | ||||||
|             case Gdk.BUTTON_PRIMARY: |             case Gdk.BUTTON_PRIMARY: | ||||||
|                 this._handlePrimaryButtonPress(event, button); |                 if(isDouble) | ||||||
|  |                     this.window.toggleFullscreen(); | ||||||
|                 break; |                 break; | ||||||
|             case Gdk.BUTTON_SECONDARY: |             case Gdk.BUTTON_SECONDARY: | ||||||
|                 if(event.get_event_type() === Gdk.EventType.BUTTON_PRESS) |                 this.player.toggle_play(); | ||||||
|                     this.player.toggle_play(); |  | ||||||
|                 break; |  | ||||||
|             default: |  | ||||||
|                 break; |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     _handlePrimaryButtonPress(event, button) |  | ||||||
|     { |  | ||||||
|         let eventType = event.get_event_type(); |  | ||||||
|  |  | ||||||
|         switch(eventType) { |  | ||||||
|             case Gdk.EventType.DOUBLE_BUTTON_PRESS: |  | ||||||
|                 this.window.toggleFullscreen(); |  | ||||||
|                 break; |                 break; | ||||||
|             default: |             default: | ||||||
|                 break; |                 break; | ||||||
| @@ -388,6 +370,9 @@ var App = GObject.registerClass({ | |||||||
|  |  | ||||||
|     _onPlayerDragUpdate(gesture, offsetX, offsetY) |     _onPlayerDragUpdate(gesture, offsetX, offsetY) | ||||||
|     { |     { | ||||||
|  |         if(!this.dragAllowed || this.activeWindow.isFullscreen) | ||||||
|  |             return; | ||||||
|  |  | ||||||
|         let { gtk_double_click_distance } = this.player.widget.get_settings(); |         let { gtk_double_click_distance } = this.player.widget.get_settings(); | ||||||
|  |  | ||||||
|         if ( |         if ( | ||||||
|   | |||||||
| @@ -83,15 +83,18 @@ class ClapperPlayer extends GstPlayer.Player | |||||||
|         this.keyController = new Gtk.EventControllerKey(); |         this.keyController = new Gtk.EventControllerKey(); | ||||||
|         this.motionController = new Gtk.EventControllerMotion(); |         this.motionController = new Gtk.EventControllerMotion(); | ||||||
|         this.scrollController = new Gtk.EventControllerScroll(); |         this.scrollController = new Gtk.EventControllerScroll(); | ||||||
|  |         this.clickGesture = new Gtk.GestureClick(); | ||||||
|         this.dragGesture = new Gtk.GestureDrag(); |         this.dragGesture = new Gtk.GestureDrag(); | ||||||
|  |  | ||||||
|         this.scrollController.set_flags( |         this.scrollController.set_flags( | ||||||
|             Gtk.EventControllerScrollFlags.BOTH_AXES |             Gtk.EventControllerScrollFlags.BOTH_AXES | ||||||
|         ); |         ); | ||||||
|  |         this.clickGesture.set_button(0); | ||||||
|  |  | ||||||
|         this.widget.add_controller(this.keyController); |         this.widget.add_controller(this.keyController); | ||||||
|         this.widget.add_controller(this.motionController); |         this.widget.add_controller(this.motionController); | ||||||
|         this.widget.add_controller(this.scrollController); |         this.widget.add_controller(this.scrollController); | ||||||
|  |         this.widget.add_controller(this.clickGesture); | ||||||
|         this.widget.add_controller(this.dragGesture); |         this.widget.add_controller(this.dragGesture); | ||||||
|  |  | ||||||
|         this.connect('state-changed', this._onStateChanged.bind(this)); |         this.connect('state-changed', this._onStateChanged.bind(this)); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user