diff --git a/app/SysTray-X/windowctrl-unix.cpp b/app/SysTray-X/windowctrl-unix.cpp index edeeeb4..0d169d6 100644 --- a/app/SysTray-X/windowctrl-unix.cpp +++ b/app/SysTray-X/windowctrl-unix.cpp @@ -158,12 +158,14 @@ QList< quint64 > WindowCtrlUnix::getWinIds() */ void WindowCtrlUnix::minimizeWindow( quint64 window, bool hide ) { + Window win = static_cast( window ); + if( hide ) { - hideWindow( static_cast( window ), hide ); + hideWindow( win, hide ); } - XIconifyWindow( m_display, static_cast( window ), m_screen ); + XIconifyWindow( m_display, win, m_screen ); XFlush( m_display ); } @@ -173,7 +175,9 @@ void WindowCtrlUnix::minimizeWindow( quint64 window, bool hide ) */ void WindowCtrlUnix::normalizeWindow( quint64 window ) { - hideWindow( static_cast( window ), false ); + Window win = static_cast( window ); + + hideWindow( win, false ); XEvent event = { 0 }; event.xclient.type = ClientMessage; @@ -184,8 +188,8 @@ void WindowCtrlUnix::normalizeWindow( quint64 window ) event.xclient.format = 32; XSendEvent( m_display, m_root_window, False, SubstructureRedirectMask | SubstructureNotifyMask, &event ); - XMapRaised( m_display, static_cast( window ) ); -// XMapWindow( m_display, static_cast( window ) ); + XMapRaised( m_display, win ); +// XMapWindow( m_display, win ); XFlush( m_display ); } @@ -195,6 +199,8 @@ void WindowCtrlUnix::normalizeWindow( quint64 window ) */ void WindowCtrlUnix::hideWindow( quint64 window, bool set ) { + Window win = static_cast( window ); + char prop_name[] = "_NET_WM_STATE"; Atom prop = XInternAtom( m_display, prop_name, True ); Atom prop_skip_taskbar = XInternAtom( m_display, WindowStates[ STATE_SKIP_TASKBAR ].toUtf8(), True ); @@ -205,7 +211,7 @@ void WindowCtrlUnix::hideWindow( quint64 window, bool set ) unsigned long len; unsigned char* list = nullptr; - if( XGetWindowProperty( m_display, static_cast( window ), prop, 0, sizeof( Atom ), False, XA_ATOM, + if( XGetWindowProperty( m_display, win, prop, 0, sizeof( Atom ), False, XA_ATOM, &type, &format, &len, &remain, &list ) == Success ) { Atom* atom_list = reinterpret_cast( list ); @@ -236,7 +242,8 @@ void WindowCtrlUnix::hideWindow( quint64 window, bool set ) /* * Set the atom */ - XChangeProperty( m_display, static_cast( window ), prop, XA_ATOM, 32, PropModeAppend, reinterpret_cast( &prop_skip_taskbar ), 1 ); + XChangeProperty( m_display, win, prop, XA_ATOM, 32, PropModeAppend, + reinterpret_cast( &prop_skip_taskbar ), 1 ); } else if( !set && present ) @@ -244,7 +251,8 @@ void WindowCtrlUnix::hideWindow( quint64 window, bool set ) /* * Remove the atom */ - XChangeProperty( m_display, static_cast( window ), prop, XA_ATOM, format, PropModeReplace, reinterpret_cast( new_atom_list ), static_cast( len - 1 ) ); + XChangeProperty( m_display, win, prop, XA_ATOM, format, PropModeReplace, + reinterpret_cast( new_atom_list ), static_cast( len - 1 ) ); } /* diff --git a/app/SysTray-X/windowctrl-unix.h b/app/SysTray-X/windowctrl-unix.h index c21d7f0..5e333bb 100644 --- a/app/SysTray-X/windowctrl-unix.h +++ b/app/SysTray-X/windowctrl-unix.h @@ -148,6 +148,14 @@ class WindowCtrlUnix : public QObject */ void normalizeWindow( quint64 window ); + /** + * @brief hideWindow. Hide a window from the taskbar. + * + * @param window The window. + * @param set The state of the window. + */ + void hideWindow( quint64 window, bool set ); + @@ -163,14 +171,6 @@ class WindowCtrlUnix : public QObject private: - /** - * @brief hideWindow. Hide a window from the taskbar. - * - * @param window The window. - * @param set The state of the window. - */ - void hideWindow( quint64 window, bool set ); - /** * @brief listXWindows. Get all the windows. * diff --git a/app/SysTray-X/windowctrl.cpp b/app/SysTray-X/windowctrl.cpp index 2561ae9..e9a1c5a 100644 --- a/app/SysTray-X/windowctrl.cpp +++ b/app/SysTray-X/windowctrl.cpp @@ -147,7 +147,27 @@ void WindowCtrl::slotMinimizeHideChange() */ void WindowCtrl::slotWindowState( QString state ) { - m_state = state; + if( m_state != state ) + { + m_state = state; + + if( state == "normal" ) + { + foreach( quint64 win_id, getWinIds() ) + { + hideWindow( win_id, false ); + } + } + else + { + foreach( quint64 win_id, getWinIds() ) + { + hideWindow( win_id, m_minimize_hide ); + } + } + + emit signalConsole( "New state: " + state ); + } } diff --git a/webext/background.js b/webext/background.js index b1f1a7b..3aca012 100644 --- a/webext/background.js +++ b/webext/background.js @@ -30,7 +30,7 @@ SysTrayX.Messaging = { browser.windows.onRemoved.addListener(SysTrayX.Window.closed); // Try to catch the window state - // browser.windows.onFocusChanged.addListener(SysTrayX.Window.focusChanged); + browser.windows.onFocusChanged.addListener(SysTrayX.Window.focusChanged); }, //