Created
November 4, 2012 13:53
-
-
Save draftcode/4012016 to your computer and use it in GitHub Desktop.
WindowManager test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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