Skip to content

Instantly share code, notes, and snippets.

@draftcode
Created November 4, 2012 13:53
Show Gist options
  • Select an option

  • Save draftcode/4012016 to your computer and use it in GitHub Desktop.

Select an option

Save draftcode/4012016 to your computer and use it in GitHub Desktop.
WindowManager test
extern "C" {
#include <X11/Xlib.h>
#include <X11/cursorfont.h>
#include <X11/extensions/Xinerama.h>
}
int main(void) {
Display *display(XOpenDisplay(nullptr));
if (!display) return 1;
XSetWindowAttributes at = {
.event_mask = SubstructureRedirectMask,
.cursor = XCreateFontCursor(display, XC_left_ptr),
};
const int screen_count(ScreenCount(display));
for (int i = 0; i < screen_count; ++i) {
Window root_window(RootWindow(display, i));
XChangeWindowAttributes(display, root_window, CWEventMask | CWCursor, &at);
}
while (true) {
XEvent event;
XNextEvent(display, &event);
if (event.type == MapRequest) {
XMapRequestEvent *map_request_event(&event.xmaprequest);
XMapWindow(map_request_event->display, map_request_event->window);
XSetInputFocus(map_request_event->display, map_request_event->window,
RevertToPointerRoot, CurrentTime);
}
}
XCloseDisplay(display);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment