Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 69207fa3 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Initial connection of the Qt's tablet code to Krita

It doesn't work yet though
parent 5f827875
......@@ -256,6 +256,13 @@ else()
set(HAVE_X11 FALSE)
endif()
find_package(XCB COMPONENTS XCB ATOM)
if(XCB_FOUND)
set(HAVE_XCB TRUE)
else()
set(HAVE_XCB FALSE)
endif()
# use sane compile flags
add_definitions(
-DQT_USE_QSTRINGBUILDER
......
......@@ -50,6 +50,7 @@
#endif
#elif defined HAVE_X11
#include <ui/input/wintab/kis_tablet_support_x11.h>
#include <ui/input/wintab/kis_xi2_event_filter.h>
#endif
extern "C" int main(int argc, char **argv)
......@@ -131,6 +132,10 @@ extern "C" int main(int argc, char **argv)
app.setAttribute(Qt::AA_DontShowIconsInMenus);
}
#if defined HAVE_X11
app.installNativeEventFilter(KisXi2EventFilter::instance());
#endif
// then create the pixmap from an xpm: we cannot get the
// location of our datadir before we've started our components,
// so use an xpm.
......@@ -157,7 +162,6 @@ extern "C" int main(int argc, char **argv)
QObject::connect(&app, SIGNAL(fileOpenRequest(QString)),
&app, SLOT(fileOpenRequested(QString)));
int state = app.exec();
return state;
......
......@@ -357,6 +357,9 @@ if(UNIX)
set(kritaui_LIB_SRCS
${kritaui_LIB_SRCS}
input/wintab/kis_tablet_support_x11.cpp
input/wintab/qxcbconnection_xi2.cpp
input/wintab/qxcbconnection.cpp
input/wintab/kis_xi2_event_filter.cpp
)
endif()
endif()
......@@ -453,7 +456,9 @@ if (HAVE_KIO)
endif()
if (NOT WIN32 AND NOT APPLE)
target_link_libraries(kritaui ${X11_X11_LIB} ${X11_Xinput_LIB})
target_link_libraries(kritaui ${X11_X11_LIB}
${X11_Xinput_LIB}
${XCB_LIBRARIES})
endif()
if(APPLE)
......
/*
* Copyright (c) 2015 Dmitry Kazakov <dimula73@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "kis_xi2_event_filter.h"
#include "kis_debug.h"
#include <QGlobalStatic>
//#include <X11/extensions/XInput2.h>
//#include <X11/extensions/XI2proto.h>
#include <xcb/xcb.h>
#include "qxcbconnection_xi2.h"
struct KisXi2EventFilter::Private
{
QScopedPointer<QXcbConnection> connection;
};
Q_GLOBAL_STATIC(KisXi2EventFilter, s_instance)
KisXi2EventFilter::KisXi2EventFilter()
: m_d(new Private)
{
m_d->connection.reset(new QXcbConnection(true, ":0"));
}
KisXi2EventFilter::~KisXi2EventFilter()
{
}
bool KisXi2EventFilter::nativeEventFilter(const QByteArray &eventType, void *message, long *result)
{
Q_UNUSED(result);
xcb_generic_event_t *event = static_cast<xcb_generic_event_t*>(message);
uint response_type = event->response_type & ~0x80;
switch (response_type) {
case XCB_GE_GENERIC: {
xcb_ge_event_t *geEvent = reinterpret_cast<xcb_ge_event_t *>(event);
qDebug() << "Got a generic event!";
m_d->connection->xi2HandleEvent(geEvent);
}
default:
break;
}
return false;
}
KisXi2EventFilter* KisXi2EventFilter::instance()
{
return s_instance;
}
/*
* Copyright (c) 2015 Dmitry Kazakov <dimula73@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __KIS_XI2_EVENT_FILTER_H
#define __KIS_XI2_EVENT_FILTER_H
#include <QAbstractNativeEventFilter>
#include "kritaui_export.h"
#include <QScopedPointer>
class KRITAUI_EXPORT KisXi2EventFilter : public QAbstractNativeEventFilter
{
public:
KisXi2EventFilter();
~KisXi2EventFilter();
static KisXi2EventFilter* instance();
bool nativeEventFilter(const QByteArray &eventType, void *message, long *result);
private:
struct Private;
const QScopedPointer<Private> m_d;
};
#endif /* __KIS_XI2_EVENT_FILTER_H */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment