示例#1
0
/* @brief Draw the responses to the query.
 *
 * Note: the window may be resized in this function.
 *
 * @param connection A connection to the Xorg server.
 * @param window An xcb window created by xcb_generate_id.
 * @param cr A cairo context for drawing to the screen.
 * @param surface A cairo surface for drawing to the screen.
 * @param results An array of results to be drawn.
 * @param result_count The number of results to be drawn.
 * @return Void.
 */
static void draw_response_text(xcb_connection_t *connection, xcb_window_t window, cairo_t *cr, cairo_surface_t *surface, result_t *results, uint32_t result_count) {

  if (window != 0) {
    uint32_t new_height = min(settings.height * (result_count + 1), settings.max_height);
    uint32_t values[] = { settings.width, new_height};

    xcb_configure_window (connection, window, XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, values);
    cairo_xcb_surface_set_size(surface, settings.width, new_height);
  }

  int32_t line, index;
  if (global.result_count - 1 < global.result_highlight) {
    global.result_highlight = global.result_count - 1;
  }

  uint32_t max_results = settings.max_height / settings.height - 1;
  uint32_t display_results = min(result_count, max_results);
  if ((global.result_offset + display_results) < (global.result_highlight + 1)) {
    global.result_offset = global.result_highlight - (display_results - 1);
    display_results = global.result_count - global.result_offset;
  } else if (global.result_offset > global.result_highlight) {
    global.result_offset = global.result_highlight;
  }

  for (index = global.result_offset, line = 1; index < global.result_offset + display_results; index++, line++) {
    if (index != global.result_highlight) {
      draw_line(cr, results[index].text, line, &settings.result_fg, &settings.result_bg);
    } else {
      draw_line(cr, results[index].text, line, &settings.highlight_fg, &settings.highlight_bg);
    }
  }
  cairo_surface_flush(surface);
  xcb_flush(connection);
}
示例#2
0
    inline Surface::self_ref
      Surface::setSize(Dimensions<> dim)
    {
      this->dimensions_ = dim;

      cairo_xcb_surface_set_size(
          this->cairoSurface_.get(),
          dim.width(),
          dim.height()
        );

      return *this;
    }
示例#3
0
static cairo_test_status_t
preamble (cairo_test_context_t *ctx)
{
    cairo_surface_t *surface;

    /* get the error surface */
    surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, INT_MAX, INT_MAX);

#if CAIRO_HAS_GL_SURFACE
    cairo_gl_surface_set_size (surface, 0, 0);
    cairo_gl_surface_swapbuffers (surface);
#endif

#if CAIRO_HAS_OS2_SURFACE
    cairo_os2_surface_set_hwnd (surface, 0);
    cairo_os2_surface_set_size (surface, 0, 0);
    cairo_os2_surface_set_manual_window_refresh (surface, FALSE);
#endif

#if CAIRO_HAS_PDF_SURFACE
    cairo_pdf_surface_restrict_to_version (surface, CAIRO_PDF_VERSION_1_4);
    cairo_pdf_surface_set_size (surface, 0, 0);
#endif

#if CAIRO_HAS_PS_SURFACE
    cairo_ps_surface_set_eps (surface, FALSE);
    cairo_ps_surface_set_size (surface, 0, 0);
    cairo_ps_surface_restrict_to_level (surface, CAIRO_PS_LEVEL_2);
    cairo_ps_surface_dsc_comment (surface, NULL);
    cairo_ps_surface_dsc_begin_setup (surface);
    cairo_ps_surface_dsc_begin_page_setup (surface);
#endif

#if CAIRO_HAS_XCB_SURFACE
    cairo_xcb_surface_set_size (surface, 0, 0);
#endif

#if CAIRO_HAS_XLIB_SURFACE
    cairo_xlib_surface_set_size (surface, 0, 0);
    cairo_xlib_surface_set_drawable (surface, 0, 0, 0);
