Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Set window types to input
Compatibility with MCompositor and Maliit 0.8.
InputMethodQuick method call moved just because otherwise Qt was aborting,
possibly due to opengl drivers, but registering after set up is done is
more logical anyways.

RevBy: Jan Arne Petersen
  • Loading branch information
pvuorela committed Apr 24, 2013
1 parent c7337c1 commit 39baf74
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/quick/inputmethodquick.cpp
Expand Up @@ -41,13 +41,13 @@ QQuickView *createWindow(MAbstractInputMethodHost *host)
{
QScopedPointer<QQuickView> view(new QQuickView);

host->registerWindow(view.data(), Maliit::PositionCenterBottom);

QSurfaceFormat format;
format.setAlphaBufferSize(8);
view->setFormat(format);
view->setColor(QColor(Qt::transparent));

host->registerWindow(view.data(), Maliit::PositionCenterBottom);

return view.take();
}

Expand Down
4 changes: 1 addition & 3 deletions src/windowgroup.cpp
Expand Up @@ -62,10 +62,8 @@ void WindowGroup::setupWindow(QWindow *window, Maliit::Position position)
}
m_window_list.append (WindowData(window, position));

window->setFlags (Qt::Dialog |
Qt::FramelessWindowHint |
window->setFlags (Qt::FramelessWindowHint |
Qt::WindowStaysOnTopHint |
Qt::X11BypassWindowManagerHint |
Qt::WindowDoesNotAcceptFocus);

connect (window, SIGNAL (visibleChanged(bool)),
Expand Down
47 changes: 45 additions & 2 deletions src/xcbplatform.cpp
Expand Up @@ -28,9 +28,52 @@ namespace Maliit
void XCBPlatform::setupInputPanel(QWindow* window,
Maliit::Position position)
{
Q_UNUSED(window);
Q_UNUSED(position);
// nothing to do.

if (not window) {
return;
}

// set window type as input, supported by at least mcompositor
QPlatformNativeInterface *xcbiface = QGuiApplication::platformNativeInterface();
xcb_connection_t *xcbConnection
= static_cast<xcb_connection_t *>(xcbiface->nativeResourceForWindow("connection", window));
if (!xcbConnection) {
qWarning("Unable to get Xcb connection");
return;
}

const char * windowType = "_NET_WM_WINDOW_TYPE";
const char * windowTypeInput = "_NET_WM_WINDOW_TYPE_INPUT";

xcb_intern_atom_cookie_t windowTypeCookie =
xcb_intern_atom(xcbConnection, false, strlen(windowType), windowType);
xcb_intern_atom_cookie_t typeInputCookie =
xcb_intern_atom(xcbConnection, false, strlen(windowTypeInput), windowTypeInput);

xcb_atom_t windowTypeAtom;
xcb_atom_t windowTypeInputAtom;

xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(xcbConnection, windowTypeCookie, 0);
if (reply) {
windowTypeAtom = reply->atom;
free(reply);
} else {
qWarning("Unable to fetch window type atom");
return;
}

reply = xcb_intern_atom_reply(xcbConnection, typeInputCookie, 0);
if (reply) {
windowTypeInputAtom = reply->atom;
free(reply);
} else {
qWarning("Unable to fetch window type input atom");
return;
}

xcb_change_property(xcbConnection, XCB_PROP_MODE_REPLACE, window->winId(), windowTypeAtom, XCB_ATOM_ATOM,
32, 1, &windowTypeInputAtom);
}

void XCBPlatform::setInputRegion(QWindow* window,
Expand Down

0 comments on commit 39baf74

Please sign in to comment.