Skip to content

Commit d5306ca

Browse files
Sneakpeakcssdexeonify
authored andcommitted
crop: Disable window dragging when cropping
This lets users hold and drag to select a crop area. This is implemented by temporarily setting `window-dragging` property to no when cropping. Releasing the mouse confirms the crop. The behaviour for point-and-click to crop is unchanged. This option can be disabled with a `script-opt`. Recent changes to mpv caused issues detecting mouse input when selecting an area. Disabling `window-dragging` resolves this problem. Ref: Sneakpeakcss/mpv-scripts@136d435
1 parent 9837a3a commit d5306ca

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

script-opts/crop.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ frame_border_color=EEEEEE
1515
# hexadecimal: 00 is opaque, FF is transparent
1616
shade_opacity=77
1717
mouse_support=yes
18+
disable_window_dragging=yes
1819

1920
# movement is defined in pixels in the window
2021
# which explains the mismatch with the text (in video space)

scripts/crop.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ local opts = {
88
draw_crosshair = true,
99
draw_text = true,
1010
mouse_support = true,
11+
disable_window_dragging = true,
1112
coarse_movement = 30,
1213
left_coarse = "LEFT",
1314
right_coarse = "RIGHT",
@@ -375,6 +376,9 @@ function cancel_crop()
375376
mp.unregister_idle(draw_crop_zone)
376377
mp.set_osd_ass(1280, 720, '')
377378
active = false
379+
if opts.disable_window_dragging and not mp.get_property_bool("window-dragging") then
380+
mp.set_property_bool("window-dragging", true)
381+
end
378382
end
379383

380384
-- adjust coordinates based on previous values
@@ -525,6 +529,9 @@ function start_crop(mode)
525529
active = true
526530
active_mode = mode_maybe
527531

532+
if opts.disable_window_dragging then
533+
mp.set_property_bool("window-dragging", false)
534+
end
528535
if opts.mouse_support then
529536
cursor.x, cursor.y = mp.get_mouse_pos()
530537
end

0 commit comments

Comments
 (0)