mirror of
https://github.com/Ximi1970/systray-x.git
synced 2026-05-07 13:46:34 +02:00
Use different state for minimize to tray
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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:
|
||||
|
||||
/**
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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 ) );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user