私はXlibとQt 4.7を使って自分のウィンドウマネージャを書いています。だから私のアプリケーションでは、XServerからすべてのイベントをキャッチします。
問題は次にあります。 「MapRequest」イベントでウィンドウを表示すると、内部コンテンツが別のウィンドウに表示されることがあります。ほとんどの場合、開いている新しいWebページの後にブラウザ(FirefoxやGoogle Chromeなど)でこの問題が発生することがよくあります。開いているダイアログウィンドウの後にQt CreatorとDolphinでメディアプレーヤーでも表示されることがあります。その理由は何でしょうか?私が忘れたのは?
アドバイスは大歓迎です。
ここにMapRequestハンドラがあります。
bool Manager::mapRequestHandler(XEvent* pEvent)
{
Window lWindow = pEvent->xmaprequest.window;
QMWindowWidget* lWidget = findWidget(lWindow);
if (!lWidget)
{
lWidget = (QMWindowWidget*)QWidget::find(lWindow);
}
if (lWidget)
{
XMapWindow(QX11Info::display(), lWindow);
lWidget->show();
XRaiseWindow(QX11Info::display(), lWidget->winId());
return true;
}
else
{
qDebug()<<"CREATING WINDOW IN MAP_REQUEST...";
createClientWindow(lWindow); //this function calls only here.
qDebug()<<"WINDOW CREATED";
return true;
}
return false;
}
ここにはcreateClientWindow()関数があります。
void Manager::createClientWindow(Qt::HANDLE pWinID)
{
XWindowAttributes lWinAttr;
if(!XGetWindowAttributes(QX11Info::display(), pWinID, &lWinAttr))
{
return;
}
if(lWinAttr.override_redirect)
{
return;
}
QStringList lWindowType = getWindowType(pWinID);
if(lWindowType[0] == "Desktop")
{
return;
}
else if(lWindowType[0] == "Splash" || lWindowType[0] == "Dock" ||
lWindowType[0] == "KDE_override" || lWindowType[0] == "Popup_menu")
{
XMapWindow(QX11Info::display(), pWinID);
XRaiseWindow(QX11Info::display(), pWinID);
return;
}
else
{
QMWindowWidget *lWindowWidget = new QMWindowWidget(pWinID, lWinAttr);
connect(lWindowWidget, SIGNAL(destroyed(QObject*)), this, SLOT(slotWidgetDestroyed(QObject*)));
mListWindows.append(lWindowWidget);
}
}
QMWindowWidgetのコンストラクタです。
mClientAttr = pWinAttr;
mWmHints = XGetWMHints(QX11Info::display(), pWindow);
XGrabServer(QX11Info::display());
XTextProperty lTitle;
XGetWMName(QX11Info::display(), pWindow, &lTitle);
this->setWindowTitle(QString::fromUtf8((const char*)lTitle.value));
qDebug()<setGeometry(widgetX, widgetY, pWinAttr.width + 6, pWinAttr.height + 33);
XSelectInput(QX11Info::display(),this->winId(),
KeyReleaseMask | KeyPressMask |
ButtonMotionMask|
ButtonPressMask | ButtonReleaseMask |
FocusChangeMask |
ExposureMask |
StructureNotifyMask |
SubstructureNotifyMask |
SubstructureRedirectMask);
XReparentWindow(QX11Info::display(), pWindow, this->winId(), 3, 30);
XSelectInput(QX11Info::display(), pWindow,
ColormapChangeMask |
PropertyChangeMask |
StructureNotifyMask);
this->show();
XMapWindow(QX11Info::display(), pWindow);
XRaiseWindow(QX11Info::display(), this->winId());
XSetInputFocus(QX11Info::display(), pWindow, RevertToParent, CurrentTime);
XUngrabServer(QX11Info::display());
XSync(QX11Info::display(), false);