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); }
void X11WindowedBackend::createCursor(const QImage &img, const QPoint &hotspot) { const xcb_pixmap_t pix = xcb_generate_id(m_connection); const xcb_gcontext_t gc = xcb_generate_id(m_connection); const xcb_cursor_t cid = xcb_generate_id(m_connection); xcb_create_pixmap(m_connection, 32, pix, m_screen->root, img.width(), img.height()); xcb_create_gc(m_connection, gc, pix, 0, nullptr); xcb_put_image(m_connection, XCB_IMAGE_FORMAT_Z_PIXMAP, pix, gc, img.width(), img.height(), 0, 0, 0, 32, img.byteCount(), img.constBits()); XRenderPicture pic(pix, 32); xcb_render_create_cursor(m_connection, cid, pic, hotspot.x(), hotspot.y()); for (auto it = m_windows.constBegin(); it != m_windows.constEnd(); ++it) { xcb_change_window_attributes(m_connection, (*it).window, XCB_CW_CURSOR, &cid); } xcb_free_pixmap(m_connection, pix); xcb_free_gc(m_connection, gc); if (m_cursor) { xcb_free_cursor(m_connection, m_cursor); } m_cursor = cid; xcb_flush(m_connection); markCursorAsRendered(); }
void client_focus(Client *c) { if(!c || !ISVISIBLE(c)) { for(c = selmon->stack; c && !ISVISIBLE(c); c = c->snext); } if(selmon->sel) { client_unfocus(selmon->sel, false); } if(c) { if(c->mon != selmon) { selmon = c->mon; } if(c->isurgent) { client_clear_urgent(c); } client_detach_stack(c); client_attach_stack(c); grabbuttons(c, true); xcb_change_window_attributes(conn, c->win, XCB_CW_BORDER_PIXEL, (uint32_t*)&dc.sel[ColBorder]); xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, c->win, XCB_CURRENT_TIME); } else { xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, root, XCB_CURRENT_TIME); } selmon->sel = c; draw_bars(); }
/* * Calls draw_image on a new pixmap and swaps that with the current pixmap * */ void redraw_screen(void) { /* avoid drawing if monitor state is not on */ if (dpms_capable) { xcb_dpms_info_reply_t *dpms_info = xcb_dpms_info_reply(conn,xcb_dpms_info(conn), NULL); if (dpms_info) { /* monitor is off when DPMS state is enabled and power level is not * DPMS_MODE_ON */ uint8_t monitor_off = dpms_info->state && dpms_info->power_level != XCB_DPMS_DPMS_MODE_ON; free(dpms_info); if (monitor_off) return; } } xcb_pixmap_t bg_pixmap = draw_image(last_resolution); xcb_change_window_attributes(conn, win, XCB_CW_BACK_PIXMAP, (uint32_t[1]){ bg_pixmap }); /* XXX: Possible optimization: Only update the area in the middle of the * screen instead of the whole screen. */ xcb_clear_area(conn, 0, win, 0, 0, last_resolution[0], last_resolution[1]); xcb_free_pixmap(conn, bg_pixmap); xcb_flush(conn); }
QXcbScreen::QXcbScreen(QXcbConnection *connection, xcb_screen_t *screen, int number) : QXcbObject(connection) , m_screen(screen) , m_number(number) { printf ("\n"); printf ("Information of screen %d:\n", screen->root); printf (" width.........: %d\n", screen->width_in_pixels); printf (" height........: %d\n", screen->height_in_pixels); printf (" depth.........: %d\n", screen->root_depth); printf (" white pixel...: %x\n", screen->white_pixel); printf (" black pixel...: %x\n", screen->black_pixel); printf ("\n"); const quint32 mask = XCB_CW_EVENT_MASK; const quint32 values[] = { // XCB_CW_EVENT_MASK XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW | XCB_EVENT_MASK_PROPERTY_CHANGE }; xcb_change_window_attributes(xcb_connection(), screen->root, mask, values); xcb_generic_error_t *error; xcb_get_property_reply_t *reply = xcb_get_property_reply(xcb_connection(), xcb_get_property(xcb_connection(), false, screen->root, atom(QXcbAtom::_NET_SUPPORTING_WM_CHECK), XCB_ATOM_WINDOW, 0, 1024), &error); if (reply && reply->format == 32 && reply->type == XCB_ATOM_WINDOW) { xcb_window_t windowManager = *((xcb_window_t *)xcb_get_property_value(reply)); if (windowManager != XCB_WINDOW_NONE) { xcb_get_property_reply_t *windowManagerReply = xcb_get_property_reply(xcb_connection(), xcb_get_property(xcb_connection(), false, windowManager, atom(QXcbAtom::_NET_WM_NAME), atom(QXcbAtom::UTF8_STRING), 0, 1024), &error); if (windowManagerReply && windowManagerReply->format == 8 && windowManagerReply->type == atom(QXcbAtom::UTF8_STRING)) { m_windowManagerName = QString::fromUtf8((const char *)xcb_get_property_value(windowManagerReply), xcb_get_property_value_length(windowManagerReply)); printf("Running window manager: %s\n", qPrintable(m_windowManagerName)); } else if (error) { connection->handleXcbError(error); free(error); } free(windowManagerReply); } } else if (error) { connection->handleXcbError(error); free(error); } free(reply); m_syncRequestSupported = m_windowManagerName != QLatin1String("KWin"); }
void watch(xcb_window_t win, bool state) { if (win == XCB_NONE) return; uint32_t value = (state ? XCB_EVENT_MASK_PROPERTY_CHANGE : XCB_EVENT_MASK_NO_EVENT); xcb_change_window_attributes(dpy, win, XCB_CW_EVENT_MASK, &value); }
/** * (Try to) register to mouse events on a window if needed. */ static void RegisterEvents (vlc_object_t *obj, xcb_connection_t *conn, xcb_window_t wnd) { /* Subscribe to parent window resize events */ uint32_t value = XCB_EVENT_MASK_POINTER_MOTION; xcb_change_window_attributes (conn, wnd, XCB_CW_EVENT_MASK, &value); /* Try to subscribe to click events */ /* (only one X11 client can get them, so might not work) */ if (var_InheritBool (obj, "mouse-events")) { value |= XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE; xcb_change_window_attributes (conn, wnd, XCB_CW_EVENT_MASK, &value); } }
static void cursor_set (xcb_connection_t *c, xcb_screen_t *screen, xcb_window_t window, int cursor_id) { uint32_t values_list[3]; xcb_void_cookie_t cookie_font; xcb_void_cookie_t cookie_gc; xcb_generic_error_t *error; xcb_font_t font; xcb_cursor_t cursor; xcb_gcontext_t gc; uint32_t mask; uint32_t value_list; font = xcb_generate_id (c); cookie_font = xcb_open_font_checked (c, font, strlen ("cursor"), "cursor"); error = xcb_request_check (c, cookie_font); if (error) { fprintf (stderr, "ERROR: can't open font : %d\n", error->error_code); xcb_disconnect (c); exit (-1); } cursor = xcb_generate_id (c); xcb_create_glyph_cursor (c, cursor, font, font, cursor_id, cursor_id + 1, 0, 0, 0, 0, 0, 0); gc = xcb_generate_id (c); mask = XCB_GC_FOREGROUND | XCB_GC_BACKGROUND | XCB_GC_FONT; values_list[0] = screen->black_pixel; values_list[1] = screen->white_pixel; values_list[2] = font; cookie_gc = xcb_create_gc_checked (c, gc, window, mask, values_list); error = xcb_request_check (c, cookie_gc); if (error) { fprintf (stderr, "ERROR: can't create gc : %d\n", error->error_code); xcb_disconnect (c); exit (-1); } mask = XCB_CW_CURSOR; value_list = cursor; xcb_change_window_attributes (c, window, mask, &value_list); xcb_free_cursor (c, cursor); cookie_font = xcb_close_font_checked (c, font); error = xcb_request_check (c, cookie_font); if (error) { fprintf (stderr, "ERROR: can't close font : %d\n", error->error_code); xcb_disconnect (c); exit (-1); } }
/** * Wrap an existing X11 window to embed the video. */ static int EmOpen (vout_window_t *wnd, const vout_window_cfg_t *cfg) { xcb_window_t window = var_InheritInteger (wnd, "drawable-xid"); if (window == 0) return VLC_EGENERIC; if (AcquireDrawable (VLC_OBJECT(wnd), window)) return VLC_EGENERIC; vout_window_sys_t *p_sys = malloc (sizeof (*p_sys)); xcb_connection_t *conn = xcb_connect (NULL, NULL); if (p_sys == NULL || xcb_connection_has_error (conn)) goto error; p_sys->embedded = true; p_sys->keys = NULL; wnd->handle.xid = window; wnd->control = Control; wnd->sys = p_sys; p_sys->conn = conn; xcb_get_geometry_reply_t *geo = xcb_get_geometry_reply (conn, xcb_get_geometry (conn, window), NULL); if (geo == NULL) { msg_Err (wnd, "bad X11 window 0x%08"PRIx8, window); goto error; } p_sys->root = geo->root; free (geo); if (var_InheritBool (wnd, "keyboard-events")) { p_sys->keys = CreateKeyHandler (VLC_OBJECT(wnd), conn); if (p_sys->keys != NULL) { const uint32_t mask = XCB_CW_EVENT_MASK; const uint32_t values[1] = { XCB_EVENT_MASK_KEY_PRESS, }; xcb_change_window_attributes (conn, window, mask, values); } } CacheAtoms (p_sys); if ((p_sys->keys != NULL) && vlc_clone (&p_sys->thread, Thread, wnd, VLC_THREAD_PRIORITY_LOW)) DestroyKeyHandler (p_sys->keys); xcb_flush (conn); (void) cfg; return VLC_SUCCESS; error: xcb_disconnect (conn); free (p_sys); ReleaseDrawable (VLC_OBJECT(wnd), window); return VLC_EGENERIC; }
struct window *add_win(struct window **list, xcb_window_t wid) { struct window *w = NULL; uint32_t mask = XCB_CW_EVENT_MASK; const uint32_t vals[1] = { XCB_EVENT_MASK_PROPERTY_CHANGE }; uint8_t flag; if ((w = malloc(sizeof(struct window)))) { w->id = wid; w->damage = xcb_generate_id(X); flag = XCB_DAMAGE_REPORT_LEVEL_NON_EMPTY; xcb_damage_create(X, w->damage, w->id, flag); w->region = xcb_generate_id(X); flag = XCB_SHAPE_SK_BOUNDING; xcb_xfixes_create_region_from_window(X, w->region, w->id, flag); w->pixmap = XCB_NONE; w->picture = XCB_NONE; w->opacity = get_window_opacity(w->id); w->alpha = XCB_NONE; w->prev = NULL; w->next = *list; *list = w; xcb_change_window_attributes(X, w->id, mask, vals); } else { fprintf(stderr, "add_window: can't alloc memory\n"); } return w; }
/** Set a simple window border color. * \param sw The simple window to change border width. * \param color The border color. */ void simplewindow_border_color_set(simple_window_t *sw, const xcolor_t *color) { xcb_change_window_attributes(globalconf.connection, sw->window, XCB_CW_BORDER_PIXEL, &color->pixel); sw->border.color = *color; }
static void set_override(xcb_window_t w, int or) { uint32_t mask = XCB_CW_OVERRIDE_REDIRECT; uint32_t val[] = { or }; xcb_change_window_attributes(conn, w, mask, val); }
void register_events(xcb_window_t w, uint32_t m) { uint32_t val[] = { m }; xcb_change_window_attributes(conn, w, XCB_CW_EVENT_MASK, val); xcb_flush(conn); }
/** 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; }
/* * Calls draw_image on a new pixmap and swaps that with the current pixmap * */ void redraw_screen(void) { xcb_pixmap_t bg_pixmap = draw_image(last_resolution); xcb_change_window_attributes(conn, win, XCB_CW_BACK_PIXMAP, (uint32_t[1]){bg_pixmap}); /* XXX: Possible optimization: Only update the area in the middle of the * screen instead of the whole screen. */ xcb_clear_area(conn, 0, win, 0, 0, last_resolution[0], last_resolution[1]); xcb_free_pixmap(conn, bg_pixmap); xcb_flush(conn); }
void subscribe_events(xcb_connection_t *c, xcb_drawable_t root) { const static uint32_t events[] = { XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE }; xcb_change_window_attributes(c, root, XCB_CW_EVENT_MASK, events); }
/* * Initialize yabar */ void ya_init() { signal(SIGTERM, ya_sighandler); signal(SIGINT, ya_sighandler); signal(SIGKILL, ya_sighandler); signal(SIGHUP, ya_sighandler); ya.depth = 32; ya.c = xcb_connect(NULL, NULL); ya.scr = xcb_setup_roots_iterator(xcb_get_setup(ya.c)).data; ya.visualtype = ya_get_visualtype(); if (ya.visualtype == NULL) { // if depth=32 not found, fallback to depth=24 ya.depth = 24; ya.visualtype = ya_get_visualtype(); } ya.colormap = xcb_generate_id(ya.c); xcb_create_colormap(ya.c, XCB_COLORMAP_ALLOC_NONE, ya.colormap, ya.scr->root, ya.visualtype->visual_id); const xcb_query_extension_reply_t *ya_reply; ya_reply = xcb_get_extension_data(ya.c, &xcb_randr_id); if (ya_reply->present) { ya.gen_flag |= GEN_RANDR; ya_init_randr(); } #ifdef YA_INTERNAL_EWMH ya.ewmh = malloc(sizeof(xcb_ewmh_connection_t)); if (xcb_ewmh_init_atoms_replies(ya.ewmh, xcb_ewmh_init_atoms(ya.c, ya.ewmh), NULL)==0) { fprintf(stderr, "Cannot use EWMH\n"); //Should exit program or not? //To be decided. } ya.lstwin = XCB_NONE; uint32_t evm = XCB_EVENT_MASK_PROPERTY_CHANGE; xcb_change_window_attributes(ya.c, ya.curwin, XCB_CW_EVENT_MASK, &evm); xcb_change_window_attributes(ya.c, ya.scr->root, XCB_CW_EVENT_MASK, &evm); xcb_get_property_cookie_t prop_ck = xcb_ewmh_get_active_window(ya.ewmh, 0); xcb_ewmh_get_active_window_reply(ya.ewmh, prop_ck, &ya.curwin, NULL); xcb_get_property_cookie_t ws_ck = xcb_ewmh_get_current_desktop(ya.ewmh, 0); xcb_ewmh_get_current_desktop_reply(ya.ewmh, ws_ck, &ya.curws, NULL); //fprintf(stderr, "WINNN = %x DESK= %x\n", ya.curwin, ya.curws); #endif //YA_INTERNAL_EWMH ya_config_parse(); }
static MetaGroup* meta_group_new (MetaX11Display *x11_display, Window group_leader) { MetaGroup *group; #define N_INITIAL_PROPS 3 Atom initial_props[N_INITIAL_PROPS]; int i; g_assert (N_INITIAL_PROPS == (int) G_N_ELEMENTS (initial_props)); group = g_new0 (MetaGroup, 1); group->x11_display = x11_display; group->windows = NULL; group->group_leader = group_leader; group->refcount = 1; /* owned by caller, hash table has only weak ref */ xcb_connection_t *xcb_conn = XGetXCBConnection (x11_display->xdisplay); xcb_generic_error_t *e; g_autofree xcb_get_window_attributes_reply_t *attrs = xcb_get_window_attributes_reply (xcb_conn, xcb_get_window_attributes (xcb_conn, group_leader), &e); if (e) return NULL; const uint32_t events[] = { attrs->your_event_mask | XCB_EVENT_MASK_PROPERTY_CHANGE }; xcb_change_window_attributes (xcb_conn, group_leader, XCB_CW_EVENT_MASK, events); if (x11_display->groups_by_leader == NULL) x11_display->groups_by_leader = g_hash_table_new (meta_unsigned_long_hash, meta_unsigned_long_equal); g_assert (g_hash_table_lookup (x11_display->groups_by_leader, &group_leader) == NULL); g_hash_table_insert (x11_display->groups_by_leader, &group->group_leader, group); /* Fill these in the order we want them to be gotten */ i = 0; initial_props[i++] = x11_display->atom_WM_CLIENT_MACHINE; initial_props[i++] = x11_display->atom__NET_WM_PID; initial_props[i++] = x11_display->atom__NET_STARTUP_ID; g_assert (N_INITIAL_PROPS == i); meta_group_reload_properties (group, initial_props, N_INITIAL_PROPS); meta_topic (META_DEBUG_GROUPS, "Created new group with leader 0x%lx\n", group->group_leader); return group; }
void client_unfocus(Client *c, bool setfocus) { if(!c) return; grabbuttons(c, false); xcb_change_window_attributes(conn, c->win, XCB_CW_BORDER_PIXEL, (uint32_t*)&dc.norm[ColBorder]); if(setfocus) xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, c->win, XCB_CURRENT_TIME); }
/* * Handle property notify events, called from ya_main when such events occur. */ void ya_handle_prop_notify(xcb_property_notify_event_t *ep) { uint32_t no_ev_val = XCB_EVENT_MASK_NO_EVENT; uint32_t pr_ev_val = XCB_EVENT_MASK_PROPERTY_CHANGE; ya_ewmh_blk *ewblk; if(ep->atom == ya.ewmh->_NET_ACTIVE_WINDOW) { xcb_get_property_cookie_t win_ck = xcb_ewmh_get_active_window(ya.ewmh, 0); xcb_ewmh_get_active_window_reply(ya.ewmh, win_ck, &ya.curwin, NULL); xcb_get_property_cookie_t ws_ck = xcb_ewmh_get_current_desktop(ya.ewmh, 0); xcb_ewmh_get_current_desktop_reply(ya.ewmh, ws_ck, &ya.curws, NULL); if (ya.curwin != ya.lstwin) { xcb_change_window_attributes(ya.c, ya.lstwin, XCB_CW_EVENT_MASK, &no_ev_val); xcb_change_window_attributes(ya.c, ya.curwin, XCB_CW_EVENT_MASK, &pr_ev_val); #ifdef YA_NOWIN_COL if(((ya.curwin == XCB_NONE) && (ya.lstwin != XCB_NONE)) || ((ya.curwin != XCB_NONE) && (ya.lstwin == XCB_NONE))) { ya_bar_t *bar = ya.curbar; for(;bar; bar= bar->next_bar) { if((bar->attr & BARA_DYN_COL)) ya_redraw_bar(bar); } } #endif //YA_NOWIN_COL } else if(ya.curwin==XCB_NONE && ya.lstwin==XCB_NONE) { //Don't return, used when switch between two empty workspaces } else { return; } } else if ((ep->atom == ya.ewmh->_NET_WM_NAME) || (ep->atom == ya.ewmh->_NET_WM_VISIBLE_NAME)) { //Same window, but title changed. Therefore don't return. } else { return; } for(ewblk = ya.ewmh_blk; ewblk; ewblk=ewblk->next_ewblk) { ya_exec_intern_ewmh_blk(ewblk->blk); } ya.lstwin = ya.curwin; ya.lstws = ya.curws; }
int main () { xcb_connection_t* connection; xcb_screen_t* screen; xcb_window_t root_window; xcb_alloc_color_reply_t *color_reply; xcb_colormap_t colormap = { 0 }; uint32_t params[1]; uint16_t r,g,b; connection = xcb_connect(NULL, NULL); if (!connection) { fprintf(stderr, "ERROR: can't connect to an X server\n"); return -1; } screen = xcb_setup_roots_iterator(xcb_get_setup(connection)).data; if (!screen) { fprintf(stderr, "ERROR: can't setup a screen\n"); xcb_disconnect(connection); return -1; } root_window = screen->root; colormap = screen->default_colormap; r = 60000, g = 20000, b = 20000; color_reply = xcb_alloc_color_reply(connection, xcb_alloc_color(connection, colormap, r, g, b), NULL); if(!color_reply) { fprintf(stderr, "ERROR: can't alloc an color\n"); xcb_disconnect(connection); return 0; } params[0] = color_reply->pixel; // sets the root_window back_pixel to pixel(params) xcb_change_window_attributes(connection, root_window, XCB_CW_BACK_PIXEL, params); // free color resources free(color_reply); // waits all things are send?? xcb_flush(connection); // xcb_destroy_window(connection, window); xcb_disconnect(connection); return 0; }
/// Xembeds a X window void xembed(xcb_window_t client) { client_win = client; uint32_t values[4]; uint32_t mask; xcb_void_cookie_t cookie; xcb_generic_error_t *error; // order of the following operations is important here! // move window below other windows values[0] = XCB_STACK_MODE_BELOW; mask = XCB_CONFIG_WINDOW_STACK_MODE; cookie = xcb_configure_window_checked(con, client_win, mask, values); error = xcb_request_check(con, cookie); if(error) { std::cerr << "Could not change client attributes." << std::endl; exit(1); } // reparent client cookie = xcb_reparent_window_checked(con, client_win, win, 0, 0); error = xcb_request_check(con, cookie); if(error) { std::cerr << "Could not reparent client." << std::endl; exit(1); } // move and resize client window values[0] = 0; values[1] = 0; values[2] = width; values[3] = height; mask = XCB_CONFIG_WINDOW_X |XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT; cookie = xcb_configure_window_checked(con, client_win, mask, values); error = xcb_request_check(con, cookie); if(error) { std::cerr << "Could not resize client." << std::endl; exit(1); } // make client overwrite-redirected values[0] = true; mask = XCB_CW_OVERRIDE_REDIRECT; cookie = xcb_change_window_attributes(con, client_win, mask, values); error = xcb_request_check(con, cookie); if(error) { std::cerr << "Could not change client attributes." << std::endl; exit(1); } }
static void towel_window_hide_cursor(towel_window_t *win) { xcb_cursor_t cur = xcb_generate_id (win->conn); xcb_pixmap_t pix = xcb_generate_id (win->conn); xcb_create_pixmap(win->conn, 1, pix, win->screen->root, 1, 1); xcb_create_cursor(win->conn, cur, pix, pix, 0, 0, 0, 0, 0, 0, 0, 0); xcb_change_window_attributes(win->conn, win->id, XCB_CW_CURSOR, &(uint32_t){cur}); xcb_free_pixmap(win->conn, pix); }
void XWaylandManager::setCursor(xcb_window_t window, const CursorType &cursor) { if (m_lastCursor == cursor) return; m_lastCursor = cursor; quint32 cursorValueList = m_cursors[cursor]; xcb_change_window_attributes(Xcb::connection(), window, XCB_CW_CURSOR, &cursorValueList); xcb_flush(Xcb::connection()); }
/** Handle a systray request. * \param embed_win The window to embed. * \param phys_screen The physical monitor to display on. * \param info The embedding info * \return 0 on no error. */ int systray_request_handle(xcb_window_t embed_win, int phys_screen, xembed_info_t *info) { xembed_window_t em; xcb_get_property_cookie_t em_cookie; const uint32_t select_input_val[] = { XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_PROPERTY_CHANGE | XCB_EVENT_MASK_ENTER_WINDOW }; /* check if not already trayed */ if(xembed_getbywin(&globalconf.embedded, embed_win)) return -1; p_clear(&em_cookie, 1); if(!info) em_cookie = xembed_info_get_unchecked(globalconf.connection, embed_win); xcb_change_window_attributes(globalconf.connection, embed_win, XCB_CW_EVENT_MASK, select_input_val); window_state_set(embed_win, XCB_ICCCM_WM_STATE_WITHDRAWN); /* we grab the window, but also make sure it's automatically reparented back * to the root window if we should die. */ xcb_change_save_set(globalconf.connection, XCB_SET_MODE_INSERT, embed_win); xcb_reparent_window(globalconf.connection, embed_win, globalconf.screens.tab[phys_screen].systray.window, 0, 0); em.win = embed_win; em.phys_screen = phys_screen; if(info) em.info = *info; else xembed_info_get_reply(globalconf.connection, em_cookie, &em.info); xembed_embedded_notify(globalconf.connection, em.win, globalconf.screens.tab[phys_screen].systray.window, MIN(XEMBED_VERSION, em.info.version)); xembed_window_array_append(&globalconf.embedded, em); widget_invalidate_bytype(widget_systray); return 0; }
// === 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; }
static void subscribe(xcb_window_t win) { uint32_t values[2]; /* subscribe to events */ values[0] = XCB_EVENT_MASK_ENTER_WINDOW; values[1] = XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY; xcb_change_window_attributes(conn, win, XCB_CW_EVENT_MASK, values); /* border width */ values[0] = BORDERWIDTH; xcb_configure_window(conn, win, XCB_CONFIG_WINDOW_BORDER_WIDTH, values); }
/** Handle a systray request. * \param embed_win The window to embed. */ int systray_request_handle(xcb_window_t embed_win, int phys_screen, xembed_info_t *info) { xembed_window_t em; xcb_get_property_cookie_t em_cookie; int i; const uint32_t select_input_val[] = { XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_PROPERTY_CHANGE | XCB_EVENT_MASK_ENTER_WINDOW }; /* check if not already trayed */ if(xembed_getbywin(&globalconf.embedded, embed_win)) return -1; p_clear(&em_cookie, 1); if(!info) em_cookie = xembed_info_get_unchecked(globalconf.connection, embed_win); xcb_change_window_attributes(globalconf.connection, embed_win, XCB_CW_EVENT_MASK, select_input_val); window_state_set(embed_win, XCB_WM_STATE_WITHDRAWN); xcb_reparent_window(globalconf.connection, embed_win, globalconf.screens[phys_screen].systray.window, 0, 0); em.win = embed_win; em.phys_screen = phys_screen; if(info) em.info = *info; else xembed_info_get_reply(globalconf.connection, em_cookie, &em.info); xembed_embedded_notify(globalconf.connection, em.win, globalconf.screens[phys_screen].systray.window, MIN(XEMBED_VERSION, em.info.version)); xembed_window_array_append(&globalconf.embedded, em); for(i = 0; i < globalconf.nscreen; i++) widget_invalidate_bytype(i, widget_systray); return 0; }
/* * Opens the window we use for input/output and maps it * */ xcb_window_t open_input_window(xcb_connection_t *conn, uint32_t width, uint32_t height) { xcb_window_t win = xcb_generate_id(conn); //xcb_cursor_t cursor_id = xcb_generate_id(conn); #if 0 /* Use the default cursor (left pointer) */ if (cursor > -1) { i3Font *cursor_font = load_font(conn, "cursor"); xcb_create_glyph_cursor(conn, cursor_id, cursor_font->id, cursor_font->id, XCB_CURSOR_LEFT_PTR, XCB_CURSOR_LEFT_PTR + 1, 0, 0, 0, 65535, 65535, 65535); } #endif uint32_t mask = 0; uint32_t values[3]; mask |= XCB_CW_BACK_PIXEL; values[0] = 0; mask |= XCB_CW_OVERRIDE_REDIRECT; values[1] = 1; mask |= XCB_CW_EVENT_MASK; values[2] = XCB_EVENT_MASK_EXPOSURE; xcb_create_window(conn, XCB_COPY_FROM_PARENT, win, /* the window id */ root, /* parent == root */ 50, 50, width, height, /* dimensions */ 0, /* border = 0, we draw our own */ XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_WINDOW_CLASS_COPY_FROM_PARENT, /* copy visual from parent */ mask, values); #if 0 if (cursor > -1) xcb_change_window_attributes(conn, result, XCB_CW_CURSOR, &cursor_id); #endif /* Map the window (= make it visible) */ xcb_map_window(conn, win); return win; }
/** * Disconnect from the X server. */ static void Close (vlc_object_t *obj) { vout_display_t *vd = (vout_display_t *)obj; vout_display_sys_t *sys = vd->sys; ResetPictures (vd); /* show the default cursor */ xcb_change_window_attributes (sys->conn, sys->embed->handle.xid, XCB_CW_CURSOR, &(uint32_t) { XCB_CURSOR_NONE }); xcb_flush (sys->conn); /* colormap, window and context are garbage-collected by X */ xcb_disconnect (sys->conn); vout_display_DeleteWindow (vd, sys->embed); free (sys); }