From 1e9b663c06a451b215f6fe47e920ff130f4d963a Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Thu, 28 Apr 2016 09:49:13 -0400 Subject: Have lumina listen to the X root window property changes directly - and update the screen numbers/geometries 50ms after the WM changes the _NET_DESKTOP_GEOMETRY or _NET_WORKAREA properties on it. This bypasses a bug in the QDesktopWidget class where it might not send out the changed() signals when something really did change (noticed this in virtualbox instances in particular). --- src-qt5/core/libLumina/LuminaUtils.cpp | 2 +- src-qt5/core/lumina-desktop/LSession.cpp | 14 ++++++++++---- src-qt5/core/lumina-desktop/LSession.h | 1 + src-qt5/core/lumina-desktop/LXcbEventFilter.cpp | 7 ++++++- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src-qt5/core/libLumina/LuminaUtils.cpp b/src-qt5/core/libLumina/LuminaUtils.cpp index fa38d6df..f429cb31 100644 --- a/src-qt5/core/libLumina/LuminaUtils.cpp +++ b/src-qt5/core/libLumina/LuminaUtils.cpp @@ -899,7 +899,7 @@ ResizeMenu::ResizeMenu(QWidget *parent) : QMenu(parent){ contents = 0; connect(this, SIGNAL(aboutToShow()), this, SLOT(clearFlags()) ); connect(this, SIGNAL(aboutToHide()), this, SLOT(clearFlags()) ); - connect(cAct, SIGNAL(hovered()), this, SLOT(actionHovered()) ); + connect(cAct, SIGNAL(hovered()), this, SLOT(clearFlags()) ); } ResizeMenu::~ResizeMenu(){ diff --git a/src-qt5/core/lumina-desktop/LSession.cpp b/src-qt5/core/lumina-desktop/LSession.cpp index b1a4b55e..2ab01d79 100644 --- a/src-qt5/core/lumina-desktop/LSession.cpp +++ b/src-qt5/core/lumina-desktop/LSession.cpp @@ -48,8 +48,7 @@ LSession::LSession(int &argc, char ** argv) : LSingleApplication(argc, argv, "lu TrayStopping = false; screenTimer = new QTimer(this); screenTimer->setSingleShot(true); - screenTimer->setInterval(1000); //2 seconds - This needs to be long(ish) to prevent being called while - // X is still setting up any screens + screenTimer->setInterval(50); connect(screenTimer, SIGNAL(timeout()), this, SLOT(updateDesktops()) ); for(int i=1; iaddPath( QDir::homePath()+"/Desktop" ); //connect internal signals/slots - connect(this->desktop(), SIGNAL(screenCountChanged(int)), this, SLOT(screensChanged()) ); - connect(this->desktop(), SIGNAL(resized(int)), this, SLOT(screenResized(int)) ); + //connect(this->desktop(), SIGNAL(screenCountChanged(int)), this, SLOT(screensChanged()) ); + //connect(this->desktop(), SIGNAL(resized(int)), this, SLOT(screenResized(int)) ); connect(watcher, SIGNAL(directoryChanged(QString)), this, SLOT(watcherChange(QString)) ); connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(watcherChange(QString)) ); connect(this, SIGNAL(aboutToQuit()), this, SLOT(SessionEnding()) ); @@ -723,6 +722,13 @@ void LSession::playAudioFile(QString filepath){ // ======================= // XCB EVENT FILTER FUNCTIONS // ======================= +void LSession::RootSizeChange(){ + qDebug() << "Got Root Size Change"; + if(DESKTOPS.isEmpty()){ return; } //Initial setup not run yet + screenTimer->start(); + //QTimer::singleShot(0,this, SLOT(screensChanged()) ); +} + void LSession::WindowPropertyEvent(){ if(DEBUG){ qDebug() << "Window Property Event"; } QList newapps = XCB->WindowList(); diff --git a/src-qt5/core/lumina-desktop/LSession.h b/src-qt5/core/lumina-desktop/LSession.h index ae217bd8..bdcc94a4 100644 --- a/src-qt5/core/lumina-desktop/LSession.h +++ b/src-qt5/core/lumina-desktop/LSession.h @@ -61,6 +61,7 @@ public: //Special functions for XCB event filter parsing only // (DO NOT USE MANUALLY) + void RootSizeChange(); void WindowPropertyEvent(); void WindowPropertyEvent(WId); void SysTrayDockRequest(WId); diff --git a/src-qt5/core/lumina-desktop/LXcbEventFilter.cpp b/src-qt5/core/lumina-desktop/LXcbEventFilter.cpp index 7ee4f974..c8321c49 100644 --- a/src-qt5/core/lumina-desktop/LXcbEventFilter.cpp +++ b/src-qt5/core/lumina-desktop/LXcbEventFilter.cpp @@ -17,6 +17,7 @@ XCBEventFilter::XCBEventFilter(LSession *sessionhandle) : QAbstractNativeEventFi session = sessionhandle; //save this for interaction with the session later TrayDmgFlag = 0; stopping = false; + session->XCB->SelectInput(QX11Info::appRootWindow()); //make sure we get root window events InitAtoms(); } @@ -41,7 +42,11 @@ bool XCBEventFilter::nativeEventFilter(const QByteArray &eventType, void *messag //qDebug() << " - Root Window:" << QX11Info::appRootWindow(); //qDebug() << " - Given Window:" << ((xcb_property_notify_event_t*)ev)->window; //System-specific proprty change - if( SysNotifyAtoms.contains( ((xcb_property_notify_event_t*)ev)->atom ) ){ + if( ((xcb_property_notify_event_t*)ev)->window == QX11Info::appRootWindow() \ + && ( ( ((xcb_property_notify_event_t*)ev)->atom == session->XCB->EWMH._NET_DESKTOP_GEOMETRY) \ + || (((xcb_property_notify_event_t*)ev)->atom == session->XCB->EWMH._NET_WORKAREA) )){ + session->RootSizeChange(); + }else if( SysNotifyAtoms.contains( ((xcb_property_notify_event_t*)ev)->atom ) ){ //Update the status/list of all running windows session->WindowPropertyEvent(); -- cgit