summaryrefslogtreecommitdiffstats
path: root/kwin
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-09-15 20:20:48 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-09-15 20:20:48 +0000
commit3bcc1ce0c9fc46449ff6e4bdbca7f9c582192e64 (patch)
tree3111da2539d7df02b244f891809030aad685cfda /kwin
parentff7322912780843dfb3bce1d720452aeed89592e (diff)
downloadtdebase-3bcc1ce0c9fc46449ff6e4bdbca7f9c582192e64.tar.gz
tdebase-3bcc1ce0c9fc46449ff6e4bdbca7f9c582192e64.zip
Allow kwin to replace itself automatically
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1253854 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kwin')
-rw-r--r--kwin/main.cpp51
1 files changed, 49 insertions, 2 deletions
diff --git a/kwin/main.cpp b/kwin/main.cpp
index 8a15c219c..efd788ad6 100644
--- a/kwin/main.cpp
+++ b/kwin/main.cpp
@@ -100,8 +100,50 @@ Application::Application( )
if( !owner.claim( args->isSet( "replace" ), true ))
{
- fputs(i18n("kwin: unable to claim manager selection, another wm running? (try using --replace)\n").local8Bit(), stderr);
- ::exit(1);
+ Display* dpy = qt_xdisplay();
+ Window w;
+ Atom a;
+ static char net_wm_sm[] = "WM_Sxx";
+
+ snprintf (net_wm_sm, sizeof (net_wm_sm), "WM_S%d", screen_number);
+ a = XInternAtom (dpy, net_wm_sm, False);
+
+ w = XGetSelectionOwner (dpy, a);
+
+ if (w != None)
+ {
+ Atom actual;
+ int format;
+ unsigned long n, left;
+ unsigned char *data;
+ Atom kwinRunningAtom = XInternAtom (dpy, "_KDE_WM_IS_KWIN", True);
+
+ int result = XGetWindowProperty (dpy, w, kwinRunningAtom, 0L, 1L, False,
+ XA_ATOM, &actual, &format,
+ &n, &left, &data);
+
+ if (result == Success && data != None && format == 32 )
+ {
+ Atom a;
+ a = *(long*)data;
+ XFree ( (void *) data);
+ if( !owner.claim( true, true ))
+ {
+ fputs(i18n("kwin: unable to claim manager selection, another wm running? (try using --replace)\n").local8Bit(), stderr);
+ ::exit(1);
+ }
+ }
+ else
+ {
+ fputs(i18n("kwin: unable to claim manager selection, another wm running? (try using --replace)\n").local8Bit(), stderr);
+ ::exit(1);
+ }
+ }
+ else
+ {
+ fputs(i18n("kwin: unable to claim manager selection, another wm running? (try using --replace)\n").local8Bit(), stderr);
+ ::exit(1);
+ }
}
connect( &owner, TQT_SIGNAL( lostOwnership()), TQT_SLOT( lostSelection()));
@@ -120,6 +162,11 @@ Application::Application( )
options = new Options;
atoms = new Atoms;
+ // Signal that we are The KWin!
+ Atom kde_wm_system_modal_notification;
+ kde_wm_system_modal_notification = XInternAtom(qt_xdisplay(), "_KDE_WM_IS_KWIN", False);
+ XChangeProperty(qt_xdisplay(), owner.ownerWindow(), kde_wm_system_modal_notification, XA_INTEGER, 32, PropModeReplace, (unsigned char *) "TRUE", 1L);
+
// create workspace.
(void) new Workspace( isSessionRestored() );