如果 Chrome 处于焦点状态,则按 Alt-tab 切换工作区

如果 Chrome 处于焦点状态,则按 Alt-tab 切换工作区

MATE 18.10

我已设置工作区,以便 alt-tab 可在当前工作区中的窗口间循环切换。但是,如果我在 chrome 窗口中,alt-tab 会将我发送到另一个工作区中的另一个 chrome 窗口。

在我见过的任何 chrome 文档中,Alt-tab 都没有作为快捷方式出现。

因此看起来 Chrome 正在抓取 alt-tab,或者 MATE 的某一层正在传递它而不是对其采取行动。

有人知道发生了什么事吗? 以及/或者如何解决它?

答案1

假设问题确实是某些 Chrome 窗口设置了窗口管理器标志_NET_WM_STATE_DEMANDS_ATTENTION,而您的窗口管理器未能聚焦正确的窗口,那么您可以运行如下脚本来找出问题:

#!/bin/bash
# Copyright 2020 Mikko Rantalainen <[email protected]>
# License: MIT
set -e

# check 'wmctrl' has been installed
wmctrl --version > /dev/null || { echo "This script requires command 'wmctrl', aborting." 1>&2; exit 1; }

# save active window id
ACTIVE_ID=$(xprop -root | grep _NET_ACTIVE_WINDOW\(WINDOW\) | sed 's/.*window id # //')

wmctrl -l | while read id desktop machine title
do
    if xprop -id "$id" | grep -q "_NET_WM_STATE_DEMANDS_ATTENTION"
    then
        printf "\nWindow id %s (%s) on desktop #%s demands attention:\n" "$id" "$machine" "$desktop"
        #xprop -id "$id" | grep -E '(WM_CLASS|^WM_NAME.*UTF8)'
        printf -- "- %s\n" "$title"
        if test "$1" = "--clear"
        then
        wmctrl -i -a "$id"
        sleep 1
        fi
    fi
done

if test "$1" = "--clear"
then
    wmctrl -i -a "$ACTIVE_ID"
else
    echo ""
    echo "Pass flag '--clear' to focus each window demanding attention" 1>&2
    echo "for 1 seconds to clear the demands attention flag" 1>&2
fi

将文件保存为 ~/bin/list-window-demands-attention ,然后可以在终端中运行它:

$ list-window-demands-attention

Window id 0x0320005e (desktop) on desktop #2 demands attention:
- linux - How to check actual RAM usage of tmpfs? - Unix & Linux Stack Exchange - Google Chrome

Window id 0x03200079 (desktop) on desktop #2 demands attention:
- breaking-thunderbolt-security-bjorn-ruytenberg-20200417.pdf - Google Chrome

Pass flag '--clear' to focus each window demanding attention
for 1 seconds to clear the demands attention flag

这应该足以确定您需要聚焦哪些窗口以清除标志。如果您不介意实际的窗口而只想清除标志,您可以传递,--clear脚本将显示每个窗口 1 秒,然后返回到切换任何窗口之前处于活动状态的窗口。聚焦的窗口将提升到窗口堆栈的顶部。

list-window-demands-attention --clear

如果您不想每个窗口等待 1 秒,请随意注释掉或删除上述sleep 1内容。

答案2

据官方称Google 帮助中心没有 Alt+Tab

在 Chrome 网上应用店中搜索 Shortkeys,那里有答案。这将允许您覆盖任何默认的 Chrome 快捷键。我找到了几个。但我不能提出任何建议。

我以后会避免再问这样的问题,因为这是 Chrome 的问题,而不是 Ubuntu 的问题。

根据这个:https://www.computerhope.com/shortcut/chrome.htm 它们可以设置为 alt+tab。

已编辑:移动内容以更好地显示我的答案。

相关内容