diff options
author | Ken Moore <moorekou@gmail.com> | 2015-09-16 11:09:26 -0400 |
---|---|---|
committer | Ken Moore <moorekou@gmail.com> | 2015-09-16 11:09:26 -0400 |
commit | 470d9b82a7269cfec9e6b9d79074deff7bb62dc9 (patch) | |
tree | 643dbc7c6f17e8168cbc271af43afd605f3a3434 | |
parent | Ensure that the screen brightness slider in the system dashboard only goes do... (diff) | |
download | lumina-470d9b82a7269cfec9e6b9d79074deff7bb62dc9.tar.gz lumina-470d9b82a7269cfec9e6b9d79074deff7bb62dc9.tar.bz2 lumina-470d9b82a7269cfec9e6b9d79074deff7bb62dc9.zip |
Fix up all the window activation detection/management within the lumina session. Now when a submenu on the panel is closed somehow or a window was modified with the task manager, it will properly find/activate the right window again.
-rw-r--r-- | libLumina/LuminaX11.h | 2 | ||||
-rw-r--r-- | lumina-desktop/LPanel.cpp | 31 | ||||
-rw-r--r-- | lumina-desktop/LPanel.h | 4 | ||||
-rw-r--r-- | lumina-desktop/LSession.cpp | 30 | ||||
-rw-r--r-- | lumina-desktop/LSession.h | 4 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/LPPlugin.h | 4 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/appmenu/LAppMenuPlugin.cpp | 1 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/clock/LClock.cpp | 1 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/desktopbar/LDeskBar.cpp | 4 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/desktopswitcher/LDesktopSwitcher.cpp | 1 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/systemdashboard/LSysDashboard.cpp | 1 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/systemstart/LStartButton.cpp | 1 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/taskmanager/LTaskButton.cpp | 9 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/taskmanager/LTaskButton.h | 2 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/taskmanager/LTaskManagerPlugin.cpp | 9 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/userbutton/LUserButton.cpp | 1 |
16 files changed, 80 insertions, 25 deletions
diff --git a/libLumina/LuminaX11.h b/libLumina/LuminaX11.h index 8fe741f9..4c791abd 100644 --- a/libLumina/LuminaX11.h +++ b/libLumina/LuminaX11.h @@ -49,7 +49,7 @@ class LXCB{ public: - enum WINDOWSTATE {VISIBLE, INVISIBLE, ACTIVE, ATTENTION, IGNORE}; + enum WINDOWSTATE {IGNORE, INVISIBLE, VISIBLE, ACTIVE, ATTENTION}; //note that this in order of priority xcb_ewmh_connection_t EWMH; //This is where all the screen info and atoms are located diff --git a/lumina-desktop/LPanel.cpp b/lumina-desktop/LPanel.cpp index 11b4629c..53eb1801 100644 --- a/lumina-desktop/LPanel.cpp +++ b/lumina-desktop/LPanel.cpp @@ -15,7 +15,6 @@ LPanel::LPanel(QSettings *file, int scr, int num, QWidget *parent) : QWidget(){ this->setMouseTracking(true); if(DEBUG){ qDebug() << " - Creating Panel:" << scr << num; } bgWindow = parent; //save for later - tmpID = 0; //Setup the widget overlay for the entire panel to provide transparency effects panelArea = new QWidget(this); QBoxLayout *tmp = new QBoxLayout(QBoxLayout::LeftToRight); @@ -246,6 +245,7 @@ void LPanel::UpdatePanel(bool geomonly){ if(plug != 0){ PLUGINS.insert(i, plug); layout->insertWidget(i, PLUGINS[i]); + connect(plug, SIGNAL(MenuClosed()), this, SLOT(checkPanelFocus())); }else{ //invalid plugin type plugins.removeAt(i); //remove this invalid plugin from the list @@ -293,6 +293,20 @@ void LPanel::UpdateTheme(){ } } +// =================== +// PRIVATE SLOTS +// =================== +void LPanel::checkPanelFocus(){ + if( !this->geometry().contains(QCursor::pos()) ){ + //Move the panel back to it's "hiding" spot + if(hidden){ this->move(hidepoint); } + //Re-active the old window + if(LSession::handle()->activeWindow()!=0){ + LSession::handle()->XCB->ActivateWindow(LSession::handle()->activeWindow()); + } + } + +} //=========== // PROTECTED @@ -319,8 +333,7 @@ void LPanel::enterEvent(QEvent *event){ //Move the panel out so it is fully available this->move(showpoint); } - //tmpID = LSession::handle()->XCB->ActiveWindow(); - //this->activateWindow(); + this->activateWindow(); event->accept(); //just to quiet the compile warning } @@ -332,17 +345,7 @@ void LPanel::leaveEvent(QEvent *event){ //pt = this->mapFromGlobal(pt); //qDebug() << "Mouse Point (local):" << pt.x() << pt.y(); qDebug() << "Contained:" << this->geometry().contains(pt);*/ - if( !this->geometry().contains(QCursor::pos()) ){ - //Move the panel back to it's "hiding" spot - if(hidden){ this->move(hidepoint); } - //Only re-activate the old window if the panel is still currently active and the old window is still visible - if(tmpID!=0){ - LXCB::WINDOWSTATE state = LSession::handle()->XCB->WindowState(tmpID); - if( state!=LXCB::IGNORE && state !=LXCB::INVISIBLE && (this->winId()==LSession::handle()->XCB->ActiveWindow()) ){ LSession::handle()->XCB->ActivateWindow(tmpID); } - tmpID = 0; - } - } - + checkPanelFocus(); event->accept(); //just to quiet the compile warning } diff --git a/lumina-desktop/LPanel.h b/lumina-desktop/LPanel.h index cee1b5c7..396ffecc 100644 --- a/lumina-desktop/LPanel.h +++ b/lumina-desktop/LPanel.h @@ -41,7 +41,6 @@ private: int panelnum; int viswidth; QList<LPPlugin*> PLUGINS; - WId tmpID; //temporary window ID public: LPanel(QSettings *file, int scr = 0, int num =0, QWidget *parent=0); //settings file, screen number, panel number @@ -66,6 +65,9 @@ public slots: void UpdateLocale(); //Locale Changed externally void UpdateTheme(); //Theme Changed externally +private slots: + void checkPanelFocus(); + protected: void paintEvent(QPaintEvent *event); void enterEvent(QEvent *event); diff --git a/lumina-desktop/LSession.cpp b/lumina-desktop/LSession.cpp index bd9ffeaa..4d631bc9 100644 --- a/lumina-desktop/LSession.cpp +++ b/lumina-desktop/LSession.cpp @@ -19,7 +19,7 @@ #include <unistd.h> //for usleep() usage #ifndef DEBUG -#define DEBUG 1 +#define DEBUG 0 #endif XCBEventFilter *evFilter = 0; @@ -40,6 +40,7 @@ LSession::LSession(int &argc, char ** argv) : QApplication(argc, argv){ sysWindow = 0; TrayDmgEvent = 0; TrayDmgError = 0; + lastActiveWin = 0; cleansession = true; TrayStopping = false; screenTimer = new QTimer(this); @@ -637,6 +638,26 @@ QSettings* LSession::DesktopPluginSettings(){ return DPlugSettings; } +WId LSession::activeWindow(){ + //Check the last active window pointer first + WId active = XCB->ActiveWindow(); + qDebug() << "Check Active Window:" << active << lastActiveWin; + if(RunningApps.contains(active)){ lastActiveWin = active; } + else if(RunningApps.contains(lastActiveWin) && XCB->WindowState(lastActiveWin) >= LXCB::VISIBLE){} //no change needed + else{ + //Need to change the last active window - find the first one which is visible + lastActiveWin = 0; //fallback value - nothing active + for(int i=0; i<RunningApps.length(); i++){ + if(XCB->WindowState(RunningApps[i]) >= LXCB::VISIBLE){ + lastActiveWin = RunningApps[i]; + break; + } + } + qDebug() << " -- New Last Active Window:" << lastActiveWin; + } + return lastActiveWin; +} + //Temporarily change the session locale (nothing saved between sessions) void LSession::switchLocale(QString localeCode){ LUtils::setLocaleEnv(localeCode); //will set everything to this locale (no custom settings) @@ -687,6 +708,8 @@ void LSession::WindowPropertyEvent(){ } } } + + //Now save the list and send out the event RunningApps = newapps; emit WindowListEvent(); } @@ -695,7 +718,8 @@ void LSession::WindowPropertyEvent(WId win){ //Emit the single-app signal if the window in question is one used by the task manager if(RunningApps.contains(win)){ if(DEBUG){ qDebug() << "Single-window property event"; } - emit WindowListEvent(); + //emit WindowListEvent(); + WindowPropertyEvent(); //Run through the entire routine for window checks }else if(RunningTrayApps.contains(win)){ emit TrayIconChanged(win); } @@ -716,6 +740,8 @@ void LSession::WindowConfigureEvent(WId win){ if(RunningTrayApps.contains(win)){ if(DEBUG){ qDebug() << "SysTray: Configure Event"; } emit TrayIconChanged(win); //trigger a repaint event + }else if(RunningApps.contains(win)){ + WindowPropertyEvent(); } } diff --git a/lumina-desktop/LSession.h b/lumina-desktop/LSession.h index 94f9b04d..247b7ecb 100644 --- a/lumina-desktop/LSession.h +++ b/lumina-desktop/LSession.h @@ -86,6 +86,9 @@ public: QSettings* sessionSettings(); QSettings* DesktopPluginSettings(); + //Keep track of which non-desktop window should be treated as active + WId activeWindow(); //This will return the last active window if a desktop element is currently active + //Temporarily change the session locale (nothing saved between sessions) void switchLocale(QString localeCode); @@ -117,6 +120,7 @@ private: bool TrayStopping; //Task Manager Variables + WId lastActiveWin; QList<WId> RunningApps; QList<WId> checkWin; QFileInfoList desktopFiles; diff --git a/lumina-desktop/panel-plugins/LPPlugin.h b/lumina-desktop/panel-plugins/LPPlugin.h index 52df3298..40508522 100644 --- a/lumina-desktop/panel-plugins/LPPlugin.h +++ b/lumina-desktop/panel-plugins/LPPlugin.h @@ -68,7 +68,9 @@ public slots: //This needs to be re-implemented in the subclasses plugin //This is where any horizontal/vertical orientations can be changed appropriately } - + +signals: + void MenuClosed(); //This needs to be emitted when any plugin's menu is closed for some reason (check/set focus properly) }; #endif
\ No newline at end of file diff --git a/lumina-desktop/panel-plugins/appmenu/LAppMenuPlugin.cpp b/lumina-desktop/panel-plugins/appmenu/LAppMenuPlugin.cpp index c38c4d3f..c64f934b 100644 --- a/lumina-desktop/panel-plugins/appmenu/LAppMenuPlugin.cpp +++ b/lumina-desktop/panel-plugins/appmenu/LAppMenuPlugin.cpp @@ -14,6 +14,7 @@ LAppMenuPlugin::LAppMenuPlugin(QWidget *parent, QString id, bool horizontal) : L button->setAutoRaise(true); button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); button->setMenu( LSession::handle()->applicationMenu() ); + connect(button->menu(), SIGNAL(aboutToHide()), this, SIGNAL(MenuClosed())); button->setPopupMode(QToolButton::InstantPopup); this->layout()->setContentsMargins(0,0,0,0); this->layout()->addWidget(button); diff --git a/lumina-desktop/panel-plugins/clock/LClock.cpp b/lumina-desktop/panel-plugins/clock/LClock.cpp index 2c7e3e07..b9f15c49 100644 --- a/lumina-desktop/panel-plugins/clock/LClock.cpp +++ b/lumina-desktop/panel-plugins/clock/LClock.cpp @@ -17,6 +17,7 @@ LClock::LClock(QWidget *parent, QString id, bool horizontal) : LPPlugin(parent, button->setPopupMode(QToolButton::DelayedPopup); //make sure it runs the update routine first button->setMenu(new QMenu()); connect(button, SIGNAL(clicked()), this, SLOT(openMenu())); + connect(button->menu(), SIGNAL(aboutToHide()), this, SIGNAL(MenuClosed())); calendar = new QCalendarWidget(this); calAct = new QWidgetAction(this); calAct->setDefaultWidget(calendar); diff --git a/lumina-desktop/panel-plugins/desktopbar/LDeskBar.cpp b/lumina-desktop/panel-plugins/desktopbar/LDeskBar.cpp index d95ae2f5..0aa896ce 100644 --- a/lumina-desktop/panel-plugins/desktopbar/LDeskBar.cpp +++ b/lumina-desktop/panel-plugins/desktopbar/LDeskBar.cpp @@ -60,6 +60,7 @@ void LDeskBarPlugin::initializeDesktop(){ appB->setMenu(appM); this->layout()->addWidget(appB); connect(appM,SIGNAL(triggered(QAction*)),this,SLOT(ActionTriggered(QAction*)) ); + connect(appM, SIGNAL(aboutToHide()), this, SIGNAL(MenuClosed())); //Directories on the desktop dirB = new QToolButton(this); dirB->setToolButtonStyle(Qt::ToolButtonIconOnly); @@ -69,6 +70,7 @@ void LDeskBarPlugin::initializeDesktop(){ dirB->setMenu(dirM); this->layout()->addWidget(dirB); connect(dirM,SIGNAL(triggered(QAction*)),this,SLOT(ActionTriggered(QAction*)) ); + connect(dirM, SIGNAL(aboutToHide()), this, SIGNAL(MenuClosed())); //Audio Files on the desktop audioM = new QMenu(this); connect(audioM,SIGNAL(triggered(QAction*)),this,SLOT(ActionTriggered(QAction*)) ); @@ -205,6 +207,7 @@ void LDeskBarPlugin::desktopChanged(){ if(!videoM->isEmpty()){ fileM->addMenu(videoM); } if(!otherM->isEmpty()){ fileM->addMenu(otherM); } //Check for a single submenu, and skip the main if need be + disconnect(fileB->menu(), SIGNAL(aboutToHide()), this, SIGNAL(MenuClosed()) ); if(fileM->actions().length()==1){ if(!audioM->isEmpty()){ fileB->setMenu(audioM); } else if(!pictureM->isEmpty()){ fileB->setMenu(pictureM); } @@ -214,6 +217,7 @@ void LDeskBarPlugin::desktopChanged(){ }else{ fileB->setMenu(fileM); } + connect(fileB->menu(), SIGNAL(aboutToHide()), this, SIGNAL(MenuClosed())); } //end of check for if updates are needed //Setup the visibility of the buttons diff --git a/lumina-desktop/panel-plugins/desktopswitcher/LDesktopSwitcher.cpp b/lumina-desktop/panel-plugins/desktopswitcher/LDesktopSwitcher.cpp index a1de725d..95c52d9a 100644 --- a/lumina-desktop/panel-plugins/desktopswitcher/LDesktopSwitcher.cpp +++ b/lumina-desktop/panel-plugins/desktopswitcher/LDesktopSwitcher.cpp @@ -19,6 +19,7 @@ LDesktopSwitcher::LDesktopSwitcher(QWidget *parent, QString id, bool horizontal) label->setToolTip(QString("Workspace 1")); menu = new QMenu(this); connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(menuActionTriggered(QAction*))); + connect(menu, SIGNAL(aboutToHide()), this, SIGNAL(MenuClosed())); label->setMenu(menu); this->layout()->addWidget(label); diff --git a/lumina-desktop/panel-plugins/systemdashboard/LSysDashboard.cpp b/lumina-desktop/panel-plugins/systemdashboard/LSysDashboard.cpp index 45de0126..267a7cb0 100644 --- a/lumina-desktop/panel-plugins/systemdashboard/LSysDashboard.cpp +++ b/lumina-desktop/panel-plugins/systemdashboard/LSysDashboard.cpp @@ -18,6 +18,7 @@ LSysDashboard::LSysDashboard(QWidget *parent, QString id, bool horizontal) : LPP this->layout()->setContentsMargins(0,0,0,0); this->layout()->addWidget(button); menu = new QMenu(this); + connect(menu, SIGNAL(aboutToHide()), this, SIGNAL(MenuClosed())); sysmenu = new LSysMenuQuick(this); connect(sysmenu, SIGNAL(CloseMenu()), this, SLOT(closeMenu()) ); mact = new QWidgetAction(this); diff --git a/lumina-desktop/panel-plugins/systemstart/LStartButton.cpp b/lumina-desktop/panel-plugins/systemstart/LStartButton.cpp index cb43b7c3..673c04ec 100644 --- a/lumina-desktop/panel-plugins/systemstart/LStartButton.cpp +++ b/lumina-desktop/panel-plugins/systemstart/LStartButton.cpp @@ -17,6 +17,7 @@ LStartButtonPlugin::LStartButtonPlugin(QWidget *parent, QString id, bool horizon this->layout()->addWidget(button); menu = new QMenu(this); menu->setContentsMargins(1,1,1,1); + connect(menu, SIGNAL(aboutToHide()), this, SIGNAL(MenuClosed())); startmenu = new StartMenu(this); connect(startmenu, SIGNAL(CloseMenu()), this, SLOT(closeMenu()) ); mact = new QWidgetAction(this); diff --git a/lumina-desktop/panel-plugins/taskmanager/LTaskButton.cpp b/lumina-desktop/panel-plugins/taskmanager/LTaskButton.cpp index eda1f2cd..01105c97 100644 --- a/lumina-desktop/panel-plugins/taskmanager/LTaskButton.cpp +++ b/lumina-desktop/panel-plugins/taskmanager/LTaskButton.cpp @@ -25,6 +25,8 @@ LTaskButton::LTaskButton(QWidget *parent, bool smallDisplay) : LTBWidget(parent) connect(this, SIGNAL(clicked()), this, SLOT(buttonClicked()) ); connect(winMenu, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(openActionMenu()) ); connect(winMenu, SIGNAL(triggered(QAction*)), this, SLOT(winClicked(QAction*)) ); + connect(winMenu, SIGNAL(aboutToHide()), this, SIGNAL(MenuClosed())); + connect(actMenu, SIGNAL(aboutToHide()), this, SIGNAL(MenuClosed())); } LTaskButton::~LTaskButton(){ @@ -107,10 +109,13 @@ void LTaskButton::UpdateButton(){ QAction *tmp = winMenu->addAction( WINLIST[i].icon(junk), WINLIST[i].text() ); tmp->setData(i); //save which number in the WINLIST this entry is for LXCB::WINDOWSTATE stat = WINLIST[i].status(true); //update the saved state for the window - if(stat==LXCB::ATTENTION){ showstate = stat; } //highest priority + if(stat<LXCB::ACTIVE && WINLIST[i].windowID() == LSession::handle()->activeWindow()){ stat = LXCB::ACTIVE; } + if(stat > showstate){ showstate = stat; } //higher priority + + /*if(stat==LXCB::ATTENTION){ showstate = stat; } //highest priority else if( stat==LXCB::ACTIVE && showstate != LXCB::ATTENTION){ showstate = stat; } //next priority else if( stat==LXCB::VISIBLE && showstate != LXCB::ATTENTION && showstate != LXCB::ACTIVE){ showstate = stat; } - else if(showstate == LXCB::INVISIBLE || showstate == LXCB::IGNORE){ showstate = stat; } //anything is the same/better + else if(showstate == LXCB::INVISIBLE || showstate == LXCB::IGNORE){ showstate = stat; } //anything is the same/better*/ } //Now setup the button appropriately // - visibility diff --git a/lumina-desktop/panel-plugins/taskmanager/LTaskButton.h b/lumina-desktop/panel-plugins/taskmanager/LTaskButton.h index b980071e..c26492e4 100644 --- a/lumina-desktop/panel-plugins/taskmanager/LTaskButton.h +++ b/lumina-desktop/panel-plugins/taskmanager/LTaskButton.h @@ -64,5 +64,7 @@ private slots: void winClicked(QAction*); void openActionMenu(); +signals: + void MenuClosed(); }; #endif diff --git a/lumina-desktop/panel-plugins/taskmanager/LTaskManagerPlugin.cpp b/lumina-desktop/panel-plugins/taskmanager/LTaskManagerPlugin.cpp index 79a164b8..be3e665a 100644 --- a/lumina-desktop/panel-plugins/taskmanager/LTaskManagerPlugin.cpp +++ b/lumina-desktop/panel-plugins/taskmanager/LTaskManagerPlugin.cpp @@ -35,8 +35,8 @@ void LTaskManagerPlugin::UpdateButtons(){ //Get the current window list QList<WId> winlist = LSession::handle()->XCB->WindowList(); //Do not change the status of the previously active window if it just changed to a non-visible window - WId activeWin = LSession::handle()->XCB->ActiveWindow(); - bool skipActive = !winlist.contains(activeWin); + //WId activeWin = LSession::handle()->XCB->ActiveWindow(); + //bool skipActive = !winlist.contains(activeWin); //qDebug() << "Update Buttons:" << winlist; if(updating > ctime){ return; } //another thread kicked off already - stop this one //Now go through all the current buttons first @@ -74,9 +74,9 @@ void LTaskManagerPlugin::UpdateButtons(){ if(!updated){ //qDebug() << "Update Button:" << i; if(updating > ctime){ return; } //another thread kicked off already - stop this one - if(!skipActive || !BUTTONS[i]->isActive()){ + //if(!skipActive || !BUTTONS[i]->isActive()){ QTimer::singleShot(1,BUTTONS[i], SLOT(UpdateButton()) ); //keep moving on - } + //} } } //Now go through the remaining windows @@ -108,6 +108,7 @@ void LTaskManagerPlugin::UpdateButtons(){ but->setIconSize(QSize(this->width(), this->width())); } this->layout()->addWidget(but); + connect(but, SIGNAL(MenuClosed()), this, SIGNAL(MenuClosed())); BUTTONS << but; } } diff --git a/lumina-desktop/panel-plugins/userbutton/LUserButton.cpp b/lumina-desktop/panel-plugins/userbutton/LUserButton.cpp index 2ee2b494..1fefa304 100644 --- a/lumina-desktop/panel-plugins/userbutton/LUserButton.cpp +++ b/lumina-desktop/panel-plugins/userbutton/LUserButton.cpp @@ -17,6 +17,7 @@ LUserButtonPlugin::LUserButtonPlugin(QWidget *parent, QString id, bool horizonta this->layout()->addWidget(button); menu = new QMenu(this); menu->setContentsMargins(1,1,1,1); + connect(menu, SIGNAL(aboutToHide()), this, SIGNAL(MenuClosed())); usermenu = new UserWidget(this); connect(usermenu, SIGNAL(CloseMenu()), this, SLOT(closeMenu()) ); mact = new QWidgetAction(this); |