Changeset View
Changeset View
Standalone View
Standalone View
main_x11.cpp
Show All 14 Lines | |||||
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | GNU General Public License for more details. | 17 | GNU General Public License for more details. | ||
18 | 18 | | |||
19 | You should have received a copy of the GNU General Public License | 19 | You should have received a copy of the GNU General Public License | ||
20 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 20 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | *********************************************************************/ | 21 | *********************************************************************/ | ||
22 | #include "main_x11.h" | 22 | #include "main_x11.h" | ||
23 | | ||||
23 | #include <config-kwin.h> | 24 | #include <config-kwin.h> | ||
24 | // kwin | 25 | | ||
25 | #include "platform.h" | 26 | #include "platform.h" | ||
26 | #include "sm.h" | 27 | #include "sm.h" | ||
27 | #include "workspace.h" | 28 | #include "workspace.h" | ||
28 | #include "xcbutils.h" | 29 | #include "xcbutils.h" | ||
29 | 30 | | |||
30 | // KDE | | |||
31 | #include <KConfigGroup> | 31 | #include <KConfigGroup> | ||
32 | #include <KCrash> | 32 | #include <KCrash> | ||
33 | #include <KLocalizedString> | 33 | #include <KLocalizedString> | ||
34 | #include <KPluginLoader> | 34 | #include <KPluginLoader> | ||
35 | #include <KPluginMetaData> | 35 | #include <KPluginMetaData> | ||
36 | #include <KSelectionOwner> | ||||
36 | #include <KQuickAddons/QtQuickSettings> | 37 | #include <KQuickAddons/QtQuickSettings> | ||
37 | // Qt | 38 | | ||
38 | #include <qplatformdefs.h> | 39 | #include <qplatformdefs.h> | ||
39 | #include <QComboBox> | 40 | #include <QComboBox> | ||
40 | #include <QCommandLineParser> | 41 | #include <QCommandLineParser> | ||
41 | #include <QDialog> | 42 | #include <QDialog> | ||
42 | #include <QDialogButtonBox> | 43 | #include <QDialogButtonBox> | ||
43 | #include <QFile> | 44 | #include <QFile> | ||
44 | #include <QLabel> | 45 | #include <QLabel> | ||
45 | #include <QPushButton> | 46 | #include <QPushButton> | ||
Show All 12 Lines | |||||
58 | namespace KWin | 59 | namespace KWin | ||
59 | { | 60 | { | ||
60 | 61 | | |||
61 | static void sighandler(int) | 62 | static void sighandler(int) | ||
62 | { | 63 | { | ||
63 | QApplication::exit(); | 64 | QApplication::exit(); | ||
64 | } | 65 | } | ||
65 | 66 | | |||
66 | | ||||
67 | | ||||
68 | class AlternativeWMDialog : public QDialog | 67 | class AlternativeWMDialog : public QDialog | ||
69 | { | 68 | { | ||
70 | public: | 69 | public: | ||
71 | AlternativeWMDialog() | 70 | AlternativeWMDialog() | ||
72 | : QDialog() { | 71 | : QDialog() { | ||
73 | QWidget* mainWidget = new QWidget(this); | 72 | QWidget* mainWidget = new QWidget(this); | ||
74 | QVBoxLayout* layout = new QVBoxLayout(mainWidget); | 73 | QVBoxLayout* layout = new QVBoxLayout(mainWidget); | ||
75 | QString text = i18n( | 74 | QString text = i18n( | ||
Show All 30 Lines | |||||
106 | QString selectedWM() const { | 105 | QString selectedWM() const { | ||
107 | return wmList->currentText(); | 106 | return wmList->currentText(); | ||
108 | } | 107 | } | ||
109 | 108 | | |||
110 | private: | 109 | private: | ||
111 | QComboBox* wmList; | 110 | QComboBox* wmList; | ||
112 | }; | 111 | }; | ||
113 | 112 | | |||
114 | //************************************ | 113 | class KWinSelectionOwner : public KSelectionOwner | ||
115 | // KWinSelectionOwner | 114 | { | ||
116 | //************************************ | 115 | Q_OBJECT | ||
117 | 116 | public: | |||
118 | KWinSelectionOwner::KWinSelectionOwner(int screen_P) | 117 | explicit KWinSelectionOwner(int screen) | ||
119 | : KSelectionOwner(make_selection_atom(screen_P), screen_P) | 118 | : KSelectionOwner(make_selection_atom(screen), screen) | ||
120 | { | 119 | { | ||
121 | } | 120 | } | ||
122 | 121 | | |||
123 | xcb_atom_t KWinSelectionOwner::make_selection_atom(int screen_P) | 122 | private: | ||
124 | { | 123 | bool genericReply(xcb_atom_t target_P, xcb_atom_t property_P, xcb_window_t requestor_P) override { | ||
125 | if (screen_P < 0) | 124 | if (target_P == xa_version) { | ||
126 | screen_P = QX11Info::appScreen(); | 125 | int32_t version[] = { 2, 0 }; | ||
127 | QByteArray screen(QByteArrayLiteral("WM_S")); | 126 | xcb_change_property(connection(), XCB_PROP_MODE_REPLACE, requestor_P, | ||
128 | screen.append(QByteArray::number(screen_P)); | 127 | property_P, XCB_ATOM_INTEGER, 32, 2, version); | ||
129 | ScopedCPointer<xcb_intern_atom_reply_t> atom(xcb_intern_atom_reply( | 128 | } else | ||
130 | connection(), | 129 | return KSelectionOwner::genericReply(target_P, property_P, requestor_P); | ||
131 | xcb_intern_atom_unchecked(connection(), false, screen.length(), screen.constData()), | 130 | return true; | ||
132 | nullptr)); | | |||
133 | if (atom.isNull()) { | | |||
134 | return XCB_ATOM_NONE; | | |||
135 | } | 131 | } | ||
136 | return atom->atom; | 132 | | ||
133 | void replyTargets(xcb_atom_t property_P, xcb_window_t requestor_P) override { | ||||
134 | KSelectionOwner::replyTargets(property_P, requestor_P); | ||||
135 | xcb_atom_t atoms[ 1 ] = { xa_version }; | ||||
136 | // PropModeAppend ! | ||||
137 | xcb_change_property(connection(), XCB_PROP_MODE_APPEND, requestor_P, | ||||
138 | property_P, XCB_ATOM_ATOM, 32, 1, atoms); | ||||
137 | } | 139 | } | ||
138 | 140 | | |||
139 | void KWinSelectionOwner::getAtoms() | 141 | void getAtoms() override { | ||
140 | { | | |||
141 | KSelectionOwner::getAtoms(); | 142 | KSelectionOwner::getAtoms(); | ||
142 | if (xa_version == XCB_ATOM_NONE) { | 143 | if (xa_version == XCB_ATOM_NONE) { | ||
143 | const QByteArray name(QByteArrayLiteral("VERSION")); | 144 | const QByteArray name(QByteArrayLiteral("VERSION")); | ||
144 | ScopedCPointer<xcb_intern_atom_reply_t> atom(xcb_intern_atom_reply( | 145 | ScopedCPointer<xcb_intern_atom_reply_t> atom(xcb_intern_atom_reply( | ||
145 | connection(), | 146 | connection(), | ||
146 | xcb_intern_atom_unchecked(connection(), false, name.length(), name.constData()), | 147 | xcb_intern_atom_unchecked(connection(), false, name.length(), name.constData()), | ||
147 | nullptr)); | 148 | nullptr)); | ||
148 | if (!atom.isNull()) { | 149 | if (!atom.isNull()) { | ||
149 | xa_version = atom->atom; | 150 | xa_version = atom->atom; | ||
150 | } | 151 | } | ||
151 | } | 152 | } | ||
152 | } | 153 | } | ||
153 | 154 | | |||
154 | void KWinSelectionOwner::replyTargets(xcb_atom_t property_P, xcb_window_t requestor_P) | 155 | xcb_atom_t make_selection_atom(int screen_P) { | ||
155 | { | 156 | if (screen_P < 0) | ||
156 | KSelectionOwner::replyTargets(property_P, requestor_P); | 157 | screen_P = QX11Info::appScreen(); | ||
157 | xcb_atom_t atoms[ 1 ] = { xa_version }; | 158 | QByteArray screen(QByteArrayLiteral("WM_S")); | ||
158 | // PropModeAppend ! | 159 | screen.append(QByteArray::number(screen_P)); | ||
159 | xcb_change_property(connection(), XCB_PROP_MODE_APPEND, requestor_P, | 160 | ScopedCPointer<xcb_intern_atom_reply_t> atom(xcb_intern_atom_reply( | ||
160 | property_P, XCB_ATOM_ATOM, 32, 1, atoms); | 161 | connection(), | ||
162 | xcb_intern_atom_unchecked(connection(), false, screen.length(), screen.constData()), | ||||
163 | nullptr)); | ||||
164 | if (atom.isNull()) { | ||||
165 | return XCB_ATOM_NONE; | ||||
161 | } | 166 | } | ||
162 | 167 | return atom->atom; | |||
163 | bool KWinSelectionOwner::genericReply(xcb_atom_t target_P, xcb_atom_t property_P, xcb_window_t requestor_P) | | |||
164 | { | | |||
165 | if (target_P == xa_version) { | | |||
166 | int32_t version[] = { 2, 0 }; | | |||
167 | xcb_change_property(connection(), XCB_PROP_MODE_REPLACE, requestor_P, | | |||
168 | property_P, XCB_ATOM_INTEGER, 32, 2, version); | | |||
169 | } else | | |||
170 | return KSelectionOwner::genericReply(target_P, property_P, requestor_P); | | |||
171 | return true; | | |||
172 | } | 168 | } | ||
173 | 169 | static xcb_atom_t xa_version; | |||
170 | }; | ||||
174 | xcb_atom_t KWinSelectionOwner::xa_version = XCB_ATOM_NONE; | 171 | xcb_atom_t KWinSelectionOwner::xa_version = XCB_ATOM_NONE; | ||
175 | 172 | | |||
176 | //************************************ | 173 | //************************************ | ||
177 | // ApplicationX11 | 174 | // ApplicationX11 | ||
178 | //************************************ | 175 | //************************************ | ||
179 | 176 | | |||
180 | ApplicationX11::ApplicationX11(int &argc, char **argv) | 177 | ApplicationX11::ApplicationX11(int &argc, char **argv) | ||
181 | : Application(OperationModeX11, argc, argv) | 178 | : Application(OperationModeX11, argc, argv) | ||
▲ Show 20 Lines • Show All 288 Lines • ▼ Show 20 Line(s) | 441 | #endif | |||
470 | 467 | | |||
471 | a.start(); | 468 | a.start(); | ||
472 | 469 | | |||
473 | KWin::SessionSaveDoneHelper helper; | 470 | KWin::SessionSaveDoneHelper helper; | ||
474 | Q_UNUSED(helper); // The sessionsavedonehelper opens a side channel to the smserver, | 471 | Q_UNUSED(helper); // The sessionsavedonehelper opens a side channel to the smserver, | ||
475 | // listens for events and talks to it, so it needs to be created. | 472 | // listens for events and talks to it, so it needs to be created. | ||
476 | return a.exec(); | 473 | return a.exec(); | ||
477 | } | 474 | } | ||
475 | | ||||
476 | #include "main_x11.moc" |