#endif

    cairo_surface_set_mime_data (surface, NULL, NULL, 0, NULL, 0);
    cairo_surface_set_device_offset (surface, 0, 0);
    cairo_surface_set_fallback_resolution (surface, 0, 0);

    cairo_surface_destroy (surface);

    return CAIRO_TEST_SUCCESS;
}
示例#4
0
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);
}
示例#5
0
void menuwin_set_window() {

	uint32_t v[4];
	uint32_t value_mask;

	value_mask=XCB_CONFIG_WINDOW_X|XCB_CONFIG_WINDOW_Y|XCB_CONFIG_WINDOW_WIDTH|XCB_CONFIG_WINDOW_HEIGHT;
	if (key_win.possition==1) {
		if (key_win.has_keyboard&0x01) { // keyboard enabled?
			// Grab the mouse to avoid other windows to receive events

			menuwin_grab_mouse();

			v[2]=width;
			v[3]=5*height/KEYS_H_DIVISOR;
			if (key_win.has_keyboard&0x02) { // keyboard on top?
				v[0]=0;
				v[1]=0;
			} else {
				v[0]=0;
				v[1]=(KEYS_H_DIVISOR-5)*height/KEYS_H_DIVISOR;
			}
		} else {
			menuwin_ungrab_mouse(1);
			v[0]=0;
			v[1]=(KEYS_H_DIVISOR-1)*height/KEYS_H_DIVISOR;
			v[2]=width;
			v[3]=height/KEYS_H_DIVISOR;
		}
	} else {
		menuwin_ungrab_mouse(1);
		v[0]=0;
		v[1]=height-1;
		v[2]=width;
		v[3]=1;
	}
	key_win.width=v[2];
	key_win.height=v[3];
	xcb_configure_window(conn,key_win.window,value_mask,v);
	cairo_xcb_surface_set_size(key_win.surface,v[2],v[3]);
	menuwin_expose(NULL);
}
示例#6
0
void shutdown_init() {

	xcb_void_cookie_t void_cookie;

	shutdown_win.surface=NULL;
	
	shutdown_win.window = xcb_generate_id(conn);
	uint32_t values[1] = {XCB_EVENT_MASK_EXPOSURE|XCB_EVENT_MASK_BUTTON_RELEASE};

	void_cookie=xcb_create_window_checked (conn,XCB_COPY_FROM_PARENT,shutdown_win.window,scr->root,0,height-1,width,1,0,XCB_WINDOW_CLASS_INPUT_OUTPUT,scr->root_visual,XCB_CW_EVENT_MASK,values);

	xcb_flush(conn);

	if (xcb_request_check(conn,void_cookie)) {
		printf("Can't create the shutdown window\n");
		shutdown_win.window = 0;
	} else {
		uint32_t v[4];
		uint32_t value_mask;

		value_mask=XCB_CONFIG_WINDOW_X|XCB_CONFIG_WINDOW_Y|XCB_CONFIG_WINDOW_WIDTH|XCB_CONFIG_WINDOW_HEIGHT;
		v[0]=width/4;;
		v[1]=height/4;
		v[2]=width/2;
		v[3]=height/2;
		shutdown_win.width=v[2];
		shutdown_win.height=v[3];
		xcb_configure_window(conn,shutdown_win.window,value_mask,v);
		xcb_change_property(conn,XCB_PROP_MODE_REPLACE,shutdown_win.window,atoms[TWM_ATOM__NET_WM_NAME],XCB_ATOM_STRING,8,strlen(TWM_NAME),TWM_NAME);
		xcb_change_property(conn,XCB_PROP_MODE_REPLACE,shutdown_win.window,atoms[TWM_ATOM__NET_WM_WINDOW_TYPE],XCB_ATOM_ATOM,32,1,&atoms[TWM_ATOM__NET_WM_WINDOW_TYPE_DOCK]);
		shutdown_win.cache=wincache_fill_element(shutdown_win.window);
		shutdown_win.cache->mapped=0;
		xcb_flush(conn);
		shutdown_win.surface=cairo_xcb_surface_create(conn,shutdown_win.window,visual_type,width/2,height/2);
		cairo_xcb_surface_set_size(shutdown_win.surface,v[2],v[3]);
		xcb_flush(conn);
	}
}
示例#7
0
static cairo_test_status_t
test_cairo_xcb_surface_set_size (cairo_surface_t *surface)
{
    cairo_xcb_surface_set_size (surface, 5, 5);
    return CAIRO_TEST_SUCCESS;
}
示例#8
0
/*
 * Resize the surface to the given size.
 *
 */
void draw_util_surface_set_size(surface_t *surface, int width, int height) {
    surface->width = width;
    surface->height = height;
    cairo_xcb_surface_set_size(surface->surface, width, height);
}