简体   繁体   English

如何将焦点放在 xorg 中的单个窗口上?

[英]How to give focus to a single window in xorg?

I am not that well versed with xorg and the xlib libraray.I am not a C programmer.I installed st-simple terminal.Heard the fact that we can run only a terminal or a browser in xorg server without a window manager in a online article and confirmed it on arch wiki.我不太熟悉 xorg 和 xlib 库。我不是 C 程序员。我安装了 st-simple 终端。听说我们只能在 xorg 服务器中运行终端或浏览器,而没有在线窗口管理器文章并在 arch wiki 上确认。 .So to try it I ran. .所以为了尝试,我跑了。

startx /usr/local/bin/st

st did start but it did not have focus.Though I could write in it.I just want a solution which tells me how to give st focus as the unfocused cursor puts me off. st 确实开始了,但它没有焦点。虽然我可以在里面写。我只是想要一个解决方案,它告诉我如何在未聚焦的光标让我失望时给予 st 焦点。

Thanks in advance提前致谢

That st thing probably doesn't believe in PointerRoot and focus-follows-mouse.st的事情可能不相信PointerRoot和焦点如下鼠标。 Try giving it the focus explicitly with XSetInputFocus(3) .尝试使用XSetInputFocus(3)明确给予它焦点。

If you have a C compiler and the xorg -dev or -devel packages installed, try running this inside your st terminal:如果您有 C 编译器并安装了 xorg -dev 或 -devel 软件包,请尝试您的st终端中运行它:

echo '
#include <X11/Xlib.h>
#include <stdlib.h>
int main(){
    Display *dpy; char *ws; Window w;
    if((dpy = XOpenDisplay(0)) && (ws = getenv("WINDOWID")) && (w = strtoul(ws, 0, 0))){
        XSetInputFocus(dpy, w, RevertToPointerRoot, 0); XSync(dpy, False);
    }
}' | cc -Wall -lX11 -x c - -o getfocus && ./getfocus

There may be utilities like xdotool able to do that, but as far as I know they're not installed by default.可能有像xdotool这样的实用程序能够做到这一点,但据我所知,默认情况下它们没有安装。

Even better would be to fix that " suckless " terminal emulator so it sucks less and not assume a window manager and a point-to-type interface.更好的是修复那个“无用的”终端仿真器,这样它就少了一些,而不是假设一个窗口管理器和一个点到类型的界面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM