void screenWidget::cursor_hide(BYTE hide) { if (hide == TRUE) { setCursor(Qt::BlankCursor); } else { cursor_set(); } }
int trap_SetCursor(lua_State *s) { CURSOR *cursor; trap_args(s, "SetCursor", "p", &cursor); cursor_set(cursor); return 0; }
void init(const char *_cmd) { x11_init(); checkotherwm(); cmd = _cmd; /* Setup the motion struct */ motion = xcalloc(1, sizeof(struct motion)); motion->type = NoMotion; sysinfo_init(); clients_init(); bars_init(settings()->barfont); launcher_init(); /* Select wvents to handle */ XSelectInput(dpy, root, WM_EVENT_MASK); /* Setup cursors */ cursors_init(); cursor_set(root, NormalCursor); /* Setup key bindings */ keys = settings()->keys; key_init(); key_grab_all(keys); /* Init atoms and EWMH */ atoms_init(); ewmh_init(wm_name); /* Init program lists */ program_init(getenv("PATH")); /* Create monitors */ create_monitors(); /* Init ewmh desktop functionality */ ewmh_root_set_number_of_desktops( monitor_count(mons) * N_WORKSPACES); ewmh_root_set_current_desktop(0); get_windows(); set_environment(); }
int main () { xcb_screen_iterator_t screen_iter; xcb_connection_t *c; const xcb_setup_t *setup; xcb_screen_t *screen; xcb_generic_event_t *e; xcb_generic_error_t *error; xcb_void_cookie_t cookie_window; xcb_void_cookie_t cookie_map; xcb_window_t window; uint32_t mask; uint32_t values[2]; int screen_number; uint8_t is_hand = 0; /* getting the connection */ c = xcb_connect (NULL, &screen_number); if (!c) { fprintf (stderr, "ERROR: can't connect to an X server\n"); return -1; } /* getting the current screen */ setup = xcb_get_setup (c); screen = NULL; screen_iter = xcb_setup_roots_iterator (setup); for (; screen_iter.rem != 0; --screen_number, xcb_screen_next (&screen_iter)) if (screen_number == 0) { screen = screen_iter.data; break; } if (!screen) { fprintf (stderr, "ERROR: can't get the current screen\n"); xcb_disconnect (c); return -1; } /* creating the window */ window = xcb_generate_id (c); mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK; values[0] = screen->white_pixel; values[1] = XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_POINTER_MOTION; cookie_window = xcb_create_window_checked (c, screen->root_depth, window, screen->root, 20, 200, WIDTH, HEIGHT, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, screen->root_visual, mask, values); cookie_map = xcb_map_window_checked (c, window); /* error managing */ error = xcb_request_check (c, cookie_window); if (error) { fprintf (stderr, "ERROR: can't create window : %d\n", error->error_code); xcb_disconnect (c); return -1; } error = xcb_request_check (c, cookie_map); if (error) { fprintf (stderr, "ERROR: can't map window : %d\n", error->error_code); xcb_disconnect (c); return -1; } cursor_set (c, screen, window, 68); xcb_flush(c); while (1) { e = xcb_poll_for_event(c); if (e) { switch (e->response_type & ~0x80) { case XCB_EXPOSE: { char *text; text = "click here to change cursor"; button_draw (c, screen, window, (WIDTH - 7 * strlen(text)) / 2, (HEIGHT - 16) / 2, text); text = "Press ESC key to exit..."; text_draw (c, screen, window, 10, HEIGHT - 10, text); break; } case XCB_BUTTON_PRESS: { xcb_button_press_event_t *ev; int length; ev = (xcb_button_press_event_t *)e; length = strlen ("click here to change cursor"); if ((ev->event_x >= (WIDTH - 7 * length) / 2) && (ev->event_x <= ((WIDTH - 7 * length) / 2 + 7 * length + 6)) && (ev->event_y >= (HEIGHT - 16) / 2 - 19) && (ev->event_y <= ((HEIGHT - 16) / 2))) is_hand = 1 - is_hand; is_hand ? cursor_set (c, screen, window, 58) : cursor_set (c, screen, window, 68); } case XCB_KEY_RELEASE: { xcb_key_release_event_t *ev; ev = (xcb_key_release_event_t *)e; switch (ev->detail) { /* ESC */ case 9: free (e); xcb_disconnect (c); return 0; } } } free (e); } } return 0; }