Shark.cpp
branchv_0
changeset 7 e6065118326f
parent 6 fd93a46db15b
child 8 80ad08521091
--- a/Shark.cpp	Fri Dec 01 21:02:02 2023 +0100
+++ b/Shark.cpp	Sat Dec 02 15:02:56 2023 +0100
@@ -102,6 +102,7 @@
 	int x11fd = XConnectionNumber(dpy);
 	EPoll epoll;
 	epoll.add(x11fd);
+	epoll.add(fileMonitor.getFD());
 	try {
 		epoll.add(setNonBlocking(STDIN_FILENO));
 	} catch (const EPoll::Exception& e) {
@@ -211,6 +212,14 @@
 				}
 				logOutput << std::endl;
 
+			} else if (epoll[epollEvent].data.fd == fileMonitor.getFD()) {
+				std::cout << "FileMonitor event:" << std::endl;
+				for (FileEvent fe; fileMonitor.readEvent(fe);) {
+					std::cout << "   "
+							<< " file: " << fe.fileName
+							<< " mask: " << fe.mask
+							<< std::endl;
+				}
 			} else {
 				logOutput
 						<< "error: event on an unexpected FD: "
@@ -353,6 +362,7 @@
 void Shark::loadTextures() {
 	for (const Configuration::Texture& tex : cfg.textures) {
 		textures.push_back(loadTexture(tex.fileName));
+		watchedFiles.push_back(fileMonitor.watch(tex.fileName));
 		// TODO: review texture loading and binding
 		// works even without this - default texture
 		// glUniform1i(ProgAttr.jazz, jazz);
@@ -400,6 +410,7 @@
 
 			program->attachShader(*shader.get());
 			shaders.push_back(shader);
+			watchedFiles.push_back(fileMonitor.watch(fileName));
 			std::cerr << "GLSL loaded: " << fileName.c_str() << std::endl;
 		}