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

List:       kde-core-devel
Subject:    [PATCH]: menu button in window deco
From:       "Aaron J. Seigo" <aseigo () olympusproject ! org>
Date:       2002-07-20 1:20:35
[Download RAW message or body]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi ...

while experimenting with kwin window decorations, i discovered that single 
clicking the menu button when the menu is already shown does not hide the 
menu. this is unlike other menus in KDE.

even worse, double clicking on the menu button actually closes the window! 
this is hidden, destructive, duplicated behaviour that is overloaded onto a 
widget whose purpose is not closing windows (it's popping up a menu).

the attached patch applies to the appropriate window decos in kdebase and 
changes the menu button to hide the popup when clicked if the menu is 
visible, and not to close the window when the button is double clicked.

talking with frederik on IRC i discovered that the "double click == close" is 
how it works (worked?) in Windows. therefore i have left it as is in quartz 
and redmond, since those are both windows-alikes (as i understand it?)

if the patch is approved for committing, i'd like to make similar changes to 
the decos in kdeartwork ...

take care.

- -- 
Aaron J. Seigo
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA  EE75 D6B7 2EB1 A7F1 DB43

"Everything should be made as simple as possible, but not simpler"
    - Albert Einstein
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE9OLrj1rcusafx20MRAnN9AKCF+QGclFETgXzSCCmIFUDA/sbnnwCglNGZ
lC332lEmBDpn5CmaPt0Ekz8=
=50mL
-----END PGP SIGNATURE-----

["menuButton.diff" (text/x-diff)]

Index: b2/b2client.cpp
===================================================================
RCS file: /home/kde/kdebase/kwin/clients/b2/b2client.cpp,v
retrieving revision 1.26
diff -u -3 -d -p -r1.26 b2client.cpp
--- b2/b2client.cpp	2001/11/03 01:21:40	1.26
+++ b2/b2client.cpp	2002/07/20 00:53:04
@@ -778,9 +778,17 @@ void B2Client::activeChange(bool on)
 
 void B2Client::menuButtonPressed()
 {
-    workspace()->clientPopup(this)->
-        popup(button[BtnMenu]->mapToGlobal(button[BtnMenu]->
+    static B2Client *tc = 0;
+    if (tc == this) {
+        workspace()->clientPopup(this)->hide();
+        tc = 0;
+    }
+    else {
+        workspace()->clientPopup(this)->
+            popup(button[BtnMenu]->mapToGlobal(button[BtnMenu]->
                                            rect().bottomLeft()));
+        tc = this;
+    }
 }
 
 void B2Client::slotReset()
Index: default/kdedefault.cpp
===================================================================
RCS file: /home/kde/kdebase/kwin/clients/default/kdedefault.cpp,v
retrieving revision 1.12
diff -u -3 -d -p -r1.12 kdedefault.cpp
--- default/kdedefault.cpp	2002/05/11 18:21:14	1.12
+++ default/kdedefault.cpp	2002/07/20 00:53:04
@@ -1069,22 +1069,21 @@ Client::MousePosition KDEDefaultClient::
 // Make sure the menu button follows double click conventions set in kcontrol
 void KDEDefaultClient::menuButtonPressed()
 {
-    static QTime* t = 0;
     static KDEDefaultClient* tc = 0;
-    if ( !t )
-        t = new QTime;
 
-    if ( tc != this || t->elapsed() > QApplication::doubleClickInterval() )
+    if ( tc == this )
     {
+        workspace()->clientPopup(this)->hide();
+        tc = 0;
+    }
+    else
+    {
         QPoint menupoint ( button[BtnMenu]->rect().bottomLeft().x()-1,
                            button[BtnMenu]->rect().bottomLeft().y()+2 );
         workspace()->clientPopup(this)->popup(
 							button[BtnMenu]->mapToGlobal( menupoint ));
+        tc = this;
     }
-    else closeWindow();
-
-    t->start();
-    tc = this;
 }
 
 
Index: icewm/icewm.cpp
===================================================================
RCS file: /home/kde/kdebase/kwin/clients/icewm/icewm.cpp,v
retrieving revision 1.17
diff -u -3 -d -p -r1.17 icewm.cpp
--- icewm/icewm.cpp	2001/12/29 17:27:17	1.17
+++ icewm/icewm.cpp	2002/07/20 00:53:05
@@ -1354,12 +1354,14 @@ Client::MousePosition IceWMClient::mouse
 // Make sure the menu button follows double click conventions set in kcontrol
 void IceWMClient::menuButtonPressed()
 {
-	static QTime* t = 0;
 	static IceWMClient* tc = 0;
-	if ( !t )
-		t = new QTime;
  
-	if ( tc != this || t->elapsed() > QApplication::doubleClickInterval() )
+	if ( tc == this )
+    {
+        workspace()->clientPopup(this)->hide();
+        tc = 0;
+    }
+    else
 	{
 		QPoint menuPoint ( button[BtnSysMenu]->rect().bottomLeft() );
 
@@ -1370,12 +1372,9 @@ void IceWMClient::menuButtonPressed()
 		// Animate the menu button when pressed
 		if (button[BtnSysMenu])
 			button[BtnSysMenu]->animateClick();
-	}
-	else 
-		closeWindow();
-
-	t->start();
-	tc = this;           
+    
+    	tc = this;           
+    }
 }
 
 
Index: kde1/kde1client.cpp
===================================================================
RCS file: /home/kde/kdebase/kwin/clients/kde1/kde1client.cpp,v
retrieving revision 1.16
diff -u -3 -d -p -r1.16 kde1client.cpp
--- kde1/kde1client.cpp	2002/05/11 22:05:01	1.16
+++ kde1/kde1client.cpp	2002/07/20 00:53:05
@@ -445,12 +445,14 @@ void StdClient::iconChange()
  */
 void StdClient::menuButtonPressed()
 {
-    static QTime* t = 0;
     static StdClient* tc = 0;
-    if ( !t )
-	t = new QTime;
 
-    if ( tc != this || t->elapsed() > QApplication::doubleClickInterval() )
+    if ( tc == this )
+    {
+        workspace()->clientPopup(this)->hide();
+        tc = 0;
+    }
+    else
     {
         QPoint menupoint ( button[0]->rect().bottomLeft().x()-1,
                            button[0]->rect().bottomLeft().y()+2 );
@@ -459,11 +461,9 @@ void StdClient::menuButtonPressed()
 
         // Animate the click when the menu button is pressed
         button[0]->animateClick();
-    } else
-	closeWindow();
-
-    t->start();
-    tc = this;
+    
+        tc = this;
+    }
 }
 
 
Index: keramik/keramik.cpp
===================================================================
RCS file: /home/kde/kdebase/kwin/clients/keramik/keramik.cpp,v
retrieving revision 1.7
diff -u -3 -d -p -r1.7 keramik.cpp
--- keramik/keramik.cpp	2002/07/19 13:33:45	1.7
+++ keramik/keramik.cpp	2002/07/20 00:53:05
@@ -1187,28 +1187,26 @@ void KeramikClient::stickyChange( bool o
 
 void KeramikClient::menuButtonPressed()
 {
-	static QTime *t = NULL;
-	static KeramikClient *tc = NULL;
+	static KeramikClient *tc = 0;
 
-	if ( !t )
-		t = new QTime;
 
-	if ( tc != this || t->elapsed() > QApplication::doubleClickInterval() )
+	if (tc == this)
+	{
+		workspace()->clientPopup( this )->hide();
+		tc = 0;
+	}
+	else
 	{
 		QPoint menuPoint ( button[MenuButton]->rect().bottomLeft().x() - 6, 
-				button[MenuButton]->rect().bottomLeft().y() + 3 );
+					button[MenuButton]->rect().bottomLeft().y() + 3 );
 		workspace()->clientPopup( this )->popup( button[MenuButton]->mapToGlobal( menuPoint ) );
 	
 		// Post a fake mouse button release event to the menu button
 		// to ensure that it's redrawn in its unpressed state
 		QApplication::postEvent( button[MenuButton], new QMouseEvent( QEvent::MouseButtonRelease,
 						QPoint(0,0), Qt::LeftButton, Qt::LeftButton ) );
-	} else
-		closeWindow();
-
-	
-	t->start();
-	tc = this;
+		tc = this;
+	}
 }
 
 
