From f18b5470eca7ebb3a1316d897fbde4071a62380e Mon Sep 17 00:00:00 2001 From: Ale Martinez Date: Wed, 27 May 2020 17:58:35 -0300 Subject: [PATCH] Create Overlay Widgets with Qt::Tool flag on Linux Michael Dagenais found this change makes the widgets to play nicer with Windows Managers and avoids them to get on top of other programs windows. Minimize and Restore is automatically handled now, so this commit partially reverts b89019264ed5a8a40ab104c22002e53a2b6ce01d, removing MainWindow state changes tracking, but keeping VideoWindow position tracking. --- src/Gui/MainWindow.cpp | 11 ----------- src/Gui/MainWindow.h | 4 ---- src/Train/MeterWidget.cpp | 2 +- src/Train/VideoWindow.cpp | 7 ------- src/Train/VideoWindow.h | 1 - 5 files changed, 1 insertion(+), 24 deletions(-) diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp index 7ff52f1c8..da6cfcfec 100644 --- a/src/Gui/MainWindow.cpp +++ b/src/Gui/MainWindow.cpp @@ -1027,17 +1027,6 @@ MainWindow::closeEvent(QCloseEvent* event) appsettings->setValue(GC_SETTINGS_MAIN_STATE, saveState()); } -void -MainWindow::changeEvent(QEvent *event) -{ - if(event->type() != QEvent::WindowStateChange) return; - - // Some overlay Widgets (Meter) are top level windows - // and need to follow the MainWindow state - Qt::WindowStates states = windowState(); - emit mainWindowStateChanged(states & Qt::WindowMinimized, isVisible()); -} - MainWindow::~MainWindow() { // aside from the tabs, we may need to clean diff --git a/src/Gui/MainWindow.h b/src/Gui/MainWindow.h index 1cea167e8..4948c692a 100644 --- a/src/Gui/MainWindow.h +++ b/src/Gui/MainWindow.h @@ -94,9 +94,6 @@ class MainWindow : public QMainWindow // currently selected tab Tab *athleteTab() { return currentTab; } - signals: - void mainWindowStateChanged(bool minimized, bool visible); - protected: // used by ChooseCyclistDialog to see which athletes @@ -107,7 +104,6 @@ class MainWindow : public QMainWindow virtual void resizeEvent(QResizeEvent*); virtual void moveEvent(QMoveEvent*); virtual void closeEvent(QCloseEvent*); - virtual void changeEvent(QEvent *); virtual void dragEnterEvent(QDragEnterEvent *); virtual void dropEvent(QDropEvent *); diff --git a/src/Train/MeterWidget.cpp b/src/Train/MeterWidget.cpp index 9552e2dc4..56aaa78f2 100644 --- a/src/Train/MeterWidget.cpp +++ b/src/Train/MeterWidget.cpp @@ -28,7 +28,7 @@ MeterWidget::MeterWidget(QString Name, QWidget *parent, QString Source) : QWidge setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); #ifdef Q_OS_LINUX - setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint); + setWindowFlags(Qt::Tool | Qt::FramelessWindowHint); setAttribute(Qt::WA_TranslucentBackground); #else setWindowFlags(Qt::Window | Qt::FramelessWindowHint); diff --git a/src/Train/VideoWindow.cpp b/src/Train/VideoWindow.cpp index 871273c37..8faf2097a 100644 --- a/src/Train/VideoWindow.cpp +++ b/src/Train/VideoWindow.cpp @@ -140,7 +140,6 @@ VideoWindow::VideoWindow(Context *context) : connect(context, SIGNAL(seek(long)), this, SLOT(seekPlayback(long))); connect(context, SIGNAL(unpause()), this, SLOT(resumePlayback())); connect(context, SIGNAL(mediaSelected(QString)), this, SLOT(mediaSelected(QString))); - connect(this->window(), SIGNAL(mainWindowStateChanged(bool, bool)), this, SLOT(mainWindowStateChanged(bool, bool))); } } @@ -177,12 +176,6 @@ void VideoWindow::resizeEvent(QResizeEvent * ) prevPosition = mapToGlobal(pos()); } -void VideoWindow::mainWindowStateChanged(bool minimized, bool visible) -{ - if(minimized) foreach(MeterWidget* p, m_metersWidget) p->hide(); - else if(visible && isVisible()) foreach(MeterWidget* p, m_metersWidget) p->show(); -} - void VideoWindow::startPlayback() { if (context->currentVideoSyncFile()) { diff --git a/src/Train/VideoWindow.h b/src/Train/VideoWindow.h index 14b39f741..41bfb48b1 100644 --- a/src/Train/VideoWindow.h +++ b/src/Train/VideoWindow.h @@ -158,7 +158,6 @@ class VideoWindow : public GcChartWindow void telemetryUpdate(RealtimeData rtd); void seekPlayback(long ms); void mediaSelected(QString filename); - void mainWindowStateChanged(bool minimized, bool visible); protected: