mirror of
https://github.com/Ximi1970/systray-x.git
synced 2026-02-15 02:36:48 +01:00
Check parent executable name
This commit is contained in:
@@ -40,6 +40,27 @@ qint64 WindowCtrlUnix::getPpid()
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Is the pid from thunderbird
|
||||
*/
|
||||
bool WindowCtrlUnix::isThunderbird( qint64 pid )
|
||||
{
|
||||
return getProcessName( pid ).contains( "thunderbird", Qt::CaseInsensitive );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get the process name
|
||||
*/
|
||||
QString WindowCtrlUnix::getProcessName( qint64 pid )
|
||||
{
|
||||
QString process_name = QString( "/proc/%1/exe" ).arg( pid );
|
||||
QFileInfo process( process_name );
|
||||
|
||||
return process.canonicalFilePath();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Find window(s) by title
|
||||
*/
|
||||
@@ -237,7 +258,7 @@ QList< quint64 > WindowCtrlUnix::getWinIds()
|
||||
*/
|
||||
void WindowCtrlUnix::minimizeWindow( quint64 window, bool hide )
|
||||
{
|
||||
if( !window )
|
||||
if( !isThunderbird( getPpid() ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -259,7 +280,7 @@ void WindowCtrlUnix::minimizeWindow( quint64 window, bool hide )
|
||||
*/
|
||||
void WindowCtrlUnix::normalizeWindow( quint64 window )
|
||||
{
|
||||
if( !window )
|
||||
if( !isThunderbird( getPpid() ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -288,7 +309,7 @@ void WindowCtrlUnix::normalizeWindow( quint64 window )
|
||||
*/
|
||||
void WindowCtrlUnix::hideWindow( quint64 window, bool set )
|
||||
{
|
||||
if( !window )
|
||||
if( !isThunderbird( getPpid() ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -375,7 +396,7 @@ void WindowCtrlUnix::hideWindow( quint64 window, bool set )
|
||||
*/
|
||||
void WindowCtrlUnix::deleteWindow( quint64 window )
|
||||
{
|
||||
if( !window )
|
||||
if( !isThunderbird( getPpid() ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
* Qt includes
|
||||
*/
|
||||
#include <QObject>
|
||||
#include <QFileInfo>
|
||||
|
||||
/*
|
||||
* Predefines
|
||||
@@ -121,6 +122,24 @@ class WindowCtrlUnix : public QObject
|
||||
*/
|
||||
qint64 getPpid();
|
||||
|
||||
/**
|
||||
* @brief isThunderbird. Is this a thunderbird pid.
|
||||
*
|
||||
* @param pid The process Id to check.
|
||||
*
|
||||
* @return True if this is thunderbird.
|
||||
*/
|
||||
bool isThunderbird( qint64 pid );
|
||||
|
||||
/**
|
||||
* @brief getProcessName. Get the name of the proces by pid.
|
||||
*
|
||||
* @param pid The process Id.
|
||||
*
|
||||
* @return The process name.
|
||||
*/
|
||||
QString getProcessName( qint64 pid );
|
||||
|
||||
/**
|
||||
* @brief findWindow. Find window by (sub)title.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user