X11 - 无法XGrabKeyboard后移到窗口 [英] x11 - Unable to move window after XGrabKeyboard

查看:341
本文介绍了X11 - 无法XGrabKeyboard后移到窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

呼叫后 XGrabKeyboard() ,我的应用程序捕获和显示所有关键presses /版本,包括为GUI和PRINTSCREEN键。 但是,用户不再能够移动应用程序的窗口。到目前为止,这发生在Fedora 17和Ubuntu 12.04。

After calling XGrabKeyboard(), my application captures and displays all key presses / releases, including those for the GUI and PrintScreen keys. However, the user is no longer able to move the application's window. So far, this occurs on Fedora 17 and Ubuntu 12.04.

我怎么能允许用户移动应用程序,同时的 XGrabKeyboard()

How can I allow the user to move the application while being under the effect of XGrabKeyboard()?

下面是样本code为我的Qt应用程序:

Below is sample code for my Qt application:

bool KeyboardStatus::x11Event(XEvent *event) {
    switch (event->type) {
        case FocusIn:
            XGrabKeyboard(x11Info().display(), winId(), false, GrabModeAsync, GrabModeAsync, CurrentTime);
            break;

        case FocusOut:
            XUngrabKeyboard(x11Info().display(), CurrentTime);
            break;

        case KeyPress:
            // Display which key was pressed to user
            return true;

        case KeyRelease:
            // Display which key was released to user
            return true;
    }

    return false;
}

以抢出声明事件处理程序并不能解决问题。这里是一个说明该问题的示例项目: TestGrab.zip

推荐答案

我已经试过这对KDE,FVWM和GNOME(只用Xlib的),只有在GNOME窗口管理器有这个问题。

I have tried this on KDE, FVWM and GNOME (just using Xlib), and only the GNOME window manager has this problem.

我想这可能是可能拿起ConfigureNotify事件来修复它,但是当你尝试移动窗口就不会产生。

I thought it might be possible to fix it by picking up the ConfigureNotify event, but it is not generated when you try to move the window.

这篇关于X11 - 无法XGrabKeyboard后移到窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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