MCPcopy Create free account
hub / github.com/OneLoneCoder/olcPixelGameEngine / HandleSystemEvent

Method HandleSystemEvent

olcPixelGameEngine.h:7186–7265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7184 }
7185
7186 virtual olc::rcode HandleSystemEvent() override
7187 {
7188 using namespace X11;
7189 // Handle Xlib Message Loop - we do this in the
7190 // same thread that OpenGL was created so we dont
7191 // need to worry too much about multithreading with X11
7192 XEvent xev;
7193 while (XPending(olc_Display))
7194 {
7195 XNextEvent(olc_Display, &xev);
7196 if (xev.type == Expose)
7197 {
7198 XWindowAttributes gwa;
7199 XGetWindowAttributes(olc_Display, olc_Window, &gwa);
7200 ptrPGE->olc_UpdateWindowSize(gwa.width, gwa.height);
7201 }
7202 else if (xev.type == ConfigureNotify)
7203 {
7204 XConfigureEvent xce = xev.xconfigure;
7205 ptrPGE->olc_UpdateWindowSize(xce.width, xce.height);
7206 }
7207 else if (xev.type == KeyPress)
7208 {
7209 KeySym ks;
7210
7211 // DragonEye still loves numpads, but this is a better way
7212 XLookupString(&xev.xkey, NULL, 0, &ks, NULL);
7213
7214 if (ks != NoSymbol)
7215 ptrPGE->olc_UpdateKeyState(ks, true);
7216 }
7217 else if (xev.type == KeyRelease)
7218 {
7219 KeySym ks;
7220 XLookupString(&xev.xkey, NULL, 0, &ks, NULL);
7221
7222 if (ks != NoSymbol)
7223 ptrPGE->olc_UpdateKeyState(ks, false);
7224 }
7225 else if (xev.type == ButtonPress)
7226 {
7227 switch (xev.xbutton.button)
7228 {
7229 case 1: ptrPGE->olc_UpdateMouseState(0, true); break;
7230 case 2: ptrPGE->olc_UpdateMouseState(2, true); break;
7231 case 3: ptrPGE->olc_UpdateMouseState(1, true); break;
7232 case 4: ptrPGE->olc_UpdateMouseWheel(120); break;
7233 case 5: ptrPGE->olc_UpdateMouseWheel(-120); break;
7234 default: break;
7235 }
7236 }
7237 else if (xev.type == ButtonRelease)
7238 {
7239 switch (xev.xbutton.button)
7240 {
7241 case 1: ptrPGE->olc_UpdateMouseState(0, false); break;
7242 case 2: ptrPGE->olc_UpdateMouseState(2, false); break;
7243 case 3: ptrPGE->olc_UpdateMouseState(1, false); break;

Callers

nothing calls this directly

Calls 7

olc_UpdateWindowSizeMethod · 0.80
olc_UpdateKeyStateMethod · 0.80
olc_UpdateMouseStateMethod · 0.80
olc_UpdateMouseWheelMethod · 0.80
olc_UpdateMouseMethod · 0.80
olc_UpdateKeyFocusMethod · 0.80
olc_TerminateMethod · 0.80

Tested by

no test coverage detected