void QXcbWindow::setGeometry(const QRect &rect) { QPlatformWindow::setGeometry(rect); const quint32 mask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT; const quint32 values[] = { rect.x(), rect.y(), rect.width(), rect.height() }; Q_XCB_CALL(xcb_configure_window(xcb_connection(), m_window, mask, values)); }
void XWaylandManager::handleConfigureRequest(xcb_configure_request_event_t *event) { qCDebug(XWAYLAND_TRACE, "XCB_CONFIGURE_REQUEST (window %d) %d,%d @ %dx%d", event->window, event->x, event->y, event->width, event->height); if (!m_windowsMap.contains(event->window)) return; XWaylandShellSurface *shellSurface = m_windowsMap[event->window]; if (!shellSurface->surface()) return; if (shellSurface->fullscreen()) { xcb_configure_notify_event_t notify; notify.response_type = XCB_CONFIGURE_NOTIFY; notify.pad0 = 0; notify.event = event->window; notify.window = event->window; notify.above_sibling = XCB_WINDOW_NONE; notify.x = event->x; notify.y = event->y; notify.width = event->width; notify.height = event->height; notify.border_width = 0; notify.override_redirect = 0; notify.pad1 = 0; xcb_send_event(Xcb::connection(), 0, event->window, XCB_EVENT_MASK_STRUCTURE_NOTIFY, (char *) ¬ify); return; } int x = 0, y = 0; QSize size = shellSurface->surface()->size(); if (event->value_mask & XCB_CONFIG_WINDOW_WIDTH) size.setWidth(event->width); if (event->value_mask & XCB_CONFIG_WINDOW_HEIGHT) size.setHeight(event->height); quint32 i = 0, values[16]; values[i++] = x; values[i++] = y; values[i++] = size.width(); values[i++] = size.height(); values[i++] = 0; quint32 mask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT | XCB_CONFIG_WINDOW_BORDER_WIDTH; if (event->value_mask & XCB_CONFIG_WINDOW_SIBLING) { values[i++] = event->sibling; mask |= XCB_CONFIG_WINDOW_SIBLING; } if (event->value_mask & XCB_CONFIG_WINDOW_STACK_MODE) { values[i++] = event->stack_mode; mask |= XCB_CONFIG_WINDOW_STACK_MODE; } xcb_configure_window(Xcb::connection(), event->window, mask, values); }
void window_stack(xcb_window_t w1, xcb_window_t w2, uint32_t mode) { if (w2 == XCB_NONE) { return; } uint16_t mask = XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE; uint32_t values[] = {w2, mode}; xcb_configure_window(dpy, w1, mask, values); }
/** 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; }
static void systray_update(int base_size, bool horizontal, bool reverse, int spacing) { if(base_size <= 0) return; int embedded_len = globalconf.embedded.len + 1; /* Give the systray window the correct size */ uint32_t config_vals[4] = { base_size, base_size, 0, 0 }; if(horizontal) config_vals[0] = base_size * embedded_len + spacing * (embedded_len - 1); else config_vals[1] = base_size * embedded_len + spacing * (embedded_len - 1); xcb_configure_window(globalconf.connection, globalconf.systray.window, XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, config_vals); /* Now resize each embedded window */ config_vals[0] = config_vals[1] = 0; config_vals[2] = config_vals[3] = base_size; fprintf(stderr, "embedded len: %d \n", sizeof(globalconf.embedded.tab) / sizeof(globalconf.embedded.tab[0])); for(int i = 0; i < embedded_len + 1; i++) { xembed_window_t *em; if(reverse) em = &globalconf.embedded.tab[(embedded_len - i - 1)]; else em = &globalconf.embedded.tab[i]; xcb_configure_window(globalconf.connection, em->win, XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, config_vals); xcb_map_window(globalconf.connection, em->win); if(horizontal) config_vals[0] += base_size + spacing; else config_vals[1] += base_size + spacing; } }
/** * Return a direct buffer */ static picture_pool_t *Pool (vout_display_t *vd, unsigned requested_count) { vout_display_sys_t *p_sys = vd->sys; (void)requested_count; if (!p_sys->pool) { vout_display_place_t place; vout_display_PlacePicture (&place, &vd->source, vd->cfg, false); /* */ const uint32_t values[] = { place.x, place.y, place.width, place.height }; xcb_configure_window (p_sys->conn, p_sys->window, XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, values); picture_t *pic = picture_NewFromFormat (&vd->fmt); if (!pic) return NULL; assert (pic->i_planes == 1); memset (p_sys->resource, 0, sizeof(p_sys->resource)); unsigned count; picture_t *pic_array[MAX_PICTURES]; for (count = 0; count < MAX_PICTURES; count++) { picture_resource_t *res = &p_sys->resource[count]; res->p->i_lines = pic->p->i_lines; res->p->i_pitch = pic->p->i_pitch; if (PictureResourceAlloc (vd, res, res->p->i_pitch * res->p->i_lines, p_sys->conn, p_sys->shm)) break; pic_array[count] = picture_NewFromResource (&vd->fmt, res); if (!pic_array[count]) { PictureResourceFree (res, p_sys->conn); memset (res, 0, sizeof(*res)); break; } } picture_Release (pic); if (count == 0) return NULL; p_sys->pool = picture_pool_New (count, pic_array); /* TODO release picture resources if NULL */ xcb_flush (p_sys->conn); } return p_sys->pool; }
void Window::resize_to(uint32_t width, uint32_t height) { assert(width != 0); assert(height != 0); uint16_t mask = XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT; uint32_t values[] = {width, height}; xcb_configure_window(conn->xcb(), window, mask, values); }
static void raise_window(xcb_connection_t *xcb_conn, xcb_window_t window) { const uint32_t values[] = { XCB_STACK_MODE_ABOVE }; xcb_configure_window(xcb_conn, window, XCB_CONFIG_WINDOW_STACK_MODE, values); }
xcb_window_t open_fullscreen_window(xcb_connection_t *conn, xcb_screen_t *scr, char *color, xcb_pixmap_t pixmap) { uint32_t mask = 0; uint32_t values[3]; xcb_window_t win = xcb_generate_id(conn); if (pixmap == XCB_NONE) { mask |= XCB_CW_BACK_PIXEL; values[0] = get_colorpixel(color); } else { mask |= XCB_CW_BACK_PIXMAP; values[0] = pixmap; } mask |= XCB_CW_OVERRIDE_REDIRECT; values[1] = 1; mask |= XCB_CW_EVENT_MASK; values[2] = XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_VISIBILITY_CHANGE | XCB_EVENT_MASK_STRUCTURE_NOTIFY; xcb_create_window(conn, XCB_COPY_FROM_PARENT, win, /* the window id */ scr->root, /* parent == root */ 0, 0, scr->width_in_pixels, scr->height_in_pixels, /* 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); char *name = "i3lock"; xcb_change_property(conn, XCB_PROP_MODE_REPLACE, win, XCB_ATOM_WM_NAME, XCB_ATOM_STRING, 8, strlen(name), name); /* Map the window (= make it visible) */ xcb_map_window(conn, win); /* Raise window (put it on top) */ values[0] = XCB_STACK_MODE_ABOVE; xcb_configure_window(conn, win, XCB_CONFIG_WINDOW_STACK_MODE, values); return win; }
void Client::setRect(const Rect &rect) { mRect = rect; xcb_connection_t* conn = WindowManager::instance()->connection(); const uint16_t mask = (XCB_CONFIG_WINDOW_X|XCB_CONFIG_WINDOW_Y |XCB_CONFIG_WINDOW_WIDTH|XCB_CONFIG_WINDOW_HEIGHT); const uint32_t values[4] = { static_cast<uint32_t>(rect.x), static_cast<uint32_t>(rect.y), static_cast<uint32_t>(rect.width), static_cast<uint32_t>(rect.height) }; xcb_configure_window(conn, mFrame, mask, values); }
void overlay_show(struct overlay * overlay, int x, int y, int w, int h, int border) { xcb_connection_t * connection = overlay->connection; const uint32_t XYWH = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT; xcb_map_window(overlay->connection, overlay->top); xcb_map_window(overlay->connection, overlay->left); xcb_map_window(overlay->connection, overlay->right); xcb_map_window(overlay->connection, overlay->bottom); uint32_t xywh[4]; xywh[0] = x; xywh[1] = y; xywh[2] = w; xywh[3] = border; xcb_configure_window(connection, overlay->top, XYWH, xywh); xywh[0] = x; xywh[1] = y; xywh[2] = border; xywh[3] = h; xcb_configure_window(connection, overlay->left, XYWH, xywh); xywh[0] = x+w-border; xywh[1] = y; xywh[2] = border; xywh[3] = h; xcb_configure_window(connection, overlay->right, XYWH, xywh); xywh[0] = x; xywh[1] = y+h-border; xywh[2] = w; xywh[3] = border; xcb_configure_window(connection, overlay->bottom, XYWH, xywh); xcb_flush(overlay->connection); }
void client_resize_client(Client *c, int x, int y, int w, int h) { uint32_t values[] = { x, y, w, h, c->bw }; xcb_configure_window(conn, c->win, XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT | XCB_CONFIG_WINDOW_BORDER_WIDTH, values); c->oldx = c->x; c->x = x; c->oldy = c->y; c->y = y; c->oldw = c->w; c->w = w; c->oldh = c->h; c->h = h; client_configure(c); xcb_flush(conn); }
static void center_pointer (xcb_window_t win) { uint32_t values[1]; xcb_get_geometry_reply_t *geom; geom = xcb_get_geometry_reply(conn, xcb_get_geometry(conn, win), NULL); xcb_warp_pointer(conn, XCB_NONE, win, 0, 0, 0, 0, (geom->width + (BORDERWIDTH * 2)) / 2, (geom->height + (BORDERWIDTH * 2)) / 2); values[0] = XCB_STACK_MODE_ABOVE; xcb_configure_window(conn, win, XCB_CONFIG_WINDOW_STACK_MODE, values); }
void Client::move(const Point& point) { warning() << "move" << point << this; mRect.x = point.x; mRect.y = point.y; if (!mFrame) return; xcb_connection_t* conn = WindowManager::instance()->connection(); const uint16_t mask = XCB_CONFIG_WINDOW_X|XCB_CONFIG_WINDOW_Y; const uint32_t values[2] = { static_cast<uint32_t>(point.x), static_cast<uint32_t>(point.y) }; xcb_configure_window(conn, mFrame, mask, values); }
static void systray_update(int base_size, bool horizontal, bool reverse) { if(base_size <= 0) return; /* Give the systray window the correct size */ uint32_t config_vals[4] = { base_size, base_size, 0, 0 }; if(horizontal) config_vals[0] = base_size * globalconf.embedded.len; else config_vals[1] = base_size * globalconf.embedded.len; xcb_configure_window(globalconf.connection, globalconf.systray.window, XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, config_vals); /* Now resize each embedded window */ config_vals[0] = config_vals[1] = 0; config_vals[2] = config_vals[3] = base_size; for(int i = 0; i < globalconf.embedded.len; i++) { xembed_window_t *em; if(reverse) em = &globalconf.embedded.tab[(globalconf.embedded.len - i - 1)]; else em = &globalconf.embedded.tab[i]; xcb_configure_window(globalconf.connection, em->win, XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, config_vals); xcb_map_window(globalconf.connection, em->win); if(horizontal) config_vals[0] += base_size; else config_vals[1] += base_size; } }
void RootWindow::onConfigureRequestEvent( xcb_configure_request_event_t* event) { printf("configure_request on root: window=0x%08X x=%d y=%d width=%d height=%d\n", event->window, event->x, event->y, event->width, event->height); uint32_t mask = { XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT | XCB_CONFIG_WINDOW_BORDER_WIDTH }; uint32_t values[5] = { event->x, event->y, event->width, event->height, event->border_width }; xcb_configure_window(mWindow.getConnection(), event->window, mask, values); xcb_flush(mWindow.getConnection()); }
/** Move and/or resize a drawin * \param L The Lua VM state. * \param udx The index of the drawin. * \param geometry The new geometry. */ static void drawin_moveresize(lua_State *L, int udx, area_t geometry) { drawin_t *w = luaA_checkudata(L, udx, &drawin_class); int number_of_vals = 0; uint32_t moveresize_win_vals[4], mask_vals = 0; if(w->geometry.x != geometry.x) { w->geometry.x = moveresize_win_vals[number_of_vals++] = geometry.x; mask_vals |= XCB_CONFIG_WINDOW_X; } if(w->geometry.y != geometry.y) { w->geometry.y = moveresize_win_vals[number_of_vals++] = geometry.y; mask_vals |= XCB_CONFIG_WINDOW_Y; } if(geometry.width > 0 && w->geometry.width != geometry.width) { w->geometry.width = moveresize_win_vals[number_of_vals++] = geometry.width; mask_vals |= XCB_CONFIG_WINDOW_WIDTH; } if(geometry.height > 0 && w->geometry.height != geometry.height) { w->geometry.height = moveresize_win_vals[number_of_vals++] = geometry.height; mask_vals |= XCB_CONFIG_WINDOW_HEIGHT; } drawin_update_drawing(w, udx); /* Activate BMA */ client_ignore_enterleave_events(); if(mask_vals) xcb_configure_window(globalconf.connection, w->window, mask_vals, moveresize_win_vals); /* Deactivate BMA */ client_restore_enterleave_events(); if(mask_vals & XCB_CONFIG_WINDOW_X) luaA_object_emit_signal(L, udx, "property::x", 0); if(mask_vals & XCB_CONFIG_WINDOW_Y) luaA_object_emit_signal(L, udx, "property::y", 0); if(mask_vals & XCB_CONFIG_WINDOW_WIDTH) luaA_object_emit_signal(L, udx, "property::width", 0); if(mask_vals & XCB_CONFIG_WINDOW_HEIGHT) luaA_object_emit_signal(L, udx, "property::height", 0); }
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); }
static void _eventd_nd_xcb_surface_update(EventdNdSurface *self, gint width, gint height) { self->width = width; self->height = height; guint16 mask = XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT; guint32 vals[] = { width, height }; xcb_configure_window(self->context->xcb_connection, self->window, mask, vals); cairo_xcb_surface_set_size(self->surface, width, height); _eventd_nd_xcb_surface_shape(self); }
//_____________________________________________ void SizeGrip::updateActiveState( void ) { #if OXYGEN_HAVE_X11 if( QX11Info::isPlatformX11() ) { const quint32 value = XCB_STACK_MODE_ABOVE; xcb_configure_window( QX11Info::connection(), winId(), XCB_CONFIG_WINDOW_STACK_MODE, &value ); xcb_map_window( QX11Info::connection(), winId() ); } #endif update(); }
/** Move a simple window. * \param sw The simple window to move. * \param x New x coordinate. * \param y New y coordinate. */ void simplewindow_move(simple_window_t *sw, int x, int y) { const uint32_t move_win_vals[] = { x, y }; if(x != sw->geometry.x || y != sw->geometry.y) { sw->geometry.x = x; sw->geometry.y = y; xcb_configure_window(globalconf.connection, sw->window, XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, move_win_vals); } }
static int init_bar() { uint32_t vals[4]; xcb_void_cookie_t cookie; xcb_generic_error_t *err; /* create status bar window at the bottom */ bar_.w = nil_.scr->width_in_pixels; bar_.h = nil_.font.ascent + nil_.font.descent + 2; bar_.x = 0; bar_.y = nil_.scr->height_in_pixels - bar_.h; bar_.win = xcb_generate_id(nil_.con); vals[0] = XCB_BACK_PIXMAP_PARENT_RELATIVE; vals[1] = 1; /* override_redirect */ vals[2] = XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_EXPOSURE; vals[3] = nil_.cursor[CURSOR_NORMAL]; cookie = xcb_create_window_checked(nil_.con, nil_.scr->root_depth, bar_.win, nil_.scr->root, bar_.x, bar_.y, bar_.w, bar_.h, 0, XCB_COPY_FROM_PARENT, nil_.scr->root_visual, XCB_CW_BACK_PIXMAP | XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK | XCB_CW_CURSOR, vals); err = xcb_request_check(nil_.con, cookie); if (err) { NIL_ERR("create window %d", err->error_code); return -1; } vals[0] = XCB_STACK_MODE_ABOVE; xcb_configure_window(nil_.con, bar_.win, XCB_CONFIG_WINDOW_STACK_MODE, &vals[0]); cookie = xcb_map_window_checked(nil_.con, bar_.win); err = xcb_request_check(nil_.con, cookie); if (err) { NIL_ERR("map window %d", err->error_code); return -1; } /* graphic context */ bar_.gc = xcb_generate_id(nil_.con); vals[0] = nil_.color.bar_fg; vals[1] = nil_.color.bar_bg; vals[2] = nil_.font.id; cookie = xcb_create_gc_checked(nil_.con, bar_.gc, bar_.win, XCB_GC_FOREGROUND | XCB_GC_BACKGROUND | XCB_GC_FONT, vals); err = xcb_request_check(nil_.con, cookie); if (err) { NIL_ERR("map window %d", err->error_code); return -1; } return 0; }
extern void gl_update(gs_device_t *device) { Display *display = device->plat->display; xcb_window_t window = device->cur_swap->wi->window; uint32_t values[] = { device->cur_swap->info.cx, device->cur_swap->info.cy }; xcb_configure_window( XGetXCBConnection(display), window, XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, values ); }
//_______________________________________________________________________________ void SizeGrip::updatePosition( void ) { #if OXYGEN_HAVE_X11 if( !QX11Info::isPlatformX11() ) return; auto c = m_decoration.data()->client().data(); QPoint position( c->width() - GripSize - Offset, c->height() - GripSize - Offset ); quint32 values[2] = { quint32(position.x()), quint32(position.y()) }; xcb_configure_window( QX11Info::connection(), winId(), XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, values ); #endif }
static void setup_win (xcb_window_t win) { uint32_t mask = 0, values[3]; values[0] = XCB_EVENT_MASK_ENTER_WINDOW; values[1] = XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY; xcb_change_window_attributes_checked(conn, win, XCB_CW_EVENT_MASK, values); /* border width */ values[0] = BORDERWIDTH; values[1] = XCB_NONE; mask = XCB_CONFIG_WINDOW_BORDER_WIDTH; xcb_configure_window(conn, win, mask, values); }
static void teleport (xcb_window_t win, int x, int y, int w, int h) { uint32_t values[4]; uint32_t mask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT; values[0] = x; values[1] = y; values[2] = w; values[3] = h; xcb_configure_window(conn, win, mask, values); }
static void _e_alert_button_move_resize(xcb_window_t btn, int x, int y, int w, int h) { uint32_t list[4], mask; if (!btn) return; mask = (XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT); list[0] = x; list[1] = y; list[2] = w; list[3] = h; xcb_configure_window(conn, btn, mask, (const uint32_t *)&list); }
void v_window::_initOSWindow() { int screenNumber = 0; _xcb_connection = xcb_connect(nullptr,&screenNumber); const xcb_setup_t* setup = xcb_get_setup(_xcb_connection); xcb_screen_iterator_t it = xcb_setup_roots_iterator(setup); xcb_screen_t* screen = it.data; _xcb_window = xcb_generate_id(_xcb_connection); uint32_t value_mask, value_list[ 32 ]; int16_t x=0,y=0; value_mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK; value_list[0] = screen->black_pixel; value_list[1] = XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_STRUCTURE_NOTIFY; //需要接收的事件 xcb_create_window(_xcb_connection, XCB_COPY_FROM_PARENT, _xcb_window, screen->root, x,y, _width,_height, 1, XCB_WINDOW_CLASS_INPUT_OUTPUT, screen->root_visual, value_mask, value_list); /* Magic code that will send notification when window is destroyed */ xcb_intern_atom_cookie_t cookie = xcb_intern_atom( _xcb_connection, 1, 12, "WM_PROTOCOLS" ); xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply( _xcb_connection, cookie, 0 ); xcb_intern_atom_cookie_t cookie2 = xcb_intern_atom( _xcb_connection, 0, 16, "WM_DELETE_WINDOW" ); _xcb_atom_window_reply = xcb_intern_atom_reply( _xcb_connection, cookie2, 0 ); xcb_change_property( _xcb_connection, XCB_PROP_MODE_REPLACE, _xcb_window, ( *reply ).atom, 4, 32, 1, &( *_xcb_atom_window_reply ).atom ); free( reply ); xcb_map_window(_xcb_connection,_xcb_window); // Force the x/y coordinates to 100,100 results are identical in consecutive const uint32_t coords[] = { 100, 100 }; xcb_configure_window( _xcb_connection, _xcb_window, XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, coords ); xcb_flush(_xcb_connection); }
static void _eventd_nd_xcb_move_surface(EventdNdSurface *self, gint x, gint y, gpointer data) { x += self->context->geometry.x; y += self->context->geometry.y; guint16 mask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y; guint32 vals[] = { x, y }; xcb_configure_window(self->context->xcb_connection, self->window, mask, vals); if ( ! self->mapped ) { xcb_map_window(self->context->xcb_connection, self->window); self->mapped = TRUE; } _eventd_nd_xcb_surface_draw(self); }
static void event_handle_configurerequest_configure_window(xcb_configure_request_event_t *ev) { uint16_t config_win_mask = 0; uint32_t config_win_vals[7]; unsigned short i = 0; if(ev->value_mask & XCB_CONFIG_WINDOW_X) { config_win_mask |= XCB_CONFIG_WINDOW_X; config_win_vals[i++] = ev->x; } if(ev->value_mask & XCB_CONFIG_WINDOW_Y) { config_win_mask |= XCB_CONFIG_WINDOW_Y; config_win_vals[i++] = ev->y; } if(ev->value_mask & XCB_CONFIG_WINDOW_WIDTH) { config_win_mask |= XCB_CONFIG_WINDOW_WIDTH; config_win_vals[i++] = ev->width; } if(ev->value_mask & XCB_CONFIG_WINDOW_HEIGHT) { config_win_mask |= XCB_CONFIG_WINDOW_HEIGHT; config_win_vals[i++] = ev->height; } if(ev->value_mask & XCB_CONFIG_WINDOW_BORDER_WIDTH) { config_win_mask |= XCB_CONFIG_WINDOW_BORDER_WIDTH; config_win_vals[i++] = ev->border_width; } if(ev->value_mask & XCB_CONFIG_WINDOW_SIBLING) { config_win_mask |= XCB_CONFIG_WINDOW_SIBLING; config_win_vals[i++] = ev->sibling; } if(ev->value_mask & XCB_CONFIG_WINDOW_STACK_MODE) { config_win_mask |= XCB_CONFIG_WINDOW_STACK_MODE; config_win_vals[i++] = ev->stack_mode; } xcb_configure_window(globalconf.connection, ev->window, config_win_mask, config_win_vals); }