[patch] b2 window decoration

Luciano Montanaro mikelima at virgilio.it
Tue Jul 23 10:40:27 BST 2002


Hello, 
this patch has been ignored for a while on the kwin list.
The stirring about the inconsistent menu button double click
made me dig again for it, for a possible inclusion.
My original message and patch follows.
Luciano


--------------Boundary-00=_ZEYA4ZL50VM898TNI60F
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Hello,=20
I played around a bit with the b2 client for kwin.=20
I added the ability to double-click on the menu button to close the windo=
w,=20
as most other clients do, and adding spacers now works.
I sent the patch to kde-devel for review (bad place, probably), and someo=
ne=20
hinted that the QTime * in the double click code is leaked when changing=20
theme. I changed my code around, and here is the result.
I also fixed the default theme.
If the patches are good, I'd like them to be applied to both the trunk an=
d=20
KDE 3.0 branches.
=20
--=20
Luciano Montanaro//
               \x/ mikelima at virgilio.it

--------------Boundary-00=_ZEYA4ZL50VM898TNI60F
Content-Type: text/x-diff;
  charset="us-ascii";
  name="b2.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="b2.diff"

diff -u b2/b2client.cpp b2.ml/b2client.cpp
--- b2/b2client.cpp	Sat Nov  3 02:21:40 2001
+++ b2.ml/b2client.cpp	Tue Apr  2 07:42:29 2002
@@ -500,6 +500,8 @@
                             this, SLOT(closeWindow()));
                     titleLayout->addWidget(button[BtnClose]);
                 }
+	    case '_': // Spacer item (only for non-tool windows)
+		if (!isTool()) titleLayout->addSpacing(2);
 	}
     } 
 }
@@ -778,16 +780,24 @@
 
 void B2Client::menuButtonPressed()
 {
-    workspace()->clientPopup(this)->
-        popup(button[BtnMenu]->mapToGlobal(button[BtnMenu]->
-                                           rect().bottomLeft()));
+    static B2Client* tc = 0;
+
+    if (tc != this || t.elapsed() > QApplication::doubleClickInterval()) {
+        workspace()->clientPopup(this)->popup(
+		button[BtnMenu]->mapToGlobal(
+		    button[BtnMenu]->rect().bottomLeft()));
+    } else {
+        closeWindow();
+    }
+    t.start();
+    tc = this;
 }
 
 void B2Client::slotReset()
 {
     redraw_pixmaps();
-    QColor c = options->colorGroup(Options::TitleBar, isActive()).
-        color(QColorGroup::Button);
+    QColor c = options->colorGroup(Options::TitleBar, 
+		    isActive()).color(QColorGroup::Button);
 
     for(int i = 0; i < BtnCount; i++)
         if (button[i]) {
diff -u b2/b2client.h b2.ml/b2client.h
--- b2/b2client.h	Sat Sep  8 12:12:23 2001
+++ b2.ml/b2client.h	Tue Apr  2 08:00:01 2002
@@ -12,6 +12,7 @@
 
 #include <qvariant.h>
 #include <qbitmap.h>
+#include <qdatetime.h>
 #include <kpixmap.h>
 #include "../../client.h"
 #include "../../kwinbutton.h"
@@ -118,6 +119,7 @@
         BtnHelp, BtnCount};
     B2Button* button[BtnCount];
     QGridLayout *g;
+    QTime t;
     int bar_x_ofs;
     B2Titlebar *titlebar;
     int in_unobs;

--------------Boundary-00=_ZEYA4ZL50VM898TNI60F
Content-Type: text/x-diff;
  charset="us-ascii";
  name="default.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="default.diff"

Common subdirectories: default.orig/.deps and default/.deps
Only in default.orig/: .libs
Common subdirectories: default.orig/CVS and default/CVS
Common subdirectories: default.orig/config and default/config
diff -u default.orig/kdedefault.cpp default/kdedefault.cpp
--- default.orig/kdedefault.cpp	Fri Apr  5 21:22:17 2002
+++ default/kdedefault.cpp	Fri Apr  5 21:23:59 2002
@@ -1064,12 +1064,9 @@
 // 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 || t.elapsed() > QApplication::doubleClickInterval() )
     {
         QPoint menupoint ( button[BtnMenu]->rect().bottomLeft().x()-1,
                            button[BtnMenu]->rect().bottomLeft().y()+2 );
@@ -1078,7 +1075,7 @@
     }
     else closeWindow();
 
-    t->start();
+    t.start();
     tc = this;
 }
 
diff -u default.orig/kdedefault.h default/kdedefault.h
--- default.orig/kdedefault.h	Fri Apr  5 21:22:17 2002
+++ default/kdedefault.h	Tue Apr  9 15:09:59 2002
@@ -16,6 +16,7 @@
 
 #include <qbutton.h>
 #include <qbitmap.h>
+#include <qdatetime.h>
 #include <kpixmap.h>
 #include "../../client.h"
 #include "../../kwinbutton.h"
@@ -111,9 +112,9 @@
 		bool          largeButtons;
 		QHBoxLayout*  hb;
 		QSpacerItem*  titlebar;
+        QTime t;
 };
 
 };
-
 #endif
 // vim: ts=4
Only in default.orig/: kdedefault.moc
Only in default.orig/: kwin_default.la
Only in default.orig/: kwin_default.la.closure
Only in default.orig/: kwin_default_la.all_cpp.cpp
Only in default.orig/: kwin_default_la.all_cpp.lo
Only in default.orig/: kwin_default_la_meta_unload.cpp

--------------Boundary-00=_ZEYA4ZL50VM898TNI60F--






More information about the kde-core-devel mailing list