mirror of
https://github.com/Ximi1970/systray-x.git
synced 2026-06-20 20:41:20 +02:00
Hide from switcher
This commit is contained in:
@@ -4,6 +4,9 @@
|
||||
/*
|
||||
* show all actions (normalize, minimize, hide, show/hide)
|
||||
*/
|
||||
#define DEBUG_DISPLAY_ACTIONS
|
||||
//#define DEBUG_DISPLAY_ACTIONS
|
||||
//#define DEBUG_DISPLAY_ACTIONS_DETAILS
|
||||
//#define DEBUG_DISPLAY_ACTIONS_END
|
||||
|
||||
|
||||
#endif // DEBUG_H
|
||||
|
||||
@@ -62,7 +62,7 @@ Preferences::Preferences( QObject *parent ) : QObject( parent )
|
||||
m_number_alignment = 4;
|
||||
m_number_margins = QMargins();
|
||||
|
||||
m_minimize_type = PREF_DEFAULT_MINIMIZE;
|
||||
m_minimize_type = PREF_MINIMIZE_METHOD_1;
|
||||
m_start_minimized = false;
|
||||
m_close_type = PREF_MINIMIZE_MAIN_CLOSE_CHILDREN_WINDOWS;
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
* Local includes
|
||||
*/
|
||||
#include "debug.h"
|
||||
#include "systray-x-lib-x11.h"
|
||||
|
||||
/*
|
||||
* Local includes
|
||||
@@ -32,8 +31,9 @@ WindowCtrlUnix::WindowCtrlUnix( QObject *parent ) : QObject( parent )
|
||||
* Initialize
|
||||
*/
|
||||
m_tb_windows = QList< quint64 >();
|
||||
m_tb_windows_pos = QList< QPoint >();
|
||||
m_tb_window_states = QList< Preferences::WindowState >();;
|
||||
m_tb_window_positions = QList< QPoint >();
|
||||
m_tb_window_states = QList< Preferences::WindowState >();
|
||||
m_tb_window_hints = QMap< quint64, SizeHints >();
|
||||
|
||||
/*
|
||||
* Get the base display and window
|
||||
@@ -98,6 +98,7 @@ bool WindowCtrlUnix::findWindow( const QString& title )
|
||||
QList< WindowItem > windows = listXWindows( m_display, GetDefaultRootWindow( m_display ) );
|
||||
|
||||
m_tb_windows = QList< quint64 >();
|
||||
m_tb_window_positions = QList< QPoint >();
|
||||
for( int i = 0 ; i < windows.length() ; ++i )
|
||||
{
|
||||
WindowItem win = windows.at( i );
|
||||
@@ -113,6 +114,7 @@ bool WindowCtrlUnix::findWindow( const QString& title )
|
||||
* Store the XID
|
||||
*/
|
||||
m_tb_windows.append( win.window );
|
||||
m_tb_window_positions.append( QPoint() );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -131,30 +133,42 @@ bool WindowCtrlUnix::findWindow( const QString& title )
|
||||
*/
|
||||
void WindowCtrlUnix::findWindows( qint64 pid )
|
||||
{
|
||||
#ifdef DEBUG_DISPLAY_ACTIONS
|
||||
emit signalConsole( "Find windows and states" );
|
||||
#endif
|
||||
|
||||
QList< WindowItem > windows = listXWindows( m_display, GetDefaultRootWindow( m_display ) );
|
||||
|
||||
QList< QPoint > old_positions = m_tb_window_positions;
|
||||
|
||||
m_tb_windows = QList< quint64 >();
|
||||
m_tb_window_positions = QList< QPoint >();
|
||||
for( int i = 0 ; i < windows.length() ; ++i )
|
||||
{
|
||||
WindowItem win = windows.at( i );
|
||||
|
||||
quint32 n_propPID;
|
||||
qint32 n_propPID;
|
||||
void* propPID = GetWindowProperty( m_display, win.window, "_NET_WM_PID", &n_propPID );
|
||||
|
||||
if( propPID != nullptr )
|
||||
{
|
||||
if( pid == *((reinterpret_cast<qint64 *>( propPID ) ) ) )
|
||||
{
|
||||
quint32 n_state;
|
||||
void* state = GetWindowProperty( m_display, win.window, "WM_STATE", &n_state );
|
||||
qint32 n_state;
|
||||
void* state = GetWindowProperty( m_display, win.window, "_NET_WM_STATE", &n_state );
|
||||
|
||||
if( state != nullptr )
|
||||
{
|
||||
if( *reinterpret_cast<long *>( state ) > 0 )
|
||||
m_tb_windows.append( win.window );
|
||||
|
||||
QPoint point;
|
||||
if( m_tb_windows.length() <= old_positions.length() )
|
||||
{
|
||||
m_tb_windows.append( win.window );
|
||||
point = old_positions.at( m_tb_window_positions.length() - 1 );
|
||||
}
|
||||
|
||||
m_tb_window_positions.append( point );
|
||||
|
||||
Free( state );
|
||||
}
|
||||
}
|
||||
@@ -163,7 +177,9 @@ void WindowCtrlUnix::findWindows( qint64 pid )
|
||||
}
|
||||
}
|
||||
|
||||
// emit signalConsole( QString( "Number of windows found: %1" ).arg( m_tb_windows.length() ) );
|
||||
#ifdef DEBUG_DISPLAY_ACTIONS_DETAILS
|
||||
emit signalConsole( QString( "Number of windows found: %1" ).arg( m_tb_windows.length() ) );
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Get the new window states, store the old ones
|
||||
@@ -171,44 +187,57 @@ void WindowCtrlUnix::findWindows( qint64 pid )
|
||||
m_tb_window_states = QList< Preferences::WindowState >();
|
||||
for( int i = 0 ; i< m_tb_windows.length() ; ++i )
|
||||
{
|
||||
QStringList atom_list;
|
||||
int state = -1;
|
||||
|
||||
quint32 n_states;
|
||||
void* states = GetWindowProperty( m_display, m_tb_windows.at( i ), "_NET_WM_STATE", &n_states );
|
||||
qint32 n_state;
|
||||
void* state_ptr = GetWindowProperty( m_display, m_tb_windows.at( i ), "WM_STATE", &n_state );
|
||||
|
||||
if( states != nullptr )
|
||||
if( state_ptr != nullptr )
|
||||
{
|
||||
for( quint32 i = 0; i < n_states ; ++i )
|
||||
{
|
||||
char* atom_name = GetAtomName( m_display, reinterpret_cast<long *>( states )[ i ] );
|
||||
state = *reinterpret_cast<long *>( state_ptr );
|
||||
|
||||
atom_list.append( atom_name );
|
||||
|
||||
if( atom_name )
|
||||
{
|
||||
Free( atom_name );
|
||||
}
|
||||
}
|
||||
|
||||
Free( states );
|
||||
Free( state_ptr );
|
||||
}
|
||||
|
||||
// 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" ) )
|
||||
*/
|
||||
|
||||
if( state == -1 || state == 3 )
|
||||
{
|
||||
#ifdef DEBUG_DISPLAY_ACTIONS_DETAILS
|
||||
emit signalConsole( QString( "WinID %1, state: %2, Minimized").arg( m_tb_windows.at( i ) ).arg( state ) );
|
||||
#endif
|
||||
|
||||
m_tb_window_states.append( Preferences::STATE_MINIMIZED );
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DEBUG_DISPLAY_ACTIONS_DETAILS
|
||||
emit signalConsole( QString( "WinID %1, state: %2, Normal").arg( m_tb_windows.at( i ) ).arg( state ) );
|
||||
#endif
|
||||
|
||||
m_tb_window_states.append( Preferences::STATE_NORMAL );
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG_DISPLAY_ACTIONS_END
|
||||
emit signalConsole( "Find windows and states done" );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get the Thunderbird window IDs
|
||||
*/
|
||||
QList< quint64 > WindowCtrlUnix::getWinIds()
|
||||
{
|
||||
return m_tb_windows;
|
||||
}
|
||||
|
||||
|
||||
@@ -256,7 +285,7 @@ void WindowCtrlUnix::displayWindowElements( quint64 window )
|
||||
{
|
||||
QString name;
|
||||
|
||||
quint32 n_name;
|
||||
qint32 n_name;
|
||||
void* name_ptr = GetWindowProperty( m_display, window, "_NET_WM_NAME", &n_name );
|
||||
|
||||
if( name_ptr != nullptr )
|
||||
@@ -270,12 +299,12 @@ void WindowCtrlUnix::displayWindowElements( quint64 window )
|
||||
|
||||
QStringList types;
|
||||
|
||||
quint32 n_types;
|
||||
qint32 n_types;
|
||||
void* types_ptr = GetWindowProperty( m_display, window, "_NET_WM_WINDOW_TYPE", &n_types );
|
||||
|
||||
if( types_ptr != nullptr )
|
||||
{
|
||||
for( quint32 i = 0; i < n_types; ++i )
|
||||
for( qint32 i = 0; i < n_types; ++i )
|
||||
{
|
||||
char* type_name = GetAtomName( m_display, reinterpret_cast<long *>( types_ptr )[ i ] );
|
||||
|
||||
@@ -297,12 +326,12 @@ void WindowCtrlUnix::displayWindowElements( quint64 window )
|
||||
|
||||
QStringList states;
|
||||
|
||||
quint32 n_states;
|
||||
qint32 n_states;
|
||||
void* states_ptr = GetWindowProperty( m_display,window, "_NET_WM_STATE", &n_states );
|
||||
|
||||
if( states_ptr != nullptr )
|
||||
{
|
||||
for( quint32 i = 0; i < n_states ; ++i )
|
||||
for( qint32 i = 0; i < n_states ; ++i )
|
||||
{
|
||||
char* atom_name = GetAtomName( m_display, reinterpret_cast<long *>( states_ptr )[ i ] );
|
||||
|
||||
@@ -374,81 +403,117 @@ void WindowCtrlUnix::displayWindowElements( quint64 window )
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get the Thunderbird window IDs
|
||||
*/
|
||||
QList< quint64 > WindowCtrlUnix::getWinIds()
|
||||
{
|
||||
return m_tb_windows;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get window positions
|
||||
*/
|
||||
void WindowCtrlUnix::updatePositions()
|
||||
{
|
||||
QList< QPoint > positions;
|
||||
#ifdef DEBUG_DISPLAY_ACTIONS
|
||||
emit signalConsole( "Update positions" );
|
||||
#endif
|
||||
|
||||
bool changed = false;
|
||||
for( int i = 0 ; i < m_tb_windows.length() ; ++i )
|
||||
{
|
||||
quint64 window = m_tb_windows.at( i );
|
||||
if( m_tb_window_states.at( i ) != Preferences::STATE_MINIMIZED )
|
||||
{
|
||||
quint64 window = m_tb_windows.at( i );
|
||||
|
||||
/*
|
||||
* Get border / title bar sizes
|
||||
*/
|
||||
long left;
|
||||
long top;
|
||||
long right;
|
||||
long bottom;
|
||||
GetWindowFrameExtensions( m_display, window, &left, &top, &right, &bottom );
|
||||
/*
|
||||
* Get border / title bar sizes
|
||||
*/
|
||||
long left;
|
||||
long top;
|
||||
long right;
|
||||
long bottom;
|
||||
GetWindowFrameExtensions( m_display, window, &left, &top, &right, &bottom );
|
||||
|
||||
/*
|
||||
* Get the position
|
||||
*/
|
||||
long x;
|
||||
long y;
|
||||
GetWindowPosition( m_display, window, &x, &y );
|
||||
#ifdef DEBUG_DISPLAY_ACTIONS_DETAILS
|
||||
emit signalConsole( QString( "Margins: %1, %2, %3, %4" ).arg( left ).arg( top ).arg( right ).arg( bottom ) );
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Add to the list
|
||||
*/
|
||||
positions.append( QPoint( x - left, y - top ) );
|
||||
/*
|
||||
* Get the position
|
||||
*/
|
||||
long x;
|
||||
long y;
|
||||
GetWindowPosition( m_display, window, &x, &y );
|
||||
|
||||
// emit signalConsole( QString( "Update pos: %1, %2" ).arg( x - left ).arg( y - top ) );
|
||||
/*
|
||||
* Update the list?
|
||||
*/
|
||||
QPoint point = QPoint( x - left, y - top );
|
||||
|
||||
if( m_tb_window_positions[ i ] != point )
|
||||
{
|
||||
m_tb_window_positions[ i ] = point;
|
||||
|
||||
/*
|
||||
* Mar the list changed
|
||||
*/
|
||||
changed = true;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_DISPLAY_ACTIONS_DETAILS
|
||||
emit signalConsole( QString( "Update pos: %1, %2" ).arg( x - left ).arg( y - top ) );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if( m_tb_windows_pos != positions )
|
||||
if( changed )
|
||||
{
|
||||
m_tb_windows_pos = positions;
|
||||
|
||||
emit signalPositions( m_tb_windows_pos );
|
||||
emit signalPositions( m_tb_window_positions );
|
||||
}
|
||||
|
||||
#ifdef DEBUG_DISPLAY_ACTIONS_END
|
||||
emit signalConsole( "Update positions done" );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Minimize a window
|
||||
*/
|
||||
void WindowCtrlUnix::minimizeWindow( quint64 window, bool hide )
|
||||
void WindowCtrlUnix::minimizeWindow( quint64 window )
|
||||
{
|
||||
#ifdef DEBUG_DISPLAY_ACTIONS
|
||||
emit signalConsole( "Minimize" );
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Remove from taskbar
|
||||
* Save the hints
|
||||
*/
|
||||
hideWindow( window, hide );
|
||||
GetWMNormalHints( m_display, window, &m_tb_window_hints[ window ] );
|
||||
|
||||
/*
|
||||
* Minimize the window
|
||||
*/
|
||||
IconifyWindow( m_display, window );
|
||||
|
||||
/*
|
||||
* Sync the events
|
||||
*/
|
||||
Sync( m_display );
|
||||
|
||||
if( getMinimizeType() != Preferences::PREF_DEFAULT_MINIMIZE )
|
||||
{
|
||||
#ifdef DEBUG_DISPLAY_ACTIONS
|
||||
emit signalConsole( "Withdraw window" );
|
||||
#endif
|
||||
/*
|
||||
* Remove from taskbar and task switchers
|
||||
*/
|
||||
WithdrawWindow( m_display, window );
|
||||
}
|
||||
|
||||
/*
|
||||
* Flush the pipes
|
||||
*/
|
||||
Flush( m_display );
|
||||
|
||||
#ifdef DEBUG_DISPLAY_ACTIONS_END
|
||||
emit signalConsole( "Minimize done" );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -483,6 +548,10 @@ void WindowCtrlUnix::hideWindow( quint64 window, bool hide )
|
||||
}
|
||||
|
||||
Flush( m_display );
|
||||
|
||||
#ifdef DEBUG_DISPLAY_ACTIONS_END
|
||||
emit signalConsole( QString( "Hide: %1").arg(hide) );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -495,12 +564,32 @@ void WindowCtrlUnix::normalizeWindow( quint64 window )
|
||||
emit signalConsole( "Normalize" );
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Show window on taskbar an in switcher
|
||||
*/
|
||||
if( getMinimizeType() != Preferences::PREF_DEFAULT_MINIMIZE )
|
||||
{
|
||||
MapWindow( m_display, window );
|
||||
|
||||
SetWMNormalHints( m_display, window, m_tb_window_hints[ window ] );
|
||||
}
|
||||
|
||||
/*
|
||||
* Raise the window to the top
|
||||
*/
|
||||
MapRaised( m_display, window );
|
||||
|
||||
/*
|
||||
* Flush the pipes
|
||||
*/
|
||||
Flush( m_display );
|
||||
|
||||
/*
|
||||
* Get the current desktop
|
||||
*/
|
||||
int current_desktop = 0;
|
||||
|
||||
quint32 n_current_desktop;
|
||||
qint32 n_current_desktop;
|
||||
long* current_desktop_ptr = (long*)GetWindowProperty( m_display, 0, "_NET_CURRENT_DESKTOP", &n_current_desktop );
|
||||
|
||||
if( current_desktop_ptr != nullptr )
|
||||
@@ -521,25 +610,19 @@ void WindowCtrlUnix::normalizeWindow( quint64 window )
|
||||
SendEvent( m_display, window, "_NET_WM_DESKTOP", current_desktop, 1 );
|
||||
}
|
||||
|
||||
/*
|
||||
* Show window on taskbar
|
||||
*/
|
||||
hideWindow( window, false );
|
||||
|
||||
/*
|
||||
* Normalize
|
||||
*/
|
||||
SendEvent( m_display, window, "_NET_ACTIVE_WINDOW" );
|
||||
|
||||
/*
|
||||
* Raise the window to the top
|
||||
*/
|
||||
MapRaised( m_display, window );
|
||||
|
||||
/*
|
||||
* Flush the pipes
|
||||
*/
|
||||
Flush( m_display );
|
||||
|
||||
#ifdef DEBUG_DISPLAY_ACTIONS_END
|
||||
emit signalConsole( "Normalize done" );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -563,7 +646,7 @@ void WindowCtrlUnix::setPositions( QList< QPoint > window_positions )
|
||||
{
|
||||
quint64 window = m_tb_windows.at( i );
|
||||
|
||||
#ifdef DEBUG_DISPLAY_ACTIONS
|
||||
#ifdef DEBUG_DISPLAY_ACTIONS_DETAILS
|
||||
emit signalConsole( QString( "Set pos: %1, %2").arg( window_positions.at( i ).x() ).arg( window_positions.at( i ).y() ) );
|
||||
#endif
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
* Local includes
|
||||
*/
|
||||
#include "preferences.h"
|
||||
#include "systray-x-lib-x11.h"
|
||||
|
||||
/*
|
||||
* System includes
|
||||
@@ -17,6 +18,7 @@
|
||||
* Qt includes
|
||||
*/
|
||||
#include <QObject>
|
||||
#include <QMap>
|
||||
#include <QPoint>
|
||||
|
||||
/*
|
||||
@@ -170,6 +172,13 @@ class WindowCtrlUnix : public QObject
|
||||
*/
|
||||
void findWindows( qint64 pid );
|
||||
|
||||
/**
|
||||
* @brief getWinIds. Get the Thunderbird window IDs.
|
||||
*
|
||||
* @return The list of window ID.
|
||||
*/
|
||||
QList< quint64 > getWinIds();
|
||||
|
||||
/**
|
||||
* @brief getWindowStates. Get the states of the TB windows.
|
||||
*
|
||||
@@ -191,13 +200,6 @@ class WindowCtrlUnix : public QObject
|
||||
*/
|
||||
void displayWindowElements( quint64 window );
|
||||
|
||||
/**
|
||||
* @brief getWinIds. Get the Thunderbird window IDs.
|
||||
*
|
||||
* @return The list of window ID.
|
||||
*/
|
||||
QList< quint64 > getWinIds();
|
||||
|
||||
/**
|
||||
* @brief updatePositions. Update the window positions.
|
||||
*/
|
||||
@@ -207,9 +209,8 @@ class WindowCtrlUnix : public QObject
|
||||
* @brief minimizeWindow. Minimize window.
|
||||
*
|
||||
* @param window The window.
|
||||
* @param hide Hide from taskbar.
|
||||
*/
|
||||
void minimizeWindow( quint64 window, bool hide );
|
||||
void minimizeWindow( quint64 window );
|
||||
|
||||
/**
|
||||
* @brief normalizeWindow. Normalize window.
|
||||
@@ -263,9 +264,9 @@ class WindowCtrlUnix : public QObject
|
||||
void signalConsole( QString message );
|
||||
|
||||
/**
|
||||
* @brief signalPosition. Signal the new window position.
|
||||
* @brief signalPositions. Signal the new window position.
|
||||
*
|
||||
* @param position
|
||||
* @param positions
|
||||
*/
|
||||
void signalPositions( QList< QPoint > positions );
|
||||
|
||||
@@ -282,15 +283,20 @@ class WindowCtrlUnix : public QObject
|
||||
QList< quint64 > m_tb_windows;
|
||||
|
||||
/**
|
||||
* @brief m_tb_windows_pos. The Thunderbird window positions.
|
||||
* @brief m_tb_window_positions. The Thunderbird window positions.
|
||||
*/
|
||||
QList< QPoint > m_tb_windows_pos;
|
||||
QList< QPoint > m_tb_window_positions;
|
||||
|
||||
/**
|
||||
* @brief m_tb_window_states. The Thunderbird window states.
|
||||
*/
|
||||
QList< Preferences::WindowState > m_tb_window_states;
|
||||
|
||||
/**
|
||||
* @brief m_tb_window_hints. The Thunderbird window hints.
|
||||
*/
|
||||
QMap< quint64, SizeHints > m_tb_window_hints;
|
||||
|
||||
/**
|
||||
* @brief m_minimize_type. Minimize type.
|
||||
*/
|
||||
|
||||
@@ -78,12 +78,23 @@ void WindowCtrl::slotWindowTest1()
|
||||
// emit signalConsole( QString( "Found XID: %1" ).arg( getWinId() ) );
|
||||
|
||||
// findWindow( "- Mozilla Thunderbird" );
|
||||
displayWindowElements( "- Mozilla Thunderbird" );
|
||||
// displayWindowElements( "- Mozilla Thunderbird" );
|
||||
// findWindow( 4313 );
|
||||
// displayWindowElements( getWinId() );
|
||||
|
||||
// findWindows( m_ppid );
|
||||
|
||||
#ifdef MINIMIZE_TEST
|
||||
emit signalConsole( QString( "Pid: %1").arg( m_ppid ) );
|
||||
findWindows( m_ppid );
|
||||
|
||||
QList< quint64 > win_ids = getWinIds();
|
||||
|
||||
emit signalConsole( QString( "Number of ids: %1" ).arg( win_ids.length() ) );
|
||||
|
||||
minimizeWindow( win_ids.at( 0 ) );
|
||||
#endif
|
||||
|
||||
emit signalConsole("Test 1 done");
|
||||
}
|
||||
|
||||
@@ -103,8 +114,17 @@ void WindowCtrl::slotWindowTest2()
|
||||
|
||||
// hideWindow( getWinId(), true );
|
||||
|
||||
// findWindow( m_ppid );
|
||||
// emit signalConsole( QString( "Hwnd ppid: %1" ).arg( getWinIds()[0] ) );
|
||||
#ifdef NORMALIZE_TEST
|
||||
|
||||
emit signalConsole( QString( "Pid: %1").arg( m_ppid ) );
|
||||
findWindows( m_ppid );
|
||||
|
||||
QList< quint64 > win_ids = getWinIds();
|
||||
|
||||
emit signalConsole( QString( "Number of ids: %1" ).arg( win_ids.length() ) );
|
||||
|
||||
normalizeWindow( win_ids.at( 0 ) );
|
||||
#endif
|
||||
|
||||
emit signalConsole("Test 2 done");
|
||||
}
|
||||
@@ -192,7 +212,7 @@ void WindowCtrl::slotWindowState( Preferences::WindowState state )
|
||||
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 );
|
||||
minimizeWindow( win_ids.at( i ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -208,7 +228,7 @@ void WindowCtrl::slotWindowState( Preferences::WindowState state )
|
||||
|
||||
if( ( win_states.at( i ) == Preferences::STATE_MINIMIZED && getMinimizeType() != Preferences::PREF_DEFAULT_MINIMIZE ) )
|
||||
{
|
||||
minimizeWindow( win_ids.at( i ), true );
|
||||
minimizeWindow( win_ids.at( i ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -225,7 +245,9 @@ void WindowCtrl::slotWindowState( Preferences::WindowState state )
|
||||
*/
|
||||
if( state == Preferences::STATE_MINIMIZED_ALL || state == Preferences::STATE_MINIMIZED_ALL_STARTUP )
|
||||
{
|
||||
// emit signalConsole( QString( "Minimize all" ) );
|
||||
#ifdef DEBUG_DISPLAY_ACTIONS
|
||||
emit signalConsole( QString( "Minimize all" ) );
|
||||
#endif
|
||||
|
||||
QList< quint64 > win_ids = getWinIds();
|
||||
|
||||
@@ -280,9 +302,13 @@ void WindowCtrl::slotShowHide()
|
||||
}
|
||||
else
|
||||
{
|
||||
minimizeWindow( win_ids.at( i ), getMinimizeType() != Preferences::PREF_DEFAULT_MINIMIZE );
|
||||
minimizeWindow( win_ids.at( i ) );
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG_DISPLAY_ACTIONS
|
||||
emit signalConsole( "Show/Hide end" );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -33,9 +33,18 @@ quint64 GetDefaultRootWindow( void* display )
|
||||
|
||||
|
||||
/*
|
||||
* Get the screen number
|
||||
* Get the default screen number
|
||||
*/
|
||||
int GetScreen( void* display, quint64 window )
|
||||
int GetDefaultScreen( void* display )
|
||||
{
|
||||
return XDefaultScreen( (Display*)display );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get the screen number of window
|
||||
*/
|
||||
int GetScreenNumberOfScreen( void* display, quint64 window )
|
||||
{
|
||||
XWindowAttributes xwa;
|
||||
XGetWindowAttributes( (Display*)display, window, &xwa );
|
||||
@@ -105,7 +114,85 @@ int FetchName( void* display, quint64 window, char** name )
|
||||
*/
|
||||
void IconifyWindow( void* display, quint64 window )
|
||||
{
|
||||
XIconifyWindow( (Display*)display, window, GetScreen( display, window ) );
|
||||
XIconifyWindow( (Display*)display, window, GetDefaultScreen( display ) );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* With draw the window
|
||||
*/
|
||||
void WithdrawWindow( void* display, quint64 window )
|
||||
{
|
||||
XWithdrawWindow( (Display*)display, window, GetDefaultScreen( display ) );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Map the window
|
||||
*/
|
||||
void MapWindow( void* display, quint64 window )
|
||||
{
|
||||
XMapWindow( (Display*)display, window );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get the hints
|
||||
*/
|
||||
void GetWMNormalHints( void* display, quint64 window, SizeHints* hints )
|
||||
{
|
||||
XSizeHints size_hint;
|
||||
long dummy;
|
||||
XGetWMNormalHints( (Display*)display, window, &size_hint, &dummy);
|
||||
|
||||
hints->flags = size_hint.flags;
|
||||
hints->x = size_hint.x;
|
||||
hints->y = size_hint.y;
|
||||
hints->width = size_hint.width;
|
||||
hints->height = size_hint.height;
|
||||
hints->min_width = size_hint.min_width;
|
||||
hints->min_height = size_hint.min_height;
|
||||
hints->max_width = size_hint.max_width;
|
||||
hints->max_height = size_hint.max_height;
|
||||
hints->width_inc = size_hint.width_inc;
|
||||
hints->height_inc = size_hint.height_inc;
|
||||
hints->min_aspect.x = size_hint.min_aspect.x;
|
||||
hints->min_aspect.y = size_hint.min_aspect.y;
|
||||
hints->max_aspect.x = size_hint.max_aspect.x;
|
||||
hints->max_aspect.y = size_hint.max_aspect.y;
|
||||
hints->base_width = size_hint.base_width;
|
||||
hints->base_height = size_hint.base_height;
|
||||
hints->win_gravity = size_hint.win_gravity;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Set the hints
|
||||
*/
|
||||
void SetWMNormalHints( void* display, quint64 window, SizeHints hints )
|
||||
{
|
||||
XSizeHints size_hint;
|
||||
|
||||
size_hint.flags = USPosition;
|
||||
size_hint.x = hints.x;
|
||||
size_hint.y = hints.y;
|
||||
size_hint.width = hints.width;
|
||||
size_hint.height = hints.height;
|
||||
size_hint.min_width = hints.min_width;
|
||||
size_hint.min_height = hints.min_height;
|
||||
size_hint.max_width = hints.max_width;
|
||||
size_hint.max_height = hints.max_height;
|
||||
size_hint.width_inc = hints.width_inc;
|
||||
size_hint.height_inc = hints.height_inc;
|
||||
size_hint.min_aspect.x = hints.min_aspect.x;
|
||||
size_hint.min_aspect.y = hints.min_aspect.y;
|
||||
size_hint.max_aspect.x = hints.max_aspect.x;
|
||||
size_hint.max_aspect.y = hints.max_aspect.y;
|
||||
size_hint.base_width = hints.base_width;
|
||||
size_hint.base_height = hints.base_height;
|
||||
size_hint.win_gravity = hints.win_gravity;
|
||||
|
||||
XSetWMNormalHints( (Display*)display, window, &size_hint );
|
||||
}
|
||||
|
||||
|
||||
@@ -118,6 +205,15 @@ void MapRaised( void* display, quint64 window )
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Set the input focus
|
||||
*/
|
||||
void SetInputFocus( void* display, quint64 window )
|
||||
{
|
||||
XSetInputFocus( (Display*)display, window, RevertToParent, CurrentTime );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get the name of the atom
|
||||
*/
|
||||
@@ -157,7 +253,7 @@ void ChangeWindowTypeProperty( void* display, quint64 window, const char* win
|
||||
/*
|
||||
* Get the title of the window
|
||||
*/
|
||||
void* GetWindowProperty( void* display, quint64 window, const char* atom, quint32* nlist )
|
||||
void* GetWindowProperty( void* display, quint64 window, const char* atom, qint32* nlist )
|
||||
{
|
||||
Display* dsp = (Display*)display;
|
||||
|
||||
@@ -180,20 +276,17 @@ void* GetWindowProperty( void* display, quint64 window, const char* atom, quin
|
||||
unsigned char* list = NULL;
|
||||
|
||||
if( XGetWindowProperty( dsp, win, prop, 0, LONG_MAX, False, AnyPropertyType,
|
||||
&type, &format, &len, &remain, &list ) == Success && len && list )
|
||||
&type, &format, &len, &remain, &list ) == Success )
|
||||
{
|
||||
if( nlist != NULL )
|
||||
{
|
||||
*nlist = (quint32)len;
|
||||
*nlist = (qint32)len;
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
if( nlist != NULL )
|
||||
{
|
||||
*nlist = (quint32)0;
|
||||
}
|
||||
*nlist = (qint32)-1;
|
||||
|
||||
if( list )
|
||||
{
|
||||
|
||||
@@ -1,15 +1,24 @@
|
||||
#ifndef SYSTRAY_X_LIB_H
|
||||
#define SYSTRAY_X_LIB_H
|
||||
|
||||
/*
|
||||
* System includes
|
||||
*/
|
||||
//#include <sys/types.h>
|
||||
|
||||
|
||||
typedef int qint32; /* 32 bit signed */
|
||||
typedef unsigned int quint32; /* 32 bit unsigned */
|
||||
typedef unsigned long long quint64; /* 64 bit unsigned */
|
||||
|
||||
typedef struct {
|
||||
long flags; /* marks which fields in this structure are defined */
|
||||
int x, y; /* obsolete for new window mgrs, but clients */
|
||||
int width, height; /* should set so old wm's don't mess up */
|
||||
int min_width, min_height;
|
||||
int max_width, max_height;
|
||||
int width_inc, height_inc;
|
||||
struct {
|
||||
int x; /* numerator */
|
||||
int y; /* denominator */
|
||||
} min_aspect, max_aspect;
|
||||
int base_width, base_height; /* added by ICCCM version 1 */
|
||||
int win_gravity; /* added by ICCCM version 1 */
|
||||
} SizeHints;
|
||||
|
||||
/*
|
||||
* State actions
|
||||
@@ -21,6 +30,9 @@ enum StateActions
|
||||
_NET_WM_STATE_TOGGLE
|
||||
};
|
||||
|
||||
/*
|
||||
* State atoms
|
||||
*/
|
||||
enum StateAtoms
|
||||
{
|
||||
_ATOM_SKIP_TASKBAR = 0,
|
||||
@@ -28,6 +40,9 @@ enum StateAtoms
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Protocol atoms
|
||||
*/
|
||||
enum ProtocolAtoms
|
||||
{
|
||||
_ATOM_DELETE_WINDOW = 0
|
||||
@@ -49,52 +64,52 @@ void* OpenDisplay();
|
||||
/**
|
||||
* @brief GetDefaultRootWindow
|
||||
*
|
||||
* @param display The display
|
||||
* @param display The display
|
||||
*
|
||||
* @return The root window.
|
||||
*/
|
||||
quint64 GetDefaultRootWindow( void* display );
|
||||
|
||||
/**
|
||||
* @brief GetScreen. Get the screen number.
|
||||
* @brief GetScreenNumberOfScreen. Get the screen number of the window.
|
||||
*
|
||||
* @param display The display
|
||||
* @param window The window
|
||||
*
|
||||
* @return The screen number.
|
||||
*/
|
||||
int GetScreen( void* display, quint64 window );
|
||||
int GetScreenNumberOfScreen( void* display, quint64 window );
|
||||
|
||||
/**
|
||||
* @brief Free. Free allocated X11 resources.
|
||||
*
|
||||
* @param free Pointer to the resource
|
||||
* @param free Pointer to the resource
|
||||
*/
|
||||
void Free( void* free );
|
||||
|
||||
/**
|
||||
* @brief Flush. Flush the event pipes.
|
||||
*
|
||||
* @param display The display
|
||||
* @param display The display
|
||||
*/
|
||||
void Flush( void* display );
|
||||
|
||||
/**
|
||||
* @brief Sync
|
||||
*
|
||||
* @param display The display
|
||||
* @param display The display
|
||||
*/
|
||||
void Sync( void* display );
|
||||
|
||||
/**
|
||||
* @brief QueryTree. Query te window tree.
|
||||
*
|
||||
* @param display The display
|
||||
* @param window The window
|
||||
* @param root The root window
|
||||
* @param parent The parent window
|
||||
* @param children The list of children
|
||||
* @param childrenCount The number of children
|
||||
* @param display The display
|
||||
* @param window The window
|
||||
* @param root The root window
|
||||
* @param parent The parent window
|
||||
* @param children The list of children
|
||||
* @param childrenCount The number of children
|
||||
*
|
||||
* @return The status of the query.
|
||||
*/
|
||||
@@ -103,9 +118,9 @@ int QueryTree( void* display, quint64 window, quint64* root, quint64* parent,
|
||||
/**
|
||||
* @brief FetchName. Get the name of the window.
|
||||
*
|
||||
* @param display The display
|
||||
* @param window The window
|
||||
* @param name Storage for the name
|
||||
* @param display The display
|
||||
* @param window The window
|
||||
* @param name Storage for the name
|
||||
*
|
||||
* @return The status.
|
||||
*/
|
||||
@@ -119,6 +134,40 @@ int FetchName( void* display, quint64 window, char** name );
|
||||
*/
|
||||
void IconifyWindow( void* display, quint64 window );
|
||||
|
||||
/**
|
||||
* @brief WithdrawWindow
|
||||
*
|
||||
* @param display The display
|
||||
* @param window The window
|
||||
*/
|
||||
void WithdrawWindow( void* display, quint64 window );
|
||||
|
||||
/**
|
||||
* @brief MapWindow. Raise the window to the top.
|
||||
*
|
||||
* @param display The display
|
||||
* @param window The window
|
||||
*/
|
||||
void MapWindow( void* display, quint64 window );
|
||||
|
||||
/**
|
||||
* @brief GetWMNormalHints
|
||||
*
|
||||
* @param display The display
|
||||
* @param window The window
|
||||
* @param hints Storage for the hints
|
||||
*/
|
||||
void GetWMNormalHints( void* display, quint64 window, SizeHints* hints );
|
||||
|
||||
/**
|
||||
* @brief SetWMNormalHints
|
||||
*
|
||||
* @param display The display
|
||||
* @param window The window
|
||||
* @param hints The hints
|
||||
*/
|
||||
void SetWMNormalHints( void* display, quint64 window, SizeHints hints );
|
||||
|
||||
/**
|
||||
* @brief MapRaised. Raise the window to the top.
|
||||
*
|
||||
@@ -127,11 +176,19 @@ void IconifyWindow( void* display, quint64 window );
|
||||
*/
|
||||
void MapRaised( void* display, quint64 window );
|
||||
|
||||
/**
|
||||
* @brief SetInputFocus
|
||||
*
|
||||
* @param display The display
|
||||
* @param window The window
|
||||
*/
|
||||
void SetInputFocus( void* display, quint64 window );
|
||||
|
||||
/**
|
||||
* @brief GetAtomName. Get the atom name.
|
||||
*
|
||||
* @param display The display
|
||||
* @param atom The atom.
|
||||
* @param display The display
|
||||
* @param atom The atom.
|
||||
*
|
||||
* @return The atom name.
|
||||
*/
|
||||
@@ -140,34 +197,34 @@ char* GetAtomName( void* display, long atom );
|
||||
/**
|
||||
* @brief ChangeWindowTypeProperty. Change the window typw property.
|
||||
*
|
||||
* @param display The display
|
||||
* @param window The window
|
||||
* @param win_type The new window type.
|
||||
* @param display The display
|
||||
* @param window The window
|
||||
* @param win_type The new window type.
|
||||
*/
|
||||
void ChangeWindowTypeProperty( void* display, quint64 window, const char* win_type );
|
||||
|
||||
/**
|
||||
* @brief GetWindowProperty. Get a window property.
|
||||
*
|
||||
* @param display The display
|
||||
* @param window The window
|
||||
* @param atom The atom to get
|
||||
* @param nlist Storage for the number of found properties
|
||||
* @param display The display
|
||||
* @param window The window
|
||||
* @param atom The atom to get
|
||||
* @param nlist Storage for the number of found properties
|
||||
*
|
||||
* @return The properties list
|
||||
*/
|
||||
void* GetWindowProperty( void* display, quint64 window, const char* atom, quint32* nlist );
|
||||
void* GetWindowProperty( void* display, quint64 window, const char* atom, qint32* nlist );
|
||||
|
||||
/**
|
||||
* @brief SendEvent. Send an X event.
|
||||
*
|
||||
* @param display The display
|
||||
* @param window The window
|
||||
* @param msg_type The name of the atom.
|
||||
* @param prop0 The first optional property of the event
|
||||
* @param prop1 The second optional property of the event
|
||||
* @param prop2 The third optional property of the event
|
||||
* @param prop3 The fourth optional property of the event
|
||||
* @param display The display
|
||||
* @param window The window
|
||||
* @param msg_type The name of the atom.
|
||||
* @param prop0 The first optional property of the event
|
||||
* @param prop1 The second optional property of the event
|
||||
* @param prop2 The third optional property of the event
|
||||
* @param prop3 The fourth optional property of the event
|
||||
*/
|
||||
void SendEvent( void* display, quint64 window, const char* msg_type,
|
||||
long prop0 = 0, long prop1 = 0, long prop2 = 0, long prop3 = 0 );
|
||||
@@ -175,32 +232,32 @@ void SendEvent( void* display, quint64 window, const char* msg_type,
|
||||
/**
|
||||
* @brief GetWindowFrameExtensions. Get the sizes of the window frame extensions.
|
||||
*
|
||||
* @param display The display
|
||||
* @param window The window
|
||||
* @param left Storage for the left extension size
|
||||
* @param top Storage for the top extension size
|
||||
* @param right Storage for the right extension size
|
||||
* @param bottom Storage for the bottom extension size
|
||||
* @param display The display
|
||||
* @param window The window
|
||||
* @param left Storage for the left extension size
|
||||
* @param top Storage for the top extension size
|
||||
* @param right Storage for the right extension size
|
||||
* @param bottom Storage for the bottom extension size
|
||||
*/
|
||||
void GetWindowFrameExtensions( void *display, quint64 window, long* left, long* top, long* right, long* bottom );
|
||||
|
||||
/**
|
||||
* @brief GetWindowPosition. Get the window position.
|
||||
*
|
||||
* @param display The display
|
||||
* @param window The window
|
||||
* @param pos_x Storage for the x coordinate
|
||||
* @param pos_y Storage for the y coordinate
|
||||
* @param display The display
|
||||
* @param window The window
|
||||
* @param pos_x Storage for the x coordinate
|
||||
* @param pos_y Storage for the y coordinate
|
||||
*/
|
||||
void GetWindowPosition( void *display, quint64 window, long* pos_x, long* pos_y );
|
||||
|
||||
/**
|
||||
* @brief MoveWindow. Set the window position.
|
||||
*
|
||||
* @param display The display
|
||||
* @param window The window
|
||||
* @param x The x coordinate
|
||||
* @param y The y coordinate
|
||||
* @param display The display
|
||||
* @param window The window
|
||||
* @param x The x coordinate
|
||||
* @param y The y coordinate
|
||||
*/
|
||||
void MoveWindow( void* display, quint64 window, int x, int y );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user