Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove "Left-click will be ignored for a short time after the focus window" #39

Closed
natural-harmonia-gropius opened this issue Dec 30, 2023 · 13 comments

Comments

@natural-harmonia-gropius
Copy link
Owner

100ms not always well worked, states based approach should no more race issue.

https://github.com/natural-harmonia-gropius/input-event/blob/239b2fc9c7486b9874e592bb8a95408d17e3c663/inputevent.lua#L445C1-L449C5

and

https://github.com/natural-harmonia-gropius/input-event?tab=readme-ov-file#left-click-will-be-ignored-for-a-short-time-after-the-focus-window

mpv.conf

[background]
profile-cond=not focused and get("current-tracks/video/albumart") == false
profile-restore=copy-equal
script-opts-append=inputevent-configs=input.conf,~~/input.noleft.conf
pause

input.noleft.conf

MBTN_LEFT   ignore  #@click
@natural-harmonia-gropius
Copy link
Owner Author

Closed by 4a73dd1

@verygoodlee
Copy link
Contributor

新版可灵活配置,更优雅了,但是会影响到双击行为。
一般来说设置成 左键单击切换暂停,双击切换全屏,
在窗口失焦状态下双击变成了切换暂停了,三击才是切换全屏,体验有些割裂,
旧版没这个问题。

natural-harmonia-gropius added a commit that referenced this issue Jan 30, 2024
…indow"

For 4a73dd1 the #39 (comment) shows regression, and it will conflict with other scripts.
@natural-harmonia-gropius
Copy link
Owner Author

加回去了

@verygoodlee
Copy link
Contributor

verygoodlee commented Jan 30, 2024

我倒是有个方案,也是用auto profile实现,可以直接在profile-cond里写lua代码调用script-message-to
实现新版一样的效果只要这样写,重新绑定MBTN_LEFT click这一个键

[inputevent-noleft-onfocus]
profile-cond=mp.commandv('script-message-to','inputevent','bind','MBTN_LEFT',focused and '{"click": "cycle pause"}' or '{"click": ""}')

要想不影响双击的话,加个定时器,获取焦点时延迟绑定,延迟时间大概1.5倍的input-doubleclick-time

[inputevent-noleft-onfocus]
profile-cond=mp.add_timeout(focused and input_doubleclick_time*1.5/1000 or 0, function() mp.commandv('script-message-to','inputevent','bind','MBTN_LEFT',focused and '{"click": "cycle pause"}' or '{"click": ""}') end)

暂时用着不错,估计还是有些特殊情况有冲突。

最大的缺点是可读性可维护性太差了,这里写lua代码不能换行,必须强制压为一行,
只是一种取巧写法,利用auto profile去监测属性变化并执行代码,并不是auto profile的正常用法。

verygoodlee added a commit to verygoodlee/input-event that referenced this issue Jan 30, 2024
…data/inputevent/onfocus:cycle pause}` instead
@verygoodlee
Copy link
Contributor

旧版的硬编码写死还是不太好,有些人可能不需要这个功能,可以试用下这个 verygoodlee/input-event@14ce642 可配置的。

获取焦点的时候写入一个 user-data属性user-data/inputevent/onfocus,并在1.5倍input-doubleclick-time定时之后删除它。

绑定按键使用property-expansion 语法判断一下,不存在这个属性时才执行
MBTN_LEFT ${!user-data/inputevent/onfocus:cycle pause}

@natural-harmonia-gropius 如果觉得不错可以提个PR合并一下

@natural-harmonia-gropius
Copy link
Owner Author

我觉得就像 _DBL 存在逻辑问题一样,获取窗口焦点的一次点击不应该触发任何事件。一般默认左键单击是播放/暂停,通过鼠标来获取焦点会让正在播放的视频暂停,这是反直觉的。

如果有人有实际的需要我再想怎么改。

@verygoodlee
Copy link
Contributor

verygoodlee commented Jan 30, 2024

我试了几个有单击暂停功能的网页播放器,获取焦点时也会暂停,不过浏览器中有较多空白区域可以获取焦点,不会刻意去点视频区域获取焦点。
win10的电影和电视和win11的媒体播放器压根就不支持单击暂停,pot mpc这些也多年未用了,不记得他们是什么行为

@natural-harmonia-gropius
Copy link
Owner Author

我下载mpc-hc试了下会播放/暂停。没有必要跟从别人的行为啊,逻辑上就是点这一下会暂停很烦人。而且mpv除了顶栏就没有空白区域,就这唯一的顶栏还可以关掉,对一些用户来说是没有安全单击区域的。

@verygoodlee
Copy link
Contributor

最近在用这个原生右键菜单 https://github.com/tsl0922/mpv-menu-plugin ,也有类似的问题 tsl0922/mpv-menu-plugin#23,没有一个通用的解决方案。
这个右键菜单不会使主窗口失去焦点,所以暂时inputevent不能解决,如果关闭菜单时能给inputevent发个script-message,或许能解决。

@natural-harmonia-gropius
Copy link
Owner Author

@verygoodlee
Copy link
Contributor

https://github.com/natural-harmonia-gropius/mpv-menu-plugin/actions/runs/7723662042

你试试看这个行不行

可以的,但是和inputevent的有点冲突,inputevent的单击双击都绑定的MBTN_LEFT,直接禁用MBTN_LEFT会导致双击也失效,要完美搭配inputevent使用还是得自己改改

@natural-harmonia-gropius
Copy link
Owner Author

搭配inputevent

@verygoodlee 试试 https://github.com/tsl0922/mpv-menu-plugin/actions 最新版,在inputevent最后面加上这个。

mp.register_script_message('menu-close', function()
    local binding = bind_map["MBTN_LEFT"]
    if not binding then
        return
    end
    binding:ignore("click", binding.duration)
end)

@verygoodlee
Copy link
Contributor

是的,上次就是这么改的,可以复用一下on_focused_update

mp.register_script_message("menu-close", function() on_focused_update(nil, true) end)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants