summaryrefslogtreecommitdiff
path: root/lxqt-base/lxqt-panel/files/lxqt-panel-0.10.0-autohide.patch
blob: 5f2bbdae6f23fd646e459984c9230815265a8d2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
Patch for autohide issue https://github.com/lxde/lxqt/issues/871
taken from https://github.com/lxde/lxqt-panel/pull/275

diff --git panel/CMakeLists.txt panel/CMakeLists.txt
index 4e23b53..a7f8176 100644
--- panel/CMakeLists.txt
+++ panel/CMakeLists.txt
@@ -2,6 +2,7 @@ set(PROJECT lxqt-panel)
 
 set(PRIV_HEADERS
     panelpluginsmodel.h
+    windownotifier.h
     lxqtpanel.h
     lxqtpanelapplication.h
     lxqtpanellayout.h
@@ -26,6 +27,7 @@ set(PUB_HEADERS
 set(SOURCES
     main.cpp
     panelpluginsmodel.cpp
+    windownotifier.cpp
     lxqtpanel.cpp
     lxqtpanelapplication.cpp
     lxqtpanellayout.cpp
diff --git panel/ilxqtpanel.h panel/ilxqtpanel.h
index e7b2844..71e4990 100644
--- panel/ilxqtpanel.h
+++ panel/ilxqtpanel.h
@@ -32,6 +32,7 @@
 #include "lxqtpanelglobals.h"
 
 class ILXQtPanelPlugin;
+class QWidget;
 
 /**
  **/
@@ -74,6 +75,17 @@ public:
      **/
     virtual QRect calculatePopupWindowPos(const QPoint &absolutePos, const QSize &windowSize) const = 0;
     virtual QRect calculatePopupWindowPos(const ILXQtPanelPlugin *plugin, const QSize &windowSize) const = 0;
+
+    /*!
+     * \brief By calling this function plugin (or any other object) notifies the panel
+     * about showing a (standalone) window/menu -> panel needs this to avoid "hiding" in case any
+     * standalone window is shown. The widget must be shown later than this notification call because
+     * panel need to observe it's show/hide/close events.
+     *
+     * \param w the shown window
+     *
+     */
+    virtual void willShowWindow(QWidget * w) = 0;
 };
 
 #endif // ILXQTPANEL_H
diff --git panel/ilxqtpanelplugin.h panel/ilxqtpanelplugin.h
index 1503923..3a09def 100644
--- panel/ilxqtpanelplugin.h
+++ panel/ilxqtpanelplugin.h
@@ -186,6 +186,16 @@ public:
         return mPanel->calculatePopupWindowPos(this, windowSize);
     }
 
+    /*!
+     * \brief By calling this function plugin notifies the panel about showing a (standalone) window/menu.
+     *
+     * \param w the shown window
+     *
+     */
+    inline void willShowWindow(QWidget * w)
+    {
+        mPanel->willShowWindow(w);
+    }
 
     virtual bool isSeparate() const { return false;  }
     virtual bool isExpandable() const { return false; }
diff --git panel/lxqtpanel.cpp panel/lxqtpanel.cpp
index 5159c15..d6b70ca 100644
--- panel/lxqtpanel.cpp
+++ panel/lxqtpanel.cpp
@@ -35,6 +35,7 @@
 #include "popupmenu.h"
 #include "plugin.h"
 #include "panelpluginsmodel.h"
+#include "windownotifier.h"
 #include <LXQt/PluginInfo>
 
 #include <QScreen>
@@ -116,6 +117,7 @@ LXQtPanel::LXQtPanel(const QString &configGroup, LXQt::Settings *settings, QWidg
     mSettings(settings),
     mConfigGroup(configGroup),
     mPlugins{nullptr},
+    mStandaloneWindows{new WindowNotifier},
     mPanelSize(0),
     mIconSize(0),
     mLineCount(0),
@@ -175,6 +177,9 @@ LXQtPanel::LXQtPanel(const QString &configGroup, LXQt::Settings *settings, QWidg
     connect(LXQt::Settings::globalSettings(), SIGNAL(settingsChanged()), this, SLOT(update()));
     connect(lxqtApp, SIGNAL(themeChanged()), this, SLOT(realign()));
 
+    connect(mStandaloneWindows.data(), &WindowNotifier::firstShown, this, &LXQtPanel::showPanel);
+    connect(mStandaloneWindows.data(), &WindowNotifier::lastHidden, this, &LXQtPanel::hidePanel);
+
     readSettings();
     // the old position might be on a visible screen
     ensureVisible();
@@ -589,6 +594,7 @@ void LXQtPanel::showConfigDialog()
         mConfigDialog = new ConfigPanelDialog(this, nullptr /*make it top level window*/);
 
     mConfigDialog->showConfigPanelPage();
+    mStandaloneWindows->observeWindow(mConfigDialog.data());
     mConfigDialog->show();
     mConfigDialog->raise();
     mConfigDialog->activateWindow();
@@ -608,6 +614,7 @@ void LXQtPanel::showAddPluginDialog()
         mConfigDialog = new ConfigPanelDialog(this, nullptr /*make it top level window*/);
 
     mConfigDialog->showConfigPluginsPage();
+    mStandaloneWindows->observeWindow(mConfigDialog.data());
     mConfigDialog->show();
     mConfigDialog->raise();
     mConfigDialog->activateWindow();
@@ -967,6 +974,7 @@ void LXQtPanel::showPopupMenu(Plugin *plugin)
      * of QDesktopWidget::availableGeometry)
      */
     menu->setGeometry(calculatePopupWindowPos(QCursor::pos(), menu->sizeHint()));
+    willShowWindow(menu);
     menu->show();
 }
 
@@ -1043,6 +1051,14 @@ QRect LXQtPanel::calculatePopupWindowPos(const ILXQtPanelPlugin *plugin, const Q
 /************************************************
 
  ************************************************/
+void LXQtPanel::willShowWindow(QWidget * w)
+{
+    mStandaloneWindows->observeWindow(w);
+}
+
+/************************************************
+
+ ************************************************/
 QString LXQtPanel::qssPosition() const
 {
     return positionToStr(position());
@@ -1107,20 +1123,17 @@ void LXQtPanel::showPanel()
 
 void LXQtPanel::hidePanel()
 {
-    if (mHidable && !mHidden)
+    if (mHidable && !mHidden
+            && !geometry().contains(QCursor::pos())
+            && !mStandaloneWindows->isAnyWindowShown()
+       )
         mHideTimer.start();
 }
 
 void LXQtPanel::hidePanelWork()
 {
-    if (mHidable && !mHidden && !geometry().contains(QCursor::pos()))
-    {
-        mHidden = true;
-        setPanelGeometry();
-    } else
-    {
-        mHideTimer.start();
-    }
+    mHidden = true;
+    setPanelGeometry();
 }
 
 void LXQtPanel::setHidable(bool hidable, bool save)
@@ -1128,7 +1141,7 @@ void LXQtPanel::setHidable(bool hidable, bool save)
     if (mHidable == hidable)
         return;
 
-    mHidable = mHidden = hidable;
+    mHidable = hidable;
 
     if (save)
         saveSettings(true);
diff --git panel/lxqtpanel.h panel/lxqtpanel.h
index 8ff4b8c..990063f 100644
--- panel/lxqtpanel.h
+++ panel/lxqtpanel.h
@@ -48,6 +48,7 @@ class PluginInfo;
 class LXQtPanelLayout;
 class ConfigPanelDialog;
 class PanelPluginsModel;
+class WindowNotifier;
 
 /*! \brief The LXQtPanel class provides a single lxqt-panel.
  */
@@ -80,11 +81,12 @@ public:
     void showPopupMenu(Plugin *plugin = 0);
 
     // ILXQtPanel .........................
-    ILXQtPanel::Position position() const { return mPosition; }
-    QRect globalGometry() const;
+    ILXQtPanel::Position position() const override { return mPosition; }
+    QRect globalGometry() const override;
     Plugin *findPlugin(const ILXQtPanelPlugin *iPlugin) const;
-    QRect calculatePopupWindowPos(QPoint const & absolutePos, QSize const & windowSize) const;
-    QRect calculatePopupWindowPos(const ILXQtPanelPlugin *plugin, const QSize &windowSize) const;
+    QRect calculatePopupWindowPos(QPoint const & absolutePos, QSize const & windowSize) const override;
+    QRect calculatePopupWindowPos(const ILXQtPanelPlugin *plugin, const QSize &windowSize) const override;
+    void willShowWindow(QWidget * w) override;
 
     // For QSS properties ..................
     QString qssPosition() const;
@@ -95,8 +97,8 @@ public:
 
     // Settings
     int panelSize() const { return mPanelSize; }
-    int iconSize() const { return mIconSize; }
-    int lineCount() const { return mLineCount; }
+    int iconSize() const override { return mIconSize; }
+    int lineCount() const override { return mLineCount; }
     int length() const { return mLength; }
     bool lengthInPercents() const { return mLengthInPercents; }
     LXQtPanel::Alignment alignment() const { return mAlignment; }
@@ -138,8 +140,8 @@ signals:
     void pluginRemoved();
 
 protected:
-    bool event(QEvent *event);
-    void showEvent(QShowEvent *event);
+    bool event(QEvent *event) override;
+    void showEvent(QShowEvent *event) override;
 
 public slots:
     void showConfigDialog();
@@ -156,6 +158,7 @@ private:
     QFrame *LXQtPanelWidget;
     QString mConfigGroup;
     QScopedPointer<PanelPluginsModel> mPlugins;
+    QScopedPointer<WindowNotifier> mStandaloneWindows; //!< object for storing info if some standalone window is shown (for preventing hide)
 
     int findAvailableScreen(LXQtPanel::Position position);
     void updateWmStrut();
diff --git panel/plugin.cpp panel/plugin.cpp
index a4acc78..be23a8e 100644
--- panel/plugin.cpp
+++ panel/plugin.cpp
@@ -477,6 +477,7 @@ void Plugin::showConfigureDialog()
     if (!dialog)
         return;
 
+    mPanel->willShowWindow(dialog);
     dialog->show();
     dialog->raise();
     dialog->activateWindow();
diff --git panel/windownotifier.cpp panel/windownotifier.cpp
new file mode 100644
index 0000000..0b41057
--- /dev/null
+++ panel/windownotifier.cpp
@@ -0,0 +1,65 @@
+/* BEGIN_COMMON_COPYRIGHT_HEADER
+ * (c)LGPL2+
+ *
+ * LXQt - a lightweight, Qt based, desktop toolset
+ * http://lxqt.org
+ *
+ * Copyright: 2015 LXQt team
+ * Authors:
+ *   Palo Kisa <palo.kisa@gmail.com>
+ *
+ * This program or library is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ *
+ * END_COMMON_COPYRIGHT_HEADER */
+
+#include "windownotifier.h"
+#include <QWidget>
+#include <QEvent>
+
+void WindowNotifier::observeWindow(QWidget * w)
+{
+    //installing the same filter object multiple times doesn't harm
+    w->installEventFilter(this);
+}
+
+
+bool WindowNotifier::eventFilter(QObject * watched, QEvent * event)
+{
+    QWidget * widget = qobject_cast<QWidget *>(watched); //we're observing only QWidgetw
+    auto it = std::lower_bound(mShownWindows.begin(), mShownWindows.end(), widget);
+    switch (event->type())
+    {
+        case QEvent::Close:
+            watched->removeEventFilter(this);
+            //no break
+        case QEvent::Hide:
+            Q_ASSERT(mShownWindows.end() != it);
+            mShownWindows.erase(it);
+            if (mShownWindows.isEmpty())
+                emit lastHidden();
+            break;
+        case QEvent::Show:
+            {
+                const bool first_shown = mShownWindows.isEmpty();
+                mShownWindows.insert(it, widget); //we keep the mShownWindows sorted
+                if (first_shown)
+                    emit firstShown();
+            }
+        default:
+            break;
+    }
+    return false;
+}
diff --git panel/windownotifier.h panel/windownotifier.h
new file mode 100644
index 0000000..53f2f3f
--- /dev/null
+++ panel/windownotifier.h
@@ -0,0 +1,53 @@
+/* BEGIN_COMMON_COPYRIGHT_HEADER
+ * (c)LGPL2+
+ *
+ * LXQt - a lightweight, Qt based, desktop toolset
+ * http://lxqt.org
+ *
+ * Copyright: 2015 LXQt team
+ * Authors:
+ *   Palo Kisa <palo.kisa@gmail.com>
+ *
+ * This program or library is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ *
+ * END_COMMON_COPYRIGHT_HEADER */
+
+#if !defined(WINDOWNOTIFIER_H)
+#define WINDOWNOTIFIER_H
+
+#include <QObject>
+
+class QWidget;
+
+class WindowNotifier : public QObject
+{
+    Q_OBJECT
+public:
+    using QObject::QObject;
+
+    void observeWindow(QWidget * w);
+    inline bool isAnyWindowShown() const { return !mShownWindows.isEmpty(); }
+
+    virtual bool eventFilter(QObject * watched, QEvent * event) override;
+signals:
+    void lastHidden();
+    void firstShown();
+
+private:
+    QList<QWidget *> mShownWindows; //!< known shown windows (sorted)
+};
+
+#endif
diff --git plugin-clock/lxqtclock.cpp plugin-clock/lxqtclock.cpp
index 79c2c17..d4603de 100644
--- plugin-clock/lxqtclock.cpp
+++ plugin-clock/lxqtclock.cpp
@@ -286,6 +286,7 @@ void LXQtClock::activated(ActivationReason reason)
     {
         QRect pos = calculatePopupWindowPos(mCalendarPopup->size());
         mCalendarPopup->move(pos.topLeft());
+        willShowWindow(mCalendarPopup);
         mCalendarPopup->show();
     }
     else
diff --git plugin-directorymenu/directorymenu.cpp plugin-directorymenu/directorymenu.cpp
index 8c5ec28..e332e05 100644
--- plugin-directorymenu/directorymenu.cpp
+++ plugin-directorymenu/directorymenu.cpp
@@ -58,11 +58,11 @@ DirectoryMenu::DirectoryMenu(const ILXQtPanelPluginStartupInfo &startupInfo) :
 
 DirectoryMenu::~DirectoryMenu()
 {
-	if(mMenu)
-	{
-		delete mMenu;
-		mMenu = 0;
-	}
+    if(mMenu)
+    {
+        delete mMenu;
+        mMenu = 0;
+    }
 }
 
 void DirectoryMenu::showMenu()
@@ -102,67 +102,67 @@ void DirectoryMenu::showMenu()
             break;
     }
 
+    willShowWindow(mMenu);
     // Just using Qt`s activateWindow() won't work on some WMs like Kwin.
     // Solution is to execute menu 1ms later using timer
-    mButton.activateWindow();
-    mMenu->exec(QPoint(x, y));
+    mMenu->popup(calculatePopupWindowPos(mMenu->sizeHint()).topLeft());
 }
 
 void DirectoryMenu::buildMenu(const QString& path)
 {
-	if(mMenu)
-	{
-		delete mMenu;
-		mMenu = 0;
-	}
+    if(mMenu)
+    {
+        delete mMenu;
+        mMenu = 0;
+    }
 
-	mPathStrings.clear();
+    mPathStrings.clear();
 
-	mMenu = new QMenu();
+    mMenu = new QMenu();
 
-	addActions(mMenu, path);
+    addActions(mMenu, path);
 }
 
 void DirectoryMenu::openDirectory(const QString& path)
 {
-	QDesktopServices::openUrl(QUrl("file://" + QDir::toNativeSeparators(path)));
+    QDesktopServices::openUrl(QUrl("file://" + QDir::toNativeSeparators(path)));
 }
 
 void DirectoryMenu::addMenu(QString path)
 {
-	QSignalMapper* sender = (QSignalMapper* )QObject::sender();
-	QMenu* parentMenu = (QMenu*) sender->mapping(path);
+    QSignalMapper* sender = (QSignalMapper* )QObject::sender();
+    QMenu* parentMenu = (QMenu*) sender->mapping(path);
 
-	if(parentMenu->isEmpty())
-	{
-		addActions(parentMenu, path);
-	}
+    if(parentMenu->isEmpty())
+    {
+        addActions(parentMenu, path);
+    }
 }
 
 void DirectoryMenu::addActions(QMenu* menu, const QString& path)
 {
-	mPathStrings.push_back(path);
+    mPathStrings.push_back(path);
 
-	QAction* openDirectoryAction = menu->addAction(XdgIcon::fromTheme("folder"), tr("Open"));
-	connect(openDirectoryAction, SIGNAL(triggered()), mOpenDirectorySignalMapper, SLOT(map()));
-	mOpenDirectorySignalMapper->setMapping(openDirectoryAction, mPathStrings.back());
+    QAction* openDirectoryAction = menu->addAction(XdgIcon::fromTheme("folder"), tr("Open"));
+    connect(openDirectoryAction, SIGNAL(triggered()), mOpenDirectorySignalMapper, SLOT(map()));
+    mOpenDirectorySignalMapper->setMapping(openDirectoryAction, mPathStrings.back());
 
-	menu->addSeparator();
+    menu->addSeparator();
 
-	QDir dir(path);
-	QFileInfoList list = dir.entryInfoList();
+    QDir dir(path);
+    QFileInfoList list = dir.entryInfoList();
 
-	foreach (const QFileInfo& entry, list)
+    foreach (const QFileInfo& entry, list)
     {
-    	if(entry.isDir() && !entry.isHidden())
-    	{
-			mPathStrings.push_back(entry.fileName());
+        if(entry.isDir() && !entry.isHidden())
+        {
+            mPathStrings.push_back(entry.fileName());
 
-			QMenu* subMenu = menu->addMenu(XdgIcon::fromTheme("folder"), mPathStrings.back());
+            QMenu* subMenu = menu->addMenu(XdgIcon::fromTheme("folder"), mPathStrings.back());
 
-    		connect(subMenu, SIGNAL(aboutToShow()), mMenuSignalMapper, SLOT(map()));
-    		mMenuSignalMapper->setMapping(subMenu, entry.absoluteFilePath());
-    	}
+            connect(subMenu, SIGNAL(aboutToShow()), mMenuSignalMapper, SLOT(map()));
+            mMenuSignalMapper->setMapping(subMenu, entry.absoluteFilePath());
+        }
     }
 }
 
diff --git plugin-dom/domplugin.cpp plugin-dom/domplugin.cpp
index ffd05c6..0988a2b 100644
--- plugin-dom/domplugin.cpp
+++ plugin-dom/domplugin.cpp
@@ -51,6 +51,7 @@ void DomPlugin::showDialog()
         dialog->setAttribute(Qt::WA_DeleteOnClose);
     }
 
+    willShowWindow(dialog);
     dialog->show();
     dialog->activateWindow();
 }
diff --git plugin-mainmenu/lxqtmainmenu.cpp plugin-mainmenu/lxqtmainmenu.cpp
index 9673a4f..b9ff6e4 100644
--- plugin-mainmenu/lxqtmainmenu.cpp
+++ plugin-mainmenu/lxqtmainmenu.cpp
@@ -130,6 +130,7 @@ void LXQtMainMenu::showMenu()
     if (!mMenu)
         return;
 
+    willShowWindow(mMenu);
     // Just using Qt`s activateWindow() won't work on some WMs like Kwin.
     // Solution is to execute menu 1ms later using timer
     mMenu->popup(calculatePopupWindowPos(mMenu->sizeHint()).topLeft());
@@ -227,8 +228,6 @@ void LXQtMainMenu::buildMenu()
     menu->installEventFilter(this);
     connect(menu, &QMenu::aboutToHide, &mHideTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
     connect(menu, &QMenu::aboutToShow, &mHideTimer, &QTimer::stop);
-    // panel notification (needed in case of auto-hide)
-    connect(menu, &QMenu::aboutToHide, dynamic_cast<LXQtPanel *>(panel()), &LXQtPanel::hidePanel);
 
     QMenu *oldMenu = mMenu;
     mMenu = menu;
diff --git plugin-mount/popup.cpp plugin-mount/popup.cpp
index 1c3e7c1..7993681 100644
--- plugin-mount/popup.cpp
+++ plugin-mount/popup.cpp
@@ -90,7 +90,12 @@ Popup::Popup(ILXQtPanelPlugin * plugin, QWidget* parent):
 
 void Popup::showHide()
 {
-    setVisible(isHidden());
+    if (isHidden())
+    {
+        mPlugin->willShowWindow(this);
+        show();
+    } else
+        close();
 }
 
 void Popup::onDeviceAdded(QString const & udi)
diff --git plugin-statusnotifier/statusnotifierbutton.cpp plugin-statusnotifier/statusnotifierbutton.cpp
index fb124c6..71cf78f 100644
--- plugin-statusnotifier/statusnotifierbutton.cpp
+++ plugin-statusnotifier/statusnotifierbutton.cpp
@@ -249,8 +249,10 @@ void StatusNotifierButton::mouseReleaseEvent(QMouseEvent *event)
     else if (Qt::RightButton == event->button())
     {
         if (mMenu)
-            mMenu->popup(QCursor::pos());
-        else
+        {
+            mPlugin->willShowWindow(mMenu);
+            mMenu->popup(mPlugin->calculatePopupWindowPos(mMenu->sizeHint()).topLeft());
+        } else
             interface->ContextMenu(QCursor::pos().x(), QCursor::pos().y());
     }
 
diff --git plugin-taskbar/lxqttaskgroup.cpp plugin-taskbar/lxqttaskgroup.cpp
index 6828216..79e27f5 100644
--- plugin-taskbar/lxqttaskgroup.cpp
+++ plugin-taskbar/lxqttaskgroup.cpp
@@ -84,6 +84,7 @@ void LXQtTaskGroup::contextMenuEvent(QContextMenuEvent *event)
         mPreventPopup = false;
     });
     menu->setGeometry(mPlugin->panel()->calculatePopupWindowPos(mapToGlobal(event->pos()), menu->sizeHint()));
