diff --git a/app/SysTray-X/SysTray-X-app/windowctrl-unix.h b/app/SysTray-X/SysTray-X-app/windowctrl-unix.h index cca964f..bb24e33 100644 --- a/app/SysTray-X/SysTray-X-app/windowctrl-unix.h +++ b/app/SysTray-X/SysTray-X-app/windowctrl-unix.h @@ -237,13 +237,6 @@ class WindowCtrlUnix : public QObject */ const QList< quint64 >& getWinIds() const; - /** - * @brief removeRefId. Remove the TB window Id from the reference list. - * - * @param id The TB window id. - */ - void removeRefId( int id ); - /** * @brief getRefIds. Get the reference IDs. * @@ -251,6 +244,13 @@ class WindowCtrlUnix : public QObject */ const QMap< int, quint64 >& getRefIds() const; + /** + * @brief removeRefId. Remove the TB window Id from the reference list. + * + * @param id The TB window id. + */ + void removeRefId( int id ); + /** * @brief getWindowState. Get the state of a TB windows. * diff --git a/app/SysTray-X/SysTray-X-app/windowctrl-win.cpp b/app/SysTray-X/SysTray-X-app/windowctrl-win.cpp index c905255..060c15b 100644 --- a/app/SysTray-X/SysTray-X-app/windowctrl-win.cpp +++ b/app/SysTray-X/SysTray-X-app/windowctrl-win.cpp @@ -219,6 +219,50 @@ const Preferences::WindowState& WindowCtrlWin::getWindowState( const quint64 } +/* + * Try to match the TB window id to a x11 window + */ +void WindowCtrlWin::identifyWindow( int id ) +{ + /* + * Get all the windows connected to TB + */ + findWindows( getPpid() ); + + /* + * Get the list + */ + QList win_list = m_tb_windows; + + /* + * Remove known ids + */ + QMapIterator it(m_tb_window_refs); + while (it.hasNext()) { + it.next(); + + int found = win_list.indexOf( it.value() ); + if( found != -1 ) + { + win_list.removeAt( found ); + } + } + + /* + * Should only one remain + */ + if( win_list.length() > 0 ) + { + m_tb_window_refs[ id ] = win_list[ 0 ]; + } + + if( win_list.length() != 1 ) + { + // emit signalConsole( QString( "Unexpected Ids: %1" ).arg( win_list.length() ) ); + } +} + + /* * Get the Thunderbird window IDs */ @@ -228,6 +272,24 @@ QList< quint64 > WindowCtrlWin::getWinIds() } +/* + * Get the reference IDs + */ +const QMap< int, quint64 >& WindowCtrlWin::getRefIds() const +{ + return m_tb_window_refs; +} + + +/* + * Get the reference IDs + */ +void WindowCtrlWin::removeRefId( int id ) +{ + m_tb_window_refs.remove( id ); +} + + /* * Minimize a window to the taskbar */ diff --git a/app/SysTray-X/SysTray-X-app/windowctrl-win.h b/app/SysTray-X/SysTray-X-app/windowctrl-win.h index 3648c5a..1525adc 100644 --- a/app/SysTray-X/SysTray-X-app/windowctrl-win.h +++ b/app/SysTray-X/SysTray-X-app/windowctrl-win.h @@ -150,6 +150,13 @@ class WindowCtrlWin : public QObject */ void findWindows( qint64 pid ); + /** + * @brief identifyWindow. Try to connect th TB window id to a X11 window. + * + * @param id The TB windows id. + */ + void identifyWindow( int id ); + /** * @brief getWindowState. Get the state of a TB windows. * @@ -166,6 +173,20 @@ class WindowCtrlWin : public QObject */ QList< quint64 > getWinIds(); + /** + * @brief getRefIds. Get the reference IDs. + * + * @return The list of reference IDs. + */ + const QMap< int, quint64 >& getRefIds() const; + + /** + * @brief removeRefId. Remove the TB window Id from the reference list. + * + * @param id The TB window id. + */ + void removeRefId( int id ); + /** * @brief minimizeWindowToTaskbar. Minimize window to the taskbar. * @@ -263,6 +284,11 @@ class WindowCtrlWin : public QObject */ QList< quint64 > m_tb_windows_hidden; + /** + * @brief m_tb_window_refs. The Thunderbird window ids referenced to x11 windows. + */ + QMap< int, quint64 > m_tb_window_refs; + /** * @brief m_tb_window_states. The Thunderbird window states. */ diff --git a/app/SysTray-X/SysTray-X-app/windowctrl.cpp b/app/SysTray-X/SysTray-X-app/windowctrl.cpp index 42dd4f8..dea6dfb 100644 --- a/app/SysTray-X/SysTray-X-app/windowctrl.cpp +++ b/app/SysTray-X/SysTray-X-app/windowctrl.cpp @@ -413,6 +413,8 @@ void WindowCtrl::slotNewWindow( int id ) * Try to find a corresponding x11 window */ identifyWindow( id ); + + displayRefs(); } @@ -427,6 +429,8 @@ void WindowCtrl::slotCloseWindow( int id, bool quit ) * Window is closed by TB */ removeRefId( id ); + + displayRefs(); return; } @@ -444,4 +448,18 @@ void WindowCtrl::slotCloseWindow( int id, bool quit ) minimizeWindowToTaskbar( ref_list[ id ] ); } } + + displayRefs(); +} + +void WindowCtrl::displayRefs() +{ + QMap< int, quint64 > ref_list = getRefIds(); + + QMapIterator it( ref_list ); + while (it.hasNext()) { + it.next(); + + emit signalConsole( QString( "Ref: %1, %2" ).arg( it.key() ).arg( it.value(), 16 ) ); + } } diff --git a/app/SysTray-X/SysTray-X-app/windowctrl.h b/app/SysTray-X/SysTray-X-app/windowctrl.h index 699c9a2..ede7959 100644 --- a/app/SysTray-X/SysTray-X-app/windowctrl.h +++ b/app/SysTray-X/SysTray-X-app/windowctrl.h @@ -141,6 +141,8 @@ class WindowCtrl : public QObject */ void slotCloseWindow( int id, bool quit ); + void displayRefs(); + private: /**