From 9b9570699bca7bd5a53fcaed6361e2b5dbd697cd Mon Sep 17 00:00:00 2001 From: Bill Soudan Date: Thu, 8 Jun 2000 01:33:53 +0000 Subject: [PATCH] added start-on-proper-desktop support, as well as fixing a few buglets in kwin that this exposed. svn path=/trunk/kdebase/kwin/; revision=52536 --- atoms.cpp | 5 +++++ atoms.h | 2 ++ client.cpp | 42 +++++++++++++++++++++++++++++++++++++----- 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/atoms.cpp b/atoms.cpp index 6710531782..7978bc2210 100644 --- a/atoms.cpp +++ b/atoms.cpp @@ -65,6 +65,11 @@ Atoms::Atoms() atoms[n] = &net_avoid_spec; names[n++] = (char *) "_NET_AVOID_SPEC"; + // FIXME: standardize? KWIN_ prefix is deliberate so this isn't missed + // set by kdelibs/kio/kmapnotify.c + atoms[n] = &kwin_initial_desktop; + names[n++] = (char *) "KWIN_INITIAL_DESKTOP"; // _NET_INITIAL_DESKTOP? + XInternAtoms( qt_xdisplay(), names, n, FALSE, atoms_return ); for (int i = 0; i < n; i++ ) *atoms[i] = atoms_return[i]; diff --git a/atoms.h b/atoms.h index ba4de21754..4a4415c5cb 100644 --- a/atoms.h +++ b/atoms.h @@ -31,6 +31,8 @@ public: Atom net_kde_docking_windows; Atom net_avoid_spec; + Atom kwin_initial_desktop; + }; diff --git a/client.cpp b/client.cpp index cd7db9461d..2ec44d0379 100644 --- a/client.cpp +++ b/client.cpp @@ -328,7 +328,7 @@ Client::Client( Workspace *ws, WId w, QWidget *parent, const char *name, WFlags { avoid = false; anchor = AnchorNorth; - + wspace = ws; win = w; XWindowAttributes attr; @@ -368,6 +368,33 @@ Client::Client( Workspace *ws, WId w, QWidget *parent, const char *name, WFlags setSticky( TRUE ); updateAvoidPolicy(); + + // should we open this window on a certain desktop? + Atom type; + int format; + unsigned long nitems, bytes; + long *data = 0L; + + int status=XGetWindowProperty(qt_xdisplay(), w, atoms->kwin_initial_desktop, 0, 1L, + False, atoms->kwin_initial_desktop, &type, &format, &nitems, &bytes, + (unsigned char **)&data); + + if (status==Success) { + if (nitems>0) + desk=data[0]; // window had the initial desktop property! + + XFree((char *)data); + } + + // if this window is transient, ensure that it is opened on the + // same window as its parent. this is necessary when an application + // starts up on a different desktop than is currently displayed + // + // are there any other cases we need to check? + // + if (transient_for != None) + desk=KWM::desktop(transient_for); + } /*! @@ -450,10 +477,13 @@ void Client::manage( bool isMapped ) XFree(hints); } - // initial desktop placement + // initial desktop placement - note we don't clobber desk if it is + // set to some value, in case the initial desktop code in the + // constructor has already set a value for us if ( info ) { desk = info->desktop; - } else { + } else if (desk<=0) { + // assume window wants to be visible on the current desktop desk = workspace()->currentDesktop(); @@ -461,9 +491,9 @@ void Client::manage( bool isMapped ) desk = KWM::desktop( win ); } + // initial desktop code needs this now KWM::moveToDesktop( win, desk ); // KDE 1.x compatibility - setMappingState( state ); if ( state == NormalState && isOnDesktop( workspace()->currentDesktop() ) ) { Events::raise( isTransient() ? Events::TransNew : Events::New ); @@ -605,7 +635,9 @@ bool Client::mapRequest( XMapRequestEvent& /* e */ ) show(); break; case NormalState: - show(); // for safety + // only show window if we're on current desktop + if (desk == KWM::currentDesktop()) + show(); // for safety break; }