I have created two sets of header and source files which reads the global mouse pointer coordinates (Which Qt5
is unable to) by using the libxdo
and it calculates the velocity mathematically and when the velocity of the mouse pointer is above the threshold value, it should display the only Qt window.
The another set of header and source grabs (hook) and listens the global keyboard events and while pressing a key combination, the project runs in the background with the Qt window (after I integrate it with it) being hidden. Whatever I type is being stored in a file until I press [ESC]
.
Now the Qt window should only appear when I move the mouse pointer above a certain velocity and the text should be shown there.
If while typing I move the mouse, the window should appear and I can see the text that is being written in the QWindow. But when I move the mouse again, it should be hidden.
I'm not using libqxt
for qt5 and the above program should run until I logout
of the system. Using Ubuntu 16.04
.
I'm trying like this in the main.cxx
:
#include <QApplication>
#include "mainwindow.hpp"
#include <QDesktopWidget>
#include <QMetaObject>
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
MainWindow window;
int width = QApplication::desktop()->width(), height = QApplication::desktop()->height();
window.setGeometry ((width - 0.75 * width),height - 20, (width/2) , 10);
window.setWindowFlags (Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
window.hide();
QMetaObject::invokeMethod( this, "keygrab", Qt::QueuedConnection, Q_ARG() );
QMetaObject::invokeMethod( this, "mousevelocity", Qt::QueuedConnection, Q_ARG() );
return app.exec();
}
But I'm completely messed up with the libx11 and libxdo
members and functions inside the mainwindow.cxx
of this Qt application and I don't know what will be the best way instead of this or if it is the best, I have a problem as I have multiple main functions with multiple infinite loop for the keygrab and the mousepointer. I can't call them from the main of Qt application and even the above code runs the application first and then invoke them but I need the reverse way
.
P.S. Sorry, first timer.