mirror of
https://github.com/Ximi1970/systray-x.git
synced 2026-05-06 12:45:40 +02:00
Update mult win handling
This commit is contained in:
@@ -317,7 +317,7 @@ void SysTrayXLink::DecodeMessage( const QByteArray& message )
|
||||
{
|
||||
QString window_state_str = jsonObject[ "window" ].toString();
|
||||
|
||||
int window_state;
|
||||
Preferences::WindowState window_state;
|
||||
if( window_state_str == Preferences::STATE_NORMAL_STR )
|
||||
{
|
||||
window_state = Preferences::STATE_NORMAL;
|
||||
|
||||
@@ -184,7 +184,7 @@ class SysTrayXLink : public QObject
|
||||
/**
|
||||
* @brief signalWindowState. Signal a change in the window state.
|
||||
*/
|
||||
void signalWindowState( int state );
|
||||
void signalWindowState( Preferences::WindowState state );
|
||||
|
||||
/**
|
||||
* @brief signalKdeIntegration. Signal KDE integration (and use the KStatusNotifierItem icon)
|
||||
|
||||
@@ -20,7 +20,7 @@ WindowCtrlUnix::WindowCtrlUnix( QObject *parent ) : QObject( parent )
|
||||
* Initialize
|
||||
*/
|
||||
m_tb_windows = QList< quint64 >();
|
||||
m_window_state = Preferences::STATE_UNKNOWN;
|
||||
m_tb_window_states = QList< Preferences::WindowState >();;
|
||||
|
||||
/*
|
||||
* Get the base display and window
|
||||
@@ -40,26 +40,6 @@ void WindowCtrlUnix::setMinimizeType( Preferences::MinimizeType type )
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Set the window state.
|
||||
*/
|
||||
void WindowCtrlUnix::setWindowState( int state )
|
||||
{
|
||||
m_window_state = state;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief getWindowState. Get the window state.
|
||||
*
|
||||
* @return The state.
|
||||
*/
|
||||
int WindowCtrlUnix::getWindowState() const
|
||||
{
|
||||
return m_window_state;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get the minimize type
|
||||
*/
|
||||
@@ -107,8 +87,10 @@ bool WindowCtrlUnix::findWindow( const QString& title )
|
||||
QList< WindowItem > windows = listXWindows( m_display, m_root_window );
|
||||
|
||||
m_tb_windows = QList< quint64 >();
|
||||
foreach( WindowItem win, windows )
|
||||
for( int i = 0 ; i < windows.length() ; ++i )
|
||||
{
|
||||
WindowItem win = windows.at( i );
|
||||
|
||||
char *name = nullptr;
|
||||
if( XFetchName( m_display, win.window, &name ) > 0 ) {
|
||||
QString win_name( name );
|
||||
@@ -148,8 +130,10 @@ void WindowCtrlUnix::findWindows( qint64 pid )
|
||||
}
|
||||
|
||||
m_tb_windows = QList< quint64 >();
|
||||
foreach( WindowItem win, windows )
|
||||
for( int i = 0 ; i < windows.length() ; ++i )
|
||||
{
|
||||
WindowItem win = windows.at( i );
|
||||
|
||||
Atom type;
|
||||
int format;
|
||||
unsigned long nItems;
|
||||
@@ -176,7 +160,38 @@ void WindowCtrlUnix::findWindows( qint64 pid )
|
||||
}
|
||||
}
|
||||
|
||||
emit signalConsole( QString( "Number of windows found: %1").arg(m_tb_windows.length()));
|
||||
emit signalConsole( QString( "Number of windows found: %1" ).arg( m_tb_windows.length() ) );
|
||||
|
||||
/*
|
||||
* Get the new window states, store the old ones
|
||||
*/
|
||||
m_tb_window_states = QList< Preferences::WindowState >();
|
||||
for( int i = 0 ; i< m_tb_windows.length() ; ++i )
|
||||
{
|
||||
QStringList atom_list = atomNetWmState( m_display, m_tb_windows.at( i ) );
|
||||
|
||||
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" ) )
|
||||
{
|
||||
m_tb_window_states.append( Preferences::STATE_MINIMIZED );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_tb_window_states.append( Preferences::STATE_NORMAL );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Get the states of the TB windows.
|
||||
*/
|
||||
const QList< Preferences::WindowState >& WindowCtrlUnix::getWindowStates() const
|
||||
{
|
||||
return m_tb_window_states;
|
||||
}
|
||||
|
||||
|
||||
@@ -187,8 +202,10 @@ void WindowCtrlUnix::displayWindowElements( const QString& title )
|
||||
{
|
||||
QList< WindowItem > windows = listXWindows( m_display, m_root_window );
|
||||
|
||||
foreach( WindowItem win, windows )
|
||||
for( int i = 0 ; i < windows.length() ; ++i )
|
||||
{
|
||||
WindowItem win = windows.at( i );
|
||||
|
||||
char *name = nullptr;
|
||||
if( XFetchName( m_display, win.window, &name ) > 0 ) {
|
||||
QString win_name( name );
|
||||
@@ -215,9 +232,9 @@ void WindowCtrlUnix::displayWindowElements( quint64 window )
|
||||
emit signalConsole( QString( "Atom name: %1" ).arg( name ) );
|
||||
|
||||
QStringList types = atomWindowType( m_display, window );
|
||||
foreach( QString type, types )
|
||||
for( int i = 0 ; i < types.length() ; ++i )
|
||||
{
|
||||
emit signalConsole( QString( "Atom type: %1" ).arg( type ) );
|
||||
emit signalConsole( QString( "Atom type: %1" ).arg( types.at( i ) ) );
|
||||
}
|
||||
|
||||
QStringList states = atomNetWmState( m_display, window );
|
||||
@@ -226,8 +243,10 @@ void WindowCtrlUnix::displayWindowElements( quint64 window )
|
||||
bool max_horz = false;
|
||||
bool hidden = false;
|
||||
|
||||
foreach( QString state, states )
|
||||
for( int i = 0 ; i < states.length() ; ++i )
|
||||
{
|
||||
QString state = states.at( i );
|
||||
|
||||
emit signalConsole( QString( "Atom state: %1" ).arg( state ) );
|
||||
|
||||
int state_code = WindowStates.indexOf( state ) ;
|
||||
|
||||
@@ -70,6 +70,7 @@ class WindowCtrlUnix : public QObject
|
||||
*/
|
||||
enum WindowState
|
||||
{
|
||||
STATE_NORMAL = -1,
|
||||
STATE_MODAL = 0,
|
||||
STATE_STICKY,
|
||||
STATE_MAXIMIZED_VERT,
|
||||
@@ -125,20 +126,6 @@ class WindowCtrlUnix : public QObject
|
||||
*/
|
||||
explicit WindowCtrlUnix( QObject *parent = nullptr );
|
||||
|
||||
/**
|
||||
* @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
|
||||
*
|
||||
@@ -194,6 +181,20 @@ class WindowCtrlUnix : public QObject
|
||||
*/
|
||||
void findWindows( qint64 pid );
|
||||
|
||||
/**
|
||||
* @brief getWindowStates. Get the states of the TB windows.
|
||||
*
|
||||
* @return The list of window states.
|
||||
*/
|
||||
const QList< Preferences::WindowState >& getWindowStates() const;
|
||||
|
||||
/**
|
||||
* @brief getWindowStates. Get the states of the TB windows.
|
||||
*
|
||||
* @return The list of window states.
|
||||
*/
|
||||
const QList< Preferences::WindowState >& getWindowPrevStates() const;
|
||||
|
||||
/**
|
||||
* @brief displayWindowElements. Display window elements (atoms).
|
||||
*
|
||||
@@ -359,15 +360,15 @@ class WindowCtrlUnix : public QObject
|
||||
*/
|
||||
QList< quint64 > m_tb_windows;
|
||||
|
||||
/**
|
||||
* @brief m_tb_window_states. The Thunderbird window states.
|
||||
*/
|
||||
QList< 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;
|
||||
};
|
||||
|
||||
#endif // WINDOWCTRLUNIX_H
|
||||
|
||||
@@ -164,35 +164,51 @@ void WindowCtrl::slotStartMinimizedChange()
|
||||
/*
|
||||
* Handle change in window state
|
||||
*/
|
||||
void WindowCtrl::slotWindowState( int state )
|
||||
void WindowCtrl::slotWindowState( Preferences::WindowState state )
|
||||
{
|
||||
|
||||
emit signalConsole( QString( "State change to: %1" ).arg( state ) );
|
||||
|
||||
#ifdef Q_OS_UNIX
|
||||
|
||||
if( getWindowState() != state )
|
||||
/*
|
||||
* Update the TB windows and states
|
||||
*/
|
||||
findWindows( m_ppid );
|
||||
|
||||
QList< quint64 > win_ids = getWinIds();
|
||||
|
||||
/*
|
||||
* Minimize all?
|
||||
*/
|
||||
if( state == Preferences::STATE_MINIMIZED_ALL )
|
||||
{
|
||||
/*
|
||||
* Update the TB windows
|
||||
*/
|
||||
findWindows( m_ppid );
|
||||
emit signalConsole( QString( "Minimize all" ) );
|
||||
|
||||
/*
|
||||
* Set the new state
|
||||
* Close pressed on one of the windows, minimize them all
|
||||
*/
|
||||
setWindowState( state );
|
||||
|
||||
QList< quint64 > win_ids = getWinIds();
|
||||
|
||||
if( state == Preferences::STATE_MINIMIZED || state == Preferences::STATE_MINIMIZED_ALL )
|
||||
for( int i = 0 ; i < win_ids.length() ; ++i )
|
||||
{
|
||||
for( int i = 0 ; i < win_ids.count() ; ++i )
|
||||
minimizeWindow( win_ids.at( i ), getMinimizeType() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QList< Preferences::WindowState > win_states = getWindowStates();
|
||||
|
||||
for( int i = 0 ; i < win_ids.length() ; ++i )
|
||||
{
|
||||
if( win_states.at( i ) == Preferences::STATE_MINIMIZED )
|
||||
{
|
||||
emit signalConsole( QString( "Hide: %1" ).arg( win_ids.at( i ) ) );
|
||||
|
||||
hideWindow( win_ids.at( i ), getMinimizeType() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( int i = 0 ; i < win_ids.count() ; ++i )
|
||||
else
|
||||
{
|
||||
emit signalConsole( QString( "Unhide: %1" ).arg( win_ids.at( i ) ) );
|
||||
|
||||
hideWindow( win_ids.at( i ), false );
|
||||
}
|
||||
}
|
||||
@@ -211,6 +227,9 @@ void WindowCtrl::slotWindowState( int state )
|
||||
*/
|
||||
void WindowCtrl::slotShowHide()
|
||||
{
|
||||
|
||||
emit signalConsole( QString( "Show/Hide" ) );
|
||||
|
||||
/*
|
||||
* Update the TB windows
|
||||
*/
|
||||
@@ -220,25 +239,20 @@ void WindowCtrl::slotShowHide()
|
||||
* Get the window ids
|
||||
*/
|
||||
QList< quint64 > win_ids = getWinIds();
|
||||
QList< Preferences::WindowState > win_states = getWindowStates();
|
||||
|
||||
/*
|
||||
* Show or hide the windows
|
||||
*/
|
||||
if( getWindowState() == Preferences::STATE_MINIMIZED )
|
||||
for( int i = 0 ; i < win_ids.length() ; ++i )
|
||||
{
|
||||
setWindowState( Preferences::STATE_NORMAL );
|
||||
|
||||
for( int i = 0 ; i < win_ids.count() ; ++i )
|
||||
if( win_states.at( i ) == Preferences::STATE_MINIMIZED )
|
||||
{
|
||||
emit signalConsole( QString( "Show %1" ).arg( win_ids.at( i ) ) );
|
||||
|
||||
normalizeWindow( win_ids.at( i ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setWindowState( Preferences::STATE_MINIMIZED );
|
||||
|
||||
for( int i = 0 ; i < win_ids.count() ; ++i )
|
||||
else
|
||||
{
|
||||
emit signalConsole( QString( "Hide %1" ).arg( win_ids.at( i ) ) );
|
||||
|
||||
minimizeWindow( win_ids.at( i ), getMinimizeType() );
|
||||
}
|
||||
}
|
||||
@@ -250,6 +264,9 @@ void WindowCtrl::slotShowHide()
|
||||
*/
|
||||
void WindowCtrl::slotClose()
|
||||
{
|
||||
|
||||
emit signalConsole( QString( "Close" ) );
|
||||
|
||||
/*
|
||||
* Update the TB windows
|
||||
*/
|
||||
|
||||
@@ -93,7 +93,7 @@ class WindowCtrl : public QObject
|
||||
*
|
||||
* @param state The new state.
|
||||
*/
|
||||
void slotWindowState( int state );
|
||||
void slotWindowState( Preferences::WindowState state );
|
||||
|
||||
/**
|
||||
* @brief slotShowHide. Slot for handling of the show / hide window signal.
|
||||
|
||||
Reference in New Issue
Block a user