Skip to main content

Command Palette

Search for a command to run...

FreeBSD作为VirtualBox虚拟机时鼠标滚轮有问题时的处理方法

Updated
1 min read

1、屏蔽掉按键8的mapping(不同人可能按键不一样)

先查看mapping(0表示屏蔽):

xmodmap -pp
There are 12 pointer buttons defined.

    Physical        Button
     Button          Code
        1              1
        2              2
        3              3
        4              4
        5              5
        6              6
        7              7
        8              0
        9              9
       10             10
       11             11
       12             12

例子中有12个按键

使用以下代码屏蔽掉按键8

xmodmap -e "pointer = 1 2 3 4 5 6 7 0 9 10 11 12"

然后再开启一个pcmanfm之类的窗口测试滚动,如果不行,换别的按键

测试成功后,将以下内容保存至~/.xmodmap

pointer = 1 2 3 4 5 6 7 0 9 10 11 12

更新.profile,加入xmodmap命令,确保每次登陆时,都会执行该动作

/usr/local/bin/xmodmap -e "pointer = 1 2 3 4 5 6 7 0 0 0 11 12"

2、Firefox滚动有问题的处理方法

输入about:config,查找mousebutton,找到mousebutton.4th.enabled,双击改为false即可

3、使用xinput和xev调整按键mapping

先通过xinput list找到对应鼠标的device Id

然后使用xinput get-button-map [devide_id]取到对应设备的mapping(0表示屏蔽),如:

1 2 3 4 5 6 7 8 9 10 11 12

使用xev打开一个窗口,在该窗口点击鼠标各按键,确认所需按键

使用xinput set-button-map [device id] [按键mapping]设置mapping,如:

xinput set-button-map 7 1 2 3 4 5 0 0 0 0 0 0 0

该操作可加入至.profile中以免下次登陆失效

4、终级方式,禁用Host/Guest鼠标平滑切换(禁用后,需使用Right Ctrl切换鼠标)

使用xinput list查看设备,找到nonamed或virtualbox相关的设备

通过xinput get-button-map [device id]查看mapping,确认为如下mapping:

1 0

使用xinput disable [device id]将该设备禁用即可

More from this blog

解决QWidget用winId获取HWND而导致Qt程序无事件消息的问题

问题原因: 当对一个QWidget调用winId时,默认情况下,Qt会对该窗口进行Native化,从而导致如鼠标等事件被其它原生窗口接管,表现出来的现像就是窗口不响应任何事件 解决思路: 防止Qt窗口Native化 解决办法: 第一步,在创建QApplication对象之前设置: QApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); //注意:Qt::AA_NativeWindows受环境变量 QT_USE_NATI...

Jul 7, 20251 min read

解决因OpenGL渲染窗口高宽比导致图形变形

在 OpenGL 中,由于窗口的 宽高比(aspect ratio) 与绘制内容的坐标系统不一致,图像会出现拉伸、压缩等变形现象。为了解决这个问题,可根据窗口的大小调整投影矩阵,确保图像在视觉上保持原始比例。 先通过glViewPort调整视口 void resizeGL(int w, int h) { glViewport(0, 0, w, h); } 再根据窗口高宽比,计算出合适的投影矩阵,这样体现出来的样式,就是截掉了宽高比之外的内容,显示的内容不变形,正圆就是正圆,不会被拉伸成...

Jun 18, 20251 min read

雷的部落格威力缩小版

29 posts

雷的部落格威力缩小版