mirror of
https://github.com/Ximi1970/systray-x.git
synced 2025-10-26 07:46:09 +01:00
Add sendevent
This commit is contained in:
@@ -315,6 +315,27 @@ void WindowCtrlUnix::normalizeWindow( quint64 window )
|
||||
}
|
||||
|
||||
|
||||
void WindowCtrlUnix::hideWindow( quint64 window, bool set )
|
||||
{
|
||||
if( set )
|
||||
{
|
||||
sendEvent( window,
|
||||
"_NET_WM_STATE",
|
||||
_NET_WM_STATE_ADD,
|
||||
static_cast<long>( XInternAtom( m_display, "_NET_WM_STATE_SKIP_TASKBAR", False ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
sendEvent( window,
|
||||
"_NET_WM_STATE",
|
||||
_NET_WM_STATE_REMOVE,
|
||||
static_cast<long>( XInternAtom( m_display, "_NET_WM_STATE_SKIP_TASKBAR", False ) ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#ifdef FF_NEET
|
||||
|
||||
/*
|
||||
* Remove window from taskbar
|
||||
*/
|
||||
@@ -400,7 +421,7 @@ void WindowCtrlUnix::hideWindow( quint64 window, bool set )
|
||||
|
||||
XFlush( m_display );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Delete the window
|
||||
@@ -421,7 +442,7 @@ void WindowCtrlUnix::deleteWindow( quint64 window )
|
||||
}
|
||||
|
||||
Atom delete_prop = XInternAtom( m_display, "WM_DELETE_WINDOW", False );
|
||||
if( prop == None )
|
||||
if( delete_prop == None )
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -464,6 +485,40 @@ QList< WindowCtrlUnix::WindowItem > WindowCtrlUnix::listXWindows( Display *dis
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Send a X event
|
||||
*/
|
||||
void WindowCtrlUnix::sendEvent( quint64 window, const char* msg, long action,
|
||||
long prop1, long prop2, long prop3, long prop4 )
|
||||
{
|
||||
Window win = static_cast<Window>( window );
|
||||
|
||||
XEvent event;
|
||||
event.xclient.type = ClientMessage;
|
||||
event.xclient.serial = 0;
|
||||
event.xclient.send_event = True;
|
||||
event.xclient.message_type = XInternAtom( m_display, msg, False );
|
||||
event.xclient.window = win;
|
||||
event.xclient.format = 32;
|
||||
event.xclient.data.l[0] = action;
|
||||
event.xclient.data.l[1] = prop1;
|
||||
event.xclient.data.l[2] = prop2;
|
||||
event.xclient.data.l[2] = prop3;
|
||||
event.xclient.data.l[2] = prop4;
|
||||
|
||||
if( XSendEvent( m_display, win, False, SubstructureRedirectMask | SubstructureNotifyMask, &event ) )
|
||||
{
|
||||
emit signalConsole( "Event sent" );
|
||||
}
|
||||
else
|
||||
{
|
||||
emit signalConsole( "Event NOT sent" );
|
||||
}
|
||||
|
||||
XFlush( m_display );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get the title of the window
|
||||
*/
|
||||
|
||||
@@ -55,6 +55,13 @@ class WindowCtrlUnix : public QObject
|
||||
TYPE_NORMAL
|
||||
};
|
||||
|
||||
enum StateActions
|
||||
{
|
||||
_NET_WM_STATE_REMOVE = 0,
|
||||
_NET_WM_STATE_ADD,
|
||||
_NET_WM_STATE_TOGGLE
|
||||
};
|
||||
|
||||
/*
|
||||
* Window states
|
||||
*/
|
||||
@@ -237,6 +244,20 @@ class WindowCtrlUnix : public QObject
|
||||
*/
|
||||
QString atomName( Display* display, quint64 window );
|
||||
|
||||
/**
|
||||
* @brief sendEvent. Send an event.
|
||||
*
|
||||
* @param window Event target.
|
||||
* @param msg The message
|
||||
* @param action The action for the properties
|
||||
* @param prop1 Property 1
|
||||
* @param prop2 Property 2
|
||||
* @param prop3 Property 3
|
||||
* @param prop4 Property 4
|
||||
*/
|
||||
void sendEvent( quint64 window, const char* msg, long action,
|
||||
long prop1, long prop2 = 0, long prop3 = 0, long prop4 = 0 );
|
||||
|
||||
/**
|
||||
* @brief atomNetWmState. Get the _NET_WM_STATE of the window.
|
||||
*
|
||||
|
||||
@@ -77,6 +77,8 @@ void WindowCtrl::slotWindowTest2()
|
||||
// findWindow( m_ppid );
|
||||
// emit signalConsole( QString( "Hwnd ppid: %1" ).arg( getWinIds()[0] ) );
|
||||
|
||||
hideWindow( getWinId(), true );
|
||||
|
||||
emit signalConsole("Test 2 done");
|
||||
}
|
||||
|
||||
@@ -86,6 +88,7 @@ void WindowCtrl::slotWindowTest3()
|
||||
emit signalConsole("Test 3 started");
|
||||
|
||||
// Do something.
|
||||
hideWindow( getWinId(), false );
|
||||
|
||||
// emit signalConsole( QString( "Pid %1" ).arg( m_pid ) );
|
||||
// emit signalConsole( QString( "Ppid %1" ).arg( m_ppid ) );
|
||||
|
||||
Reference in New Issue
Block a user