问题描述
实际在运行某些通过qt写的全屏程序过程中,如果对应的qt应用偶发会出现对应的显示卡死的情况(实际应用在操作一些菜单和子菜单过程中发现卡死情况),但是如果通过ssh远程进去后然后打开某些终端(mate-terminal)又能正常显示但是对应的终端焦点输入不能正常提示输入(键盘输入焦点未过来?)。
1. 软件信息
mate:1.12
marco:1.16
xorg:1.20.8
2. 调试方法和工具
2.1 marco源码下载
git clone https://github.com/mate-desktop/marco.git
2.2 marco调试方法学习
安装对应的xdotool、wmctrl、xprop、xwininfo工具等
在对应的源码目录下有以下对应的调试可以进行参考:
- doc/code-overview.txt
焦点问题:
Focus issues (i.e. issues with which window is active):
doc/how-to-get-focus-right.txt
meta_workspace_focus_default_window
_NET_ACTIVE_WINDOW
_NET_WM_USER_TIME
meta_window_focus
meta_display_(set_input|focus_the_no)_focus_window
XSetInputFocus (only for purposes of understanding how X focus/input works)
CurrentTime (mostly, you should just think "Bad; don't use it")
eg:bpftrace xsetinputfocus.bt
#!/usr/bin/env bpftrace
// 监听 libX11.so 中的 XSetInputFocus 调用
uprobe:/usr/lib64/libX11.so.6.3.0:XSetInputFocus
{
// 打印进程名和 PID
printf("Process: %s (PID: %d)\n", comm, pid);
// 打印参数:display, focus, revert_to, time
printf(" display: 0x%x\n", arg0);
printf(" focus: 0x%x\n", arg1);
printf(" revert_to: %d\n", arg2);
printf(" time: %d\n", arg3);
// 打印调用栈
printf("Call stack:\n");
print(ustack);
printf("\n");
}
- doc/how-to-get-focus-right.txt
- HACKING
可以通过 “grep -rn MARCO_ * | grep getenv”查看有哪些对应的日志可以进行查到如下:
MARCO_DEBUG
MARCO_DISABLE_FALLBACK_COLOR
MARCO_DEBUG_REDRAWS
MARCO_DEBUG_COMPOSITOR
MARCO_USE_LOGFILE
MARCO_DEBUG_SM
MARCO_DEBUG_XINERAMA
MARCO_DISPLAY
MARCO_VERBOSE
MARCO_SYNC
MARCO_USE_STATIC_GRAVITY
MARCO_DEBUG_BUTTON_GRABS
MARCO_DEBUG_EFFECTS
eg:MARCO_USE_LOGFILE=1 MARCO_VERBOSE=1 marco --replace
- 鼠标模式设置
gsettings get org.mate.Marco.general focus-mode ‘click sloppy mouse’
click(点击):
窗口只有在鼠标点击时才会获得焦点。
这是最严格的焦点模式,适合避免意外切换窗口焦点。
sloppy(宽松):
窗口在鼠标移动到其上时会获得焦点,但不会在鼠标移出时失去焦点。
焦点只有在点击其他窗口或桌面时才会切换。
mouse(鼠标):
窗口在鼠标移动到其上时会立即获得焦点,且鼠标移出时焦点也会立即转移。
这是最动态的焦点模式,适合习惯鼠标操作的用户。
5.其他工具和方法
# 窗口查看(如果是ssh远程进去,可以先通过export DISPLAY=:0执行后再去执行下面的命令)
$ wmctrl -l -x
0x01c00003 -1 mate-panel.Mate-panel localhost.localdomain 下方扩展边缘面板
0x00c0001c -1 desktop_window.Caja localhost.localdomain x-caja-desktop
# 查看当前焦点所属窗口
$ xdotool getwindowfocus | xargs printf "0x%x\n"
# 设置焦点
$ xdotool windowfocus <windows_id>
# 查看当前哪个窗口处于激活状态
$ xdotool getactivewindow | xargs printf "0x%x\n"
# 激活对应windows_id的窗口
$ xdotool windowactivate <windows_id>
# 对应窗口信息查看
$ xprop -id <windows_id>
# 抓取输入,通过移动鼠标到对应窗口看会有信息输出?
$ xev -id <windows_id>
2.3 xorg的源码和调试
https://wiki.archlinuxcn.org/wiki/Xorg
https://www.x.org/wiki/Development/Documentation/ServerDebugging/
www.x.org/wiki/guide/debugging
https://www.x.org/releases/current/doc/
0.开发编译
step1:下载对应的xorg-x11-server-xxx.src.rpm
step2:rpm -ivh xorg-x11-server-xxx.src.rpm && yum install rpm-build
step3:cd /root/rpmbuild/ && yum-builddep -y SPEC/xorg-x11-server.spec && rpmbuild -ba SPEC/xorg-x11-server.spec
1.默认开启远程ssh后可以直接跟xorg交互配置
/etc/profile.d/X11.sh
export DISPLAY=${DISPLAY:-:0}
export TERM=${TERM:-linux}
开启root用户访问xorg服务
xhost + si:localuser:root
2.生成xorg的coredump信息
/usr/share/X11/xorg.conf.d/20-notrapsignals.conf
Section "ServerFlags"
Option "NoTrapSignals" "true"
EndSection
3.修改Xorg的启动参数
修改文件/usr/share/lightdm/lightdm.conf.d/50-xserver-command.conf添加-logverbose 10,默认该值是3,数值越大打印信息越多。
[Seat:*]
xserver-command=X -core -noreset -logverbose 10
- 输入问题排查:内核层(evtest),libinput层(libinput debug-events),Xorg(xinput:xinput list,xinput test ,xev:xev -event keyboard)
显示本身:xdotool,xprop(xorg-x11-utils),wmctrl(wmctrl),xwininfo/xdpyinfo,xrdb,xkbcomp/setxkbmap,xtrace/xscope(抓取x11协议命令)
xtrace: xtrace -o /tmp/xclock.xtrace xclock
xscope: 服务端:xscope -i1 客户端:DISPLAY=:1 xclock