+    mPlugin->willShowWindow(menu);
     menu->show();
 }
 
@@ -418,6 +419,7 @@ void LXQtTaskGroup::setPopupVisible(bool visible, bool fast)
             recalculateFramePosition();
         }
 
+        mPlugin->willShowWindow(mPopup);
         mPopup->show();
         emit popupShown(this);
     }
diff --git plugin-volume/volumebutton.cpp plugin-volume/volumebutton.cpp
index a738a1a..98b3f10 100644
--- plugin-volume/volumebutton.cpp
+++ plugin-volume/volumebutton.cpp
@@ -133,6 +133,7 @@ void VolumeButton::showVolumeSlider()
     m_volumePopup->updateGeometry();
     m_volumePopup->adjustSize();
     QRect pos = mPlugin->calculatePopupWindowPos(m_volumePopup->size());
+    mPlugin->willShowWindow(m_volumePopup);
     m_volumePopup->openAt(pos.topLeft(), Qt::TopLeftCorner);
     m_volumePopup->activateWindow();
 }
diff --git plugin-worldclock/lxqtworldclock.cpp plugin-worldclock/lxqtworldclock.cpp
index 7386049..8fa795d 100644
--- plugin-worldclock/lxqtworldclock.cpp
+++ plugin-worldclock/lxqtworldclock.cpp
@@ -356,6 +356,7 @@ void LXQtWorldClock::activated(ActivationReason reason)
         mPopup->adjustSize();
         mPopup->setGeometry(calculatePopupWindowPos(mPopup->size()));
 
+        willShowWindow(mPopup);
         mPopup->show();
     }
     else