diff --git a/app/SysTray-X/SysTray-X-app/systrayxlink.cpp b/app/SysTray-X/SysTray-X-app/systrayxlink.cpp index 6c6a557..a8e140f 100644 --- a/app/SysTray-X/SysTray-X-app/systrayxlink.cpp +++ b/app/SysTray-X/SysTray-X-app/systrayxlink.cpp @@ -329,15 +329,11 @@ void SysTrayXLink::DecodeMessage( const QByteArray& message ) if( mailCount.contains( "unread" ) && mailCount[ "unread" ].isDouble() ) { unreadMail = mailCount[ "unread" ].toInt(); - - emit signalConsole( QString("Unread %1").arg( unreadMail ) ); } if( mailCount.contains( "new" ) && mailCount[ "new" ].isDouble() ) { newMail = mailCount[ "new" ].toInt(); - - emit signalConsole( QString("New %1").arg( newMail ) ); } emit signalMailCount( unreadMail, newMail ); diff --git a/app/SysTray-X/SysTray-X-app/windowctrl-unix.cpp b/app/SysTray-X/SysTray-X-app/windowctrl-unix.cpp index cbf77e3..381c38a 100644 --- a/app/SysTray-X/SysTray-X-app/windowctrl-unix.cpp +++ b/app/SysTray-X/SysTray-X-app/windowctrl-unix.cpp @@ -367,6 +367,18 @@ void WindowCtrlUnix::minimizeWindowToTaskbar( quint64 window ) */ GetWMNormalHints( m_display, window, &m_tb_window_hints[ window ] ); + /* + * Get the X11 window state + */ + QStringList atoms = getWindowStateX11( window ); + if( atoms.contains( "_NET_WM_STATE_MAXIMIZED_VERT" ) && atoms.contains( "_NET_WM_STATE_MAXIMIZED_HORZ" ) ) + { + /* + * Window is maximized + */ + m_tb_window_hints[ window ].flags = -1; + } + /* * Minimize the window */ @@ -407,6 +419,18 @@ void WindowCtrlUnix::minimizeWindowToTray( quint64 window ) */ GetWMNormalHints( m_display, window, &m_tb_window_hints[ window ] ); + /* + * Get the X11 window state + */ + QStringList atoms = getWindowStateX11( window ); + if( atoms.contains( "_NET_WM_STATE_MAXIMIZED_VERT" ) && atoms.contains( "_NET_WM_STATE_MAXIMIZED_HORZ" ) ) + { + /* + * Window is maximized + */ + m_tb_window_hints[ window ].flags = -1; + } + /* * Set the flags (GNOME, Wayland?) */ @@ -452,14 +476,24 @@ void WindowCtrlUnix::normalizeWindow( quint64 window ) { MapWindow( m_display, window ); - SetWMNormalHints( m_display, window, m_tb_window_hints[ window ] ); - /* * Reset the hide flags */ SendEvent( m_display, window, "_NET_WM_STATE", _NET_WM_STATE_REMOVE, _ATOM_SKIP_TASKBAR ); SendEvent( m_display, window, "_NET_WM_STATE", _NET_WM_STATE_REMOVE, _ATOM_SKIP_PAGER ); + /* + * Was the window maximized? + */ + if( m_tb_window_hints[ window ].flags == -1 ) + { + SendEvent( m_display, window, "_NET_WM_STATE", _NET_WM_STATE_ADD, _ATOM_MAXIMIZED ); + } + else + { + SetWMNormalHints( m_display, window, m_tb_window_hints[ window ] ); + } + Flush( m_display ); } @@ -622,4 +656,42 @@ QList< WindowCtrlUnix::WindowItem > WindowCtrlUnix::listXWindows( void* displa return windows; } + +/* + * Get the window state from X11 + */ +QStringList WindowCtrlUnix::getWindowStateX11( quint64 window ) +{ + qint32 n_net_wm_state; + void* net_wm_state_ptr = GetWindowProperty( m_display, window, "_NET_WM_STATE", &n_net_wm_state ); + + /* + * Get the atoms + */ + QStringList atom_list; + if( net_wm_state_ptr != nullptr ) + { + for( qint32 i = 0 ; i < n_net_wm_state ; ++i ) + { + char* atom_name = GetAtomName( m_display, reinterpret_cast( net_wm_state_ptr )[ i ] ); + + atom_list.append( atom_name ); + + if( atom_name ) + { + Free( atom_name ); + } + } + + Free( net_wm_state_ptr ); + } +/* + for( int i = 0 ; i < atom_list.length() ; ++i ) + { + emit signalConsole( QString( "Atom: %1").arg( atom_list.at( i ) ) ); + } +*/ + return atom_list; +} + #endif // Q_OS_UNIX diff --git a/app/SysTray-X/SysTray-X-app/windowctrl-unix.h b/app/SysTray-X/SysTray-X-app/windowctrl-unix.h index def2df2..1829715 100644 --- a/app/SysTray-X/SysTray-X-app/windowctrl-unix.h +++ b/app/SysTray-X/SysTray-X-app/windowctrl-unix.h @@ -238,15 +238,6 @@ class WindowCtrlUnix : public QObject */ const Preferences::WindowState& getWindowState( const quint64 window ); - /** - * @brief getWindowState. Get the state of a TB windows. - * - * @param window Window ID. - * - * @return The window state. - */ - const Preferences::WindowState& getWindowStateX11( const quint64 window ); - /** * @brief updatePositions. Update the window positions. */ @@ -287,11 +278,6 @@ class WindowCtrlUnix : public QObject */ void setPositions( QList< QPoint > window_positions ); - /** - * @brief updateX11WindowStates. Update the x11 window states. - */ - void updateX11WindowStates( CheckType check_type ); - private: /** @@ -310,6 +296,13 @@ class WindowCtrlUnix : public QObject */ QList< WindowItem > listXWindows( void* display, quint64 window, int level = 0 ); + /** + * @brief getWindowStateX11. Get the window state from X11 + * + * @param window The window. + */ + QStringList getWindowStateX11( quint64 window ); + signals: /** diff --git a/app/SysTray-X/SysTray-X-lib-x11/systray-x-lib-x11.cpp b/app/SysTray-X/SysTray-X-lib-x11/systray-x-lib-x11.cpp index d5b7e0a..e86a654 100644 --- a/app/SysTray-X/SysTray-X-lib-x11/systray-x-lib-x11.cpp +++ b/app/SysTray-X/SysTray-X-lib-x11/systray-x-lib-x11.cpp @@ -352,6 +352,25 @@ void SendEvent( void* display, quint64 window, const char* msg_type, break; } + case _ATOM_MAXIMIZED_VERT: + { + event.xclient.data.l[1] = XInternAtom( dsp, "_NET_WM_STATE_MAXIMIZED_VERT", False ); + break; + } + + case _ATOM_MAXIMIZED_HORZ: + { + event.xclient.data.l[1] = XInternAtom( dsp, "_NET_WM_STATE_MAXIMIZED_HORZ", False ); + break; + } + + case _ATOM_MAXIMIZED: + { + event.xclient.data.l[1] = XInternAtom( dsp, "_NET_WM_STATE_MAXIMIZED_VERT", False ); + event.xclient.data.l[2] = XInternAtom( dsp, "_NET_WM_STATE_MAXIMIZED_HORZ", False ); + break; + } + default: { return; diff --git a/app/SysTray-X/SysTray-X-lib-x11/systray-x-lib-x11.h b/app/SysTray-X/SysTray-X-lib-x11/systray-x-lib-x11.h index 4f7b789..87510ef 100644 --- a/app/SysTray-X/SysTray-X-lib-x11/systray-x-lib-x11.h +++ b/app/SysTray-X/SysTray-X-lib-x11/systray-x-lib-x11.h @@ -36,10 +36,12 @@ enum StateActions enum StateAtoms { _ATOM_SKIP_TASKBAR = 0, - _ATOM_SKIP_PAGER + _ATOM_SKIP_PAGER, + _ATOM_MAXIMIZED_VERT, + _ATOM_MAXIMIZED_HORZ, + _ATOM_MAXIMIZED }; - /* * Protocol atoms */