为什么XGrabKey会生成额外的聚焦和聚焦事件? [英] Why XGrabKey generates extra focus-out and focus-in events?

查看:220
本文介绍了为什么XGrabKey会生成额外的聚焦和聚焦事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道xlib函数可以在不失去原始焦点的情况下捕获按键事件吗?如何摆脱它?

Does anyone know an xlib function to trap a keypress event without losing the original focus? How to get rid of it?

(或在不生成Grab样式的焦点的情况下使用XGrabKey()"?)

(or "to use XGrabKey() without generating Grab-style focusout"?)

(或如何在系统级摆脱NotifyGrab和NotifyUngrab焦点事件?)

(or "How to get rid of NotifyGrab and NotifyUngrab focus events at system level?)

XGrabKey将失去对按键的关注,而将精力恢复于释放的键.

The XGrabKey will lose focus on key pressed and restore focus on key released.

我想捕获按键而不泄漏到原始窗口(就像XGrabKey可以做到的那样).

And I want to trap the keypress without leak it to the original window (just as XGrabKey can do it).

参考文献:

  1. ... XGrabKey将窃取焦点... https://bugs.launchpad.net/gtkhotkey/+bug/390552/评论/8

  1. ...XGrabKey will steal focus... https://bugs.launchpad.net/gtkhotkey/+bug/390552/comments/8

...该程序接收控制以响应按键组合而执行某些操作.同时,该计划已暂时成为重点... 在XGrabKey(board)期间,发现哪个窗口已被聚焦

...The program receives control to do something in response to the key combination. Meanwhile, the program has been temporarily focused... During XGrabKey(board), discover which window had been focused

... XGrabKeyboard函数主动获取键盘控制权并生成FocusIn和FocusOut事件... http://www.x.org/archive/X11R6.8.0/doc/XGrabKeyboard.3.html#toc3

...The XGrabKeyboard function actively grabs control of the keyboard and generates FocusIn and FocusOut events... http://www.x.org/archive/X11R6.8.0/doc/XGrabKeyboard.3.html#toc3

...我看不到 提供metacity当前桌面更改行为的方法(更改 并同时显示弹出对话框),而不会引起 抓窗式聚焦在窗户上... https://mail.gnome.org/archives/wm-spec-list/2007-May/msg00000.html

...I can't see a way to provide metacity's current desktop changin behavior (changing and showing the popup dialog at the same time) without causing a Grab-type focus out on the window... https://mail.gnome.org/archives/wm-spec-list/2007-May/msg00000.html

...使用NotifyGrab在FocusOut事件上不应退出全屏模式... https://bugzilla.mozilla.org/show_bug.cgi?id=578265

...Fullscreen mode should not exit on FocusOut events with NotifyGrab... https://bugzilla.mozilla.org/show_bug.cgi?id=578265

抓取键盘不允许更改焦点... 抓取键盘不允许更改焦点

grabbing keyboard doesnt allow changing focus ... grabbing keyboard doesnt allow changing focus

Grabs生成的焦点事件(XGrabKeyboard的主动抓取和XGrabKey的被动抓取) http://www.x. org/releases/X11R7.6/doc/libX11/specs/libX11/libX11.html#Focus_Events_Generated_by_Grabs

Focus Events Generated by Grabs (both the active grab of XGrabKeyboard and the passive grab of XGrabKey) http://www.x.org/releases/X11R7.6/doc/libX11/specs/libX11/libX11.html#Focus_Events_Generated_by_Grabs

XGrabKey源代码: http://cgit.freedesktop.org/xorg/lib/libX11/tree/src/GrKey.c 也许我们可以修改它以消除焦点事件?

the XGrabKey source code: http://cgit.freedesktop.org/xorg/lib/libX11/tree/src/GrKey.c maybe we could modify this to get rid of focus-out events?

有"DoFocusEvents(keybd,oldWin,grab-> window,NotifyGrab)";在ActivateKeyboardGrab()中: http://cgit.freedesktop.org/xorg/xserver/tree/dix/events.c

there is "DoFocusEvents(keybd, oldWin, grab->window, NotifyGrab);" in ActivateKeyboardGrab(): http://cgit.freedesktop.org/xorg/xserver/tree/dix/events.c

我正在为按键组合(和鼠标移动)绘图软件编写一键操作:

I'm writting a one-keystroke to keys-combination(and mouse movement) mapping software:https://code.google.com/p/diyism-myboard/

我已经在Windows中通过RegisterHotKey()和UnRegisterHotKey()实现了它: https://code.google.com/p/diyism-myboard/downloads/detail?name=MyBoard.pas

I have realized it in Windows with RegisterHotKey() and UnRegisterHotKey(): https://code.google.com/p/diyism-myboard/downloads/detail?name=MyBoard.pas

我想使用XGrabKey()和XUngrabKey()将其迁移到Linux:

And i want to migrate it into Linux with XGrabKey() and XUngrabKey(): https://code.google.com/p/diyism-myboard/downloads/detail?name=myboard.py

我创建了10美元的赏金来解决此问题.我们需要更多支持者来提供悬赏. https: //www.bountysource.com/issues/1072081-right-button-menu-flashes-while-jkli-keys-move-the-mouse-pointer

I have created $10 bounty to resolve this problem. We need more backers to place bounties. https://www.bountysource.com/issues/1072081-right-button-menu-flashes-while-jkli-keys-move-the-mouse-pointer

推荐答案

最后,如您所知,linux意味着自由,所以我修改了xserver来摆脱抓斗式对焦:

Finally, as you know linux means freedom, i modified xserver to get rid of grab-style focusout:

sudo apt-get build-dep xorg-server
apt-get source xorg-server
cd xorg-server-*
#modify or patch dix/events.c: comment off "DoFocusEvents(keybd, oldWin, grab->window, NotifyGrab);" in ActivateKeyboardGrab(), comment off "DoFocusEvents(keybd, grab->window, focusWin, NotifyUngrab);" in DeactivateKeyboardGrab()
sudo apt-get install devscripts
debuild -us -uc    #"-us -uc" to avoid the signature step
cd ..
sudo dpkg --install xserver-xorg-core_*.deb
#clear dependencies:
sudo apt-mark auto $(apt-cache showsrc xorg-server | grep Build-Depends | perl -p -e 's/(?:[\[(].+?[\])]|Build-Depends:|,|\|)//g')
sudo apt-get autoremove

我还需要在gtk上下文菜单中摆脱XGrabKeyboard:

And i also need to get rid of XGrabKeyboard in gtk context menu:

sudo apt-get build-dep gtk+2.0
apt-get source gtk+2.0
cd gtk+2.0-*
#modify or patch it: add "return TRUE;" in first line of popup_grab_on_window() of gtk/gtkmenu.c
dpkg-source --commit
debuild -us -uc  #"-us -uc" to avoid the signature step, maybe need: sudo apt-get install devscripts
cd ..
sudo dpkg --install libgtk2.0-0_*.deb
#clear dependencies:
sudo apt-mark auto $(apt-cache showsrc gtk+2.0 | grep Build-Depends | perl -p -e 's/(?:[\[(].+?[\])]|Build-Depends:|,|\|)//g')
sudo apt-get autoremove

现在,myboard.py运行良好.

Now myboard.py works well.

如果您使用的是ubuntu raring-updates版本,则可以尝试:

If you are using ubuntu raring-updates edition, you could give a try to:

https://code.google.com/p/diyism-myboard/downloads/detail?name=xserver-xorg-core_1.13.3-0ubuntu6.2_i386.deb

和:

https: //code.google.com/p/diyism-myboard/downloads/detail?name=libgtk2.0-0_2.24.17-0ubuntu2_i386.deb

这篇关于为什么XGrabKey会生成额外的聚焦和聚焦事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