Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <xcb/xcb.h>
- int main(void){
- xcb_connection_t *connection;
- xcb_screen_t *screen;
- xcb_window_t rootWindow;
- connection = xcb_connect(NULL, NULL);
- screen = xcb_setup_roots_iterator(xcb_get_setup(connection)).data;
- rootWindow = screen->root;
- uint32_t values[] = {XCB_EVENT_MASK_PROPERTY_CHANGE};
- xcb_change_window_attributes(connection, rootWindow, XCB_CW_EVENT_MASK, values);
- xcb_property_notify_event_t *ev;
- while((ev = (xcb_property_notify_event_t*)xcb_wait_for_event(connection)) != NULL){
- xcb_get_atom_name_cookie_t nameCookie;
- xcb_get_atom_name_reply_t *nameReply;
- xcb_generic_error_t *e = NULL;
- nameCookie = xcb_get_atom_name(connection, ev->atom);
- nameReply = xcb_get_atom_name_reply(connection, nameCookie, &e);
- char *atomName = xcb_get_atom_name_name(nameReply);
- if(strcmp("_NET_ACTIVE_WINDOW", atomName) == 0){
- puts("active window changed");
- }
- }
- xcb_disconnect(connection);
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment