Bug 77783 - when restarting KDE the knotes-windows get distributed randomly over all virtual desktops
Summary: when restarting KDE the knotes-windows get distributed randomly over all virt...
Status: RESOLVED FIXED
Alias: None
Product: knotes
Classification: Unmaintained
Component: general (show other bugs)
Version: unspecified
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Michael Brade
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-03-16 17:55 UTC by O Kullmann
Modified: 2004-03-23 15:18 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description O Kullmann 2004-03-16 17:55:52 UTC
Version:           2.3 (using KDE 3.1.4)
Installed from:    SuSE
Compiler:          gcc version 3.3.1 (SuSE Linux)
OS:          Linux (i686) release 2.4.21-192-default

Related to Bug 62747:

Different to Bug 62747 I have only notes shown on a specific virtual desktop (some of them always in the foreground, some not). When restarting KDE,
the size of likely all the notes and their virtual desktops seems to get
mixed up, and they are all over the places (also with the wrong sizes).

So I have to replace and resize them again and again.

Perhaps this has the same source as 62747, but who knows.
Comment 1 Andreas Von Heydwolff 2004-03-20 22:12:52 UTC
KDE 3.2.1 from current Debian SID, kernel 2.4.24: When I start knotes the screen gets cluttered  with unending masses of empty new notes, CPU usage soars to 98% and I have to kill knotes to stop it. A window flickers in a corner of the  desktop showing the message "copying libcal" ten times per second. In KDE 3.1 everything worked.

Greetings,

A.v. Heydwolff

Comment 2 Michael Brade 2004-03-21 09:37:31 UTC
On Saturday 20 March 2004 22:12, Andreas Von Heydwolff wrote:
> KDE 3.2.1 from current Debian SID, kernel 2.4.24: When I
> start knotes the screen gets cluttered  with unending masses of empty new
> notes, CPU usage soars to 98% and I have to kill knotes to stop it. A
> window flickers in a corner of the  desktop showing the message "copying
> libcal" ten times per second. In KDE 3.1 everything worked.
The bug regarding all black notes is fixed once and for all. The bug not 
restoring note positions I'll work on after CeBIT, but the new bug you just 
described (CPU 98%, flickering window) I have never heard of. Please send me 
your ~/.kde/share/apps/knotes directory zipped privately if there is no 
private data of yours in it.

Thanks,
Comment 3 Michael Brade 2004-03-23 15:18:26 UTC
CVS commit by brade: 

Very Cool! Thanks to Lubos for his function that removes sm from the client
leader KNotes is not managed anymore by KWin (again) and is now thus able to
restore its notes properly on login with manually saved sessions.

CCMAIL: 77783-done@bugs.kde.org, 76034-done@bugs.kde.org, 65744-done@bugs.kde.org


  M +1 -8      knote.cpp   1.108
  M +2 -1      knotesapp.cpp   1.80
  M +37 -1     main.cpp   1.25


--- kdepim/knotes/knote.cpp  #1.107:1.108
@@ -62,6 +62,4 @@
 #include <fixx11h.h>
 
-extern Atom qt_sm_client_id;
-
 using namespace KCal;
 
@@ -73,10 +71,5 @@ KNote::KNote( KXMLGUIBuilder* builder, Q
     m_config( 0 ), m_journal( j )
 {
-    // to disable kwin's session management (ie. saving positions of windows) we need to
-    // remove the session id from all note windows
-    XChangeProperty( x11Display(), winId(), qt_sm_client_id, XA_STRING, 8,
-        PropModeReplace, 0, 0 );
-
-    actionCollection()->setWidget( this );
+    //actionCollection()->setWidget( this );
 
     // if there is no title yet, use the start date if valid

--- kdepim/knotes/knotesapp.cpp  #1.79:1.80
@@ -415,5 +415,6 @@ void KNotesApp::showNote( KNote* note ) 
 void KNotesApp::createNote( KCal::Journal *journal )
 {
-    KNote *newNote = new KNote( this, domDocument(), journal );
+    KNote *newNote = new KNote( this, domDocument(), journal, 
+                                0, journal->uid().utf8() );
     m_noteList.insert( newNote->noteId(), newNote );
 

--- kdepim/knotes/main.cpp  #1.24:1.25
@@ -23,4 +23,8 @@
 #include <kaboutdata.h>
 #include <klocale.h>
+#include <kxerrorhandler.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
 
 #include "knotesapp.h"
@@ -29,4 +33,35 @@
 
 
+void remove_sm_from_client_leader()
+{
+    Atom type;
+    int format, status;
+    unsigned long nitems = 0;
+    unsigned long extra = 0;
+    unsigned char *data = 0;
+
+    Atom atoms[ 2 ];
+    char *atom_names[ 2 ] = { "WM_CLIENT_LEADER", "SM_CLIENT_ID" };
+
+    XInternAtoms( qt_xdisplay(), atom_names, 2, False, atoms );
+
+    QWidget w;
+    KXErrorHandler handler; // ignore X errors
+    status = XGetWindowProperty( qt_xdisplay(), w.winId(), atoms[ 0 ], 0, 10000,
+                                 FALSE, XA_WINDOW, &type, &format,
+                                 &nitems, &extra, &data );
+
+    if (status  == Success && !handler.error( false )) 
+    {
+        if (data && nitems > 0)
+        {
+            Window leader = *((Window*) data);
+            XDeleteProperty( qt_xdisplay(), leader, atoms[ 1 ] );
+        }
+        XFree(data);
+    }
+}
+
+
 Application::Application()
     : KUniqueApplication(), mMainWindow( 0 )
@@ -87,4 +121,6 @@ int main( int argc, char* argv[] )
     app.connect( &app, SIGNAL( lastWindowClosed() ), &app, SLOT( quit() ) );
 
+    remove_sm_from_client_leader();
+
     int rval = app.exec();