1 #pragma once 2 3 #include <X11/X.h> 4 #include <X11/Xlib.h> 5 6 #include "x11-types.h" 7 8 class Root; 9 class XConnection; 10 11 class XMainLoop { 12 public: 13 XMainLoop(XConnection& X, Root* root); 14 void scanExistingClients(); 15 void run(); 16 //! quit the main loop as soon as possible 17 void quit(); 18 using EventHandler = void (XMainLoop::*)(XEvent*); 19 20 void dropEnterNotifyEvents(); 21 private: 22 // members 23 XConnection& X_; 24 Root* root_; 25 bool aboutToQuit_; 26 EventHandler handlerTable_[LASTEvent]; 27 // event handlers 28 void buttonpress(XButtonEvent* be); 29 void buttonrelease(XButtonEvent* event); 30 void clientmessage(XClientMessageEvent* event); 31 void createnotify(XCreateWindowEvent* event); 32 void configurerequest(XConfigureRequestEvent* cre); 33 void configurenotify(XConfigureEvent* event); 34 void destroynotify(XUnmapEvent* event); 35 void enternotify(XCrossingEvent* ce); 36 void expose(XEvent* event); 37 void focusin(XEvent* event); 38 void keypress(XKeyEvent* event); 39 void mappingnotify(XMappingEvent* event); 40 void motionnotify(XMotionEvent* event); 41 void mapnotify(XMapEvent* event); 42 void maprequest(XMapRequestEvent* mapreq); 43 void propertynotify(XPropertyEvent* event); 44 void unmapnotify(XUnmapEvent* event); 45 46 bool duringEnterNotify_ = false; //! whether we are in enternotify() 47 }; 48