diff --git a/dev/CMakeLists.txt b/dev/CMakeLists.txt index 4895ce0..61704c9 100644 --- a/dev/CMakeLists.txt +++ b/dev/CMakeLists.txt @@ -45,7 +45,8 @@ else() endif() add_custom_target(CopyHeader - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/olcPixelGameEngine3.h ${REPO_ROOT_DIR}/olcPixelGameEngine3.h + BYPRODUCTS ${REPO_ROOT_DIR}/olcPixelGameEngine3.h + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_BINARY_DIR}/olcPixelGameEngine3.h ${REPO_ROOT_DIR}/olcPixelGameEngine3.h DEPENDS olcPixelGameEngine3.h ) diff --git a/dev/src/host_lin_x11.cpp b/dev/src/host_lin_x11.cpp index cb6866c..750f669 100644 --- a/dev/src/host_lin_x11.cpp +++ b/dev/src/host_lin_x11.cpp @@ -131,6 +131,10 @@ namespace olc::host return nullptr; }; + // Create a pollfd that we will use later to wait for events to appear on the queue + // preventing the event loop from becoming a busy loop + pollfd x11_connection_fd {.fd = ConnectionNumber(olc_Display), .events = POLLIN}; + X11::XEvent xev; while(systemActive){ while (XPending(olc_Display)) @@ -297,6 +301,9 @@ namespace olc::host } } } + + // Wait until an event appears on the x11 event queue file descriptor + poll(&x11_connection_fd, 1, -1); } systemActive = false; diff --git a/dev/src/host_lin_x11.h b/dev/src/host_lin_x11.h index 832f268..f5604bd 100644 --- a/dev/src/host_lin_x11.h +++ b/dev/src/host_lin_x11.h @@ -16,6 +16,7 @@ //! START DECLARATION #include +#include namespace X11 { #include diff --git a/olcPixelGameEngine3.h b/olcPixelGameEngine3.h index 2b919d7..f1bb19f 100644 --- a/olcPixelGameEngine3.h +++ b/olcPixelGameEngine3.h @@ -5965,6 +5965,7 @@ namespace olc #if OLC_HOST == OLC_HOST_LINUX_X11 #include +#include namespace X11 { #include @@ -12365,6 +12366,10 @@ namespace olc::host return nullptr; }; + // Create a pollfd that we will use later to wait for events to appear on the queue + // preventing the event loop from becoming a busy loop + pollfd x11_connection_fd {.fd = ConnectionNumber(olc_Display), .events = POLLIN}; + X11::XEvent xev; while(systemActive){ while (XPending(olc_Display)) @@ -12531,6 +12536,9 @@ namespace olc::host } } } + + // Wait until an event appears on the x11 event queue file descriptor + poll(&x11_connection_fd, 1, -1); } systemActive = false;