Esempio n. 1
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);
    }
  }
Esempio n. 2
0
ExcCode screen_window_resize(xcb_window_t window, int width, int height) {
	xcb_window_t client_window;
	find_toplevel_window(window, &client_window);
	get_client_window(client_window, &client_window);
	
	TRY(screen_window_unmaximize(client_window));
	
	int coord, prev_width, prev_height;
	TRY(screen_window_get_geometry(window, &coord, &coord,
			&prev_width, &prev_height));
	int prev_client_window_width, prev_client_window_height;
	TRY(window_get_real_geometry(client_window, &coord, &coord,
			&prev_client_window_width, &prev_client_window_height));
	uint32_t values[2] = {
		width - (prev_width - prev_client_window_width),
		height - (prev_height - prev_client_window_height)
	};
    xcb_void_cookie_t cookie = xcb_configure_window_checked(display,
			client_window, XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT,
			values);
	if (xcb_request_check(display, cookie) != NULL)
		PANIC(ERR_X_REQUEST, "screen_window_resize (xcb_request_check)");
    if (xcb_flush(display) <= 0)
		PANIC(ERR_X_REQUEST, "screen_window_resize (xcb_flush)");
	return 0;
}
Esempio n. 3
0
static void
set_geometry(xcb_window_t window, const struct wlc_geometry *g)
{
   assert(g);
   const uint32_t mask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT;
   const uint32_t values[] = { g->origin.x, g->origin.y, g->size.w, g->size.h };
   wlc_dlog(WLC_DBG_XWM, "-> Configure x11 window (%u) %ux%u+%d,%d", window, g->size.w, g->size.h, g->origin.x, g->origin.y);
   XCB_CALL(xcb_configure_window_checked(x11.connection, window, mask, (uint32_t*)&values));
   xcb_flush(x11.connection);
}
Esempio n. 4
0
  /** Should be called when a configure notify event is received.
   */
  void resize(uint16_t w, uint16_t h) {
    width = w;
    height = h;
    
    // resize client window, if any.
    if(client_win) {
        // moving the client back to (0, 0) is required when maximizing
        uint32_t values[4] = { 0, 0, width, height };
        uint32_t mask = XCB_CONFIG_WINDOW_X |XCB_CONFIG_WINDOW_Y |
          XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT;
        xcb_void_cookie_t cookie =
          xcb_configure_window_checked(con, client_win, mask, values);

        xcb_generic_error_t *error = xcb_request_check(con, cookie);
        if(error)
          {
            std::cerr << "Could not resize client." << std::endl;
            exit(1);
        }
    }
}
Esempio n. 5
0
void client_unmanage(Client *c, bool destroyed) {
	Monitor *m = c->mon;

	/* The server grab construct avoids race conditions. */
	client_detach(c);
	client_detach_stack(c);
	printf("unmanage %i, %i\n", destroyed, c->win);
	if(!destroyed) {
		uint32_t values[] = { c->oldbw };
		xcb_grab_server(conn);
		xcb_configure_window_checked(conn, c->win, 
			XCB_CONFIG_WINDOW_BORDER_WIDTH, values);
		xcb_ungrab_button_checked(conn, XCB_BUTTON_INDEX_ANY, c->win, 
			XCB_GRAB_ANY);
		client_set_state(c, XCB_ICCCM_WM_STATE_WITHDRAWN);
		xcb_flush(conn);
		xcb_ungrab_server(conn);
	}
	free(c);
	client_focus(NULL);
	arrange(m);
}