~fgaz/qremotecontrol-server

04d9f4d8617b18e4a694129b0997bf7da0b1d784 — Alexander Rössler 9 years ago 32e06db + af1f17d
Merge commit 'af1f17dd2bd6032d5b06172b3cd38c8f167eb55a'
4 files changed, 123 insertions(+), 7 deletions(-)

M QRemoteControl-Server.pro
M qglobalfakekey/qglobalfakekey_x11.cpp
A x11info.cpp
A x11info.h
M QRemoteControl-Server.pro => QRemoteControl-Server.pro +4 -1
@@ 4,6 4,7 @@
TARGET = qremotecontrol-server
VERSION = 2.4.2
DEFINES += VERSION=\"\\\"$$VERSION\\\"\"
DEFINES += HAVE_QT5

TRANSLATIONS = i18/de.ts i18/ru.ts i18/uk.ts i18/es.ts



@@ 15,6 16,7 @@ QT += core \
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets concurrent
TEMPLATE = app
SOURCES += main.cpp \
    x11info.cpp \
    qremotecontrolserver.cpp \
    qglobalfakekey/qglobalfakekey.cpp \
    usercommanddialog.cpp \


@@ 22,6 24,7 @@ SOURCES += main.cpp \
    icondialog.cpp

HEADERS += qremotecontrolserver.h \
    x11info.h \
    qglobalfakekey/qglobalfakekey_p.h \
    usercommanddialog.h \
    helpdialog.h \


@@ 34,8 37,8 @@ FORMS += qremotecontrolserver.ui \

linux-g++ | linux-g++-64 | linux-g++-32 {
#    QT += dbus
    greaterThan(QT_MAJOR_VERSION, 4): QT += x11extras
    LIBS += -lX11 \
            -lxcb \
            -lXtst
    SOURCES += qglobalfakekey/qglobalfakekey_x11.cpp
# playwolf/playercontroller.cpp

M qglobalfakekey/qglobalfakekey_x11.cpp => qglobalfakekey/qglobalfakekey_x11.cpp +6 -6
@@ 17,12 17,12 @@
**
***************************************************************************/
#include "qglobalfakekey_p.h"
#include <QX11Info>
#include <X11/keysym.h>
#include <X11/XF86keysym.h>
#include <X11/keysymdef.h>
#include <X11/Xmd.h>
#include <X11/extensions/XTest.h>
#include "x11info.h"

#ifndef XK_ISO_Left_Tab
#define XK_ISO_Left_Tab         0xFE20


@@ 607,7 607,7 @@ public:

QGlobalFakeKeyPrivate::QGlobalFakeKeyPrivate()
{
   display = QX11Info::display();//XOpenDisplay( NULL );
   display = X11Info::display();//XOpenDisplay( NULL );
}

QGlobalFakeKey::QGlobalFakeKey(QObject* parent)


@@ 627,7 627,7 @@ void QGlobalFakeKey::sendKey(Qt::Key key, bool down)
    KeySym keySym;
    bool shiftSet   = false;
    bool altSet     = false;
    Display *display = QX11Info::display();
    Display *display = X11Info::display();

    if (!display)   // No X server running
        return;


@@ 702,7 702,7 @@ void QGlobalFakeKey::sendKey(Qt::Key key, bool down)

void QGlobalFakeKey::sendKeyModifiers(Qt::KeyboardModifiers modifiers, bool down)
{
    //Display *display = QX11Info::display();
    //Display *display = X11Info::display();

    if (!d->display)   // No X server running
        return;


@@ 729,7 729,7 @@ void QGlobalFakeKey::sendKeyModifiers(Qt::KeyboardModifiers modifiers, bool down

void QGlobalFakeKey::sendButton(Qt::MouseButton button, bool down)
{
    //Display *display = QX11Info::display();
    //Display *display = X11Info::display();

    if (!d->display)   // No X server running
        return;


@@ 754,7 754,7 @@ void QGlobalFakeKey::sendButton(Qt::MouseButton button, bool down)

void QGlobalFakeKey::sendScroll(int direction, int delta, double acceleration)
{
    //Display *display = QX11Info::display();
    //Display *display = X11Info::display();

    if (!d->display)   // No X server running
        return;

A x11info.cpp => x11info.cpp +68 -0
@@ 0,0 1,68 @@
/*
 * Copyright (C) 2013  Il'inykh Sergey (rion)
 *
 * 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 library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 *
 */

#include "x11info.h"

#ifdef HAVE_QT5
# include <X11/Xlib.h>
# include <xcb/xcb.h>
# include <QtGlobal>
#else
# include <QX11Info>
#endif


Display* X11Info::display()
{
#ifdef HAVE_QT5
	if (!_display) {
		_display = XOpenDisplay(NULL);
	}
	return _display;
#else
	return QX11Info::display();
#endif
}

unsigned long X11Info::appRootWindow(int screen)
{
#ifdef HAVE_QT5
	return screen == -1?
				XDefaultRootWindow(display()) :
				XRootWindowOfScreen(XScreenOfDisplay(display(), screen));
#else
	return QX11Info::appRootWindow(screen);
#endif
}

#ifdef HAVE_QT5
xcb_connection_t *X11Info::xcbConnection()
{
	if (!_xcb) {
		_xcb = xcb_connect(NULL, &_xcbPreferredScreen);
		Q_ASSERT(_xcb);
	}
	return _xcb;
}

xcb_connection_t* X11Info::_xcb = 0;
#endif

Display* X11Info::_display = 0;
int X11Info::_xcbPreferredScreen = 0;

A x11info.h => x11info.h +45 -0
@@ 0,0 1,45 @@
/*
 * Copyright (C) 2013  Il'inykh Sergey (rion)
 *
 * 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 library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 *
 */

#ifndef X11INFO_H
#define X11INFO_H

typedef struct _XDisplay Display;
#ifdef HAVE_QT5
typedef struct xcb_connection_t xcb_connection_t;
#endif

class X11Info
{
	static Display *_display;
#ifdef HAVE_QT5
	static xcb_connection_t *_xcb;
#endif
	static int _xcbPreferredScreen;

public:
	static Display* display();
	static unsigned long appRootWindow(int screen = -1);
#ifdef HAVE_QT5
	static xcb_connection_t* xcbConnection();
	static inline int xcbPreferredScreen() { return _xcbPreferredScreen; }
#endif
};

#endif // X11INFO_H