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

win11窗口无法正常拖拽 #40

Closed
SOVLOOKUP opened this issue Aug 30, 2021 · 12 comments
Closed

win11窗口无法正常拖拽 #40

SOVLOOKUP opened this issue Aug 30, 2021 · 12 comments
Labels
bug Something isn't working

Comments

@SOVLOOKUP
Copy link
Member

描述一下这个bug
win11中拖拽窗口会产生漂移和变形

截图
image

@SOVLOOKUP SOVLOOKUP added the bug Something isn't working label Aug 30, 2021
@muwoo
Copy link
Contributor

muwoo commented Aug 30, 2021

@SOVLOOKUP 是不是需要授权? 窗口拖拽依托于 robotjs 所以可能需要系统权限。如果未开启,可能无法拖东,也就导致了误触拖到边缘改变窗口了

@SOVLOOKUP
Copy link
Member Author

不是授权的问题,已经开了管理员权限了,在win10的时候并不会发生这种情况。

为什么不像utools一样使用 -webkit-app-region: drag; 来定义拖动区域呢?

@muwoo
Copy link
Contributor

muwoo commented Aug 30, 2021

@SOVLOOKUP 需要对可点击区域设置 non-draggable,详见:https://www.jianshu.com/p/96327b044e85

1 similar comment
@muwoo
Copy link
Contributor

muwoo commented Aug 31, 2021

@SOVLOOKUP 需要对可点击区域设置 non-draggable,详见:https://www.jianshu.com/p/96327b044e85

@SOVLOOKUP
Copy link
Member Author

或者可以只将输入框设置为 dragable ,看作是一个自定义的标题栏

@muwoo
Copy link
Contributor

muwoo commented Aug 31, 2021

@SOVLOOKUP 输入框占了整个体积,如果输入框设置成 dragable 跟全部设置成dragable 差别不大了

muwoo added a commit that referenced this issue Sep 3, 2021
@muwoo
Copy link
Contributor

muwoo commented Sep 3, 2021

@nxnminieye
Copy link

nxnminieye commented Sep 3, 2021

@SOVLOOKUP https://github.com/clouDr-f2e/rubick/releases/tag/v0.0.3-beta.9 试试看,应该已修复

这么做就不能用户调整窗口大小了,windows下setsize是有bug的,个人的解决方案:

let diff = { x: 0, y: 0, width: 0, height: 0 }
const moveBounds = (win, x, y) => {
  var bounds = win.getBounds()
  if (bounds.x != x || bounds.y != y) {
    bounds.x = x
    bounds.y = y
    setBounds(win, bounds)
  }
}
const setBounds = (win, bounds) => {
  var _setbounds = {
    x: bounds.x - diff.x,
    y: bounds.y - diff.y,
    width: bounds.width - diff.width,
    height: bounds.height - diff.height
  }
  var _bounds = win.getBounds()
  // 预期设定与当前位置偏差小于2px则忽略设定,否则可能窗口抖动
  var x = _setbounds.x - _bounds.x
  var y = _setbounds.y - _bounds.y
  if (x * x + y * y > 4) {
    win.setBounds(_setbounds)
    _bounds = win.getBounds()
    diff.x = _bounds.x - _setbounds.x
    diff.y = _bounds.y - _setbounds.y
    diff.width = _bounds.width - _setbounds.width
    diff.height = _bounds.height - _setbounds.height
  }
}

@muwoo
Copy link
Contributor

muwoo commented Sep 3, 2021

@nxnminieye 这是一个令人兴奋的点,可以提个 pr

@SOVLOOKUP
Copy link
Member Author

@SOVLOOKUP https://github.com/clouDr-f2e/rubick/releases/tag/v0.0.3-beta.9 试试看,应该已修复

刚刚试了一下最新版本,问题并没有解决

muwoo added a commit that referenced this issue Sep 16, 2021
@muwoo
Copy link
Contributor

muwoo commented Sep 16, 2021

@SOVLOOKUP  这次真的修复了

@muwoo muwoo closed this as completed Sep 16, 2021
@nxnminieye
Copy link

@SOVLOOKUP  这次真的修复了

还是没有完全修复,多拖几次,依然会越来越大,window下setBounds和getBounds的结果是不一致,当前的做法只是单次拖动不会越拖越大(事实上单次也大了一两个像素)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants