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

List:       kde-devel
Subject:    Re: [patch] Making it harder to accidentially quit a system tray
From:       Rainer Wirtz <rainer.wirtz () gmx ! de>
Date:       2005-02-17 2:57:45
Message-ID: 200502170357.45907.rainer.wirtz () gmx ! de
[Download RAW message or body]

Am Mittwoch, 16. Februar 2005 18:13 schrieb Esben Mose Hansen:
> On Tuesday 2005-02-15 22:26, Esben Mose Hansen wrote:
> > The attached patch fixes this by disabling Quit for a very short
> > period (0.3s).
> >
> > Please review.
>
> This caused a stir. So I'm not sure what to do.
>
> 1. Is the patch, from a technical viewpoint, ok?
> 2. Is the patch, from a human interaction viewpoint ok?
> 3. Are they anyone *opposed* to committing the patch?
> 4. Are anyone *for* committing this (apart from myself, of course)
>
> And then the big one: Should I commit?

I've tested your patch, and it does not work for me. I even increased 
the block time to a full second to make sure. Admittedly I haven't 
looked too deep into it, so it may be me who's wrong and not your 
patch.

I think your idea is good, but why limit it to ksystray? There are many 
other popup menus with potentially dangerous action that can be 
triggered inadvertently.
So I shamelessly stole your idea and applied it to kpopupmenu, see 
attached patch.
It's a bit crude in that it simply blocks the MouseReleaseEvent, so 
qpopupmenu may get two MousePressEvents without a MouseReleaseEvent in 
between. I have not noted any bad effects of this, though.

What do you all think?

Rainer

PS There's no confirmation dialog appearing when I quit apps from the 
systray. The code is there and kdevelop says it's executed, but no 
dialog, strange.

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

diff -ur kdeui/kpopupmenu.cpp kdeui.patched/kpopupmenu.cpp
--- kdeui/kpopupmenu.cpp	2005-02-17 02:44:41.000000000 +0100
+++ kdeui.patched/kpopupmenu.cpp	2005-02-17 02:38:26.000000000 +0100
@@ -144,6 +144,9 @@
     bool shortcuts : 1;
     bool autoExec : 1;
 
+    bool blockMouseReleaseEvent;
+    QTimer blockTimer;
+
     QString keySeq;
     QString originalText;
 
@@ -167,6 +170,8 @@
     d = new KPopupMenuPrivate;
     resetKeyboardVars();
     connect(&(d->clearTimer), SIGNAL(timeout()), SLOT(resetKeyboardVars()));
+    connect(&(d->blockTimer), SIGNAL(timeout()), SLOT(unblockMouseReleaseEvent()));
+    connect(this, SIGNAL(aboutToShow()), SLOT(blockMouseReleaseEvent()));
 }
 
 KPopupMenu::~KPopupMenu()
@@ -504,9 +509,13 @@
 
 void KPopupMenu::mouseReleaseEvent(QMouseEvent* e)
 {
-    // Save the button, and the modifiers from state()
-    d->state = Qt::ButtonState(e->button() | (e->state() & KeyButtonMask));
-    QPopupMenu::mouseReleaseEvent(e);
+    kdDebug()<<"mouseReleaseEvent"<<d->blockMouseReleaseEvent<<endl;
+    if (!d->blockMouseReleaseEvent)
+    {
+        // Save the button, and the modifiers from state()
+        d->state = Qt::ButtonState(e->button() | (e->state() & KeyButtonMask));
+        QPopupMenu::mouseReleaseEvent(e);
+    }
 }
 
 QPopupMenu* KPopupMenu::contextMenu()
@@ -681,6 +690,19 @@
     d->m_lastTitle = title;
 }
 
+void KPopupMenu::unblockMouseReleaseEvent()
+{
+    kdDebug()<<"unblockMouseReleaseEvent"<<d->blockMouseReleaseEvent<<endl;
+    d->blockMouseReleaseEvent = false;
+}
+
+void KPopupMenu::blockMouseReleaseEvent()
+{
+    kdDebug()<<"blockMouseReleaseEvent"<<d->blockMouseReleaseEvent<<endl;
+    d->blockTimer.start(300, true);
+    d->blockMouseReleaseEvent = true;
+}
+
 void KPopupTitle::virtual_hook( int, void* )
 { /*BASE::virtual_hook( id, data );*/ }
 
diff -ur kdeui/kpopupmenu.h kdeui.patched/kpopupmenu.h
--- kdeui/kpopupmenu.h	2005-02-17 02:44:41.000000000 +0100
+++ kdeui.patched/kpopupmenu.h	2005-02-17 02:20:10.000000000 +0100
@@ -272,7 +272,8 @@
     void showCtxMenu(QPoint pos);
     void ctxMenuHiding();
     void ctxMenuHideShowingMenu();
-
+    void unblockMouseReleaseEvent();
+    void blockMouseReleaseEvent();
 private:
     class KPopupMenuPrivate;
     KPopupMenuPrivate *d;


>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


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

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