fixed bug in transient window creation at startup

This commit is contained in:
fluxgen 2004-07-14 12:13:29 +00:00
parent 18aab356ff
commit 9cee51bdf0

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: Screen.cc,v 1.283 2004/06/21 15:23:41 rathnor Exp $ // $Id: Screen.cc,v 1.284 2004/07/14 12:13:29 fluxgen Exp $
#include "Screen.hh" #include "Screen.hh"
@ -436,10 +436,26 @@ void BScreen::initWindows() {
Display *disp = FbTk::App::instance()->display(); Display *disp = FbTk::App::instance()->display();
XQueryTree(disp, rootWindow().window(), &r, &p, &children, &nchild); XQueryTree(disp, rootWindow().window(), &r, &p, &children, &nchild);
// Count number of windows created and when this counter reaches zero
// we've created all windows.
// We need to do this because sometimes the transient windows are
// before the transient_for windows in the list and we need to
// postpone the creation of transient windows until the transient_for
// is created (see: WinClient::updateTransientInfo())
//
// - Henrik
int created = nchild; // number of created/managed windows
Fluxbox *fluxbox = Fluxbox::instance();
// preen the window list of all icon windows... for better dockapp support // preen the window list of all icon windows... for better dockapp support
for (int i = 0; i < (int) nchild; i++) { for (int i = 0; i < (int) nchild; i++) {
if (children[i] == None) continue; if (children[i] == None) {
// we dont use this window, decrease counter
created--;
continue;
}
XWMHints *wmhints = XGetWMHints(disp, children[i]); XWMHints *wmhints = XGetWMHints(disp, children[i]);
@ -454,29 +470,71 @@ void BScreen::initWindows() {
} }
XFree(wmhints); XFree(wmhints);
} }
// we dont use this window, decrease counter
if (children[i] == None || (! fluxbox->validateWindow(children[i])))
created--;
} }
// manage shown windows // manage shown windows
Fluxbox *fluxbox = Fluxbox::instance(); Window transient_for = 0;
for (int i = 0; i < (int) nchild; ++i) { int safety_counter = nchild*nchild;
if (children[i] == None || (! fluxbox->validateWindow(children[i]))) while (created > 0) {
continue;
XWindowAttributes attrib; if (--safety_counter < 0) {
if (XGetWindowAttributes(disp, children[i], cerr<<"BScreen::initWindows() Warning!!! Safety counter reached!"<<endl;
&attrib)) { cerr<<"--------------"<<endl;
if (attrib.override_redirect) cerr<<"created = "<<created<<hex<<endl;
for (int i=0; i < nchild; ++i)
cerr<<"child("<<i<<") = 0x"<<children[i]<<endl;
cerr<<dec<<"--------------"<<endl;
cerr<<"Please report this to fluxbox development team."<<endl;
break;
}
for (int i = 0; i < (int) nchild; ++i) {
if (children[i] == None || (! fluxbox->validateWindow(children[i]))) {
#ifdef DEBUG
cerr<<"BScreen::initWindows(): created = "<<created<<endl;
#endif // DEBUG
continue; continue;
}
if (attrib.map_state != IsUnmapped) { // if we have a transient_for window and it isn't created yet...
FluxboxWindow *win = createWindow(children[i]); // postpone creation of this window until transient_for is created
// See comment at the begining
if (XGetTransientForHint(disp, children[i], &transient_for) &&
fluxbox->searchWindow(transient_for) == 0)
continue;
if (win) {
XMapRequestEvent mre; XWindowAttributes attrib;
mre.window = children[i]; if (XGetWindowAttributes(disp, children[i],
win->mapRequestEvent(mre); &attrib)) {
if (attrib.override_redirect) {
children[i] = None; // we dont need this anymore, since we already created a window for it
// we "created" a window...decrease creation counter
if (--created <= 0)
break; // end for-loop
continue;
}
if (attrib.map_state != IsUnmapped) {
FluxboxWindow *win = createWindow(children[i]);
if (win) {
XMapRequestEvent mre;
mre.window = children[i];
win->mapRequestEvent(mre);
}
} }
} }
children[i] = None; // we dont need this anymore, since we already created a window for it
// we created a window...decrease creation counter
if (--created <= 0)
break; // end for-loop
} }
} }