aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src-qt5/core/libLumina/NativeWindowSystem.cpp17
-rw-r--r--src-qt5/core/libLumina/NativeWindowSystem.h21
2 files changed, 37 insertions, 1 deletions
diff --git a/src-qt5/core/libLumina/NativeWindowSystem.cpp b/src-qt5/core/libLumina/NativeWindowSystem.cpp
index 723415f2..c4905d4c 100644
--- a/src-qt5/core/libLumina/NativeWindowSystem.cpp
+++ b/src-qt5/core/libLumina/NativeWindowSystem.cpp
@@ -173,7 +173,8 @@ public:
// === PUBLIC ===
NativeWindowSystem::NativeWindowSystem() : QObject(){
- obj = 0;
+ obj = 0;
+ pingTimer = 0;
}
NativeWindowSystem::~NativeWindowSystem(){
@@ -491,6 +492,13 @@ void NativeWindowSystem::WindowPropertyChanged(WId id, NativeWindow::Property pr
}
}
+void NativeWindowSystem::GotPong(WId id){
+ if(waitingForPong.contains(id)){
+ waitingForPong.remove(id);
+ }
+ if(waitingForPong.isEmpty() && pingTimer!=0){ pingTimer->stop(); }
+}
+
/*void NativeWindowSystem::NewKeyPress(int keycode, WId win){
emit NewInputEvent();
}
@@ -581,5 +589,12 @@ void NativeWindowSystem::RequestKill(WId win){
}
void NativeWindowSystem::RequestPing(WId win){
+ waitingForPong.insert(win, QDateTime::currentDateTime().addSecs(5) );
xcb_ewmh_send_wm_ping(&obj->EWMH, win, XCB_CURRENT_TIME);
+ if(pingTimer==0){
+ pingTimer = new QTimer(this);
+ pingTimer->setInterval(2000); //2seconds
+ connect(pingTimer, SIGNAL(timeout()), this, SLOT(checkPings()) );
+ }
+ pingTimer->start();
}
diff --git a/src-qt5/core/libLumina/NativeWindowSystem.h b/src-qt5/core/libLumina/NativeWindowSystem.h
index f5d4c8ae..59e54ca4 100644
--- a/src-qt5/core/libLumina/NativeWindowSystem.h
+++ b/src-qt5/core/libLumina/NativeWindowSystem.h
@@ -12,6 +12,8 @@
#define _LUMINA_NATIVE_WINDOW_SYSTEM_H
#include "NativeWindow.h"
+#include <QDateTime>
+#include <QTimer>
class NativeWindowSystem : public QObject{
Q_OBJECT
@@ -39,6 +41,23 @@ private:
class p_objects;
p_objects* obj;
+ //Internal timers/variables for managing pings
+ QTimer *pingTimer;
+ QHash<WId, QDateTime> waitingForPong;
+ void checkPings(){
+ QDateTime cur = QDateTime::currentDateTime();
+ QList<WId> waiting = waitingForPong.keys();
+ for(int i=0; i<waiting.length(); i++){
+ if(waitingForPong.value(waiting[i]) < cur){
+ waitingForPong.remove(waiting[i]); //Timeout on this window
+ if(waitingForPong.isEmpty() && pingTimer!=0){ pingTimer->stop(); }
+ NativeWindow *win = findWindow(waiting[i]);
+ if(win==0){ win = findTrayWindow(waiting[i]); }
+ if(win!=0){ win->emit WindowNotResponding(waiting[i]); }
+ }
+ }
+ }
+
// Since some properties may be easier to update in bulk
// let the native system interaction do them in whatever logical groups are best
void UpdateWindowProperties(NativeWindow* win, QList< NativeWindow::Property > props);
@@ -77,6 +96,8 @@ public slots:
void NewTrayWindowDetected(WId); //will automatically create the new NativeWindow object
void WindowCloseDetected(WId); //will update the lists and make changes if needed
void WindowPropertyChanged(WId, NativeWindow::Property); //will rescan the window and update the object as needed
+ void GotPong(WId);
+
/* void NewKeyPress(int keycode, WId win = 0);
void NewKeyRelease(int keycode, WId win = 0);
void NewMousePress(int buttoncode, WId win = 0);
bgstack15