/** Handle systray message. * \param ev The event. * \return 0 on no error. */ int systray_process_client_message(xcb_client_message_event_t *ev) { int screen_nbr = 0, ret = 0; xcb_get_geometry_cookie_t geom_c; xcb_get_geometry_reply_t *geom_r; xcb_screen_iterator_t iter; switch(ev->data.data32[1]) { case SYSTEM_TRAY_REQUEST_DOCK: geom_c = xcb_get_geometry_unchecked(globalconf.connection, ev->window); if(!(geom_r = xcb_get_geometry_reply(globalconf.connection, geom_c, NULL))) return -1; for(iter = xcb_setup_roots_iterator(xcb_get_setup(globalconf.connection)), screen_nbr = 0; iter.rem && iter.data->root != geom_r->root; xcb_screen_next (&iter), ++screen_nbr); p_delete(&geom_r); ret = systray_request_handle(ev->data.data32[2], screen_nbr, NULL); break; } return ret; }
static void resize(xcb_window_t w, int x, int y) { uint32_t val[3]; uint32_t mask = XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT | XCB_CONFIG_WINDOW_STACK_MODE; xcb_get_geometry_cookie_t c; xcb_get_geometry_reply_t *r; c = xcb_get_geometry(conn, w); r = xcb_get_geometry_reply(conn, c, NULL); if (r == NULL) return; if ((r->x + r->width + 2*r->border_width + x) > scr->width_in_pixels) x = scr->width_in_pixels - ( r->x + r->width + (2*r->border_width)); if ((r->y + r->height + 2*r->border_width + y) > scr->height_in_pixels) y = scr->height_in_pixels - ( r->y + r->height + (2*r->border_width)); val[0] = r->width + x; val[1] = r->height + y; val[2] = XCB_STACK_MODE_ABOVE; xcb_configure_window(conn, w, mask, val); xcb_warp_pointer(conn, XCB_NONE, w, 0, 0, 0, 0, r->width + x, r->height + y); free(r); }
static void swrastGetDrawableInfo(__DRIdrawable * draw, int *x, int *y, int *w, int *h, void *loaderPrivate) { struct dri2_egl_surface *dri2_surf = loaderPrivate; struct dri2_egl_display *dri2_dpy = dri2_egl_display(dri2_surf->base.Resource.Display); xcb_get_geometry_cookie_t cookie; xcb_get_geometry_reply_t *reply; xcb_generic_error_t *error; *w = *h = 0; cookie = xcb_get_geometry (dri2_dpy->conn, dri2_surf->drawable); reply = xcb_get_geometry_reply (dri2_dpy->conn, cookie, &error); if (reply == NULL) return; if (error != NULL) { _eglLog(_EGL_WARNING, "error in xcb_get_geometry"); free(error); } else { *w = reply->width; *h = reply->height; } free(reply); }
/** * 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; }
/* * Called when the properties on the root window change, e.g. when the screen * resolution changes. If so we update the window to cover the whole screen * and also redraw the image, if any. * */ void handle_screen_resize(void) { xcb_get_geometry_cookie_t geomc; xcb_get_geometry_reply_t *geom; geomc = xcb_get_geometry(conn, screen->root); if ((geom = xcb_get_geometry_reply(conn, geomc, 0)) == NULL) return; if (last_resolution[0] == geom->width && last_resolution[1] == geom->height) { free(geom); return; } last_resolution[0] = geom->width; last_resolution[1] = geom->height; free(geom); redraw_screen(); uint32_t mask = XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT; xcb_configure_window(conn, win, mask, last_resolution); xcb_flush(conn); xinerama_query_screens(); redraw_screen(); }
static bool dri3_set_drawable(struct vl_dri3_screen *scrn, Drawable drawable) { xcb_get_geometry_cookie_t geom_cookie; xcb_get_geometry_reply_t *geom_reply; xcb_void_cookie_t cookie; xcb_generic_error_t *error; xcb_present_event_t peid; bool ret = true; assert(drawable); if (scrn->drawable == drawable) return true; scrn->drawable = drawable; geom_cookie = xcb_get_geometry(scrn->conn, scrn->drawable); geom_reply = xcb_get_geometry_reply(scrn->conn, geom_cookie, NULL); if (!geom_reply) return false; scrn->width = geom_reply->width; scrn->height = geom_reply->height; scrn->depth = geom_reply->depth; free(geom_reply); if (scrn->special_event) { xcb_unregister_for_special_event(scrn->conn, scrn->special_event); scrn->special_event = NULL; } scrn->is_pixmap = false; peid = xcb_generate_id(scrn->conn); cookie = xcb_present_select_input_checked(scrn->conn, peid, scrn->drawable, XCB_PRESENT_EVENT_MASK_CONFIGURE_NOTIFY | XCB_PRESENT_EVENT_MASK_COMPLETE_NOTIFY | XCB_PRESENT_EVENT_MASK_IDLE_NOTIFY); error = xcb_request_check(scrn->conn, cookie); if (error) { if (error->error_code != BadWindow) ret = false; else { scrn->is_pixmap = true; if (scrn->front_buffer) { dri3_free_front_buffer(scrn, scrn->front_buffer); scrn->front_buffer = NULL; } } free(error); } else scrn->special_event = xcb_register_for_special_xge(scrn->conn, &xcb_present_id, peid, 0); dri3_flush_present_events(scrn); return ret; }
static bool x11_get_drawable_info(__DRIdrawable * draw, int *x, int *y, int *w, int *h, void *loaderPrivate) { struct dri2_egl_surface *dri2_surf = loaderPrivate; struct dri2_egl_display *dri2_dpy = dri2_egl_display(dri2_surf->base.Resource.Display); xcb_get_geometry_cookie_t cookie; xcb_get_geometry_reply_t *reply; xcb_generic_error_t *error; bool ret; cookie = xcb_get_geometry (dri2_dpy->conn, dri2_surf->drawable); reply = xcb_get_geometry_reply (dri2_dpy->conn, cookie, &error); if (reply == NULL) return false; if (error != NULL) { ret = false; _eglLog(_EGL_WARNING, "error in xcb_get_geometry"); free(error); } else { *x = reply->x; *y = reply->y; *w = reply->width; *h = reply->height; ret = true; } free(reply); return ret; }
void update_motion_recorder(void) { xcb_get_geometry_reply_t *geo = xcb_get_geometry_reply(dpy, xcb_get_geometry(dpy, root), NULL); if (geo != NULL) { window_resize(motion_recorder, geo->width, geo->height); } free(geo); }
/** * Gets the reply of the GetGeometry request sent by ecore_x_atom_get_prefetch(). * @ingroup Ecore_X_Drawable_Group */ EAPI void ecore_x_drawable_geometry_get_fetch(void) { xcb_get_geometry_cookie_t cookie; xcb_get_geometry_reply_t *reply; cookie.sequence = _ecore_xcb_cookie_get(); reply = xcb_get_geometry_reply(_ecore_xcb_conn, cookie, NULL); _ecore_xcb_reply_cache(reply); }
QImage SNIProxy::getImageNonComposite() { auto c = QX11Info::connection(); auto cookie = xcb_get_geometry(c, m_windowId); QScopedPointer<xcb_get_geometry_reply_t> geom(xcb_get_geometry_reply(c, cookie, Q_NULLPTR)); xcb_image_t *image = xcb_image_get(c, m_windowId, 0, 0, geom->width, geom->height, 0xFFFFFF, XCB_IMAGE_FORMAT_Z_PIXMAP); QImage qimage(image->data, image->width, image->height, image->stride, QImage::Format_ARGB32, sni_cleanup_xcb_image, image); return qimage; }
void update_floating_rectangle(node_t *n) { client_t *c = n->client; xcb_get_geometry_reply_t *geo = xcb_get_geometry_reply(dpy, xcb_get_geometry(dpy, n->id), NULL); if (geo != NULL) { c->floating_rectangle = (xcb_rectangle_t) {geo->x, geo->y, geo->width, geo->height}; } free(geo); }
/** The map request event handler. * \param ev The event. */ static void event_handle_maprequest(xcb_map_request_event_t *ev) { client_t *c; xcb_get_window_attributes_cookie_t wa_c; xcb_get_window_attributes_reply_t *wa_r; xcb_get_geometry_cookie_t geom_c; xcb_get_geometry_reply_t *geom_r; wa_c = xcb_get_window_attributes_unchecked(globalconf.connection, ev->window); if(!(wa_r = xcb_get_window_attributes_reply(globalconf.connection, wa_c, NULL))) return; if(wa_r->override_redirect) goto bailout; if(xembed_getbywin(&globalconf.embedded, ev->window)) { xcb_map_window(globalconf.connection, ev->window); xembed_window_activate(globalconf.connection, ev->window); } else if((c = client_getbywin(ev->window))) { /* Check that it may be visible, but not asked to be hidden */ if(client_on_selected_tags(c) && !c->hidden) { lua_State *L = globalconf_get_lua_State(); luaA_object_push(L, c); client_set_minimized(L, -1, false); lua_pop(L, 1); /* it will be raised, so just update ourself */ client_raise(c); } } else { geom_c = xcb_get_geometry_unchecked(globalconf.connection, ev->window); if(!(geom_r = xcb_get_geometry_reply(globalconf.connection, geom_c, NULL))) { goto bailout; } client_manage(ev->window, geom_r, wa_r); p_delete(&geom_r); } bailout: p_delete(&wa_r); }
xcb_rectangle_t get_window_rectangle(node_t *n) { client_t *c = n->client; if (c != NULL) { xcb_get_geometry_reply_t *g = xcb_get_geometry_reply(dpy, xcb_get_geometry(dpy, n->id), NULL); if (g != NULL) { xcb_rectangle_t rect = (xcb_rectangle_t) {g->x, g->y, g->width, g->height}; free(g); return rect; } } return (xcb_rectangle_t) {0, 0, screen_width, screen_height}; }
xcb_get_geometry_reply_t * get_window_geometry(xcb_connection_t * conn, xcb_window_t window) { xcb_get_geometry_cookie_t get_geometry_cookie; xcb_get_geometry_reply_t *get_geometry_reply; get_geometry_cookie = xcb_get_geometry(conn, window); get_geometry_reply = xcb_get_geometry_reply(conn, get_geometry_cookie, NULL); if (!get_geometry_reply) errx(1, "0x%08x: no such window", window); return get_geometry_reply; }
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); }
ExcCode window_get_real_geometry(xcb_window_t window, int *left, int *top, int *width, int *height) { xcb_get_geometry_cookie_t cookie = xcb_get_geometry(display, window); xcb_get_geometry_reply_t *reply = xcb_get_geometry_reply(display, cookie, NULL); if (reply == NULL) PANIC(ERR_X_REQUEST, "window_get_real_geometry"); *left = reply->x; *top = reply->y; *width = reply->width; *height = reply->height; free(reply); return 0; }
void VulkanReplay::GetOutputWindowDimensions(uint64_t id, int32_t &w, int32_t &h) { if(id == 0 || m_OutputWindows.find(id) == m_OutputWindows.end()) return; OutputWindow &outw = m_OutputWindows[id]; xcb_get_geometry_cookie_t geomCookie = xcb_get_geometry (outw.connection, outw.wnd); // window is a xcb_drawable_t xcb_get_geometry_reply_t *geom = xcb_get_geometry_reply (outw.connection, geomCookie, NULL); w = (int32_t)geom->width; h = (int32_t)geom->height; free(geom); }
void Window::get_geometry(int32_t& x, int32_t& y, uint32_t& width, uint32_t& height) { xcb_get_geometry_cookie_t c = xcb_get_geometry(conn->xcb(), window); xcb_generic_error_t* error; xcb_get_geometry_reply_t* reply = xcb_get_geometry_reply(conn->xcb(), c, &error); throw_if_error(error); x = reply->x; y = reply->y; width = reply->width; height = reply->height; free(reply); }
static void towel_window_init_cairo(towel_window_t *win) { xcb_visualtype_t *vt; xcb_get_geometry_cookie_t cookie = xcb_get_geometry_unchecked(win->conn, win->id); xcb_get_geometry_reply_t *geo = xcb_get_geometry_reply(win->conn, cookie, NULL); vt = xcb_aux_find_visual_by_id(win->screen, win->screen->root_visual); win->cs = cairo_xcb_surface_create(win->conn, win->id, vt, geo->width, geo->height); win->cr = cairo_create(win->cs); free(geo); }
/* Resizes all of the windows for the current frame for a tiled format */ void resizeAll(xcb_connection_t *conn,int frameNum,std::vector<xcb_window_t> (&frames)[NUM_FRAMES],uint32_t screenWidth,uint32_t screenHeight) { /* Exits upon empty frame */ if(frames[frameNum].empty()) { return; } int size = frames[frameNum].size(); xyWindow(conn,frames[frameNum].at(0),0,0); whWindow(conn,frames[frameNum].at(0),screenWidth,screenHeight); for(int i = 1; i<size; i++) { xcb_window_t curWindow = frames[frameNum].at(i); xcb_window_t maxWindow; int maxArea = 0; xcb_get_geometry_reply_t *maxStats; xcb_get_geometry_reply_t *geometry; /* Checking the current frame for the largest window and retrieving data about its size */ for(int j = 0; j<i; j++) { geometry = xcb_get_geometry_reply(conn,xcb_get_geometry(conn,frames[frameNum].at(j)),NULL); if(maxArea <= geometry->width*geometry->height) { maxWindow = frames[frameNum].at(j); maxStats = geometry; maxArea = geometry->width*geometry->height; } } int gap = NUM_GAP_PIXELS/2; int width = (maxStats->width)/2; int height = (maxStats->height)/2; /* Splits vertically if the largest window has a larger height than width. Otherwise splits horisontally. Gaps of width NUM_GAP_PIXELS are added between each of the windows. */ if(maxStats->height > maxStats->width) { whWindow(conn,maxWindow,maxStats->width,height-gap); xyWindow(conn,curWindow,maxStats->x,maxStats->y+height+gap); whWindow(conn,curWindow,maxStats->width,height-gap); } else { whWindow(conn,maxWindow,width-gap,maxStats->height); xyWindow(conn,curWindow,maxStats->x+width+gap,maxStats->y); whWindow(conn,curWindow,width-gap,maxStats->height); } } }
uint8_t xcb_aux_get_depth (xcb_connection_t *c, xcb_screen_t *screen) { xcb_drawable_t drawable; xcb_get_geometry_reply_t *geom; int depth = 0; drawable = screen->root; geom = xcb_get_geometry_reply (c, xcb_get_geometry(c, drawable), 0); if (geom) { depth = geom->depth; free (geom); } return depth; }
/* Read the X window geometry and record it in the client structure */ void read_client_geometry(client_t *client) { xcb_get_geometry_cookie_t geometry_cookie; xcb_get_geometry_reply_t *geometry_reply; geometry_cookie = xcb_get_geometry_unchecked(wm_conf.connection, client->window); geometry_reply = xcb_get_geometry_reply(wm_conf.connection, geometry_cookie, NULL); if (geometry_reply) { client->rect.x = geometry_reply->x; client->rect.y = geometry_reply->y; client->rect.width = geometry_reply->width; client->rect.height = geometry_reply->height; client->border_width = geometry_reply->border_width; free(geometry_reply); } else { fprintf(stderr, " ! failed to get geometry geometry for window %u\n", client->window); } }
angle::Result WindowSurfaceVkXcb::createSurfaceVk(vk::Context *context, gl::Extents *extentsOut) { VkXcbSurfaceCreateInfoKHR createInfo = {}; createInfo.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR; createInfo.flags = 0; createInfo.connection = mXcbConnection; createInfo.window = mNativeWindowType; ANGLE_VK_TRY(context, vkCreateXcbSurfaceKHR(context->getRenderer()->getInstance(), &createInfo, nullptr, &mSurface)); xcb_get_geometry_cookie_t cookie = xcb_get_geometry(mXcbConnection, mNativeWindowType); xcb_get_geometry_reply_t *reply = xcb_get_geometry_reply(mXcbConnection, cookie, nullptr); ASSERT(reply); *extentsOut = gl::Extents(reply->width, reply->height, 0); free(reply); return angle::Result::Continue; }
vk::ErrorOrResult<gl::Extents> WindowSurfaceVkXcb::createSurfaceVk(RendererVk *renderer) { VkXcbSurfaceCreateInfoKHR createInfo; createInfo.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR; createInfo.pNext = nullptr; createInfo.flags = 0; createInfo.connection = mXcbConnection; createInfo.window = mNativeWindowType; ANGLE_VK_TRY(vkCreateXcbSurfaceKHR(renderer->getInstance(), &createInfo, nullptr, &mSurface)); xcb_get_geometry_cookie_t cookie = xcb_get_geometry(mXcbConnection, mNativeWindowType); xcb_get_geometry_reply_t *reply = xcb_get_geometry_reply(mXcbConnection, cookie, nullptr); ASSERT(reply); gl::Extents result(reply->width, reply->height, 0); free(reply); return result; }
static void move(xcb_window_t win, int mode, int x, int y) { uint32_t values[2]; int real; xcb_get_geometry_reply_t *geom; if (!win || win == scr->root) return; geom = xcb_get_geometry_reply(conn, xcb_get_geometry(conn, win), NULL); if (!geom) return; if (mode == ABSOLUTE) { x -= geom->x + geom->width /2; y -= geom->y + geom->height/2; } values[0] = x ? geom->x + x : geom->x; values[1] = y ? geom->y + y : geom->y; if (x) { real = geom->width + (geom->border_width * 2); if (geom->x + x < 1) values[0] = 0; if (geom->x + x > scr->width_in_pixels - real) values[0] = scr->width_in_pixels - real; } if (y) { real = geom->height + (geom->border_width * 2); if (geom->y + y < 1) values[1] = 0; if (geom->y + y > scr->height_in_pixels - real) values[1] = scr->height_in_pixels - real; } xcb_configure_window(conn, win, XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, values); free(geom); }
static void get_geometry(xcb_window_t window, struct wlc_geometry *out_g, uint32_t *out_depth) { if (out_g) *out_g = wlc_geometry_zero; if (out_depth) *out_depth = 0; xcb_get_geometry_reply_t *reply; if ((reply = xcb_get_geometry_reply(x11.connection, xcb_get_geometry(x11.connection, window), NULL))) { if (out_g) *out_g = (struct wlc_geometry){ .origin = { reply->x, reply->y }, .size = { reply->width, reply->height } }; if (out_depth) *out_depth = reply->depth; free(reply); }
/** * Converts a Weston compositor x,y coordinate into a global screen coordinate. * When Weston is using the x11 backend, the x,y coordinate is mapped to the X * display output (needed to correctly map a uinput pointer to weston). **/ static void toScreen(int32_t *x, int32_t *y) { struct weston_output *output(Globals::output()); toDevice(x, y); std::string make(output->make); if (make == "xwayland" or make == "weston-X11") { #if defined(HAVE_X11_SUPPORT) struct x11_compositor *x11_compositor = (struct x11_compositor*)Globals::compositor(); struct x11_output *x11_output = (struct x11_output*) output; xcb_get_geometry_reply_t *geom = xcb_get_geometry_reply( x11_compositor->conn, xcb_get_geometry( x11_compositor->conn, x11_output->window ), NULL ); xcb_translate_coordinates_reply_t *trans = xcb_translate_coordinates_reply( x11_compositor->conn, xcb_translate_coordinates( x11_compositor->conn, x11_output->window, geom->root, -(geom->border_width), -(geom->border_width) ), NULL ); *x += (int16_t)trans->dst_x; *y += (int16_t)trans->dst_y; delete trans; delete geom; #else exit(EXIT_FAILURE); #endif } }
int add_winvec(struct window **list, xcb_window_t wid[], int len) { xcb_get_window_attributes_cookie_t ack[len]; xcb_get_geometry_cookie_t gck[len]; struct window *w; int i, n = 0; for (i = 0; i < len; ++i) { ack[i] = xcb_get_window_attributes_unchecked(X, wid[i]); gck[i] = xcb_get_geometry_unchecked(X, wid[i]); } for (i = 0; i < len; ++i) { xcb_get_window_attributes_reply_t *ar; xcb_get_geometry_reply_t *gr; if ((w = add_win(list, wid[i])) != NULL) { ar = xcb_get_window_attributes_reply(X, ack[i], NULL); gr = xcb_get_geometry_reply(X, gck[i], NULL); if (ar && gr) { w->visual = ar->visual; w->_class = ar->_class; w->map_state = ar->map_state; w->x = gr->x; w->y = gr->y; w->width = gr->width; w->height = gr->height; w->border_width = gr->border_width; free(ar); free(gr); ++n; } else { if (ar) free(ar); if (gr) free(gr); remove_win(list, w); continue; } } } debugf("add_winvec: added %d of %d windows to stack\n", n, len); return n; }
// === WindowGeometry() === QRect LXCB::WindowGeometry(WId win, bool includeFrame){ if(DEBUG){ qDebug() << "XCB: WindowGeometry()"; } QRect geom; if(win==0){ return geom; } xcb_get_geometry_cookie_t cookie = xcb_get_geometry(QX11Info::connection(), win); xcb_get_geometry_reply_t *reply = xcb_get_geometry_reply(QX11Info::connection(), cookie, NULL); //qDebug() << "Get Window Geometry:" << reply; if(reply != 0){ geom = QRect(0, 0, reply->width, reply->height); //make sure to use the origin point for the window //qDebug() << " - "<<reply->x << reply->y << reply->width << reply->height; free(reply); if(includeFrame){ //Need to add/include the frame extents as well (assuming the frame info is available) xcb_get_property_cookie_t cookie = xcb_ewmh_get_frame_extents_unchecked(&EWMH, win); if(cookie.sequence != 0){ xcb_ewmh_get_extents_reply_t frame; if(1== xcb_ewmh_get_frame_extents_reply(&EWMH, cookie, &frame, NULL) ){ //adjust the origin point to account for the frame geom.translate(-frame.left, -frame.top); //move to the orign point for the frame //adjust the size (include the frame sizes) geom.setWidth( geom.width() + frame.left + frame.right ); geom.setHeight( geom.height() + frame.top + frame.bottom ); } //qDebug() << " - Frame:" << frame.left << frame.right << frame.top << frame.bottom; //qDebug() << " - Modified with Frame:" << geom.x() << geom.y() << geom.width() << geom.height(); } } //Now need to convert this to absolute coordinates (not parent-relavitve) xcb_translate_coordinates_cookie_t tcookie = xcb_translate_coordinates(QX11Info::connection(), win, QX11Info::appRootWindow(), geom.x(), geom.y()); xcb_translate_coordinates_reply_t *trans = xcb_translate_coordinates_reply(QX11Info::connection(), tcookie, NULL); if(trans!=0){ //qDebug() << " - Got Translation:" << trans->dst_x << trans->dst_y; //Replace the origin point with the global position (sizing remains the same) geom.moveLeft(trans->dst_x); //adjust X coordinate (no size change) geom.moveTop(trans->dst_y); //adjust Y coordinate (no size change) free(trans); } }else{ //Need to do another catch for this situation (probably not mapped yet) } return geom; }
static towel_window_t* towel_create_window(xcb_connection_t *conn) { /* Get screen setup and root window */ towel_window_t *win = calloc(1, sizeof(towel_window_t)); const xcb_setup_t *setup = xcb_get_setup(conn); xcb_screen_iterator_t iter = xcb_setup_roots_iterator(setup); xcb_get_geometry_cookie_t geo_cookie; xcb_get_geometry_reply_t *geo; uint32_t mask = XCB_CW_EVENT_MASK; uint32_t values[] = {XCB_EVENT_MASK_EXPOSURE|XCB_EVENT_MASK_POINTER_MOTION}; win->conn = conn; win->screen = iter.data; geo_cookie = xcb_get_geometry_unchecked(conn, win->screen->root); geo = xcb_get_geometry_reply(win->conn, geo_cookie, NULL); win->x = 0; win->y = 0; win->width = geo->width; win->height = geo->height; free(geo); win->id = xcb_generate_id(conn); xcb_create_window(conn, XCB_COPY_FROM_PARENT, win->id, win->screen->root, win->x, win->y, win->width, win->height, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, win->screen->root_visual, mask, values); xcb_flush(conn); towel_window_init_cairo(win); return win; }