Use different state for minimize to tray

This commit is contained in:
Ximi1970
2020-12-31 16:44:32 +01:00
parent 06ec8f1049
commit e481d6ae50
5 changed files with 46 additions and 40 deletions

View File

@@ -25,6 +25,16 @@ const QString Preferences::STATE_DOCKED_STR = "docked";
const QString Preferences::STATE_MINIMIZED_ALL_STR = "minimized_all";
const QString Preferences::STATE_MINIMIZED_ALL_STARTUP_STR = "minimized_all_startup";
const QStringList Preferences::WindowStateString = {
"Unknown",
STATE_NORMAL_STR,
STATE_MINIMIZED_STR,
STATE_MAXIMIZED_STR,
STATE_FULLSCREEN_STR,
STATE_DOCKED_STR,
STATE_MINIMIZED_ALL_STR,
STATE_MINIMIZED_ALL_STARTUP_STR
};
/**
* @brief Preferences. Constructor.

View File

@@ -10,6 +10,7 @@
*/
#include <QObject>
#include <QString>
#include <QStringList>
#include <QByteArray>
#include <QMargins>
@@ -91,6 +92,8 @@ class Preferences : public QObject
static const QString STATE_MINIMIZED_ALL_STR;
static const QString STATE_MINIMIZED_ALL_STARTUP_STR;
static const QStringList WindowStateString;
public:
/**

View File

@@ -8,6 +8,11 @@
#include "debug.h"
#include "systray-x-lib-x11.h"
/*
* Local includes
*/
#include "preferences.h"
/*
* System includes
*/
@@ -73,23 +78,6 @@ bool WindowCtrlUnix::isThunderbird( qint64 pid ) const
}
/*
* Get the number of visible windows.
*/
int WindowCtrlUnix::getVisibleWindows()
{
/*
* Get the TB windows and states
*/
findWindows( getppid() );
/*
* Count the visible states
*/
return m_tb_window_states.count( Preferences::STATE_NORMAL );
}
/*
* Get the process name
*/
@@ -207,6 +195,11 @@ void WindowCtrlUnix::findWindows( qint64 pid )
// emit signalConsole( QString( "WinID %1, Atoms: %2" ).arg( m_tb_windows.at( i ) ).arg( atom_list.join(",") ) );
if( atom_list.contains( "_NET_WM_STATE_HIDDEN" ) && atom_list.contains( "_NET_WM_STATE_SKIP_TASKBAR" ) )
{
m_tb_window_states.append( Preferences::STATE_DOCKED );
}
else
if( atom_list.contains( "_NET_WM_STATE_HIDDEN" ) )
{
m_tb_window_states.append( Preferences::STATE_MINIMIZED );

View File

@@ -145,13 +145,6 @@ class WindowCtrlUnix : public QObject
*/
bool isThunderbird( qint64 pid ) const;
/**
* @brief visibleWindows. Get the number of visible windows.
*
* @return The number of windows.
*/
int getVisibleWindows();
/**
* @brief getProcessName. Get the name of the proces by pid.
*

View File

@@ -151,7 +151,7 @@ void WindowCtrl::slotStartMinimizedChange()
void WindowCtrl::slotWindowState( Preferences::WindowState state )
{
#ifdef DEBUG_DISPLAY_ACTIONS
emit signalConsole( QString( "State change to: %1" ).arg( state ) );
emit signalConsole( QString( "State change to: %1" ).arg( Preferences::WindowStateString.at( state ) ) );
#endif
#ifdef Q_OS_UNIX
@@ -162,6 +162,7 @@ void WindowCtrl::slotWindowState( Preferences::WindowState state )
findWindows( m_ppid );
QList< quint64 > win_ids = getWinIds();
QList< Preferences::WindowState > win_states = getWindowStates();
/*
* Minimize all?
@@ -182,30 +183,32 @@ void WindowCtrl::slotWindowState( Preferences::WindowState state )
*/
for( int i = 0 ; i < win_ids.length() ; ++i )
{
minimizeWindow( win_ids.at( i ), getMinimizeType() != Preferences::PREF_DEFAULT_MINIMIZE );
#ifdef DEBUG_DISPLAY_ACTIONS
emit signalConsole( QString( "Window state: %1, %2" )
.arg( win_ids.at( i ) )
.arg( Preferences::WindowStateString.at( win_states.at( i ) ) ) );
#endif
if( ( win_states.at( i ) != Preferences::STATE_MINIMIZED && getMinimizeType() == Preferences::PREF_DEFAULT_MINIMIZE ) ||
( win_states.at( i ) != Preferences::STATE_DOCKED && getMinimizeType() != Preferences::PREF_DEFAULT_MINIMIZE ) )
{
minimizeWindow( win_ids.at( i ), getMinimizeType() != Preferences::PREF_DEFAULT_MINIMIZE );
}
}
}
else
{
QList< Preferences::WindowState > win_states = getWindowStates();
for( int i = 0 ; i < win_ids.length() ; ++i )
{
if( win_states.at( i ) == Preferences::STATE_MINIMIZED )
{
#ifdef DEBUG_DISPLAY_ACTIONS
emit signalConsole( QString( "Hide: %1" ).arg( win_ids.at( i ) ) );
emit signalConsole( QString( "Window state: %1, %2" )
.arg( win_ids.at( i ) )
.arg( Preferences::WindowStateString.at( win_states.at( i ) ) ) );
#endif
hideWindow( win_ids.at( i ), getMinimizeType() != Preferences::PREF_DEFAULT_MINIMIZE );
}
else
if( ( win_states.at( i ) == Preferences::STATE_MINIMIZED && getMinimizeType() != Preferences::PREF_DEFAULT_MINIMIZE ) )
{
#ifdef DEBUG_DISPLAY_ACTIONS
emit signalConsole( QString( "Unhide: %1" ).arg( win_ids.at( i ) ) );
#endif
hideWindow( win_ids.at( i ), false );
minimizeWindow( win_ids.at( i ), true );
}
}
}
@@ -236,6 +239,10 @@ void WindowCtrl::slotWindowState( Preferences::WindowState state )
}
#endif
#ifdef DEBUG_DISPLAY_ACTIONS
emit signalConsole( "State change done" );
#endif
}
@@ -267,7 +274,7 @@ void WindowCtrl::slotShowHide()
#endif
if( win_states.at( i ) == Preferences::STATE_MINIMIZED )
if( win_states.at( i ) == Preferences::STATE_MINIMIZED || win_states.at( i ) == Preferences::STATE_DOCKED )
{
normalizeWindow( win_ids.at( i ) );
}