From 4e63d94c015426c2f579597ca817550197746060 Mon Sep 17 00:00:00 2001 From: Robert Blackburn Date: Sat, 4 Dec 2021 20:27:12 +0000 Subject: [PATCH 1/7] Added build folder to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 62187ac8..f526984c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ cmake-build-debug assets.zip .idea assets/ +build/ \ No newline at end of file From 97978bdb6395cc5a7db799d13805533fbb78d6c2 Mon Sep 17 00:00:00 2001 From: Robert Blackburn Date: Sat, 4 Dec 2021 20:35:00 +0000 Subject: [PATCH 2/7] Commetend out reference to custom glfw lib --- src/WallpaperEngine/Render/CContext.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/WallpaperEngine/Render/CContext.cpp b/src/WallpaperEngine/Render/CContext.cpp index e679cf18..cb2fb639 100644 --- a/src/WallpaperEngine/Render/CContext.cpp +++ b/src/WallpaperEngine/Render/CContext.cpp @@ -78,7 +78,7 @@ void CContext::initializeViewports () XRRFreeScreenResources (screenResources); // set the - glfwWindowHintPointer (GLFW_NATIVE_PARENT_HANDLE, reinterpret_cast (DefaultRootWindow (display))); + //glfwWindowHintPointer (GLFW_NATIVE_PARENT_HANDLE, reinterpret_cast (DefaultRootWindow (display))); } void CContext::render () @@ -117,4 +117,4 @@ void CContext::setDefaultViewport (glm::vec4 defaultViewport) CMouseInput* CContext::getMouse () const { return this->m_mouse; -} \ No newline at end of file +} From 94a9686eaa56454f7c3a9d8b6002ca23cdd768f7 Mon Sep 17 00:00:00 2001 From: Robert Blackburn Date: Sat, 4 Dec 2021 20:36:44 +0000 Subject: [PATCH 3/7] Added CWindow to handle making the screen a desktop window --- CMakeLists.txt | 3 + main.cpp | 210 ++++++++++++++------------- src/WallpaperEngine/Core/CWindow.cpp | 76 ++++++++++ src/WallpaperEngine/Core/CWindow.h | 18 +++ 4 files changed, 203 insertions(+), 104 deletions(-) create mode 100644 src/WallpaperEngine/Core/CWindow.cpp create mode 100644 src/WallpaperEngine/Core/CWindow.h diff --git a/CMakeLists.txt b/CMakeLists.txt index f12fcba6..c732327f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,6 +118,9 @@ add_executable( src/WallpaperEngine/Core/CObject.cpp src/WallpaperEngine/Core/CObject.h + src/WallpaperEngine/Core/CWindow.cpp + src/WallpaperEngine/Core/CWindow.h + src/WallpaperEngine/Core/Projects/CProperty.h src/WallpaperEngine/Core/Projects/CProperty.cpp src/WallpaperEngine/Core/Projects/CPropertyColor.h diff --git a/main.cpp b/main.cpp index d7bf22d9..8ae37fb5 100644 --- a/main.cpp +++ b/main.cpp @@ -20,6 +20,8 @@ #include "WallpaperEngine/Assets/CDirectory.h" #include "WallpaperEngine/Assets/CCombinedContainer.h" +#include "WallpaperEngine/Core/CWindow.h" + enum BACKGROUND_RUN_MODE { RUN_MODE_UNKNOWN = 0, @@ -32,7 +34,7 @@ float g_Time; using namespace WallpaperEngine::Core::Types; -void print_help (const char* route) +void print_help(const char *route) { std::cout << "Usage:" << route << " [options] background_path" << std::endl @@ -42,29 +44,29 @@ void print_help (const char* route) << " --fps \tLimits the FPS to the given number, useful to keep battery consumption low" << std::endl; } -std::string stringPathFixes(const std::string& s) +std::string stringPathFixes(const std::string &s) { - if (s.empty () == true) + if (s.empty() == true) return s; - std::string str (s); + std::string str(s); // remove single-quotes from the arguments - if (str [0] == '\'' && str [str.size() - 1] == '\'') + if (str[0] == '\'' && str[str.size() - 1] == '\'') str - .erase (str.size() - 1, 1) - .erase (0, 1); + .erase(str.size() - 1, 1) + .erase(0, 1); // ensure there's a slash at the end of the path - if (str [str.size() - 1] != '/') + if (str[str.size() - 1] != '/') str += '/'; - return std::move (str); + return std::move(str); } -int main (int argc, char* argv[]) +int main(int argc, char *argv[]) { - std::vector screens; + std::vector screens; int maximumFPS = 30; bool shouldEnableAudio = true; @@ -72,235 +74,235 @@ int main (int argc, char* argv[]) int option_index = 0; - static struct option long_options [] = { + static struct option long_options[] = { {"screen-root", required_argument, 0, 'r'}, - {"pkg", required_argument, 0, 'p'}, - {"dir", required_argument, 0, 'd'}, - {"silent", no_argument, 0, 's'}, - {"help", no_argument, 0, 'h'}, - {"fps", required_argument, 0, 'f'}, - {nullptr, 0, 0, 0} - }; + {"pkg", required_argument, 0, 'p'}, + {"dir", required_argument, 0, 'd'}, + {"silent", no_argument, 0, 's'}, + {"help", no_argument, 0, 'h'}, + {"fps", required_argument, 0, 'f'}, + {nullptr, 0, 0, 0}}; while (true) { - int c = getopt_long (argc, argv, "r:p:d:shf:", long_options, &option_index); + int c = getopt_long(argc, argv, "r:p:d:shf:", long_options, &option_index); if (c == -1) break; switch (c) { - case 'r': - screens.emplace_back (optarg); - break; - - case 'p': - case 'd': - std::cerr << "--dir/--pkg is deprecated and not used anymore" << std::endl; - path = stringPathFixes (optarg); - break; - - case 's': - shouldEnableAudio = false; - break; - - case 'h': - print_help (argv [0]); - break; - - case 'f': - maximumFPS = atoi (optarg); - break; - - default: - break; + case 'r': + screens.emplace_back(optarg); + break; + + case 'p': + case 'd': + std::cerr << "--dir/--pkg is deprecated and not used anymore" << std::endl; + path = stringPathFixes(optarg); + break; + + case 's': + shouldEnableAudio = false; + break; + + case 'h': + print_help(argv[0]); + break; + + case 'f': + maximumFPS = atoi(optarg); + break; + + default: + break; } } // increment the option index (useful for when no options were found) - option_index ++; + option_index++; - if (path.empty () == true) + if (path.empty() == true) { - if (option_index < argc && strlen (argv [option_index]) > 0) + if (option_index < argc && strlen(argv[option_index]) > 0) { - path = argv [option_index]; + path = argv[option_index]; } else { - print_help (argv [0]); + print_help(argv[0]); return 0; } } // first of all, initialize the window - if (glfwInit () == GLFW_FALSE) + if (glfwInit() == GLFW_FALSE) { - fprintf (stderr, "Failed to initialize GLFW\n"); + fprintf(stderr, "Failed to initialize GLFW\n"); return 1; } // initialize freeimage - FreeImage_Initialise (TRUE); + FreeImage_Initialise(TRUE); // set some window hints (opengl version to be used) - glfwWindowHint (GLFW_SAMPLES, 4); - glfwWindowHint (GLFW_CONTEXT_VERSION_MAJOR, 2); - glfwWindowHint (GLFW_CONTEXT_VERSION_MINOR, 1); + glfwWindowHint(GLFW_SAMPLES, 4); + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1); std::string project_path = path + "project.json"; - auto containers = new WallpaperEngine::Assets::CCombinedContainer (); + auto containers = new WallpaperEngine::Assets::CCombinedContainer(); // the background's path is required to load project.json regardless of the type of background we're using - containers->add (new WallpaperEngine::Assets::CDirectory (path)); + containers->add(new WallpaperEngine::Assets::CDirectory(path)); // check if scene.pkg exists and add it to the list try { std::string scene_path = path + "scene.pkg"; // add the package to the list - containers->add (new WallpaperEngine::Assets::CPackage (scene_path)); + containers->add(new WallpaperEngine::Assets::CPackage(scene_path)); } - catch(std::filesystem::filesystem_error ex) + catch (std::filesystem::filesystem_error ex) { // ignore this error, the package file was not found } catch (std::runtime_error ex) { // the package was found but there was an error loading it (wrong header or something) - fprintf (stderr, "Failed to load scene.pkg file: %s\n", ex.what()); + fprintf(stderr, "Failed to load scene.pkg file: %s\n", ex.what()); return 4; } // add containers to the list - containers->add (new WallpaperEngine::Assets::CDirectory ("./assets/")); + containers->add(new WallpaperEngine::Assets::CDirectory("./assets/")); // parse the project.json file - auto project = WallpaperEngine::Core::CProject::fromFile ("project.json", containers); - WallpaperEngine::Render::CWallpaper* wallpaper; + auto project = WallpaperEngine::Core::CProject::fromFile("project.json", containers); + WallpaperEngine::Render::CWallpaper *wallpaper; // auto projection = project->getWallpaper ()->as ()->getOrthogonalProjection (); // create the window! // TODO: DO WE NEED TO PASS MONITOR HERE OR ANYTHING? // TODO: FIGURE OUT HOW TO PUT THIS WINDOW IN THE BACKGROUND - GLFWwindow* window = glfwCreateWindow (1920, 1080, "WallpaperEngine", NULL, NULL); + GLFWwindow *window = glfwCreateWindow(1920, 1080, "WallpaperEngine", NULL, NULL); if (window == nullptr) { - fprintf (stderr, "Failed to open a GLFW window"); - glfwTerminate (); + fprintf(stderr, "Failed to open a GLFW window"); + glfwTerminate(); return 2; } - glfwMakeContextCurrent (window); + WallpaperEngine::Core::CWindow::MakeWindowsDesktop(window); + + glfwMakeContextCurrent(window); // initialize inputs - CMouseInput* mouseInput = new CMouseInput (window); + CMouseInput *mouseInput = new CMouseInput(window); // initialize custom context class - WallpaperEngine::Render::CContext* context = new WallpaperEngine::Render::CContext (screens, mouseInput); + WallpaperEngine::Render::CContext *context = new WallpaperEngine::Render::CContext(screens, mouseInput); // TODO: FIGURE THESE OUT BASED ON THE SCREEN int windowWidth = 1920; int windowHeight = 1080; // get the real framebuffer size - glfwGetFramebufferSize (window, &windowWidth, &windowHeight); + glfwGetFramebufferSize(window, &windowWidth, &windowHeight); // set the default viewport - context->setDefaultViewport ({0, 0, windowWidth, windowHeight}); + context->setDefaultViewport({0, 0, windowWidth, windowHeight}); - if (glewInit () != GLEW_OK) + if (glewInit() != GLEW_OK) { - fprintf (stderr, "Failed to initialize GLEW"); - glfwTerminate (); + fprintf(stderr, "Failed to initialize GLEW"); + glfwTerminate(); return 3; } - - if (project->getType () == "scene") + if (project->getType() == "scene") { - WallpaperEngine::Core::CScene* scene = project->getWallpaper ()->as (); - wallpaper = new WallpaperEngine::Render::CScene (scene, containers, context); + WallpaperEngine::Core::CScene *scene = project->getWallpaper()->as(); + wallpaper = new WallpaperEngine::Render::CScene(scene, containers, context); } - else if (project->getType () == "video") + else if (project->getType() == "video") { // special steps, running a video needs a root directory change, files are not loaded from the container classes // as they're streamed from disk - chdir (path.c_str ()); + chdir(path.c_str()); - WallpaperEngine::Core::CVideo* video = project->getWallpaper ()->as (); - wallpaper = new WallpaperEngine::Render::CVideo (video, containers, context); + WallpaperEngine::Core::CVideo *video = project->getWallpaper()->as(); + wallpaper = new WallpaperEngine::Render::CVideo(video, containers, context); } else { - throw std::runtime_error ("Unsupported wallpaper type"); + throw std::runtime_error("Unsupported wallpaper type"); } // ensure the context knows what wallpaper to render - context->setWallpaper (wallpaper); + context->setWallpaper(wallpaper); if (shouldEnableAudio == true) { int mixer_flags = MIX_INIT_MP3 | MIX_INIT_FLAC | MIX_INIT_OGG; - if (SDL_Init (SDL_INIT_AUDIO) < 0 || mixer_flags != Mix_Init (mixer_flags)) + if (SDL_Init(SDL_INIT_AUDIO) < 0 || mixer_flags != Mix_Init(mixer_flags)) { // Mix_GetError is an alias for SDL_GetError, so calling it directly will yield the correct result // it doesn't matter if SDL_Init or Mix_Init failed, both report the errors through the same functions - fprintf (stderr, "Cannot initialize SDL audio system, SDL_GetError: %s", SDL_GetError ()); + fprintf(stderr, "Cannot initialize SDL audio system, SDL_GetError: %s", SDL_GetError()); return 2; } // initialize audio engine - Mix_OpenAudio (22050, AUDIO_S16SYS, 2, 640); + Mix_OpenAudio(22050, AUDIO_S16SYS, 2, 640); } // TODO: FIGURE OUT THE REQUIRED INPUT MODE, AS SOME WALLPAPERS USE THINGS LIKE MOUSE POSITION // glfwSetInputMode (window, GLFW_STICKY_KEYS, GL_TRUE); // enable depth text - glEnable (GL_DEPTH_TEST); - glDepthFunc (GL_LESS); + glEnable(GL_DEPTH_TEST); + glDepthFunc(GL_LESS); // cull anything that doesn't look at the camera (might be useful to disable in the future) - glDisable (GL_CULL_FACE); + glDisable(GL_CULL_FACE); clock_t minimumTime = 1000 / maximumFPS; clock_t startTime = 0; clock_t endTime = 0; - while (glfwWindowShouldClose (window) == 0) + while (glfwWindowShouldClose(window) == 0) { // get the real framebuffer size - glfwGetFramebufferSize (window, &windowWidth, &windowHeight); + glfwGetFramebufferSize(window, &windowWidth, &windowHeight); // set the default viewport - context->setDefaultViewport ({0, 0, windowWidth, windowHeight}); + context->setDefaultViewport({0, 0, windowWidth, windowHeight}); // calculate the current time value - g_Time = (float) glfwGetTime (); + g_Time = (float)glfwGetTime(); // get the start time of the frame - startTime = clock (); + startTime = clock(); // update our inputs first - mouseInput->update (); + mouseInput->update(); // render the scene - context->render (); + context->render(); // do buffer swapping - glfwSwapBuffers (window); + glfwSwapBuffers(window); // poll for events (like closing the window) - glfwPollEvents (); + glfwPollEvents(); // get the end time of the frame - endTime = clock (); + endTime = clock(); // ensure the frame time is correct to not overrun FPS if ((endTime - startTime) < minimumTime) - usleep (static_cast ((static_cast ((minimumTime - (endTime - startTime))) / CLOCKS_PER_SEC) * 1000)); + usleep(static_cast((static_cast((minimumTime - (endTime - startTime))) / CLOCKS_PER_SEC) * 1000)); } // terminate gl - glfwTerminate (); + glfwTerminate(); // terminate SDL - SDL_Quit (); + SDL_Quit(); // terminate free image - FreeImage_DeInitialise (); + FreeImage_DeInitialise(); return 0; } \ No newline at end of file diff --git a/src/WallpaperEngine/Core/CWindow.cpp b/src/WallpaperEngine/Core/CWindow.cpp new file mode 100644 index 00000000..141d7be2 --- /dev/null +++ b/src/WallpaperEngine/Core/CWindow.cpp @@ -0,0 +1,76 @@ +#include "CWindow.h" + +using namespace WallpaperEngine::Core; + +void CWindow::MakeWindowsDesktop(GLFWwindow *window) +{ + + Window xwindow = glfwGetX11Window(window); + Display *xdisplay = glfwGetX11Display(); + + Atom xa = XInternAtom(xdisplay, "_NET_WM_WINDOW_TYPE", False); + Atom type = XInternAtom(xdisplay, "_NET_WM_WINDOW_TYPE_DESKTOP", False); + XChangeProperty(xdisplay, xwindow, + xa, XA_ATOM, 32, + PropModeReplace, (unsigned char *)&type, 1); + + xa = XInternAtom(xdisplay, "_NET_WM_DESKTOP", False); + if (xa != None) + { + unsigned int xa_prop = 0xFFFFFFFF; + XChangeProperty(xdisplay, xwindow, xa, XA_CARDINAL, 32, + PropModeAppend, + (unsigned char *)&xa_prop, 1); + } + + xa = XInternAtom(xdisplay, "_NET_WM_STATE", False); + if (xa != None) + { + Atom xa_prop = XInternAtom(xdisplay, "_NET_WM_STATE_STICKY", False); + XChangeProperty(xdisplay, xwindow, xa, XA_ATOM, 32, + PropModeAppend, + (unsigned char *)&xa_prop, 1); + } + + xa = XInternAtom(xdisplay, "_WIN_LAYER", False); + if (xa != None) + { + long prop = 0; + + XChangeProperty(xdisplay, xwindow, xa, XA_CARDINAL, 32, + PropModeAppend, + (unsigned char *)&prop, 1); + } + + xa = XInternAtom(xdisplay, "_NET_WM_STATE", False); + if (xa != None) + { + Atom xa_prop = XInternAtom(xdisplay, "_NET_WM_STATE_BELOW", False); + + XChangeProperty(xdisplay, xwindow, xa, XA_ATOM, 32, + PropModeAppend, + (unsigned char *)&xa_prop, 1); + } + + xa = XInternAtom(xdisplay, "_NET_WM_STATE", False); + if (xa != None) + { + Atom xa_prop = XInternAtom(xdisplay, "_NET_WM_STATE_SKIP_TASKBAR", False); + + XChangeProperty(xdisplay, xwindow, xa, XA_ATOM, 32, + PropModeAppend, + (unsigned char *)&xa_prop, 1); + } + + xa = XInternAtom(xdisplay, "_NET_WM_STATE", False); + if (xa != None) + { + Atom xa_prop = XInternAtom(xdisplay, "_NET_WM_STATE_SKIP_PAGER", False); + + XChangeProperty(xdisplay, xwindow, xa, XA_ATOM, 32, + PropModeAppend, + (unsigned char *)&xa_prop, 1); + } + + /// +} diff --git a/src/WallpaperEngine/Core/CWindow.h b/src/WallpaperEngine/Core/CWindow.h new file mode 100644 index 00000000..c1a37222 --- /dev/null +++ b/src/WallpaperEngine/Core/CWindow.h @@ -0,0 +1,18 @@ +#pragma once + +#define GLFW_EXPOSE_NATIVE_X11 +#include "GLFW/glfw3.h" +#include "GLFW/glfw3native.h" +#include + +namespace WallpaperEngine::Core +{ + class CWindow + { + public: + static void MakeWindowsDesktop(GLFWwindow *window); + + protected: + private: + }; +} From 5fa9fdb1c2c6b083f82653a9e40bfb4e2eabd00e Mon Sep 17 00:00:00 2001 From: Robert Blackburn Date: Sat, 4 Dec 2021 21:34:02 +0000 Subject: [PATCH 4/7] Detect and set screen resolution --- main.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/main.cpp b/main.cpp index 8ae37fb5..46229ddf 100644 --- a/main.cpp +++ b/main.cpp @@ -10,6 +10,8 @@ #include #include "GLFW/glfw3.h" +#include + #include "WallpaperEngine/Core/CProject.h" #include "WallpaperEngine/Render/CWallpaper.h" #include "WallpaperEngine/Render/CContext.h" @@ -184,8 +186,16 @@ int main(int argc, char *argv[]) // auto projection = project->getWallpaper ()->as ()->getOrthogonalProjection (); // create the window! // TODO: DO WE NEED TO PASS MONITOR HERE OR ANYTHING? + + Display *x11display = XOpenDisplay(NULL); + Screen *x11Screen = DefaultScreenOfDisplay(x11display); + int windowWidth = x11Screen->width; + int windowHeight = x11Screen->height; + + glfwWindowHint(GLFW_DECORATED, 0); + // TODO: FIGURE OUT HOW TO PUT THIS WINDOW IN THE BACKGROUND - GLFWwindow *window = glfwCreateWindow(1920, 1080, "WallpaperEngine", NULL, NULL); + GLFWwindow *window = glfwCreateWindow(windowWidth, windowHeight, "WallpaperEngine", NULL, NULL); if (window == nullptr) { @@ -203,10 +213,6 @@ int main(int argc, char *argv[]) // initialize custom context class WallpaperEngine::Render::CContext *context = new WallpaperEngine::Render::CContext(screens, mouseInput); - // TODO: FIGURE THESE OUT BASED ON THE SCREEN - int windowWidth = 1920; - int windowHeight = 1080; - // get the real framebuffer size glfwGetFramebufferSize(window, &windowWidth, &windowHeight); // set the default viewport From 6588f47549f72598d8dd67d38e67d54839c7c5ee Mon Sep 17 00:00:00 2001 From: Robert Blackburn Date: Sat, 4 Dec 2021 21:35:55 +0000 Subject: [PATCH 5/7] swaped xchange property for xsendevent --- src/WallpaperEngine/Core/CWindow.cpp | 95 +++++++++++----------------- src/WallpaperEngine/Core/CWindow.h | 8 +++ 2 files changed, 46 insertions(+), 57 deletions(-) diff --git a/src/WallpaperEngine/Core/CWindow.cpp b/src/WallpaperEngine/Core/CWindow.cpp index 141d7be2..b0a206b0 100644 --- a/src/WallpaperEngine/Core/CWindow.cpp +++ b/src/WallpaperEngine/Core/CWindow.cpp @@ -2,6 +2,31 @@ using namespace WallpaperEngine::Core; +#define _NET_WM_STATE_REMOVE 0 /* remove/unset property */ +#define _NET_WM_STATE_ADD 1 /* add/set property */ +#define _NET_WM_STATE_TOGGLE 2 /* toggle property */ + +Status x11_sendEvent(Display *display, Window xid, Atom type, Atom prop, Atom action) +{ + XEvent event; + event.xclient.type = ClientMessage; + event.xclient.serial = 0; + event.xclient.send_event = True; + event.xclient.display = display; + event.xclient.window = xid; + event.xclient.message_type = type; + event.xclient.format = 32; + + event.xclient.data.l[0] = action; + event.xclient.data.l[1] = prop; + event.xclient.data.l[2] = 0; // unused. + event.xclient.data.l[3] = 0; + event.xclient.data.l[4] = 0; + + return XSendEvent(display, DefaultRootWindow(display), False, + SubstructureRedirectMask | SubstructureNotifyMask, &event); +} + void CWindow::MakeWindowsDesktop(GLFWwindow *window) { @@ -14,63 +39,19 @@ void CWindow::MakeWindowsDesktop(GLFWwindow *window) xa, XA_ATOM, 32, PropModeReplace, (unsigned char *)&type, 1); - xa = XInternAtom(xdisplay, "_NET_WM_DESKTOP", False); - if (xa != None) - { - unsigned int xa_prop = 0xFFFFFFFF; - XChangeProperty(xdisplay, xwindow, xa, XA_CARDINAL, 32, - PropModeAppend, - (unsigned char *)&xa_prop, 1); - } - - xa = XInternAtom(xdisplay, "_NET_WM_STATE", False); - if (xa != None) - { - Atom xa_prop = XInternAtom(xdisplay, "_NET_WM_STATE_STICKY", False); - XChangeProperty(xdisplay, xwindow, xa, XA_ATOM, 32, - PropModeAppend, - (unsigned char *)&xa_prop, 1); - } - - xa = XInternAtom(xdisplay, "_WIN_LAYER", False); - if (xa != None) - { - long prop = 0; - - XChangeProperty(xdisplay, xwindow, xa, XA_CARDINAL, 32, - PropModeAppend, - (unsigned char *)&prop, 1); - } - - xa = XInternAtom(xdisplay, "_NET_WM_STATE", False); - if (xa != None) - { - Atom xa_prop = XInternAtom(xdisplay, "_NET_WM_STATE_BELOW", False); - - XChangeProperty(xdisplay, xwindow, xa, XA_ATOM, 32, - PropModeAppend, - (unsigned char *)&xa_prop, 1); - } - - xa = XInternAtom(xdisplay, "_NET_WM_STATE", False); - if (xa != None) - { - Atom xa_prop = XInternAtom(xdisplay, "_NET_WM_STATE_SKIP_TASKBAR", False); - - XChangeProperty(xdisplay, xwindow, xa, XA_ATOM, 32, - PropModeAppend, - (unsigned char *)&xa_prop, 1); - } - - xa = XInternAtom(xdisplay, "_NET_WM_STATE", False); - if (xa != None) - { - Atom xa_prop = XInternAtom(xdisplay, "_NET_WM_STATE_SKIP_PAGER", False); - - XChangeProperty(xdisplay, xwindow, xa, XA_ATOM, 32, - PropModeAppend, - (unsigned char *)&xa_prop, 1); - } + x11_sendEvent(xdisplay, xwindow, XInternAtom(xdisplay, "_NET_WM_DESKTOP", False), 0xFFFFFFFF, _NET_WM_STATE_ADD); + + x11_sendEvent(xdisplay, xwindow, XInternAtom(xdisplay, "_NET_WM_STATE", False), XInternAtom(xdisplay, "_NET_WM_STATE_STICKY", False), _NET_WM_STATE_ADD); + + x11_sendEvent(xdisplay, xwindow, XInternAtom(xdisplay, "_WIN_LAYER", False), 0, _NET_WM_STATE_ADD); + + x11_sendEvent(xdisplay, xwindow, XInternAtom(xdisplay, "_NET_WM_STATE", False), XInternAtom(xdisplay, "_NET_WM_STATE_BELOW", False), _NET_WM_STATE_ADD); + + x11_sendEvent(xdisplay, xwindow, XInternAtom(xdisplay, "_NET_WM_STATE", False), XInternAtom(xdisplay, "_NET_WM_STATE_SKIP_TASKBAR", False), _NET_WM_STATE_ADD); + + x11_sendEvent(xdisplay, xwindow, XInternAtom(xdisplay, "_NET_WM_STATE", False), XInternAtom(xdisplay, "_NET_WM_STATE_SKIP_PAGER", False), _NET_WM_STATE_ADD); + + XLowerWindow(xdisplay, xwindow); /// } diff --git a/src/WallpaperEngine/Core/CWindow.h b/src/WallpaperEngine/Core/CWindow.h index c1a37222..d05b9e1f 100644 --- a/src/WallpaperEngine/Core/CWindow.h +++ b/src/WallpaperEngine/Core/CWindow.h @@ -5,6 +5,14 @@ #include "GLFW/glfw3native.h" #include +#ifdef LONG64 +typedef unsigned long XCARD64; +typedef unsigned int XCARD32; +#else +typedef unsigned long long XCARD64; +typedef unsigned long XCARD32; +#endif + namespace WallpaperEngine::Core { class CWindow From 32a159beeda811a1d901956a5adefdb9add34f7b Mon Sep 17 00:00:00 2001 From: Robert Blackburn Date: Sun, 12 Dec 2021 15:10:27 +0000 Subject: [PATCH 6/7] git ignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index f526984c..436150f4 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ cmake-build-debug assets.zip .idea assets/ -build/ \ No newline at end of file +build/ +.vscode/ From cfdb609adbfac9127163da090fdbcf4e9dc8e991 Mon Sep 17 00:00:00 2001 From: Robert Blackburn Date: Sun, 12 Dec 2021 15:10:56 +0000 Subject: [PATCH 7/7] detect window size --- main.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index 46229ddf..8ffa2ac8 100644 --- a/main.cpp +++ b/main.cpp @@ -189,10 +189,15 @@ int main(int argc, char *argv[]) Display *x11display = XOpenDisplay(NULL); Screen *x11Screen = DefaultScreenOfDisplay(x11display); - int windowWidth = x11Screen->width; - int windowHeight = x11Screen->height; + int windowWidth = 1920; // x11Screen->width; + int windowHeight = 1080; // x11Screen->height; glfwWindowHint(GLFW_DECORATED, 0); + // glfwWindowHint(GLFW_NET_WM_WINDOW_TYPE_DESKTOP, 1); + // glfwWindowHint(GLFW_STICKY_WINDOW, 1); + // glfwWindowHint(GLFW_BELOW, 1); + // glfwWindowHint(GLFW_SKIP_TASKBAR, 1); + // glfwWindowHint(GLFW_SKIP_PAGER, 1); // TODO: FIGURE OUT HOW TO PUT THIS WINDOW IN THE BACKGROUND GLFWwindow *window = glfwCreateWindow(windowWidth, windowHeight, "WallpaperEngine", NULL, NULL);