Example #1
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;
}
Example #2
0
ExcCode screen_window_get_geometry(xcb_window_t window,
		int *left, int *top, int *width, int *height) {
	find_toplevel_window(window, &window);
	get_net_frame_window(window, &window);
	TRY(window_get_real_geometry(window, left, top, width, height));
	return 0;
}
Example #3
0
static gboolean
adjust_size_callback (WidgetInfo *info)
{
  Window toplevel;
  Window root;
  GdkWindow *window;
  gint tx;
  gint ty;
  guint twidth;
  guint theight;
  guint tborder_width;
  guint tdepth;
  gint target_width = 0;
  gint target_height = 0;

  window = gtk_widget_get_window (info->window);
  toplevel = find_toplevel_window (GDK_WINDOW_XID (window));
  XGetGeometry (GDK_WINDOW_XDISPLAY (window),
		toplevel,
		&root, &tx, &ty, &twidth, &theight, &tborder_width, &tdepth);

  switch (info->size)
    {
    case SMALL:
      target_width = SMALL_WIDTH;
      target_height = SMALL_HEIGHT;
      break;
    case MEDIUM:
      target_width = MEDIUM_WIDTH;
      target_height = MEDIUM_HEIGHT;
      break;
    case LARGE:
      target_width = LARGE_WIDTH;
      target_height = LARGE_HEIGHT;
      break;
    case ASIS:
      target_width = twidth;
      target_height = theight;
      break;
    }

  if (twidth > target_width ||
      theight > target_height)
    {
      gtk_widget_set_size_request (info->window,
				   2 + target_width - (twidth - target_width), /* Dunno why I need the +2 fudge factor; */
				   2 + target_height - (theight - target_height));
    }
  return FALSE;
}
Example #4
0
static GdkPixbuf *
take_window_shot (Window   child,
                  gboolean include_decoration)
{
  GdkDisplay *display;
  GdkScreen  *screen;
  GdkWindow  *window;
  Window      xid;
  gint        x_orig, y_orig;
  gint        x = 0, y = 0;
  gint        width, height;
  GdkPixbuf  *tmp, *tmp2;
  GdkPixbuf  *retval;

  display = gdk_display_get_default ();
  screen = gdk_screen_get_default ();

  if (include_decoration)
    xid = find_toplevel_window (gdk_x11_display_get_xdisplay (display), child);
  else
    xid = child;

  window = gdk_x11_window_foreign_new_for_display (display, xid);

  width  = gdk_window_get_width  (window);
  height = gdk_window_get_height (window);
  gdk_window_get_origin (window, &x_orig, &y_orig);

  if (x_orig < 0)
    {
      x = - x_orig;
      width = width + x_orig;
      x_orig = 0;
    }

  if (y_orig < 0)
    {
      y = - y_orig;
      height = height + y_orig;
      y_orig = 0;
    }

  if (x_orig + width > gdk_screen_get_width (screen))
    width = gdk_screen_get_width (screen) - x_orig;

  if (y_orig + height > gdk_screen_get_height (screen))
    height = gdk_screen_get_height (screen) - y_orig;

  tmp = gdk_pixbuf_get_from_drawable (NULL, window, NULL,
                                      x, y, 0, 0, width, height);

  if (include_decoration)
    tmp2 = remove_shaped_area (tmp, xid);
  else
    tmp2 = add_border_to_shot (tmp);

  retval = create_shadowed_pixbuf (tmp2);

  g_object_unref (tmp);
  g_object_unref (tmp2);

  return retval;
}