Bug 56625 - notes window appears on wrong desktop
Summary: notes window appears on wrong desktop
Status: RESOLVED FIXED
Alias: None
Product: knotes
Classification: Applications
Component: general (show other bugs)
Version: 3.0
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Michael Brade
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-03-30 17:56 UTC by Marco Krohn
Modified: 2003-04-03 19:05 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marco Krohn 2003-03-30 17:56:49 UTC
Version:           3.0 (using KDE 3.1.9)
Compiler:          gcc version 2.95.4 20011002 (Debian prerelease)
OS:          Linux (i686) release 2.4.20

If I go to the title of the note, press the right mouse button and choose "To Desktop" and then choose a number, e.g. "desktop 2" then the note does not appear on "desktop 2", but on "desktop 3". It is always wrong by one, that means n -> n+1.
Comment 1 Lubos Lunak 2003-04-03 19:05:01 UTC
Subject: kdepim/knotes

CVS commit by lunakl: 

Fix #56625 - compensate for the menu separator when using the index.
CCMAIL: 56625-done@bugs.kde.org


  M +15 -7     knote.cpp   1.80
  M +2 -1      knote.h   1.24
  M +1 -1      knotesapp.cpp   1.51


--- kdepim/knotes/knote.cpp  #1.79:1.80
@@ -92,5 +92,5 @@ KNote::KNote( KXMLGUIBuilder* builder, Q
     m_alwaysOnTop = new KToggleAction( i18n("Always on Top"), "attach", 0, this, SLOT(slotToggleAlwaysOnTop()), actionCollection(), "always_on_top" );
     connect( m_alwaysOnTop, SIGNAL(toggled(bool)), m_alwaysOnTop, SLOT(setChecked(bool)) );
-    m_toDesktop = new KListAction( i18n("To Desktop"), 0, this, SLOT(slotToDesktop(int)), actionCollection(), "to_desktop" );
+    m_toDesktop = new KListAction( i18n("To Desktop"), 0, this, SLOT(slotPopupActionToDesktop(int)), actionCollection(), "to_desktop" );
     connect( m_toDesktop->popupMenu(), SIGNAL(aboutToShow()), this, SLOT(slotUpdateDesktopActions()) );
 
@@ -181,5 +181,5 @@ KNote::KNote( KXMLGUIBuilder* builder, Q
         {
             // to avoid flicker, call this before show()
-            slotToDesktop( note_desktop );
+            toDesktop( note_desktop );
             show();
         } else {
@@ -187,5 +187,5 @@ KNote::KNote( KXMLGUIBuilder* builder, Q
             // if this is called before show(),
             // it won't work for sticky notes!!!
-            slotToDesktop( note_desktop );
+            toDesktop( note_desktop );
         }
     }
@@ -367,10 +367,17 @@ void KNote::slotToggleAlwaysOnTop()
 }
 
-void KNote::slotToDesktop( int id )
+void KNote::slotPopupActionToDesktop( int id )
 {
-    if ( id == 0 || id == NETWinInfo::OnAllDesktops )
+    if( id > 1 )
+        --id; // compensate for the menu separator
+    toDesktop( id );
+}
+
+void KNote::toDesktop( int desktop )
+{
+    if ( desktop == 0 || desktop == NETWinInfo::OnAllDesktops )
         KWin::setOnAllDesktops( winId(), true );
     else
-        KWin::setOnDesktop( winId(), id );
+        KWin::setOnDesktop( winId(), desktop );
 }
 
@@ -390,8 +397,9 @@ void KNote::slotUpdateDesktopActions()
     m_toDesktop->setItems( desktops );
 
+    kdDebug() << "updateDesktopActions:" << wm_client.desktop() << endl;
     if ( wm_client.desktop() == NETWinInfo::OnAllDesktops )
         m_toDesktop->setCurrentItem( 0 );
     else
-        m_toDesktop->setCurrentItem( wm_client.desktop() );
+        m_toDesktop->setCurrentItem( wm_client.desktop() + 1 ); // compensate for separator (+1)
 }
 

--- kdepim/knotes/knote.h  #1.23:1.24
@@ -66,4 +66,5 @@ public:
     bool isNew( const QString& app ) const;
     bool isModified( const QString& app ) const;
+    void toDesktop( int desktop );
 
 public slots:
@@ -78,5 +79,5 @@ public slots:
 
     void slotToggleAlwaysOnTop();
-    void slotToDesktop( int id );
+    void slotPopupActionToDesktop( int id );
     void slotUpdateDesktopActions();
 

--- kdepim/knotes/knotesapp.cpp  #1.50:1.51
@@ -447,5 +447,5 @@ void KNotesApp::showNote( KNote* note ) 
         // if not, show note on the current desktop
         note->show();
-        note->slotToDesktop( KWin::currentDesktop() );
+        note->toDesktop( KWin::currentDesktop() );
         KWin::setActiveWindow( note->winId() );
         note->setFocus();