I want to alter the native properties of a glfw window
It is possible, but the specific property im after (rendering the window behind all other windows) isnt working
I know for a fact this property works as i made an xlib window from scratch to test. Is GLFW blocking me from assigning this property? Is there an easy solution to this?
Code is below.
FYI Cross compatibility is not a concern rn
/*
If you would like to try it out heres the build command
`gcc -o main -Iinclude main.c -L./ -l:libglfw3.a -lm -lX11`
include contains the default glfw include folder
libglfw3.a is in the root of the project
*/
#include <stdio.h>
#include <unistd.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include "GLFW/glfw3.h"
#define GLFW_EXPOSE_NATIVE_X11
#include "GLFW/glfw3native.h"
int main()
{
GLFWwindow *window;
if( !glfwInit() ){
puts("Failed to init glfw");
return 1;
}
window = glfwCreateWindow(800, 600, "My glfw window", NULL, NULL);
if( window == NULL ){
puts("Failed to create glfw window");
return 1;
}
// Get the X11 display and window
Display* x_display = glfwGetX11Display();
Window x_window = glfwGetX11Window( window );
/* Try to set window properties to render below other windows
* This DOES NOT work
* when `xprop` is ran and the window is clicked i get this in the output
* `_NET_WM_STATE(ATOM) = `
* This should have at least the value `_NET_WM_STATE_BELOW` but it is nil
*/
Atom current_atom = XInternAtom(x_display, "_NET_WM_STATE", False);
if( current_atom != None ){
Atom atom_new_property = XInternAtom(x_display, "_NET_WM_STATE_BELOW", False);
XChangeProperty(x_display, x_window,
current_atom, XA_ATOM, 32, PropModeReplace,
(unsigned char*)&atom_new_property, 1
);
puts("This is being successfully ran!!");
}
/* Remove window decorations
* This DOES work
* simply proof that it should be possible to alter the window from xlib
*/
current_atom = XInternAtom(x_display, "_MOTIF_WM_HINTS", False);
if( current_atom != None ){
long new_properties[5] = { 2, 0, 0, 0, 0 };
XChangeProperty(x_display, x_window,
current_atom, current_atom, 32, PropModeReplace,
(unsigned char *) new_properties, 5
);
}
glfwMakeContextCurrent( window );
// App loop to keep window open for long enough
while( !glfwWindowShouldClose(window) )
{
glfwPollEvents();
sleep(1);
glfwSwapBuffers( window );
}
glfwTerminate();
return 0;
}