Index: kstep/nextclient.cpp
===================================================================
RCS file: /home/kde/kdebase/kwin/clients/kstep/nextclient.cpp,v
retrieving revision 1.19
diff -u -3 -d -p -r1.19 nextclient.cpp
--- kstep/nextclient.cpp	2002/04/26 02:03:01	1.19
+++ kstep/nextclient.cpp	2002/07/20 00:53:05
@@ -415,14 +415,13 @@ void NextClient::addButtons(QHBoxLayout*
 // (Note: this was almost straight copy and paste from KDEDefaultClient.)
 void NextClient::menuButtonPressed()
 {
-    static QTime* t = 0;
     static NextClient* tc = 0;
-    if ( !t ) {
-        t = new QTime;
-    }
 
-    if ( tc != this || t->elapsed() > QApplication::doubleClickInterval() )
+    if ( tc == this )
     {
+        workspace()->clientPopup(this)->hide();
+        tc = 0;
+    } else {
         // Probably don't need this null check, but we might as well.
         if (button[MENU_IDX]) {
             QPoint menupoint ( button[MENU_IDX]->rect().bottomLeft().x()-1,
@@ -430,12 +429,9 @@ void NextClient::menuButtonPressed()
             workspace()->clientPopup(this)->popup(
                 button[MENU_IDX]->mapToGlobal( menupoint ));
         }
-    } else {
-        closeWindow();
+    
+        tc = this;
     }
-
-    t->start();
-    tc = this;
 }
 
 // Copied, with minor edits, from KDEDefaultClient::slotMaximize()
Index: kwmtheme/kwmthemeclient.cpp
===================================================================
RCS file: /home/kde/kdebase/kwin/clients/kwmtheme/kwmthemeclient.cpp,v
retrieving revision 1.30
diff -u -3 -d -p -r1.30 kwmthemeclient.cpp
--- kwmtheme/kwmthemeclient.cpp	2002/06/25 13:14:19	1.30
+++ kwmtheme/kwmthemeclient.cpp	2002/07/20 00:53:05
@@ -779,22 +779,19 @@ Client::MousePosition KWMThemeClient::mo
 
 void KWMThemeClient::menuButtonPressed()
 {
-    static QTime* t = 0;
     static KWMThemeClient* tc = 0;
-    if ( !t )
-        t = new QTime;
 
-    if ( tc != this || t->elapsed() > QApplication::doubleClickInterval() ){
+    if ( tc == this ) {
+        workspace()->clientPopup(this)->hide();
+        mnuBtn->setPopup(0);
+        tc = 0;
+    }
+    else {
         mnuBtn->setDown(false); // will stay down if I don't do this
         workspace()->clientPopup(this)->
             popup(mnuBtn->mapToGlobal(mnuBtn->rect().bottomLeft()));
+        tc = this;
     }
-    else {
-        mnuBtn->setPopup( 0 );
-        closeWindow();
-    }
-    t->start();
-    tc = this;
 }
 
 void KWMThemeClient::iconChange()


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

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