我正在使用一台戴尔 XPS 13 笔记本电脑,它带有一个无名 USB-C 底座,用于外接 HDMI 屏幕。几乎 100% 原装 Ubuntu 20.04,带有 Xorg、Gnome-Shell 和内核 5.8。一切正常,除非我想关闭屏幕,例如只是为了在空闲时省电。发生的情况是,一切都短暂变黑几秒钟,然后闪烁几次并重新打开。我也可以通过例如运行xset dpms force off
或禁用外部输出来手动触发此错误xrandr --output DP-1 --off
。
据我所知,问题在于外部显示器正确进入省电模式会触发热插拔事件,这会导致 gnome-shell 重新配置所有屏幕,并在此过程中再次唤醒它们。
我捕获了下面一个关闭-闪烁-开启序列的输出journalctl -f
- 欢迎提出建议,关于如何让 gnome-shell 忽略这些屏幕热插拔事件有什么想法吗?
Mai 01 21:30:34 sliver /usr/lib/gdm3/gdm-x-session[2008]: (II) modeset(0): Allocate new frame buffer 1920x1200 stride
Mai 01 21:30:35 sliver /usr/lib/gdm3/gdm-x-session[2008]: (II) modeset(0): EDID vendor "DEL", prod id 41155
Mai 01 21:30:35 sliver /usr/lib/gdm3/gdm-x-session[2008]: (II) modeset(0): Using hsync ranges from config file
Mai 01 21:30:35 sliver /usr/lib/gdm3/gdm-x-session[2008]: (II) modeset(0): Using vrefresh ranges from config file
Mai 01 21:30:35 sliver /usr/lib/gdm3/gdm-x-session[2008]: (II) modeset(0): Printing DDC gathered Modelines:
Mai 01 21:30:35 sliver /usr/lib/gdm3/gdm-x-session[2008]: (II) modeset(0): Modeline "2560x1440"x0.0 241.50 2560 2608 2640 2720 1440 1443 1448 1481 +hsync -vsync (88.8 kHz eP)
Mai 01 21:30:35 sliver /usr/lib/gdm3/gdm-x-session[2008]: (II) modeset(0): Modeline "1920x1080"x0.0 148.50 1920 2008 2052 2200 1080 1084 1089 1125 +hsync +vsync (67.5 kHz e)
[...]
Mai 01 21:30:35 sliver /usr/lib/gdm3/gdm-x-session[2008]: (II) modeset(0): Modeline "1280x1024"x0.0 108.00 1280 1328 1440 1688 1024 1025 1028 1066 +hsync +vsync (64.0 kHz e)
Mai 01 21:30:35 sliver gnome-shell[2150]: meta_display_get_monitor_in_fullscreen: assertion 'monitor >= 0 && monitor < n_logical_monitors' failed
Mai 01 21:30:35 sliver gnome-shell[2150]: meta_monitor_manager_get_logical_monitor_from_number: assertion '(unsigned int) number < g_list_length (manager->logical_monitors)' failed
Mai 01 21:30:35 sliver gnome-shell[2150]: meta_workspace_get_work_area_for_monitor: assertion 'logical_monitor != NULL' failed
Mai 01 21:30:43 sliver /usr/lib/gdm3/gdm-x-session[2008]: (II) modeset(0): EDID vendor "SHP", prod id 5324
Mai 01 21:30:43 sliver /usr/lib/gdm3/gdm-x-session[2008]: (II) modeset(0): Printing DDC gathered Modelines:
Mai 01 21:30:43 sliver /usr/lib/gdm3/gdm-x-session[2008]: (II) modeset(0): Modeline "3840x2400"x0.0 592.50 3840 3888 3920 4000 2400 2403 2409 2469 -hsync -vsync (148.1 kHz eP)
Mai 01 21:30:43 sliver /usr/lib/gdm3/gdm-x-session[2008]: (II) modeset(0): Modeline "3840x2400"x0.0 474.00 3840 3888 3920 4000 2400 2403 2409 2469 -hsync -vsync (118.5 kHz e)
Mai 01 21:30:43 sliver /usr/lib/gdm3/gdm-x-session[2008]: (II) modeset(0): EDID vendor "SHP", prod id 5324
Mai 01 21:30:43 sliver /usr/lib/gdm3/gdm-x-session[2008]: (II) modeset(0): Printing DDC gathered Modelines:
Mai 01 21:30:43 sliver /usr/lib/gdm3/gdm-x-session[2008]: (II) modeset(0): Modeline "3840x2400"x0.0 592.50 3840 3888 3920 4000 2400 2403 2409 2469 -hsync -vsync (148.1 kHz eP)
Mai 01 21:30:43 sliver /usr/lib/gdm3/gdm-x-session[2008]: (II) modeset(0): Modeline "3840x2400"x0.0 474.00 3840 3888 3920 4000 2400 2403 2409 2469 -hsync -vsync (118.5 kHz e)
Mai 01 21:30:46 sliver /usr/lib/gdm3/gdm-x-session[2008]: (II) modeset(0): EDID vendor "SHP", prod id 5324
Mai 01 21:30:46 sliver /usr/lib/gdm3/gdm-x-session[2008]: (II) modeset(0): Printing DDC gathered Modelines:
Mai 01 21:30:46 sliver /usr/lib/gdm3/gdm-x-session[2008]: (II) modeset(0): Modeline "3840x2400"x0.0 592.50 3840 3888 3920 4000 2400 2403 2409 2469 -hsync -vsync (148.1 kHz eP)
Mai 01 21:30:46 sliver /usr/lib/gdm3/gdm-x-session[2008]: (II) modeset(0): Modeline "3840x2400"x0.0 474.00 3840 3888 3920 4000 2400 2403 2409 2469 -hsync -vsync (118.5 kHz e)
Mai 01 21:30:46 sliver /usr/lib/gdm3/gdm-x-session[2008]: (II) modeset(0): Allocate new frame buffer 2560x2640 stride
Mai 01 21:30:46 sliver /usr/lib/gdm3/gdm-x-session[2008]: (II) modeset(0): EDID vendor "SHP", prod id 5324
Mai 01 21:30:46 sliver /usr/lib/gdm3/gdm-x-session[2008]: (II) modeset(0): Printing DDC gathered Modelines:
Mai 01 21:30:46 sliver /usr/lib/gdm3/gdm-x-session[2008]: (II) modeset(0): Modeline "3840x2400"x0.0 592.50 3840 3888 3920 4000 2400 2403 2409 2469 -hsync -vsync (148.1 kHz eP)
Mai 01 21:30:46 sliver /usr/lib/gdm3/gdm-x-session[2008]: (II) modeset(0): Modeline "3840x2400"x0.0 474.00 3840 3888 3920 4000 2400 2403 2409 2469 -hsync -vsync (118.5 kHz e)
答案1
我刚刚发现https://askubuntu.com/a/1054222/29252,但这仅适用于较旧的 Gnome 版本。不过,我还找到了一种解决方法:如果您修补 Mutter 包以忽略 XRandR 事件 (XRR*),那么目前看来它有效(当然,这有点过头了)。修补程序在这里:
--- mutter-3.36.7+git20201123.orig/cogl/cogl/cogl-xlib-renderer.c
+++ mutter-3.36.7+git20201123/cogl/cogl/cogl-xlib-renderer.c
@@ -527,11 +527,11 @@ _cogl_xlib_renderer_connect (CoglRendere
renderer);
}
- XRRSelectInput(xlib_renderer->xdpy,
+ /*XRRSelectInput(xlib_renderer->xdpy,
DefaultRootWindow (xlib_renderer->xdpy),
RRScreenChangeNotifyMask
| RRCrtcChangeNotifyMask
- | RROutputPropertyNotifyMask);
+ | RROutputPropertyNotifyMask);*/
update_outputs (renderer, FALSE);
register_xlib_renderer (renderer);
--- mutter-3.36.7+git20201123.orig/src/backends/x11/meta-monitor-manager-xrandr.c
+++ mutter-3.36.7+git20201123/src/backends/x11/meta-monitor-manager-xrandr.c
@@ -1320,11 +1320,11 @@ meta_monitor_manager_xrandr_constructed
int major_version, minor_version;
/* We only use ScreenChangeNotify, but GDK uses the others,
and we don't want to step on its toes */
- XRRSelectInput (manager_xrandr->xdisplay,
+ /*XRRSelectInput (manager_xrandr->xdisplay,
DefaultRootWindow (manager_xrandr->xdisplay),
RRScreenChangeNotifyMask
| RRCrtcChangeNotifyMask
- | RROutputPropertyNotifyMask);
+ | RROutputPropertyNotifyMask);*/
XRRQueryVersion (manager_xrandr->xdisplay, &major_version,
&minor_version);