Prep for separate x11 static lib

This commit is contained in:
Ximi1970
2020-12-23 14:13:51 +01:00
parent 54dadf757b
commit 03a3050998
78 changed files with 242 additions and 200 deletions

View File

@@ -61,7 +61,7 @@ systray-x-app:
$(QMAKE) $(EXT_VERSION) $(OPTIONS) ../SysTray-X/SysTray-X.pro ;\
make ;\
cd ../.. ;\
cp app/build/SysTray-X .
cp app/build/SysTray-X-app/SysTray-X .
else
systray-x-app:
@echo "Creating systray-x app" ;\

View File

@@ -1,9 +1,11 @@
#-------------------------------------------------
#
# Project created by QtCreator 2020-01-12T19:19:44
# Get the defaults
#
#-------------------------------------------------
include( ../SysTray-X.pri )
#
# Defines
#
#DEFINES += NO_KDE_INTEGRATION
@@ -104,61 +106,13 @@ unix:macx: {
LIBS += -dead_strip
}
#
# Git version getters
#
win32: {
contains(QMAKE_HOST.os, Windows): {
#
# Host is Windows
#
GIT = ""C:\\Progra~1\\Git\\bin\\git.exe""
}
else {
#
# Host is Linux, cross compiling with mingw
#
GIT = git
}
}
unix:GIT = git
#
# Define the app version strings
#
BUILD_NUMBER = $$system($$GIT rev-list --count HEAD)
GIT_HASH = $$system($$GIT rev-parse HEAD)
GIT_BRANCH = $$system($$GIT rev-parse --abbrev-ref HEAD)
GIT_VERSION_LONG = $$system($$GIT describe --long)
GIT_VERSION = $$section(GIT_VERSION_LONG, -, 0, 0)
VERSION_MAJOR = $$section(GIT_VERSION, ., 0, 0)
VERSION_MINOR = $$section(GIT_VERSION, ., 1, 1)
VERSION_PATCH = $$section(GIT_VERSION, ., 2, 2)
!contains(DEFINES,EXT_VERSION) {
DEFINES += APP_VERSION_MAJOR=\\\"$$VERSION_MAJOR\\\"
DEFINES += APP_VERSION_MINOR=\\\"$$VERSION_MINOR\\\"
DEFINES += APP_VERSION_PATCH=\\\"$$VERSION_PATCH\\\"
DEFINES += APP_BUILD=\\\"$$BUILD_NUMBER\\\"
DEFINES += APP_GITHASH=\\\"$$GIT_HASH\\\"
DEFINES += APP_GITBRANCH=\\\"$$GIT_BRANCH\\\"
message("Buildnumber: "$$BUILD_NUMBER)
message("Git hash: "$$GIT_HASH)
message("Git branch: "$$GIT_BRANCH)
message("Version: "$$VERSION_MAJOR"."$$VERSION_MINOR"."$$VERSION_PATCH)
#message($$QMAKESPEC)
}
unix: {
#
# Generate JSON
#
QMAKE_POST_LINK = cp -f "$${_PRO_FILE_PWD_}/../config/linux/SysTray_X.json.template" "$${_PRO_FILE_PWD_}/../config/linux/SysTray_X.json" ;
QMAKE_POST_LINK += sed -i -e "s?SYSTRAY_X_PATH?$${OUT_PWD}/$${TARGET}?" "$${_PRO_FILE_PWD_}/../config/linux/SysTray_X.json" ;
# QMAKE_POST_LINK += cp -f "$${_PRO_FILE_PWD_}/../config/linux/SysTray_X.json" ~/.mozilla/native-messaging-hosts/SysTray_X.json ;
QMAKE_POST_LINK = cp -f "$${_PRO_FILE_PWD_}/../../config/linux/SysTray_X.json.template" "$${_PRO_FILE_PWD_}/../../config/linux/SysTray_X.json" ;
QMAKE_POST_LINK += sed -i -e "s?SYSTRAY_X_PATH?$${OUT_PWD}/$${TARGET}?" "$${_PRO_FILE_PWD_}/../../config/linux/SysTray_X.json" ;
# QMAKE_POST_LINK += cp -f "$${_PRO_FILE_PWD_}/../../config/linux/SysTray_X.json" ~/.mozilla/native-messaging-hosts/SysTray_X.json ;
}
win32: {
@@ -166,17 +120,17 @@ win32: {
JSON_EXE_PATH = $$system(powershell -Command "('$$shell_path($${OUT_PWD}/debug/$${TARGET}.exe)').replace('\\','\\\\')")
QMAKE_POST_LINK = $$[QT_INSTALL_BINS]\windeployqt.exe \"$$shell_path($${OUT_PWD}/debug/$${TARGET}.exe)\" &
QMAKE_POST_LINK += powershell -Command \"(Get-Content \'$$shell_path($${_PRO_FILE_PWD_}/../config/win32/SysTray_X.json.template)\' ).replace(\'SYSTRAY_X_PATH\',\'$$JSON_EXE_PATH\') | Set-Content \'$$shell_path($${_PRO_FILE_PWD_}/../config/win32/SysTray_X.json)\'\" &
QMAKE_POST_LINK += powershell -Command \"(Get-Content \'$$shell_path($${_PRO_FILE_PWD_}/../../config/win32/SysTray_X.json.template)\' ).replace(\'SYSTRAY_X_PATH\',\'$$JSON_EXE_PATH\') | Set-Content \'$$shell_path($${_PRO_FILE_PWD_}/../../config/win32/SysTray_X.json)\'\" &
} else {
JSON_EXE_PATH = $$system(powershell -Command "('$$shell_path($${OUT_PWD}/release/$${TARGET}.exe)').replace('\\','\\\\')")
QMAKE_POST_LINK = $$[QT_INSTALL_BINS]\windeployqt.exe \"$$shell_path($${OUT_PWD}/release/$${TARGET}.exe)\" &
QMAKE_POST_LINK += powershell -Command \"(Get-Content \'$$shell_path($${_PRO_FILE_PWD_}/../config/win32/SysTray_X.json.template)\' ).replace(\'SYSTRAY_X_PATH\',\'$$JSON_EXE_PATH\') | Set-Content \'$$shell_path($${_PRO_FILE_PWD_}/../config/win32/SysTray_X.json)\'\" &
QMAKE_POST_LINK += powershell -Command \"(Get-Content \'$$shell_path($${_PRO_FILE_PWD_}/../../config/win32/SysTray_X.json.template)\' ).replace(\'SYSTRAY_X_PATH\',\'$$JSON_EXE_PATH\') | Set-Content \'$$shell_path($${_PRO_FILE_PWD_}/../../config/win32/SysTray_X.json)\'\" &
}
JSON_JSON_PATH = $$system(powershell -Command "('$$shell_path($${_PRO_FILE_PWD_}/../config/win32/SysTray_X.json)').replace('\\','\\\\')")
JSON_JSON_PATH = $$system(powershell -Command "('$$shell_path($${_PRO_FILE_PWD_}/../../config/win32/SysTray_X.json)').replace('\\','\\\\')")
QMAKE_POST_LINK += powershell -Command \"(Get-Content \'$$shell_path($${_PRO_FILE_PWD_}/../config/win32/SysTray-X-User.reg.template)\' ).replace(\'SYSTRAY_X_JSON_PATH\',\'$$JSON_JSON_PATH\') | Set-Content \'$$shell_path($${_PRO_FILE_PWD_}/../config/win32/SysTray-X-User.reg)\'\" &
QMAKE_POST_LINK += powershell -Command \"(Get-Content \'$$shell_path($${_PRO_FILE_PWD_}/../../config/win32/SysTray-X-User.reg.template)\' ).replace(\'SYSTRAY_X_JSON_PATH\',\'$$JSON_JSON_PATH\') | Set-Content \'$$shell_path($${_PRO_FILE_PWD_}/../../config/win32/SysTray-X-User.reg)\'\" &
}
#

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View File

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View File

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 48 KiB

