[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kwin
Subject:    [Kwin] client_popup vs active_client
From:       Lubos Lunak <l.lunak () sh ! cvut ! cz>
Date:       2002-07-27 11:01:25
[Download RAW message or body]

Hello,

 after years and years of investigating, I've finally solved the mystery of 
Workspace::client_popup. Ok, or maybe I just could have asked. Anyway, could 
somebody review the attached patch that sends client_popup back to void, 
where it IMNSHO belongs?

 If I understand it correctly, client_popup should be the client for which the 
window operations menu is shown (Alt+F3). The funny part is that this may be 
different from active_client. Try e.g. to activate macmenu, run Konsole, 
select something from the macmenu, hit Alt+F4 to close Konsole, and guess 
what happens. I personally don't undestand why it should be possible to show 
the window operations menu for any other window than the active one, and 
especially the DCOP call showWindowMenuAt() is wierd (wanna close your 
kicker? why not?).

 In short, the patch makes KWin

- wipe out client_popup except for keeping it for BC reasons, replace it with 
active_client wherever it was used
- close the popup menu if active_client changes.
- Workspace::clientPopup() always returns the popup for active_client
- Workspace::showWindowMenuAt() is equal to slotWindowOperations() - all 
arguments are ignored, including the coordinates for it (which IMHO shouldn't 
be there either)
- I added some checks e.g. to prevent keyboard shortcuts to move Kicker or the 
desktop window to different desktop

 The only thing I'm not quite sure about is that requestFocus() in 
slotWindowOperations(). Is there any reason why it should stay, given that 
the window menu operations will be always shown for the active client?

 I tried the patch also with focus follows mouse policies, and I didn't notice 
any problem. Unless somebody says something, I'll commit somewhen by the end 
of the next week.

-- 
 Lubos Lunak
 l.lunak@email.cz ; l.lunak@kde.org
 http://dforce.sh.cvut.cz/~seli

["workspace.cpp.patch" (text/x-diff)]

--- workspace.cpp.sav	Thu Jul 25 15:10:05 2002
+++ workspace.cpp	Fri Jul 26 12:02:16 2002
@@ -766,7 +766,7 @@ bool Workspace::destroyClient( Client* c
     if ( !c )
         return FALSE;
 
-    if (c == popup_client && popup)
+    if (c == active_client && popup)
         popup->close();
 
     storeFakeSessionInfo( c );
@@ -1381,6 +1381,8 @@ void Workspace::setActiveClient( Client*
 {
     if ( active_client == c )
         return;
+    if( popup )
+        popup->close();
     if ( active_client ) {
         active_client->setActive( FALSE );
         if ( active_client->isFullScreen() && active_client->staysOnTop()
@@ -1561,9 +1563,6 @@ void Workspace::requestFocus( Client* c,
         return;
     }
 
-    if ( !popup || !popup->isVisible() )
-        popup_client = c;
-
     if ( c->isVisible() && !c->isShade() ) {
         c->takeFocus( force );
         should_get_focus = c;
@@ -1606,6 +1605,8 @@ void Workspace::clientHidden( Client* c 
     if ( c != active_client && ( active_client ||  c != should_get_focus ) )
         return;
 
+    if( popup )
+        popup->close();
     active_client = 0;
     should_get_focus = 0;
     c->setActive( FALSE ); // clear the state in the client
@@ -1636,9 +1637,9 @@ void Workspace::clientHidden( Client* c 
 }
 
 
-QPopupMenu* Workspace::clientPopup( Client* c )
+// KDE4 - remove the unused argument
+QPopupMenu* Workspace::clientPopup( Client* )
 {
-    popup_client = c;
     if ( !popup ) {
         popup = new QPopupMenu;
         popup->setCheckable( TRUE );
@@ -1684,18 +1685,10 @@ void Workspace::initDesktopPopup()
     popup->insertItem(i18n("To &Desktop"), desk_popup, -1, 8 );
 }
 
-void Workspace::showWindowMenuAt( unsigned long id, int x, int y )
+// KDE4 remove me
+void Workspace::showWindowMenuAt( unsigned long, int, int )
 {
-    Client *target = findClient( id );
-
-    if (!target)
-        return;
-
-    Client* c = active_client;
-    QPopupMenu* p = clientPopup( target );
-    p->exec( QPoint( x, y ) );
-    if ( hasClient( c ) )
-        requestFocus( c );
+    slotWindowOperations();
 }
 
 void Workspace::performWindowOperation( Client* c, Options::WindowOperation op ) {
@@ -1751,7 +1744,7 @@ void Workspace::performWindowOperation( 
 
 void Workspace::clientPopupActivated( int id )
 {
-    performWindowOperation( popup_client, (Options::WindowOperation) id );
+    performWindowOperation( active_client, (Options::WindowOperation) id );
 }
 
 /*!
@@ -2212,6 +2205,8 @@ void Workspace::setCurrentDesktop( int n
 
     Client* old_active_client = active_client;
     active_client = 0;
+    if( popup )
+        popup->close();
     block_focus = TRUE;
 
 //    ClientList mapList;
@@ -2689,10 +2684,11 @@ void Workspace::slotSwitchToDesktop( int
 
 void Workspace::slotWindowToDesktop( int i )
 {
-        if( i >= 1 && i <= numberOfDesktops() && popup_client
-            && ( popup_client->windowType() == NET::Normal
-                || popup_client->windowType() == NET::Dialog ))
-                sendClientToDesktop( popup_client, i );
+        if( i >= 1 && i <= numberOfDesktops() && active_client
+            && !active_client->isDesktop()
+            && !active_client->isDock()
+            && !active_client->isTopMenu())
+                sendClientToDesktop( active_client, i );
 }
 
 /*!
@@ -2700,8 +2696,8 @@ void Workspace::slotWindowToDesktop( int
  */
 void Workspace::slotWindowMaximize()
 {
-    if ( popup_client )
-        popup_client->maximize( Client::MaximizeFull );
+    if ( active_client )
+        active_client->maximize( Client::MaximizeFull );
 }
 
 /*!
@@ -2709,8 +2705,8 @@ void Workspace::slotWindowMaximize()
  */
 void Workspace::slotWindowMaximizeVertical()
 {
-    if ( popup_client )
-        popup_client->maximize( Client::MaximizeVertical );
+    if ( active_client )
+        active_client->maximize( Client::MaximizeVertical );
 }
 
 /*!
@@ -2718,8 +2714,8 @@ void Workspace::slotWindowMaximizeVertic
  */
 void Workspace::slotWindowMaximizeHorizontal()
 {
-    if ( popup_client )
-        popup_client->maximize( Client::MaximizeHorizontal );
+    if ( active_client )
+        active_client->maximize( Client::MaximizeHorizontal );
 }
 
 
@@ -2728,7 +2724,7 @@ void Workspace::slotWindowMaximizeHorizo
  */
 void Workspace::slotWindowIconify()
 {
-    performWindowOperation( popup_client, Options::IconifyOp );
+    performWindowOperation( active_client, Options::IconifyOp );
 }
 
 // This should probably be removed now that there is a "Show Desktop" binding.
@@ -2747,7 +2743,7 @@ void Workspace::slotWindowIconifyAll()
  */
 void Workspace::slotWindowShade()
 {
-    performWindowOperation( popup_client, Options::ShadeOp );
+    performWindowOperation( active_client, Options::ShadeOp );
 }
 
 /*!
@@ -2755,8 +2751,8 @@ void Workspace::slotWindowShade()
  */
 void Workspace::slotWindowRaise()
 {
-    if ( popup_client )
-        raiseClient( popup_client );
+    if ( active_client )
+        raiseClient( active_client );
 }
 
 /*!
@@ -2764,8 +2760,8 @@ void Workspace::slotWindowRaise()
  */
 void Workspace::slotWindowLower()
 {
-    if ( popup_client )
-        lowerClient( popup_client );
+    if ( active_client )
+        lowerClient( active_client );
 }
 
 /*!
@@ -2773,8 +2769,8 @@ void Workspace::slotWindowLower()
   */
 void Workspace::slotWindowRaiseOrLower()
 {
-    if  ( popup_client )
-        raiseOrLowerClient( popup_client );
+    if  ( active_client )
+        raiseOrLowerClient( active_client );
 }
 
 /*!
@@ -2784,8 +2780,9 @@ void Workspace::slotWindowToNextDesktop(
     int d = currentDesktop() + 1;
     if ( d > numberOfDesktops() )
         d = 1;
-    if (popup_client)
-      sendClientToDesktop(popup_client,d);
+    if (active_client && !active_client->isDesktop()
+        && !active_client->isDock() && !active_client->isTopMenu())
+      sendClientToDesktop(active_client,d);
     setCurrentDesktop(d);
     popupinfo->showInfo( desktopName(currentDesktop()) );
 }
@@ -2797,8 +2794,9 @@ void Workspace::slotWindowToPreviousDesk
     int d = currentDesktop() - 1;
     if ( d <= 0 )
         d = numberOfDesktops();
-    if (popup_client)
-      sendClientToDesktop(popup_client,d);
+    if (active_client && !active_client->isDesktop()
+        && !active_client->isDock() && !active_client->isTopMenu())
+      sendClientToDesktop(active_client,d);
     setCurrentDesktop(d);
     popupinfo->showInfo( desktopName(currentDesktop()) );
 }
@@ -2888,7 +2886,7 @@ void Workspace::desktopPopupAboutToShow(
 
     desk_popup->clear();
     desk_popup->insertItem( i18n("&All Desktops"), 0 );
-    if ( popup_client && popup_client->isSticky() )
+    if ( active_client && active_client->isSticky() )
         desk_popup->setItemChecked( 0, TRUE );
     desk_popup->insertSeparator( -1 );
     int id;
@@ -2904,8 +2902,8 @@ void Workspace::desktopPopupAboutToShow(
                     .arg( desktopName(i).replace( QRegExp("&"), "&&" )),
                 i
         );
-        if ( popup_client &&
-             !popup_client->isSticky() && popup_client->desktop()  == i )
+        if ( active_client &&
+             !active_client->isSticky() && active_client->desktop()  == i )
             desk_popup->setItemChecked( id, TRUE );
     }
 }
@@ -2918,7 +2916,7 @@ void Workspace::desktopPopupAboutToShow(
  */
 void Workspace::clientPopupAboutToShow()
 {
-    if ( !popup_client || !popup )
+    if ( !active_client || !popup )
         return;
 
     if ( numberOfDesktops() == 1 )
@@ -2931,15 +2929,15 @@ void Workspace::clientPopupAboutToShow()
         initDesktopPopup();
     }
 
-    popup->setItemEnabled( Options::ResizeOp, popup_client->isResizable() );
-    popup->setItemEnabled( Options::MoveOp, popup_client->isMovable() );
-    popup->setItemEnabled( Options::MaximizeOp, popup_client->isMaximizable() );
-    popup->setItemChecked( Options::MaximizeOp, popup_client->isMaximized() );
-    popup->setItemChecked( Options::ShadeOp, popup_client->isShade() );
-    popup->setItemChecked( Options::StaysOnTopOp, popup_client->staysOnTop() );
-    popup->setItemEnabled( Options::IconifyOp, popup_client->isMinimizable() );
-    popup->setItemEnabled( Options::ToggleStoreSettingsOp, !popup_client->isTransient() );
-    popup->setItemChecked( Options::ToggleStoreSettingsOp, popup_client->storeSettings() );
+    popup->setItemEnabled( Options::ResizeOp, active_client->isResizable() );
+    popup->setItemEnabled( Options::MoveOp, active_client->isMovable() );
+    popup->setItemEnabled( Options::MaximizeOp, active_client->isMaximizable() );
+    popup->setItemChecked( Options::MaximizeOp, active_client->isMaximized() );
+    popup->setItemChecked( Options::ShadeOp, active_client->isShade() );
+    popup->setItemChecked( Options::StaysOnTopOp, active_client->staysOnTop() );
+    popup->setItemEnabled( Options::IconifyOp, active_client->isMinimizable() );
+    popup->setItemEnabled( Options::ToggleStoreSettingsOp, !active_client->isTransient() );
+    popup->setItemChecked( Options::ToggleStoreSettingsOp, active_client->storeSettings() );
 }
 
 
@@ -2993,14 +2991,14 @@ void Workspace::sendClientToDesktop( Cli
  */
 void Workspace::sendToDesktop( int desk )
 {
-    if ( !popup_client )
+    if ( !active_client )
         return;
     if ( desk == 0 ) {
-        popup_client->setSticky( !popup_client->isSticky() );
+        active_client->setSticky( !active_client->isSticky() );
         return;
     }
 
-    sendClientToDesktop( popup_client, desk );
+    sendClientToDesktop( active_client, desk );
 
 }
 
@@ -3012,14 +3010,16 @@ void Workspace::slotWindowOperations()
 {
     if ( !active_client )
         return;
-    if ( active_client->isDesktop())
+    if ( active_client->isDesktop()
+        || active_client->isDock()
+        || active_client->isTopMenu())
         return;
 
     QPopupMenu* p = clientPopup( active_client );
-    Client* c = active_client;
+//    Client* c = active_client;
     p->exec( active_client->mapToGlobal( active_client->windowWrapper()->geometry().topLeft() ) );
-    if ( hasClient( c ) )
-        requestFocus( c );
+//    if ( hasClient( c ) )
+//        requestFocus( c );
 }
 
 
@@ -3030,7 +3030,7 @@ void Workspace::slotWindowClose()
 {
     if ( tab_box->isVisible() || popupinfo->isVisible() )
         return;
-    performWindowOperation( popup_client, Options::CloseOp );
+    performWindowOperation( active_client, Options::CloseOp );
 }
 
 /*!
@@ -3038,7 +3038,7 @@ void Workspace::slotWindowClose()
  */
 void Workspace::slotWindowMove()
 {
-    performWindowOperation( popup_client, Options::MoveOp );
+    performWindowOperation( active_client, Options::MoveOp );
 }
 
 /*!
@@ -3046,7 +3046,7 @@ void Workspace::slotWindowMove()
  */
 void Workspace::slotWindowResize()
 {
-    performWindowOperation( popup_client, Options::ResizeOp );
+    performWindowOperation( active_client, Options::ResizeOp );
 }
 
 

["workspace.h.patch" (text/x-diff)]

--- workspace.h.sav	Sat Jul  6 12:28:50 2002
+++ workspace.h	Fri Jul 26 11:50:19 2002
@@ -196,7 +196,16 @@ public:
 
 
 
+    /**
+     * The Client* argument is ignored, the popup is always returned
+     * for the active client
+     */
     QPopupMenu* clientPopup( Client* );
+
+    /**
+     * @deprecated Use slotWindowOperations() instead.
+     */
+    // KDE4 remove me - and it's also in the DCOP interface :(
     void showWindowMenuAt( unsigned long id, int x, int y );
 
     void iconifyOrDeiconifyTransientsOf( Client* );
@@ -362,7 +371,8 @@ private:
     int number_of_desktops;
     QMemArray<int> desktop_focus_chain;
 
-    QGuardedPtr<Client> popup_client;
+    // KDE4 remove me - unused
+    QGuardedPtr<Client> popup_client__;
 
     void loadSessionInfo();
 

["client.cpp.patch" (text/x-diff)]

--- client.cpp.sav	Thu Jul 25 12:18:54 2002
+++ client.cpp	Thu Jul 25 17:19:22 2002
@@ -584,6 +584,8 @@ Client::~Client()
     if (moveResizeMode)
        stopMoveResize();
     releaseWindow();
+    if( workspace()->activeClient() == this ) // this really shouldn't happen,
+        workspace()->setActiveClient( NULL ); // but just in case
     delete info;
     delete d;
 }

_______________________________________________
Kwin mailing list
Kwin@mail.kde.org
http://mail.kde.org/mailman/listinfo/kwin

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic