Cleanup, sync with unix

This commit is contained in:
Ximi1970
2021-09-26 12:30:08 +02:00
parent bd8b1344c9
commit d5e0766a8b
4 changed files with 26 additions and 77 deletions

View File

@@ -35,11 +35,8 @@ WindowCtrlWin::WindowCtrlWin( QObject *parent) : QObject( parent )
/*
* Initialize
*/
m_tb_window = 0;
m_window_state = Preferences::STATE_UNKNOWN;
m_tb_windows = QList< quint64 >();
m_tb_window_states = QList< Preferences::WindowState >();
m_tb_window_states = QMap< quint64, Preferences::WindowState >();
/*
* Setup the minimize intercept
@@ -62,22 +59,11 @@ WindowCtrlWin::~WindowCtrlWin()
/*
* Set the window state.
* Get the states of the TB windows.
*/
void WindowCtrlWin::setWindowState( int state )
const Preferences::WindowState& WindowCtrlWin::getWindowState( const quint64 window )
{
m_window_state = state;
}
/**
* @brief getWindowState. Get the window state.
*
* @return The state.
*/
int WindowCtrlWin::getWindowState() const
{
return m_window_state;
return m_tb_window_states[ window ];
}
@@ -195,7 +181,7 @@ BOOL CALLBACK WindowCtrlWin::enumWindowsTitleProc( HWND hwnd, LPARAM lParam )
void WindowCtrlWin::findWindows( qint64 pid )
{
m_tb_windows = QList< quint64 >();
m_tb_window_states = QList< Preferences::WindowState >();
m_tb_window_states = QMap< quint64, Preferences::WindowState >();
EnumWindowsPidProcData data{ *this, pid };
EnumWindows( &enumWindowsPidProc, reinterpret_cast<LPARAM>(&data) );
@@ -243,26 +229,17 @@ BOOL CALLBACK WindowCtrlWin::enumWindowsPidProc( HWND hWnd, LPARAM lParam )
/*
* Window is minimized
*/
data.window_ctrl.m_tb_window_states.append( Preferences::STATE_MINIMIZED );
data.window_ctrl.m_tb_window_states[ (quint64)hWnd ] = Preferences::STATE_MINIMIZED;
}
else
{
data.window_ctrl.m_tb_window_states.append( Preferences::STATE_NORMAL );
data.window_ctrl.m_tb_window_states[ (quint64)hWnd ] = Preferences::STATE_NORMAL;
}
return TRUE;
}
/*
* Get the states of the TB windows.
*/
const QList< Preferences::WindowState >& WindowCtrlWin::getWindowStates() const
{
return m_tb_window_states;
}
/*
* Check for main window
*/
@@ -295,15 +272,6 @@ void WindowCtrlWin::displayWindowElements( quint64 window )
}
/*
* Get the Thunderbird window ID
*/
quint64 WindowCtrlWin::getWinId()
{
return m_tb_window;
}
/*
* Get the Thunderbird window IDs
*/

View File

@@ -23,6 +23,7 @@
* Qt includes
*/
#include <QObject>
#include <QMap>
/*
* Forward declarations
@@ -64,20 +65,6 @@ class WindowCtrlWin : public QObject
*/
~WindowCtrlWin();
/**
* @brief setWindowState. Set the window state.
*
* @param state The state.
*/
void setWindowState( int state );
/**
* @brief getWindowState. Get the window state.
*
* @return The state.
*/
int getWindowState() const;
/**
* @brief setMinimizeType
*
@@ -134,11 +121,13 @@ class WindowCtrlWin : public QObject
void findWindows( qint64 pid );
/**
* @brief getWindowStates. Get the states of the TB windows.
* @brief getWindowState. Get the state of a TB windows.
*
* @return The list of window states.
* @param window Window ID.
*
* @return The window state.
*/
const QList< Preferences::WindowState >& getWindowStates() const;
const Preferences::WindowState& getWindowState( const quint64 window );
/**
* @brief displayWindowElements. Display window elements.
@@ -154,13 +143,6 @@ class WindowCtrlWin : public QObject
*/
void displayWindowElements( quint64 window );
/**
* @brief getWinId. Get the Thunderbird window ID.
*
* @return The TB window ID.
*/
quint64 getWinId();
/**
* @brief getWinIds. Get the Thunderbird window IDs.
*
@@ -301,11 +283,6 @@ class WindowCtrlWin : public QObject
private:
/**
* @brief m_tb_window. The Thunderbird window.
*/
quint64 m_tb_window;
/**
* @brief m_tb_window. The Thunderbird windows.
*/
@@ -314,18 +291,13 @@ class WindowCtrlWin : public QObject
/**
* @brief m_tb_window_states. The Thunderbird window states.
*/
QList< Preferences::WindowState > m_tb_window_states;
QMap< quint64, Preferences::WindowState > m_tb_window_states;
/**
* @brief m_minimize_type. Minimize type.
*/
Preferences::MinimizeType m_minimize_type;
/**
* @brief m_window_state. State of the TB window.
*/
int m_window_state;
/**
* @brief m_hook
*/

View File

@@ -220,6 +220,10 @@ void WindowCtrl::slotWindowState( Preferences::WindowState state )
*/
if( state == Preferences::STATE_MINIMIZED_ALL || state == Preferences::STATE_MINIMIZED_ALL_STARTUP )
{
#ifdef DEBUG_DISPLAY_ACTIONS
emit signalConsole( QString( "Minimize all" ) );
#endif
QList< quint64 > win_ids = getWinIds();
if( state == Preferences::STATE_MINIMIZED || state == Preferences::STATE_MINIMIZED_ALL )
@@ -276,6 +280,12 @@ void WindowCtrl::slotWindowState( Preferences::WindowState state )
*/
for( int i = 0 ; i < win_ids.length() ; ++i )
{
#ifdef DEBUG_DISPLAY_ACTIONS
emit signalConsole( QString( "Window state: %1, %2" )
.arg( win_ids.at( i ) )
.arg( Preferences::WindowStateString.at( getWindowState( win_ids.at( i ) ) ) ) );
#endif
minimizeWindow( win_ids.at( i ), getMinimizeType() );
}
}
@@ -354,7 +364,6 @@ void WindowCtrl::slotShowHide()
* Get the window ids
*/
QList< quint64 > win_ids = getWinIds();
QList< Preferences::WindowState > win_states = getWindowStates();
for( int i = 0 ; i < win_ids.length() ; ++i )
{
@@ -364,7 +373,7 @@ void WindowCtrl::slotShowHide()
.arg( Preferences::WindowStateString.at( getWindowState( win_ids.at( i ) ) ) ) );
#endif
if( win_states.at( i ) == Preferences::STATE_MINIMIZED )
if( getWindowState( win_ids.at( i ) ) == Preferences::STATE_MINIMIZED )
{
normalizeWindow( win_ids.at( i ) );
}

View File

@@ -36,7 +36,7 @@ SysTrayX.Messaging = {
}
// Minimize on startup handled by Companion app as backup
if (SysTrayX.startupState == "minimized") {
if (SysTrayX.startupState === "minimized") {
SysTrayX.Link.postSysTrayXMessage({ window: "minimized_all_startup" });
}