View File

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

Before

Width:  |  Height:  |  Size: 680 B

After

Width:  |  Height:  |  Size: 680 B

View File

@@ -338,6 +338,8 @@ void SysTrayXLink::DecodeMessage( const QByteArray& message )
{
QString window_state_str = jsonObject[ "window" ].toString();
emit signalConsole( "Window state: " + window_state_str );
Preferences::WindowState window_state;
if( window_state_str == Preferences::STATE_NORMAL_STR )
{

View File

@@ -27,8 +27,6 @@ WindowCtrlUnix::WindowCtrlUnix( QObject *parent ) : QObject( parent )
* Get the base display and window
*/
m_display = XOpenDisplay( NULL );
m_screen = 0;
m_root_window = XDefaultRootWindow( m_display );
}
@@ -102,7 +100,7 @@ QString WindowCtrlUnix::getProcessName( qint64 pid ) const
*/
bool WindowCtrlUnix::findWindow( const QString& title )
{
QList< WindowItem > windows = listXWindows( m_display, m_root_window );
QList< WindowItem > windows = listXWindows( m_display, XDefaultRootWindow( m_display ) );
m_tb_windows = QList< quint64 >();
for( int i = 0 ; i < windows.length() ; ++i )
@@ -138,7 +136,7 @@ bool WindowCtrlUnix::findWindow( const QString& title )
*/
void WindowCtrlUnix::findWindows( qint64 pid )
{
QList< WindowItem > windows = listXWindows( m_display, m_root_window );
QList< WindowItem > windows = listXWindows( m_display, XDefaultRootWindow( m_display ) );
// Get the PID property atom.
Atom atom_PID = XInternAtom( m_display, "_NET_WM_PID", True );
@@ -216,7 +214,7 @@ const QList< Preferences::WindowState >& WindowCtrlUnix::getWindowStates() co
*/
void WindowCtrlUnix::displayWindowElements( const QString& title )
{
QList< WindowItem > windows = listXWindows( m_display, m_root_window );
QList< WindowItem > windows = listXWindows( m_display, XDefaultRootWindow( m_display ) );
for( int i = 0 ; i < windows.length() ; ++i )
{
@@ -338,7 +336,7 @@ void WindowCtrlUnix::updatePositions()
Window child;
XWindowAttributes xwa;
Window win = static_cast<Window>( window );
XTranslateCoordinates( m_display, win, m_root_window, 0, 0, &x, &y, &child );
XTranslateCoordinates( m_display, win, XDefaultRootWindow( m_display ), 0, 0, &x, &y, &child );
XGetWindowAttributes( m_display, win, &xwa );
positions.append( QPoint( x - xwa.x - margin.left(), y - xwa.y - margin.top() ) );
@@ -369,7 +367,18 @@ void WindowCtrlUnix::minimizeWindow( quint64 window, int hide )
hideWindow( window, hide );
XIconifyWindow( m_display, static_cast<Window>( window ), m_screen );
/*
* Minimize the window
*/
XWindowAttributes xwa;
XGetWindowAttributes( m_display, window, &xwa );
int screen = XScreenNumberOfScreen( xwa.screen );
XIconifyWindow( m_display, window, screen );
/*
* Flush the pipes
*/
XFlush( m_display );
}
@@ -391,14 +400,6 @@ void WindowCtrlUnix::hideWindow( quint64 window, int set )
break;
}
case Preferences::PREF_MINIMIZE_METHOD_2:
{
emit signalConsole( "Hide 2" );
hideWindowAtom( window, set );
break;
}
default:
{
emit signalConsole( "Hide default" );
@@ -408,6 +409,100 @@ void WindowCtrlUnix::hideWindow( quint64 window, int set )
}
/*
* Normalize a window
*/
void WindowCtrlUnix::normalizeWindow( quint64 window )
{
emit signalConsole( "Normalize" );
/*
* Get the current desktop
*/
int current_desktop = 0;
/*
XWindowAttributes xwa;
XGetWindowAttributes( m_display, window, &xwa);
int screen = XScreenNumberOfScreen( xwa.screen );
Window root = XRootWindow( m_display, screen );
*/
quint32 n_current_desktop;
long* current_desktop_ptr = (long*)GetWindowProperty( XDefaultRootWindow( m_display ), "_NET_CURRENT_DESKTOP", &n_current_desktop );
if( current_desktop_ptr != nullptr )
{
/*
* Store it
*/
current_desktop = *current_desktop_ptr;
/*
* Cleanup
*/
XFree( current_desktop_ptr );
/*
* Set the desktop for the window
*/
XEvent event_desktop;
event_desktop.xclient.type = ClientMessage;
event_desktop.xclient.serial = 0;
event_desktop.xclient.send_event = True;
event_desktop.xclient.message_type = XInternAtom( m_display, "_NET_WM_DESKTOP", True );
event_desktop.xclient.window = window;
event_desktop.xclient.format = 32;
event_desktop.xclient.data.l[0] = current_desktop;
event_desktop.xclient.data.l[1] = 1;
XSendEvent( m_display, XDefaultRootWindow( m_display ), False, SubstructureRedirectMask | SubstructureNotifyMask, (XEvent*)&event_desktop );
}
/*
* Show window on taskbar
*/
XEvent event_taskbar;
event_taskbar.xclient.type = ClientMessage;
event_taskbar.xclient.serial = 0;
event_taskbar.xclient.send_event = True;
event_taskbar.xclient.message_type = XInternAtom( m_display, "_NET_WM_STATE", False );
event_taskbar.xclient.window = window;
event_taskbar.xclient.format = 32;
event_taskbar.xclient.data.l[0] = _NET_WM_STATE_REMOVE;
event_taskbar.xclient.data.l[1] = XInternAtom( m_display, "_NET_WM_STATE_SKIP_TASKBAR", False );
XSendEvent( m_display, XDefaultRootWindow( m_display ), False, SubstructureRedirectMask | SubstructureNotifyMask, &event_taskbar );
/*
* Normalize
*/
XEvent event_normalize;
event_normalize.xclient.type = ClientMessage;
event_normalize.xclient.serial = 0;
event_normalize.xclient.send_event = True;
event_normalize.xclient.message_type = XInternAtom( m_display, "_NET_ACTIVE_WINDOW", False );
event_normalize.xclient.window = window;
event_normalize.xclient.format = 32;
XSendEvent( m_display, XDefaultRootWindow( m_display ), False, SubstructureRedirectMask | SubstructureNotifyMask, &event_normalize );
/*
* Raise the window to the top
*/
XMapRaised( m_display, window );
/*
* Flush the pipes
*/
XFlush( m_display );
}
#ifdef WORKS
/*
* Normalize a window
*/
@@ -422,31 +517,89 @@ void WindowCtrlUnix::normalizeWindow( quint64 window )
return;
}
/*
* Get the current desktop
*/
int current_desktop = 0;
/*
XWindowAttributes xwa;
XGetWindowAttributes( m_display, window, &xwa);
int screen = XScreenNumberOfScreen( xwa.screen );
Window root = XRootWindow( m_display, screen );
*/
quint32 n_current_desktop;
long* current_desktop_ptr = (long*)GetWindowProperty( RootWindow( m_display, m_screen ), "_NET_CURRENT_DESKTOP", &n_current_desktop );
if( current_desktop_ptr != nullptr )
{
emit signalConsole( QString( "Pre Desktop %1" ).arg( *current_desktop_ptr ) );
/*
* Store it
*/
current_desktop = *current_desktop_ptr;
/*
* Cleanup
*/
XFree( current_desktop_ptr );
/*
* Set the desktop for the window
*/
XClientMessageEvent event;
event.message_type = XInternAtom( m_display, "_NET_WM_DESKTOP", True );
event.window = window;
event.format = 32;
event.type = ClientMessage;
event.data.l[0] = current_desktop;
event.data.l[1] = 1;
XSendEvent( m_display, RootWindow( m_display, m_screen ), False, SubstructureRedirectMask | SubstructureNotifyMask, (XEvent*)&event );
}
/*
* Unhide the window
*/
hideWindow( window, false );
Window win = static_cast<Window>( window );
Atom msg_atom = XInternAtom( m_display, "_NET_ACTIVE_WINDOW", False );
if( msg_atom == None )
{
return;
}
/*
* Normalize
*/
XEvent event = { 0 };
event.xclient.type = ClientMessage;
event.xclient.serial = 0;
event.xclient.send_event = True;
event.xclient.message_type = msg_atom;
event.xclient.window = win;
event.xclient.message_type = XInternAtom( m_display, "_NET_ACTIVE_WINDOW", False );
event.xclient.window = window;
event.xclient.format = 32;
XSendEvent( m_display, m_root_window, False, SubstructureRedirectMask | SubstructureNotifyMask, &event );
XSendEvent( m_display, RootWindow( m_display, m_screen ), False, SubstructureRedirectMask | SubstructureNotifyMask, &event );
XMapRaised( m_display, win );
// XMapWindow( m_display, win );
XMapRaised( m_display, window );
XFlush( m_display );
quint32 ndesktop;
long* desktop = (long*)GetWindowProperty( window, "_NET_WM_DESKTOP", &ndesktop );
if( desktop != nullptr )
{
emit signalConsole( QString( "Desktop %1" ).arg( *desktop ) );
/*
* Cleanup
*/
XFree( desktop );
}
}
#endif
/*
* Delete the window
@@ -535,93 +688,6 @@ void WindowCtrlUnix::hideWindowEvent( quint64 window, bool set )
}
/*
* Remove window from taskbar
*/
void WindowCtrlUnix::hideWindowAtom( quint64 window, bool set )
{
if( !isThunderbird( getPpid() ) )
{
return;
}
Window win = static_cast<Window>( 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 );
Atom type;
int format;
unsigned long remain;
unsigned long len;
unsigned char* list = nullptr;
if( XGetWindowProperty( m_display, win, prop, 0, sizeof( Atom ), False, XA_ATOM,
&type, &format, &len, &remain, &list ) == Success )
{
Atom* atom_list = reinterpret_cast<Atom *>( list );
Atom* new_atom_list = nullptr;
bool present = false;
if( len > 1 )
{
/*
* Check and remove atom from list
*/
new_atom_list = new Atom[ len - 1 ];
for( unsigned long i = 0, o = 0; i < len; ++i )
{
if( atom_list[ i ] == prop_skip_taskbar )
{
present = true;
continue;
}
new_atom_list[ o++ ] = atom_list[ i ];
}
}
if( set && !present )
{
/*
* Set the atom
*/
XChangeProperty( m_display, win, prop, XA_ATOM, 32, PropModeAppend,
reinterpret_cast<unsigned char*>( &prop_skip_taskbar ), 1 );
}
else
if( !set && present )
{
/*
* Remove the atom
*/
XChangeProperty( m_display, win, prop, XA_ATOM, format, PropModeReplace,
reinterpret_cast<unsigned char*>( new_atom_list ), static_cast<int>( len - 1 ) );
}
/*
* Cleanup
*/
if( new_atom_list )
{
delete [] new_atom_list;
}
}
/*
* Cleanup
*/
if( list )
{
XFree( list );
}
XFlush( m_display );
}
/*
* Get the X11 window list
*/
@@ -675,7 +741,7 @@ void WindowCtrlUnix::sendEvent( quint64 window, const char* msg, long action,
event.xclient.data.l[3] = prop3;
event.xclient.data.l[4] = prop4;
XSendEvent( m_display, DefaultRootWindow( m_display ), False, SubstructureRedirectMask | SubstructureNotifyMask, &event );
XSendEvent( m_display, XDefaultRootWindow( m_display ), False, SubstructureRedirectMask | SubstructureNotifyMask, &event );
}
@@ -866,4 +932,41 @@ QMargins WindowCtrlUnix::atomFrameExtents( Display *display, quint64 window )
}
/*
* Get the title of the window
*/
void* WindowCtrlUnix::GetWindowProperty( quint64 window, const char* atom, quint32* nlist )
{
Atom prop = XInternAtom( m_display, atom, True );
Atom type;
int format;
unsigned long remain;
unsigned long len;
unsigned char* list = nullptr;
if( XGetWindowProperty( m_display, window, prop, 0, LONG_MAX, False, AnyPropertyType,
&type, &format, &len, &remain, &list ) == Success && len && list )
{
if( nlist != nullptr )
{
*nlist = (quint32)len;
}
return list;
}
if( nlist != nullptr )
{
*nlist = (quint32)0;
}
if( list )
{
XFree( list );
}
return nullptr;
}
#endif // Q_OS_UNIX

