mirror of
https://github.com/Ximi1970/systray-x.git
synced 2026-02-02 04:19:02 +01:00
Find and use all win for a pid
This commit is contained in:
@@ -19,7 +19,6 @@ WindowCtrlUnix::WindowCtrlUnix( QObject *parent ) : QObject( parent )
|
||||
/*
|
||||
* Initialize
|
||||
*/
|
||||
m_tb_window = 0;
|
||||
m_tb_windows = QList< quint64 >();
|
||||
m_window_state = Preferences::STATE_UNKNOWN;
|
||||
|
||||
@@ -137,7 +136,7 @@ bool WindowCtrlUnix::findWindow( const QString& title )
|
||||
/*
|
||||
* Find a window by PID
|
||||
*/
|
||||
void WindowCtrlUnix::findWindow( qint64 pid )
|
||||
void WindowCtrlUnix::findWindows( qint64 pid )
|
||||
{
|
||||
QList< WindowItem > windows = listXWindows( m_display, m_root_window );
|
||||
|
||||
@@ -148,7 +147,7 @@ void WindowCtrlUnix::findWindow( qint64 pid )
|
||||
return;
|
||||
}
|
||||
|
||||
m_tb_window = 0;
|
||||
m_tb_windows = QList< quint64 >();
|
||||
foreach( WindowItem win, windows )
|
||||
{
|
||||
Atom type;
|
||||
@@ -168,10 +167,7 @@ void WindowCtrlUnix::findWindow( qint64 pid )
|
||||
|
||||
if( state > 0 )
|
||||
{
|
||||
m_tb_window = win.window;
|
||||
|
||||
XFree( propPID );
|
||||
return;
|
||||
m_tb_windows.append( win.window );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,6 +175,8 @@ void WindowCtrlUnix::findWindow( qint64 pid )
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
emit signalConsole( QString( "Number of windows found: %1").arg(m_tb_windows.length()));
|
||||
}
|
||||
|
||||
|
||||
@@ -279,15 +277,6 @@ void WindowCtrlUnix::displayWindowElements( quint64 window )
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get the Thunderbird window ID
|
||||
*/
|
||||
quint64 WindowCtrlUnix::getWinId()
|
||||
{
|
||||
return m_tb_window;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get the Thunderbird window IDs
|
||||
*/
|
||||
|
||||
@@ -188,11 +188,11 @@ class WindowCtrlUnix : public QObject
|
||||
bool findWindow( const QString& title );
|
||||
|
||||
/**
|
||||
* @brief findWindow. Find window of a process.
|
||||
* @brief findWindows. Find all windows of a process.
|
||||
*
|
||||
* @param pid The process id.
|
||||
*/
|
||||
void findWindow( qint64 pid );
|
||||
void findWindows( qint64 pid );
|
||||
|
||||
/**
|
||||
* @brief displayWindowElements. Display window elements (atoms).
|
||||
@@ -208,13 +208,6 @@ class WindowCtrlUnix : public QObject
|
||||
*/
|
||||
void displayWindowElements( quint64 window );
|
||||
|
||||
/**
|
||||
* @brief getWinId. Get the Thunderbird window ID.
|
||||
*
|
||||
* @return The window ID.
|
||||
*/
|
||||
quint64 getWinId();
|
||||
|
||||
/**
|
||||
* @brief getWinIds. Get the Thunderbird window IDs.
|
||||
*
|
||||
@@ -362,12 +355,7 @@ class WindowCtrlUnix : public QObject
|
||||
quint64 m_root_window;
|
||||
|
||||
/**
|
||||
* @brief m_tb_window. The Thunderbird window.
|
||||
*/
|
||||
quint64 m_tb_window;
|
||||
|
||||
/**
|
||||
* @brief m_tb_windows. The Thunderbird windows (used by title search).
|
||||
* @brief m_tb_windows. The Thunderbird windows.
|
||||
*/
|
||||
QList< quint64 > m_tb_windows;
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ WindowCtrl::WindowCtrl( Preferences* pref, QObject *parent )
|
||||
/*
|
||||
* Get the TB window
|
||||
*/
|
||||
findWindow( m_ppid );
|
||||
findWindows( m_ppid );
|
||||
}
|
||||
|
||||
|
||||
@@ -80,6 +80,9 @@ void WindowCtrl::slotWindowTest1()
|
||||
// findWindow( 4313 );
|
||||
// displayWindowElements( getWinId() );
|
||||
|
||||
|
||||
findWindows( m_ppid );
|
||||
|
||||
emit signalConsole("Test 1 done");
|
||||
}
|
||||
|
||||
@@ -169,13 +172,21 @@ void WindowCtrl::slotWindowState( int state )
|
||||
{
|
||||
setWindowState( state );
|
||||
|
||||
QList< quint64 > win_ids = getWinIds();
|
||||
|
||||
if( state == Preferences::STATE_MINIMIZED )
|
||||
{
|
||||
hideWindow( getWinId(), getMinimizeType() );
|
||||
for( int i = 0 ; i < win_ids.count() ; ++i )
|
||||
{
|
||||
hideWindow( win_ids.at( i ), getMinimizeType() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
hideWindow( getWinId(), false );
|
||||
for( int i = 0 ; i < win_ids.count() ; ++i )
|
||||
{
|
||||
hideWindow( win_ids.at( i ), false );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,15 +203,25 @@ void WindowCtrl::slotWindowState( int state )
|
||||
*/
|
||||
void WindowCtrl::slotShowHide()
|
||||
{
|
||||
QList< quint64 > win_ids = getWinIds();
|
||||
|
||||
if( getWindowState() == Preferences::STATE_MINIMIZED )
|
||||
{
|
||||
setWindowState( Preferences::STATE_NORMAL );
|
||||
normalizeWindow( getWinId() );
|
||||
|
||||
for( int i = 0 ; i < win_ids.count() ; ++i )
|
||||
{
|
||||
normalizeWindow( win_ids.at( i ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setWindowState( Preferences::STATE_MINIMIZED );
|
||||
minimizeWindow( getWinId(), getMinimizeType() );
|
||||
|
||||
for( int i = 0 ; i < win_ids.count() ; ++i )
|
||||
{
|
||||
minimizeWindow( win_ids.at( i ), getMinimizeType() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,5 +231,10 @@ void WindowCtrl::slotShowHide()
|
||||
*/
|
||||
void WindowCtrl::slotClose()
|
||||
{
|
||||
deleteWindow( getWinId() );
|
||||
QList< quint64 > win_ids = getWinIds();
|
||||
|
||||
for( int i = 0 ; i < win_ids.count() ; ++i )
|
||||
{
|
||||
deleteWindow( win_ids.at( i ) );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user