void overlay_hide(struct overlay * overlay) { xcb_unmap_window(overlay->connection, overlay->top); xcb_unmap_window(overlay->connection, overlay->left); xcb_unmap_window(overlay->connection, overlay->right); xcb_unmap_window(overlay->connection, overlay->bottom); xcb_flush(overlay->connection); }
void Client::unmap() { if (!mFrame) return; xcb_connection_t* conn = WindowManager::instance()->connection(); warning() << "unmapping frame???" << mFrame; xcb_unmap_window(conn, mFrame); xcb_unmap_window(conn, mWindow); }
/** Remove systray information in X. */ void systray_cleanup(void) { xcb_intern_atom_reply_t *atom_systray_r; char *atom_name; if(!(atom_name = xcb_atom_name_by_screen("_NET_SYSTEM_TRAY", globalconf.default_screen)) || !(atom_systray_r = xcb_intern_atom_reply(globalconf.connection, xcb_intern_atom_unchecked(globalconf.connection, false, a_strlen(atom_name), atom_name), NULL))) { warn("error getting systray atom"); p_delete(&atom_name); return; } p_delete(&atom_name); xcb_set_selection_owner(globalconf.connection, XCB_NONE, atom_systray_r->atom, XCB_CURRENT_TIME); p_delete(&atom_systray_r); xcb_unmap_window(globalconf.connection, globalconf.systray.window); }
/* Removes the current windows of the frame from the screen */ void unmapCurrentFrame(xcb_connection_t *conn,std::vector<xcb_window_t> (&frames)[NUM_FRAMES], int frameNum) { int size = frames[frameNum].size(); std::vector<xcb_window_t> windowVector = frames[frameNum]; for(int i=0; i<size; i++) { xcb_unmap_window(conn,windowVector.at(i)); } }
void QXcbWindow::setVisible(bool visible) { xcb_wm_hints_t hints; if (visible) { if (widget()->isMinimized()) xcb_wm_hints_set_iconic(&hints); else xcb_wm_hints_set_normal(&hints); xcb_set_wm_hints(xcb_connection(), m_window, &hints); Q_XCB_CALL(xcb_map_window(xcb_connection(), m_window)); connection()->sync(); } else { Q_XCB_CALL(xcb_unmap_window(xcb_connection(), m_window)); // send synthetic UnmapNotify event according to icccm 4.1.4 xcb_unmap_notify_event_t event; event.response_type = XCB_UNMAP_NOTIFY; event.sequence = 0; // does this matter? event.event = m_screen->root(); event.window = m_window; event.from_configure = false; Q_XCB_CALL(xcb_send_event(xcb_connection(), false, m_screen->root(), XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *)&event)); xcb_flush(xcb_connection()); } }
static void towel_window_map(towel_window_t *win) { xcb_atom_t ATOM = towel_window_get_atom(win, "ATOM"); xcb_atom_t wm_state = towel_window_get_atom(win, "_NET_WM_STATE"); xcb_atom_t wm_state_fullscreen = towel_window_get_atom(win, "_NET_WM_STATE_FULLSCREEN"); xcb_client_message_event_t ev = { .response_type = XCB_CLIENT_MESSAGE, .format = 32, .window = win->id, .type = wm_state, }; ev.data.data32[0] = 1; ev.data.data32[1] = wm_state_fullscreen; ev.data.data32[2] = 0; ev.data.data32[3] = 1; xcb_change_property(win->conn, XCB_PROP_MODE_REPLACE, win->id, wm_state, ATOM, 8, sizeof(xcb_atom_t), &wm_state_fullscreen); xcb_map_window(win->conn, win->id); } static void towel_window_unmap(towel_window_t *win) { xcb_unmap_window(win->conn, win->id); }
void xcbosd_expose(xcbosd *osd) { assert (osd); lprintf("expose (state:%d)\n", osd->clean ); switch (osd->mode) { case XCBOSD_SHAPED: xcb_shape_mask(osd->connection, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING, osd->u.shaped.window, 0, 0, osd->u.shaped.mask_bitmap); if( osd->clean==DRAWN ) { if( !osd->u.shaped.mapped ) { unsigned int stack_mode = XCB_STACK_MODE_ABOVE; xcb_configure_window(osd->connection, osd->u.shaped.window, XCB_CONFIG_WINDOW_STACK_MODE, &stack_mode); xcb_map_window(osd->connection, osd->u.shaped.window); } osd->u.shaped.mapped = 1; xcb_copy_area(osd->connection, osd->bitmap, osd->u.shaped.window, osd->gc, 0, 0, 0, 0, osd->width, osd->height); } else { if( osd->u.shaped.mapped ) xcb_unmap_window(osd->connection, osd->u.shaped.window); osd->u.shaped.mapped = 0; } break; case XCBOSD_COLORKEY: if( osd->clean!=UNDEFINED ) xcb_copy_area(osd->connection, osd->bitmap, osd->window, osd->gc, 0, 0, 0, 0, osd->width, osd->height); } }
/** Update the systray * \param L The Lua VM state. * \return The number of elements pushed on stack. * \luastack * \lparam The drawin to display the systray in. * \lparam x X position for the systray. * \lparam y Y position for the systray. * \lparam base_size The size (width and height) each systray item gets. * \lparam horiz If true, the systray is horizontal, else vertical. * \lparam bg Color of the systray background. * \lparam revers If true, the systray icon order will be reversed, else default. * \lparam spacing The size of the spacing between icons. */ int luaA_systray(lua_State *L) { systray_register(); if(lua_gettop(L) != 0) { size_t bg_len; drawin_t *w = luaA_checkudata(L, 1, &drawin_class); int x = luaL_checkinteger(L, 2); int y = luaL_checkinteger(L, 3); int base_size = luaL_checkinteger(L, 4); bool horiz = lua_toboolean(L, 5); const char *bg = luaL_checklstring(L, 6, &bg_len); bool revers = lua_toboolean(L, 7); int spacing = luaL_checkinteger(L, 8); color_t bg_color; if(color_init_reply(color_init_unchecked(&bg_color, bg, bg_len))) { uint32_t config_back[] = { bg_color.pixel }; xcb_change_window_attributes(globalconf.connection, globalconf.systray.window, XCB_CW_BACK_PIXEL, config_back); } if(globalconf.systray.parent != w) xcb_reparent_window(globalconf.connection, globalconf.systray.window, w->window, x, y); else { uint32_t config_vals[2] = { x, y }; xcb_configure_window(globalconf.connection, globalconf.systray.window, XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, config_vals); } globalconf.systray.parent = w; if(globalconf.embedded.len != 0) { systray_update(base_size, horiz, revers, spacing); xcb_map_window(globalconf.connection, globalconf.systray.window); } else xcb_unmap_window(globalconf.connection, globalconf.systray.window); } lua_pushinteger(L, globalconf.embedded.len); luaA_object_push(L, globalconf.systray.parent); return 2; }
void shutdown_hide() { if (shutdown_win.cache->mapped==1) { xcb_unmap_window(conn,shutdown_win.window); xcb_flush(conn); shutdown_win.cache->mapped=0; printf("Hide\n"); } }
static void drawin_unmap(drawin_t *drawin) { xcb_unmap_window(globalconf.connection, drawin->window); foreach(item, globalconf.drawins) if(*item == drawin) { drawin_array_remove(&globalconf.drawins, item); break; } }
void window_set_visibility(xcb_window_t win, bool visible) { uint32_t values_off[] = {ROOT_EVENT_MASK & ~XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY}; uint32_t values_on[] = {ROOT_EVENT_MASK}; xcb_change_window_attributes(dpy, root, XCB_CW_EVENT_MASK, values_off); if (visible) { xcb_map_window(dpy, win); } else { xcb_unmap_window(dpy, win); } xcb_change_window_attributes(dpy, root, XCB_CW_EVENT_MASK, values_on); }
// === Unembed Window() === bool LXCB::UnembedWindow(WId win){ if(DEBUG){ qDebug() << "XCB: UnembedWindow()"; } if(win==0){ return false; } //Display *disp = QX11Info::display(); //Remove redirects //XSelectInput(disp, win, NoEventMask); uint32_t val[] = {XCB_EVENT_MASK_NO_EVENT}; xcb_change_window_attributes(QX11Info::connection(), win, XCB_CW_EVENT_MASK, val); //Make sure it is invisible xcb_unmap_window(QX11Info::connection(), win); //Reparent the window back to the root window xcb_reparent_window(QX11Info::connection(), win, QX11Info::appRootWindow(), 0, 0); return true; }
/** Remove systray information in X. */ void systray_cleanup(void) { if(!globalconf.systray.registered) return; globalconf.systray.registered = false; xcb_set_selection_owner(globalconf.connection, XCB_NONE, globalconf.systray.atom, XCB_CURRENT_TIME); xcb_unmap_window(globalconf.connection, globalconf.systray.window); }
int handle_unmap_notify_event(void *data, xcb_connection_t *c, xcb_unmap_notify_event_t *event) { client_t *client = find_client(event->window); if (client && XCB_EVENT_SENT(event)) { fprintf(stderr, "unmap notify: unmapping window %u\n", client->window); sglib_client_t_delete(&client_list, client); xcb_unmap_window(wm_conf.connection, client->window); xcb_map_window(wm_conf.connection, event->event); free(client); } /* not right */ xcb_map_window(wm_conf.connection, event->event); return 0; }
static void _eventd_nd_xcb_surface_free(EventdNdSurface *self) { if ( self == NULL ) return; EventdNdBackendContext *context = self->context; g_hash_table_remove(context->bubbles, GUINT_TO_POINTER(self->window)); if ( self->mapped ) xcb_unmap_window(context->xcb_connection, self->window); cairo_surface_destroy(self->surface); xcb_destroy_window(context->xcb_connection, self->window); g_free(self); }
X11WindowedBackend::~X11WindowedBackend() { if (m_connection) { if (m_keySymbols) { xcb_key_symbols_free(m_keySymbols); } for (auto it = m_windows.begin(); it != m_windows.end(); ++it) { xcb_unmap_window(m_connection, (*it).window); xcb_destroy_window(m_connection, (*it).window); delete (*it).winInfo; } if (m_cursor) { xcb_free_cursor(m_connection, m_cursor); } xcb_disconnect(m_connection); } }
int main(int argc, char *argv[]) { struct spwd *sp = getspnam(getenv("USER")); if (!sp) { fprintf(stderr, "Get password failed\n"); return EXIT_FAILURE; } char *password = sp->sp_pwdp; // Parse command line parameters. struct arguments arguments = { .radius = 16, .iterations = 2, }; argp_parse(&argp, argc, argv, 0, NULL, &arguments); // Connect to X11. xcb_connection_t *conn = xcb_connect(NULL, NULL); const xcb_setup_t *setup = xcb_get_setup(conn); xcb_screen_iterator_t iter = xcb_setup_roots_iterator(setup); xcb_screen_t *screen = iter.data; // Initialize keyboard stuff. Keyboard keyboard = { .conn = conn, }; init_keyboard(&keyboard); // Take a screenshot and blur it. xcb_image_t *screenshot = take_screenshot(conn, screen); blur_image(screenshot, arguments.radius, arguments.iterations); // Create window. xcb_window_t window = create_window(conn, screen, screenshot); if (!grab_inputs(conn, screen)) { fprintf(stderr, "Failed to grab keyboard and pointer.\n"); exit(EXIT_FAILURE); } xcb_map_window(conn, window); // Original screenshot image is not needed anymore because it's copied to the X server as pixmap. xcb_image_destroy(screenshot); xcb_flush(conn); // XXX: Max password length? char input[256] = { '\0' }; char *cursor = &input[0]; running = true; xcb_generic_event_t *event; while (running && (event = xcb_wait_for_event(conn))) { switch (event->response_type & ~0x80) { case XCB_EXPOSE: break; case XCB_KEY_PRESS: if (handle_key_press(&keyboard, ((xcb_key_press_event_t *)event)->detail, input, &cursor)) { if (strcmp(crypt(input, password), password) == 0) { running = false; } else { input[0] = '\0'; cursor = &input[0]; } } break; default: if (event->response_type == keyboard.first_xkb_event) { process_keyboard_event(&keyboard, event); } break; } free(event); } free_keyboard(&keyboard); xcb_unmap_window(conn, window); xcb_destroy_window(conn, window); xcb_disconnect(conn); return EXIT_SUCCESS; }
int main(void) { xcb_connection_t *c; xcb_screen_t *s; xcb_window_t w; xcb_gcontext_t g; xcb_generic_event_t *e; uint32_t mask; uint32_t values[4]; int done =0 ; signal(SIGSEGV, handler); /* open connection with the server */ c = xcb_connect(NULL,NULL); if (xcb_connection_has_error(c)) { printf("Cannot open display\n"); exit(1); } /* get the first screen */ s = xcb_setup_roots_iterator( xcb_get_setup(c) ).data; xcb_get_geometry_reply_t *geo; /* create sub window */ w= xcb_generate_id(c); mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK; values[0] = s->black_pixel; values[1] = XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_KEY_PRESS; xcb_void_cookie_t cookie; int width =640; int height =480; mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK; values[0] = s->white_pixel; values[1] = XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_VISIBILITY_CHANGE ; values[1] = 0xffff; xcb_create_window(c, s->root_depth, w, s->root, 10, 10, width, height, 1, XCB_WINDOW_CLASS_INPUT_OUTPUT, s->root_visual, mask, values); xcb_map_window(c, w); xcb_flush(c); // xcb_reparent_window(c, child, G.s->root,100,100); values[1] |= XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE; xcb_change_window_attributes_checked(c, w, mask, values); xcb_flush(c); G.conn = c; G.s = s; create_dri_drawable(); printf("wait event\n"); while (!done ) { //printf("\re=>(x%x)", e->response_type); fflush(stdout); e = xcb_wait_for_event(c); if(!e) { printf("wait event error\n"); break;} else{ switch (e->response_type & ~0x80) { case XCB_EXPOSE: /* draw or redraw the window */ printf("XCB_EXPOSE\n"); // draw_gc(w); break; case XCB_KEY_PRESS: /* exit on key press */ printf("KEY\n"); struct xcb_key_press_event_t *ep = e; printf("key=%d\n", (char)ep->detail); if(ep->detail == 9) exit(1); draw_gc(w); //gwj done = 1; break; case XCB_MOTION_NOTIFY: { printf("XCB_MOTION\n"); } break; default: printf("default e=%d\n",e->response_type); break; } free(e); } } xcb_unmap_window(c, w); xcb_destroy_window(c, w); return 0; }
/// Destructor ~scr_window() { // clean up xcb_unmap_window(con, win); xcb_destroy_window(con, win); }
void draw_byxid(xcb_window_t xid) { xcb_connection_t *c=G.conn; xcb_window_t w=xid; xcb_get_geometry_reply_t *geo; uint32_t mask; uint32_t values[4]; geo = xcb_get_geometry_reply(G.conn, xcb_get_geometry(G.conn, w), NULL); assert(geo != NULL); printf("get (%hdx%hd)@(%dx%d)\n", geo->x, geo->y, geo->width, geo->height); // try require event handler, and draw something. //start create sub window and draw gc in it. // getchar(); /* create sub window */ xcb_window_t child; child = xcb_generate_id(c); mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK; values[0] = G.s->black_pixel; values[1] = XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_KEY_PRESS; xcb_void_cookie_t cookie; // create colormap if needed , window pixfmt is diff from root window. /* xcb_map_window(c, w); xcb_flush(c); */ //creat a half size window geo->width /=2; geo->height /=2; cookie = xcb_create_window_checked(c, G.s->root_depth, child, w, 10, 10, geo->width, geo->height, 1, XCB_WINDOW_CLASS_INPUT_OUTPUT, G.s->root_visual, mask, values); //check cookie error if(1){ xcb_generic_error_t *err; err = xcb_request_check (c, cookie); if (err){ int code = err->error_code; free (err); printf("X11 error %d", code); assert (code != 0); } } xcb_map_window(c, child); xcb_flush(c); // xcb_reparent_window(c, child, 0,100,100); // root=0 return no affected. xcb_reparent_window(c, child, G.s->root,100,100); // xcb_map_window(c, child);xcb_flush(c); // ? why make a pixmap as attribute of new sub window xcb_pixmap_t pixmap; xcb_create_pixmap (G.conn, geo->depth, pixmap, child, geo->width, geo->height); values[1] |= XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE; xcb_change_window_attributes_checked(c, child, mask, values); xcb_flush(c); // xcb_poly_fill_rectangle(c, child, g, 1, &r); // both map and flush need to show window up //getchar(); //unmap is minimum window // xcb_unmap_window(c, child); // xcb_destroy_window(c, child); create_dri_drawable(); int done =0 ; xcb_generic_event_t *e; printf("wait event\n"); while (!done ) { printf("\re=>(x%x)", e->response_type); fflush(stdout); e = xcb_wait_for_event(c); if(!e)printf("wait event error\n"); else{ switch (e->response_type & ~0x80) { case XCB_EXPOSE: /* draw or redraw the window */ printf("XCB_EXPOSE\n"); draw_gc(child); break; case XCB_KEY_PRESS: /* exit on key press */ //gwj done = 1; break; } free(e); } } xcb_unmap_window(c, child); xcb_destroy_window(c, child); }
void Window::hide() { xcb_unmap_window(conn->xcb(), window); }
/** Scan X to find windows to manage. */ static void scan(xcb_query_tree_cookie_t tree_c[]) { int i, x_screen, tree_c_len; const int screen_max = xcb_setup_roots_length(xcb_get_setup(globalconf.connection)); xcb_query_tree_reply_t *tree_r; xcb_window_t *wins = NULL; xcb_get_window_attributes_reply_t *attr_r; xcb_get_geometry_reply_t *geom_r; long state; for(x_screen = 0; x_screen < screen_max; x_screen++) { tree_r = xcb_query_tree_reply(globalconf.connection, tree_c[x_screen], NULL); if(!tree_r) continue; /* Get the tree of the children windows of the current root window */ if(!(wins = xcb_query_tree_children(tree_r))) fatal("cannot get tree children"); tree_c_len = xcb_query_tree_children_length(tree_r); xcb_get_window_attributes_cookie_t attr_wins[tree_c_len]; xcb_get_property_cookie_t state_wins[tree_c_len]; for(i = 0; i < tree_c_len; i++) { attr_wins[i] = xcb_get_window_attributes_unchecked(globalconf.connection, wins[i]); state_wins[i] = window_state_get_unchecked(wins[i]); } xcb_get_geometry_cookie_t *geom_wins[tree_c_len]; for(i = 0; i < tree_c_len; i++) { attr_r = xcb_get_window_attributes_reply(globalconf.connection, attr_wins[i], NULL); state = window_state_get_reply(state_wins[i]); if(!attr_r || attr_r->override_redirect || attr_r->map_state == XCB_MAP_STATE_UNMAPPED || state == XCB_ICCCM_WM_STATE_WITHDRAWN) { geom_wins[i] = NULL; p_delete(&attr_r); continue; } p_delete(&attr_r); /* Get the geometry of the current window */ geom_wins[i] = p_alloca(xcb_get_geometry_cookie_t, 1); *(geom_wins[i]) = xcb_get_geometry_unchecked(globalconf.connection, wins[i]); } for(i = 0; i < tree_c_len; i++) { if(!geom_wins[i] || !(geom_r = xcb_get_geometry_reply(globalconf.connection, *(geom_wins[i]), NULL))) continue; /* The window can be mapped, so force it to be undrawn for startup */ xcb_unmap_window(globalconf.connection, wins[i]); client_manage(wins[i], geom_r, phys_screen_getbycoord(geom_r->x, geom_r->y, geom_r->root), x_screen, true); p_delete(&geom_r); } p_delete(&tree_r); } }
/* Change current workspace to ws. */ void changeworkspace(uint32_t ws) { struct item *item; struct client *client; if (ws == curws) { PDEBUG("Changing to same workspace!\n"); return; } PDEBUG("Changing from workspace #%d to #%d\n", curws, ws); /* * We lose our focus if the window we focus isn't fixed. An * EnterNotify event will set focus later. */ if (NULL != focuswin && !focuswin->fixed) { setunfocus(focuswin->id); focuswin = NULL; } /* Go through list of current ws. Unmap everything that isn't fixed. */ for (item = wslist[curws]; item != NULL; item = item->next) { client = item->data; PDEBUG("changeworkspace. unmap phase. ws #%d, client-fixed: %d\n", curws, client->fixed); if (!client->fixed) { /* * This is an ordinary window. Just unmap it. Note that * this will generate an unnecessary UnmapNotify event * which we will try to handle later. */ xcb_unmap_window(conn, client->id); } } /* for */ /* Go through list of new ws. Map everything that isn't fixed. */ for (item = wslist[ws]; item != NULL; item = item->next) { client = item->data; PDEBUG("changeworkspace. map phase. ws #%d, client-fixed: %d\n", ws, client->fixed); /* Fixed windows are already mapped. Map everything else. */ if (!client->fixed) { xcb_map_window(conn, client->id); } } xcb_flush(conn); curws = ws; }