mirror of
https://github.com/Ximi1970/systray-x.git
synced 2026-05-06 19:45:57 +02:00
Check parent executable name
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
* Qt includes
|
||||
*/
|
||||
#include <QCoreApplication>
|
||||
#include <QString>
|
||||
|
||||
/*
|
||||
* Statics
|
||||
@@ -65,12 +66,21 @@ qint64 WindowCtrlWin::getPpid()
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Is the pid from thunderbird
|
||||
*/
|
||||
bool WindowCtrlWin::isThunderbird( qint64 pid )
|
||||
{
|
||||
return getProcessName( pid ).contains( "thunderbird", Qt::CaseInsensitive );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get the process name
|
||||
*/
|
||||
QString WindowCtrl::getProcessName( qint64 pid )
|
||||
QString WindowCtrlWin::getProcessName( qint64 pid )
|
||||
{
|
||||
HANDLE proc = OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, false, getPpid() );
|
||||
HANDLE proc = OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, false, pid );
|
||||
char name[ 256 ];
|
||||
GetModuleBaseNameA( proc, NULL, name, 256);
|
||||
|
||||
@@ -212,7 +222,7 @@ QList< quint64 > WindowCtrlWin::getWinIds()
|
||||
*/
|
||||
void WindowCtrlWin::minimizeWindow( quint64 window, bool hide )
|
||||
{
|
||||
if( !window )
|
||||
if( !isThunderbird( getPpid() ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -231,7 +241,7 @@ void WindowCtrlWin::minimizeWindow( quint64 window, bool hide )
|
||||
*/
|
||||
void WindowCtrlWin::normalizeWindow( quint64 window )
|
||||
{
|
||||
if( !window )
|
||||
if( !isThunderbird( getPpid() ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -246,7 +256,7 @@ void WindowCtrlWin::normalizeWindow( quint64 window )
|
||||
*/
|
||||
void WindowCtrlWin::hideWindow( quint64 window, bool state )
|
||||
{
|
||||
if( !window )
|
||||
if( !isThunderbird( getPpid() ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -278,7 +288,7 @@ void WindowCtrlWin::hideWindow( HWND hwnd )
|
||||
*/
|
||||
void WindowCtrlWin::deleteWindow( quint64 window )
|
||||
{
|
||||
if( !window )
|
||||
if( !isThunderbird( getPpid() ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,24 @@ class WindowCtrlWin : 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 title.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user