mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-31 08:21:59 +02:00
Restore window dragging by drag on player
This commit is contained in:
@@ -38,7 +38,6 @@ var App = GObject.registerClass({
|
|||||||
this.window = null;
|
this.window = null;
|
||||||
this.interface = null;
|
this.interface = null;
|
||||||
this.player = null;
|
this.player = null;
|
||||||
this.dragStartReady = false;
|
|
||||||
|
|
||||||
this.posX = 0;
|
this.posX = 0;
|
||||||
this.posY = 0;
|
this.posY = 0;
|
||||||
@@ -189,6 +188,9 @@ var App = GObject.registerClass({
|
|||||||
this.player.motionController.connect(
|
this.player.motionController.connect(
|
||||||
'motion', this._onPlayerMotion.bind(this)
|
'motion', this._onPlayerMotion.bind(this)
|
||||||
);
|
);
|
||||||
|
this.player.dragGesture.connect(
|
||||||
|
'drag-update', this._onPlayerDragUpdate.bind(this)
|
||||||
|
);
|
||||||
|
|
||||||
/* Widget signals that are disconnected after first run */
|
/* Widget signals that are disconnected after first run */
|
||||||
this._playerRealizeSignal = this.player.widget.connect(
|
this._playerRealizeSignal = this.player.widget.connect(
|
||||||
@@ -317,8 +319,6 @@ var App = GObject.registerClass({
|
|||||||
let [res, button] = event.get_button();
|
let [res, button] = event.get_button();
|
||||||
if(!res) return;
|
if(!res) return;
|
||||||
|
|
||||||
this.dragStartReady = false;
|
|
||||||
|
|
||||||
switch(button) {
|
switch(button) {
|
||||||
case Gdk.BUTTON_PRIMARY:
|
case Gdk.BUTTON_PRIMARY:
|
||||||
this._handlePrimaryButtonPress(event, button);
|
this._handlePrimaryButtonPress(event, button);
|
||||||
@@ -337,14 +337,6 @@ var App = GObject.registerClass({
|
|||||||
let eventType = event.get_event_type();
|
let eventType = event.get_event_type();
|
||||||
|
|
||||||
switch(eventType) {
|
switch(eventType) {
|
||||||
case Gdk.EventType.BUTTON_PRESS:
|
|
||||||
let [res, x, y] = event.get_root_coords();
|
|
||||||
if(!res)
|
|
||||||
break;
|
|
||||||
this.dragStartX = x;
|
|
||||||
this.dragStartY = y;
|
|
||||||
this.dragStartReady = true;
|
|
||||||
break;
|
|
||||||
case Gdk.EventType.DOUBLE_BUTTON_PRESS:
|
case Gdk.EventType.DOUBLE_BUTTON_PRESS:
|
||||||
this.window.toggleFullscreen();
|
this.window.toggleFullscreen();
|
||||||
break;
|
break;
|
||||||
@@ -392,24 +384,29 @@ var App = GObject.registerClass({
|
|||||||
else if(this.hideControlsTimeout) {
|
else if(this.hideControlsTimeout) {
|
||||||
this.clearTimeout('hideControls');
|
this.clearTimeout('hideControls');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(!this.dragStartReady || this.window.isFullscreen)
|
_onPlayerDragUpdate(gesture, offsetX, offsetY)
|
||||||
return;
|
{
|
||||||
|
let { gtk_double_click_distance } = this.player.widget.get_settings();
|
||||||
|
|
||||||
let startDrag = this.player.widget.drag_check_threshold(
|
if (
|
||||||
this.dragStartX, this.dragStartY, posX, posY
|
Math.abs(offsetX) > gtk_double_click_distance
|
||||||
);
|
|| Math.abs(offsetY) > gtk_double_click_distance
|
||||||
if(!startDrag) return;
|
) {
|
||||||
|
let [isActive, startX, startY] = gesture.get_start_point();
|
||||||
|
if(!isActive) return;
|
||||||
|
|
||||||
this.dragStartReady = false;
|
this.activeWindow.get_surface().begin_move(
|
||||||
let timestamp = event.get_time();
|
gesture.get_device(),
|
||||||
|
gesture.get_current_button(),
|
||||||
|
startX,
|
||||||
|
startY,
|
||||||
|
gesture.get_current_event_time()
|
||||||
|
);
|
||||||
|
|
||||||
this.window.begin_move_drag(
|
gesture.reset();
|
||||||
Gdk.BUTTON_PRIMARY,
|
}
|
||||||
this.dragStartX,
|
|
||||||
this.dragStartY,
|
|
||||||
timestamp
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_onWindowCloseRequest()
|
_onWindowCloseRequest()
|
||||||
|
@@ -82,9 +82,11 @@ 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.dragGesture = new Gtk.GestureDrag();
|
||||||
|
|
||||||
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.dragGesture);
|
||||||
|
|
||||||
this.connect('state-changed', this._onStateChanged.bind(this));
|
this.connect('state-changed', this._onStateChanged.bind(this));
|
||||||
this.connect('uri-loaded', this._onUriLoaded.bind(this));
|
this.connect('uri-loaded', this._onUriLoaded.bind(this));
|
||||||
|
Reference in New Issue
Block a user