From 1266db99018df4ae8103eb28fca058a566c22879 Mon Sep 17 00:00:00 2001 From: Matthias Ettrich Date: Sun, 15 Oct 2000 14:19:15 +0000 Subject: [PATCH] fixed transient_for handling for embedded main windows Patch reviewed by Lars. svn path=/trunk/kdebase/kwin/; revision=67756 --- client.cpp | 32 ++++++++++++++++++++++++++++++++ client.h | 5 +---- workspace.cpp | 9 ++++----- 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/client.cpp b/client.cpp index fab17397d3..74009bd89e 100644 --- a/client.cpp +++ b/client.cpp @@ -443,6 +443,7 @@ Client::Client( Workspace *ws, WId w, QWidget *parent, const char *name, WFlags else { transient_for = (WId) ww; transient_for_defined = TRUE; + verifyTransientFor(); } if ( mainClient()->isSticky() ) @@ -1036,6 +1037,7 @@ bool Client::propertyNotify( XPropertyEvent& e ) } else { transient_for = (WId) ww; transient_for_defined = TRUE; + verifyTransientFor(); } break; case XA_WM_HINTS: @@ -2682,6 +2684,10 @@ void Client::autoRaise() autoRaiseTimer = 0; } +/*! + Clones settings from other client. Used in + Workspace::slotResetAllClients() + */ void Client::cloneMode(Client *client) { shaded = client->shaded; @@ -2697,6 +2703,32 @@ NETWinInfo * Client::netWinInfo() return static_cast(info); } +/*! + The transient_for window may be embedded in another application, + so kwin cannot see it. Try to find the managed client for the + window and fix the transient_for property if possible. + */ +void Client::verifyTransientFor() +{ + unsigned int nwins; + Window root_return, parent_return, *wins; + if ( transient_for == 0 || transient_for == win ) + return; + WId old_transient_for = transient_for; + while ( transient_for && + transient_for != workspace()->rootWin() && + !workspace()->findClient( transient_for ) ) { + wins = 0; + int r = XQueryTree(qt_xdisplay(), transient_for, &root_return, &parent_return, &wins, &nwins); + if ( wins ) + XFree((void *) wins); + if ( r == 0) + break; + transient_for = parent_return; + } + if ( old_transient_for != transient_for && workspace()->findClient( transient_for ) ) + XSetTransientForHint( qt_xdisplay(), win, transient_for ); +} NoBorderClient::NoBorderClient( Workspace *ws, WId w, QWidget *parent, const char *name ) : Client( ws, w, parent, name ) diff --git a/client.h b/client.h index cc4b9d66c1..6b97fa8737 100644 --- a/client.h +++ b/client.h @@ -172,9 +172,6 @@ public: Colormap colormap() const; - /** - * Clone settings from other client. - */ void cloneMode(Client *); public slots: @@ -289,7 +286,7 @@ private: WinInfo* info; QTimer* autoRaiseTimer; Colormap cmap; - + void verifyTransientFor(); }; inline WId Client::window() const diff --git a/workspace.cpp b/workspace.cpp index 40da781698..e1f2027e5b 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -312,7 +312,7 @@ void Workspace::init() setCurrentDesktop( 1 ); unsigned int i, nwins; - Window dw1, dw2, *wins; + Window root_return, parent_return, *wins; XWindowAttributes attr; connect(&mgr, SIGNAL(resetAllClients()), this, @@ -320,8 +320,7 @@ void Workspace::init() connect(kapp, SIGNAL(appearanceChanged()), this, SLOT(slotResetAllClients())); -// XGrabServer( qt_xdisplay() ); - XQueryTree(qt_xdisplay(), root, &dw1, &dw2, &wins, &nwins); + XQueryTree(qt_xdisplay(), root, &root_return, &parent_return, &wins, &nwins); for (i = 0; i < nwins; i++) { XGetWindowAttributes(qt_xdisplay(), wins[i], &attr); if (attr.override_redirect ) @@ -346,8 +345,8 @@ void Workspace::init() } } } - XFree((void *) wins); -// XUngrabServer( qt_xdisplay() ); + if ( wins ) + XFree((void *) wins); propagateClients(); //CT initialize the cascading info