View File

@@ -353,6 +353,11 @@ class WindowCtrlUnix : public QObject
*/
QMargins atomFrameExtents( Display *display, quint64 window );
void* GetWindowProperty( quint64 window, const char* atom, quint32* items = nullptr );
signals:
/**
@@ -376,16 +381,6 @@ class WindowCtrlUnix : public QObject
*/
Display* m_display;
/**
* @brief m_screen. The screen number.
*/
int m_screen;
/**
* @brief m_root_window. The root window.
*/
quint64 m_root_window;
/**
* @brief m_tb_windows. The Thunderbird windows.
*/

View File

@@ -80,8 +80,7 @@ void WindowCtrl::slotWindowTest1()
// findWindow( 4313 );
// displayWindowElements( getWinId() );
findWindows( m_ppid );
// findWindows( m_ppid );
emit signalConsole("Test 1 done");
}

View File

@@ -41,7 +41,7 @@ call "C:\Program Files (x86)\Microsoft Visual Studio\2017\WDExpress\VC\Auxiliary
C:\Qt\%QT_VER%\%SPEC%\bin\qmake ..\SysTray-X\SysTray-X.pro -spec win32-msvc
nmake
xcopy /Q /Y release\SysTray-X.exe ..\dist\%WIN%\
xcopy /Q /Y release\SysTray-X-app\SysTray-X.exe ..\dist\%WIN%\
xcopy /Q /Y ..\config\win32\SysTray_X.json.template ..\dist\%WIN%\
rename ..\dist\%WIN%\SysTray_X.json.template SysTray_X.json

View File

@@ -23,7 +23,7 @@ SysTrayX.Messaging = {
filters: undefined,
init: function () {
// Minimuze on startup handled by Companion app as backup
// Minimize on startup handled by Companion app as backup
if (SysTrayX.startupState == "minimized") {
SysTrayX.Link.postSysTrayXMessage({ window: "minimized_all_startup" });
}
@@ -56,18 +56,7 @@ SysTrayX.Messaging = {
// Send preferences to app
SysTrayX.Messaging.sendPreferences();
/*
// New mail listener (TB76+)
if (SysTrayX.browserInfo.majorVersion > 75) {
//
// Mixed results, forgets accounts?, double events?
//
browser.messages.onNewMailReceived.addListener(
SysTrayX.Messaging.newMail
);
}
*/
// Catch the unread / new mails
browser.folderChange.onUnreadMailChange.addListener(function (unread) {
SysTrayX.Messaging.unreadCb(unread);
});