mirror of
https://github.com/Ximi1970/systray-x.git
synced 2026-05-06 10:56:53 +02:00
Get pid and ppid
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -1,5 +1,18 @@
|
||||
#include "preferences.h"
|
||||
|
||||
/*
|
||||
* Local includes
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* System includes
|
||||
*/
|
||||
|
||||
/*
|
||||
* Qt includes
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Preferences. Constructor.
|
||||
*/
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
/*
|
||||
* System includes
|
||||
*/
|
||||
#include <unistd.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
#include <QWidget>
|
||||
#include <QWindow>
|
||||
#include <QCoreApplication>
|
||||
|
||||
/*
|
||||
* 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");
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user