Changeset View
Changeset View
Standalone View
Standalone View
xembed-sni-proxy/main.cpp
Show All 13 Lines | |||||
14 | * | 14 | * | ||
15 | * You should have received a copy of the GNU Lesser General Public | 15 | * You should have received a copy of the GNU Lesser General Public | ||
16 | * License along with this library; if not, write to the Free Software | 16 | * License along with this library; if not, write to the Free Software | ||
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
18 | * | 18 | * | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #include <QGuiApplication> | 21 | #include <QGuiApplication> | ||
22 | #include <QSessionManager> | | |||
23 | 22 | | |||
24 | #include "fdoselectionmanager.h" | 23 | #include "fdoselectionmanager.h" | ||
25 | 24 | | |||
26 | #include "debug.h" | 25 | #include "debug.h" | ||
27 | #include "xcbutils.h" | 26 | #include "xcbutils.h" | ||
28 | #include "snidbus.h" | 27 | #include "snidbus.h" | ||
29 | 28 | | |||
30 | #include <QDBusMetaType> | 29 | #include <QDBusMetaType> | ||
31 | 30 | | |||
32 | #include <KWindowSystem> | 31 | #include <KWindowSystem> | ||
33 | 32 | | |||
34 | namespace Xcb { | 33 | namespace Xcb { | ||
35 | Xcb::Atoms* atoms; | 34 | Xcb::Atoms* atoms; | ||
36 | } | 35 | } | ||
37 | 36 | | |||
38 | int main(int argc, char ** argv) | 37 | int main(int argc, char ** argv) | ||
39 | { | 38 | { | ||
40 | //the whole point of this is to interact with X, if we are in any other session, force trying to connect to X | 39 | //the whole point of this is to interact with X, if we are in any other session, force trying to connect to X | ||
41 | //if the QPA can't load xcb, this app is useless anyway. | 40 | //if the QPA can't load xcb, this app is useless anyway. | ||
42 | qputenv("QT_QPA_PLATFORM", "xcb"); | 41 | qputenv("QT_QPA_PLATFORM", "xcb"); | ||
43 | 42 | | |||
44 | QGuiApplication::setDesktopSettingsAware(false); | 43 | QGuiApplication::setDesktopSettingsAware(false); | ||
44 | QCoreApplication::setAttribute(Qt::AA_DisableSessionManager); | ||||
45 | 45 | | |||
46 | QGuiApplication app(argc, argv); | 46 | QGuiApplication app(argc, argv); | ||
47 | 47 | | |||
48 | if (!KWindowSystem::isPlatformX11()) { | 48 | if (!KWindowSystem::isPlatformX11()) { | ||
49 | qFatal("xembed-sni-proxy is only useful XCB. Aborting"); | 49 | qFatal("xembed-sni-proxy is only useful XCB. Aborting"); | ||
50 | } | 50 | } | ||
51 | 51 | | |||
52 | auto disableSessionManagement = [](QSessionManager &sm) { | | |||
53 | sm.setRestartHint(QSessionManager::RestartNever); | | |||
54 | }; | | |||
55 | QObject::connect(&app, &QGuiApplication::commitDataRequest, disableSessionManagement); | | |||
56 | QObject::connect(&app, &QGuiApplication::saveStateRequest, disableSessionManagement); | | |||
57 | | ||||
58 | app.setQuitOnLastWindowClosed(false); | 52 | app.setQuitOnLastWindowClosed(false); | ||
59 | 53 | | |||
60 | qDBusRegisterMetaType<KDbusImageStruct>(); | 54 | qDBusRegisterMetaType<KDbusImageStruct>(); | ||
61 | qDBusRegisterMetaType<KDbusImageVector>(); | 55 | qDBusRegisterMetaType<KDbusImageVector>(); | ||
62 | qDBusRegisterMetaType<KDbusToolTipStruct>(); | 56 | qDBusRegisterMetaType<KDbusToolTipStruct>(); | ||
63 | 57 | | |||
64 | Xcb::atoms = new Xcb::Atoms(); | 58 | Xcb::atoms = new Xcb::Atoms(); | ||
65 | 59 | | |||
66 | FdoSelectionManager manager; | 60 | FdoSelectionManager manager; | ||
67 | 61 | | |||
68 | auto rc = app.exec(); | 62 | auto rc = app.exec(); | ||
69 | 63 | | |||
70 | delete Xcb::atoms; | 64 | delete Xcb::atoms; | ||
71 | return rc; | 65 | return rc; | ||
72 | } | 66 | } |