diff --git a/README.references.txt b/README.references.txt index ac2be59..f01f2cf 100644 --- a/README.references.txt +++ b/README.references.txt @@ -14,10 +14,28 @@ Close window https://docs.microsoft.com/en-us/windows/win32/learnwin32/closing-the-window +Get processes + +(EnumProcesses function) +https://www.qtcentre.org/threads/46145-Get-All-Running-Process-Win32 + + + X11 ========================================== +Get processes (parent pid, pid and arguments) + +ps -eo ppid,pid,args + + +qint64 QCoreApplication::applicationPid() to get systrayx pid -> parent pid -> tb window. + + +ps -p [PID] -o ppid + + Bash xwininfo -tree -root diff --git a/app/SysTray-X/preferences.cpp b/app/SysTray-X/preferences.cpp index 8e2bb02..3f4f5da 100644 --- a/app/SysTray-X/preferences.cpp +++ b/app/SysTray-X/preferences.cpp @@ -1,5 +1,18 @@ #include "preferences.h" +/* + * Local includes + */ + + +/* + * System includes + */ + +/* + * Qt includes + */ + /** * @brief Preferences. Constructor. */ diff --git a/app/SysTray-X/windowctrl-unix.cpp b/app/SysTray-X/windowctrl-unix.cpp index 334c465..66b082a 100644 --- a/app/SysTray-X/windowctrl-unix.cpp +++ b/app/SysTray-X/windowctrl-unix.cpp @@ -5,6 +5,7 @@ /* * System includes */ +#include #include #include @@ -23,6 +24,15 @@ WindowCtrlUnix::WindowCtrlUnix( QObject *parent ) : QObject( parent ) } +/* + * Get the parent pid of SysTray-X, TB hopefully + */ +qint64 WindowCtrlUnix::getPpid() +{ + return getppid(); +} + + /* * Find window(s) by title */ diff --git a/app/SysTray-X/windowctrl-unix.h b/app/SysTray-X/windowctrl-unix.h index 9df014d..c2ebedd 100644 --- a/app/SysTray-X/windowctrl-unix.h +++ b/app/SysTray-X/windowctrl-unix.h @@ -110,6 +110,13 @@ class WindowCtrlUnix : public QObject */ explicit WindowCtrlUnix( QObject *parent = nullptr ); + /** + * @brief getPpid. Get the parent process id. + * + * @return The ppid + */ + qint64 getPpid(); + /** * @brief findWindow. Find window with title. * diff --git a/app/SysTray-X/windowctrl.cpp b/app/SysTray-X/windowctrl.cpp index 59ac7ad..767b29f 100644 --- a/app/SysTray-X/windowctrl.cpp +++ b/app/SysTray-X/windowctrl.cpp @@ -3,6 +3,7 @@ */ #include #include +#include /* * Main include @@ -35,6 +36,12 @@ WindowCtrl::WindowCtrl( Preferences* pref, QObject *parent ) : * Initialize */ m_minimize_hide = m_pref->getMinimizeHide(); + + /* + * Get pids + */ + m_pid = QCoreApplication::applicationPid(); + m_ppid = getPpid(); } @@ -70,6 +77,9 @@ void WindowCtrl::slotWindowTest3() // Do something. + emit signalConsole( QString( "Pid %1" ).arg( m_pid ) ); + emit signalConsole( QString( "Ppid %1" ).arg( m_ppid ) ); + emit signalConsole("Test 3 done"); } diff --git a/app/SysTray-X/windowctrl.h b/app/SysTray-X/windowctrl.h index 98232e8..452f90c 100644 --- a/app/SysTray-X/windowctrl.h +++ b/app/SysTray-X/windowctrl.h @@ -95,6 +95,16 @@ class WindowCtrl : public QObject */ Preferences* m_pref; + /** + * @brief m_pid. SysTray-X process pid. + */ + qint64 m_pid; + + /** + * @brief m_ppid. SysTray-X parent process pid. + */ + qint64 m_ppid; + /** * @brief m_tb_window. Pointer to the TB window. */