LOGIN / SIGN UP
2 Author: Claes Nästén
Date: Mon Apr 20 23:11:33 +0200 2009
Subject: Move error handler to PScreen and make it possible to replace current wm.
    Now pekwm is able to replace metacity in recent gnome releases and take over
    as the window manager, it still doesn't know how to give the session up when
    exiting though.

src/ManagerWindows.cc
 
116 @@ -116,14 +116,25 @@
116 string session_name("WM_S" + Util::to_string<int>(DefaultScreen(_dpy)));
117 Atom session_atom = XInternAtom(_dpy, session_name.c_str(), false);
118 Window session_owner = XGetSelectionOwner(_dpy, session_atom);
119
120
121 if (session_owner && session_owner != _window) {
122 if (! replace) {
123 cerr << " *** WARNING: window manager already running." << endl;
124 return false;
125 }
126
127 // FIXME: Validate session owner
128 XSync(_dpy, false);
129 setXErrorsIgnore(true);
130 uint errors_before = xerrors_count;
131
132 // Select event to get notified when current owner dies.
133 XSelectInput(_dpy, session_owner, StructureNotifyMask);
134
135 XSync(_dpy, false);
136 setXErrorsIgnore(false);
137 if (errors_before != xerrors_count) {
138 session_owner = None;
139 }
140 }
141
142 Time timestamp = getTime();
...  
177 @@ -166,6 +177,8 @@
177 sleep(1);
178 }
179
180 cerr << " *** INFO: previous window manager did not exit. " << endl;
181
182 return false;
183 }
184
...  
194 @@ -181,13 +194,14 @@
194
195 event.xclient.type = ClientMessage;
196 event.xclient.message_type = Atoms::getAtom(MANAGER);
197 event.xclient.display = _dpy;
198 event.xclient.window = root;
199 event.xclient.format = 32;
200 event.xclient.data.l[0] = timestamp;
201 event.xclient.data.l[1] = session_atom;
202 event.xclient.data.l[2] = _window;
203 event.xclient.data.l[3] = 0;
191
205
206 XSendEvent(_dpy, root, false, SubstructureNotifyMask, &event);
207 }
208
...  
219 @@ -205,9 +219,21 @@
219 _gm.width = PScreen::instance()->getWidth();
220 _gm.height = PScreen::instance()->getHeight();
221
222
223 XSync(_dpy, false);
224 setXErrorsIgnore(true);
225 uint errors_before = xerrors_count;
226
227 // Select window events
228 XSelectInput(dpy, _window, RootWO::EVENT_MASK);
229
230 XSync(_dpy, false);
231 setXErrorsIgnore(false);
232 if (errors_before != xerrors_count) {
233 cerr << "pekwm: root window unavailable, can't start!" << endl;
234 exit(1);
235 }
236
237 // Set hits on the hint window, these are not updated so they are
238 // set in the constructor.
239 AtomUtil::setLong(_window, Atoms::getAtom(NET_WM_PID), static_cast<long>(getpid()));
...