Beispiel #1
0
static void
hos_ornament_init(HosOrnament *self)
{
  ornament_set_sensitive(self, TRUE);
  ornament_set_visible(self, TRUE);
  self->region = gdk_region_new();
}
Beispiel #2
0
gboolean button_pressed_ACTION_ROTATE (GtkWidget *widget, GdkEventButton *event, gpointer data)
  {
  project_OP *project_options = (project_OP *)data ;
  QCADDesignObject *htobj = NULL ;
  GdkRegion *rgn = NULL ;

  if (NULL != (htobj = QCAD_DESIGN_OBJECT (design_hit_test (project_options->design, event->x, event->y))))
    if (QCAD_IS_CELL (htobj))
      {
      GdkRectangle rcReal ;
      selection_renderer_draw (project_options->srSelection, project_options->design, widget->window, GDK_XOR) ;
      qcad_cell_rotate_dots (QCAD_CELL (htobj), PI / 4.0) ;
      selection_renderer_update (project_options->srSelection, project_options->design) ;
      selection_renderer_draw (project_options->srSelection, project_options->design, widget->window, GDK_XOR) ;

      world_to_real_rect (&(htobj->bounding_box), &rcReal) ;

      rgn = gdk_region_new () ;
      gdk_region_union_with_rect (rgn, &rcReal) ;

      // redraw_async takes care of destroying rgn
      redraw_async (rgn) ;
      }

  return FALSE ;
  }
Beispiel #3
0
static void
cheese_flash_init (CheeseFlash *self)
{
  CheeseFlashPrivate *priv = CHEESE_FLASH_GET_PRIVATE (self);

  GtkWindow *window;

  priv->flash_timeout_tag = 0;
  priv->fade_timeout_tag  = 0;

  window = GTK_WINDOW (gtk_window_new (GTK_WINDOW_POPUP));

  /* make it so it doesn't look like a window on the desktop (+fullscreen) */
  gtk_window_set_decorated (window, FALSE);
  gtk_window_set_skip_taskbar_hint (window, TRUE);
  gtk_window_set_skip_pager_hint (window, TRUE);
  gtk_window_set_keep_above (window, TRUE);

  /* Don't take focus */
  gtk_window_set_accept_focus (window, FALSE);
  gtk_window_set_focus_on_map (window, FALSE);

  /* Don't consume input */
  gtk_widget_realize (GTK_WIDGET (window));
  GdkRegion *input_region;
  input_region = gdk_region_new ();
  gdk_window_input_shape_combine_region (gtk_widget_get_window (GTK_WIDGET (window)), input_region, 0, 0);
  gdk_region_destroy (input_region);

  g_signal_connect (G_OBJECT (window), "expose-event", G_CALLBACK (cheese_flash_window_expose_event_cb), NULL);
  priv->window = window;
}
Beispiel #4
0
static void cdnewregion(cdCtxCanvas *ctxcanvas)
{
  if (ctxcanvas->new_rgn)
    gdk_region_destroy(ctxcanvas->new_rgn);

  ctxcanvas->new_rgn = gdk_region_new(); 
}
Beispiel #5
0
static VALUE
rg_initialize(int argc, VALUE *argv, VALUE self)
{
    VALUE points_or_rectangle, rbfill_rule;
    GdkRegion *region;

    rb_scan_args(argc, argv, "02", &points_or_rectangle, &rbfill_rule);
    if (NIL_P(points_or_rectangle)) {
        region = gdk_region_new();
    } else if (TYPE(points_or_rectangle) == T_ARRAY) {
        GdkFillRule fill_rule = RVAL2GENUM(rbfill_rule, GDK_TYPE_FILL_RULE);
        long n;
        GdkPoint *points = RVAL2GDKPOINTS(points_or_rectangle, &n);

        region = gdk_region_polygon(points, n, fill_rule);

        g_free(points);
    } else if (RVAL2GTYPE(points_or_rectangle) == GDK_TYPE_RECTANGLE) {
        region = gdk_region_rectangle((GdkRectangle*)RVAL2BOXED(points_or_rectangle, 
                                                                GDK_TYPE_RECTANGLE));
    } else {
        rb_raise(rb_eArgError, 
                 "invalid argument %s (expect array of Gdk::Point or Gdk::Rectangle, nil)",
                 rb_class2name(CLASS_OF(points_or_rectangle)));
    }

    G_INITIALIZE(self, region);

    return Qnil;
}
Beispiel #6
0
static GdkFilterReturn 
gdk_superwin_bin_filter (GdkXEvent *gdk_xevent,
                         GdkEvent  *event,
                         gpointer   data)
{
  XEvent *xevent = (XEvent *)gdk_xevent;
  GdkSuperWin *superwin = data;
  GdkFilterReturn retval = GDK_FILTER_CONTINUE;
  GdkRegion *region = NULL;

  switch (xevent->xany.type) {
  case Expose:
    region = gdk_region_new();
    retval = GDK_FILTER_REMOVE;
    gdk_superwin_handle_expose(superwin, xevent, &region, FALSE);
    gdk_region_destroy(region);
    break;
  case KeyPress:
    if (superwin->keyprs_func)
      superwin->keyprs_func(&xevent->xkey);
    break;
  case KeyRelease:
    if (superwin->keyrel_func)
      superwin->keyrel_func(&xevent->xkey);
    break;
  default:
    break;
  }
  return retval;
}
void
gimp_display_shell_expose_region (GimpDisplayShell *shell,
                                  cairo_region_t   *region)
{
  GdkRegion *gdk_region;
  gint       n_rectangles;
  gint       i;

  g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
  g_return_if_fail (region != NULL);

  if (! gtk_widget_get_realized (shell->canvas))
    return;

  gdk_region = gdk_region_new ();
  n_rectangles = cairo_region_num_rectangles (region);

  for (i = 0; i < n_rectangles; i++)
    {
      cairo_rectangle_int_t rectangle;

      cairo_region_get_rectangle (region, i, &rectangle);

      gdk_region_union_with_rect (gdk_region, (GdkRectangle *) &rectangle);
    }

  gdk_window_invalidate_region (gtk_widget_get_window (shell->canvas),
                                gdk_region, TRUE);
  gdk_region_destroy (gdk_region);
}
Beispiel #8
0
/* Creates a new empty GdkRegion. */
int
clip_GDK_REGIONNEW(ClipMachine * ClipMachineMemory)
{
   ClipVar  *cv = _clip_spar(ClipMachineMemory, 1);

   GdkRegion *region;

   C_object *cregion;

   CHECKOPT(1, MAP_type_of_ClipVarType);

   region = gdk_region_new();

   if (region)
    {
       cregion = _register_object(ClipMachineMemory, region, GDK_TYPE_REGION, cv, NULL);
       if (cregion)
	  _clip_mclone(ClipMachineMemory, RETPTR(ClipMachineMemory), &cregion->obj);
       else
	  gdk_region_destroy(region);
    }
   return 0;
 err:
   return 1;
}
void scenemanager_new(scenemanager_t** ppReturn)
{
	// create new scenemanager and return it
	scenemanager_t* pNew = g_new0(scenemanager_t, 1);
	pNew->pLabelHash = g_hash_table_new(g_str_hash, g_str_equal);
	pNew->pTakenRegion = gdk_region_new();
	*ppReturn = pNew;
}
Beispiel #10
0
static void
clip_region_clear(DiaRenderer *object)
{
  DiaGdkRenderer *renderer = DIA_GDK_RENDERER (object);

  if (renderer->clip_region != NULL)
    gdk_region_destroy(renderer->clip_region);

  renderer->clip_region =  gdk_region_new();

  gdk_gc_set_clip_region(renderer->gc, renderer->clip_region);
}
Beispiel #11
0
static void
clip_region_clear(DiaRenderer *object)
{
  DiaCairoInteractiveRenderer *renderer = DIA_CAIRO_INTERACTIVE_RENDERER (object);

  if (renderer->clip_region != NULL)
    gdk_region_destroy(renderer->clip_region);

  renderer->clip_region =  gdk_region_new();

  gdk_gc_set_clip_region(renderer->gc, renderer->clip_region);
}
void scenemanager_clear(scenemanager_t* pSceneManager)
{
	g_assert(pSceneManager != NULL);

	// destroy and recreate hash table (XXX: better way to clear it?)
	g_hash_table_destroy(pSceneManager->pLabelHash);
	pSceneManager->pLabelHash = g_hash_table_new(g_str_hash, g_str_equal);

	// Empty the region (XXX: better way?)
	gdk_region_destroy(pSceneManager->pTakenRegion);
	pSceneManager->pTakenRegion = gdk_region_new();
}
void GraphicsContext::drawFocusRing(const Color& color)
{
    if (paintingDisabled())
        return;

    const Vector<IntRect>& rects = focusRingRects();
    unsigned rectCount = rects.size();

    cairo_t* cr = m_data->cr;
    cairo_save(cr);
    cairo_push_group(cr);
    cairo_new_path(cr);

#if PLATFORM(GTK)
    GdkRegion* reg = gdk_region_new();
    for (unsigned i = 0; i < rectCount; i++) {
        GdkRectangle rect = rects[i];
        gdk_region_union_with_rect(reg, &rect);
    }
    gdk_cairo_region(cr, reg);
    gdk_region_destroy(reg);

    setColor(cr, color);
    cairo_set_line_width(cr, 2.0f);
    setPlatformStrokeStyle(DottedStroke);
#else
    int radius = (focusRingWidth() - 1) / 2;
    for (unsigned i = 0; i < rectCount; i++)
        addPath(Path::createRoundedRectangle(rects[i], FloatSize(radius, radius)));

    // Force the alpha to 50%.  This matches what the Mac does with outline rings.
    Color ringColor(color.red(), color.green(), color.blue(), 127);
    setColor(cr, ringColor);
    cairo_set_line_width(cr, focusRingWidth());
    setPlatformStrokeStyle(SolidStroke);
#endif

    cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
    cairo_stroke_preserve(cr);

    cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
    cairo_set_fill_rule(cr, CAIRO_FILL_RULE_WINDING);
    cairo_fill(cr);

    cairo_pop_group_to_source(cr);
    cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
    cairo_paint(cr);
    cairo_restore(cr);
}
Beispiel #14
0
static void
cvw_set_dirty(CcViewWidget* self, CcDRect dirty) {
	if(G_UNLIKELY(!GTK_WIDGET_REALIZED(self))) {
		return;
	}

	if(G_UNLIKELY(!self->root)) {
		return;
	}

	{
		GtkWidget* widget = GTK_WIDGET(self);
		CcDRect visible = {
			0.0, 0.0,
			1.0 * widget->allocation.width, 1.0 * widget->allocation.height
		};

		cc_view_world_to_window(CC_VIEW(self), &dirty.x1, &dirty.y1);
		cc_view_world_to_window(CC_VIEW(self), &dirty.x2, &dirty.y2);

		dirty.x1 = floor(dirty.x1);
		dirty.y1 = floor(dirty.y1);
		dirty.x2 = ceil (dirty.x2);
		dirty.y2 = ceil (dirty.y2);

		if(cc_d_rect_intersect(dirty, visible)) {
			GdkRectangle rect = {((gint)dirty.x1),
					      ((gint)dirty.y1),
					      ((gint)dirty.x2 - dirty.x1),
					      ((gint)dirty.y2 - dirty.y1)};

			if(G_UNLIKELY(!self->priv->redraw_timeout)) {
				self->priv->dirty_region = gdk_region_new();
				self->priv->redraw_timeout = g_timeout_add(40, // ~25 FPS
									   (GSourceFunc)cvw_redraw_timeout,
									   self);
			}

			gdk_region_union_with_rect(self->priv->dirty_region, &rect);
#ifdef DEBUG_SAVED_FRAMES
			self->priv->requests++;
#endif
		}
	}
}
Beispiel #15
0
bool wxRegion::DoUnionWithRegion( const wxRegion& region )
{
    wxCHECK_MSG( region.Ok(), false, _T("invalid region") );

    if (!m_refData)
    {
        m_refData = new wxRegionRefData();
        M_REGIONDATA->m_region = gdk_region_new();
    }
    else
    {
        AllocExclusive();
    }

    gdk_region_union( M_REGIONDATA->m_region, region.GetRegion() );

    return true;
}
Beispiel #16
0
void MCNativeLayerX11::doAttach()
{
    if (m_socket == NULL)
    {
        // Create a new GTK socket to deal with the XEMBED protocol
        GtkSocket *t_socket;
		t_socket = GTK_SOCKET(gtk_socket_new());
        
        // Create a new GTK window to hold the socket
        MCRectangle t_rect;
        t_rect = m_object->getrect();
        m_child_window = GTK_WINDOW(gtk_window_new(GTK_WINDOW_POPUP));
        gtk_widget_set_parent_window(GTK_WIDGET(m_child_window), getStackGdkWindow());
        gtk_widget_realize(GTK_WIDGET(m_child_window));
        gdk_window_reparent(gtk_widget_get_window(GTK_WIDGET(m_child_window)), getStackGdkWindow(), t_rect.x, t_rect.y);
        
        // Add the socket to the window
        gtk_container_add(GTK_CONTAINER(m_child_window), GTK_WIDGET(t_socket));
        
        // The socket needs to be realised before going any further or any
        // operations on it will fail.
        gtk_widget_realize(GTK_WIDGET(t_socket));
        
        // Show the socket (we'll control visibility at the window level)
        gtk_widget_show(GTK_WIDGET(t_socket));
        
        // Create an empty region to act as an input mask while in edit mode
        m_input_shape = gdk_region_new();

		// Retain a reference to the socket
		m_socket = GTK_SOCKET(g_object_ref(G_OBJECT(t_socket)));
    }
    
    // Attach the X11 window to this socket
    if (gtk_socket_get_plug_window(m_socket) == NULL)
        gtk_socket_add_id(m_socket, m_widget_xid);
    //fprintf(stderr, "XID: %u\n", gtk_socket_get_id(m_socket));
    
    // Act as if there were a re-layer to put the widget in the right place
    doRelayer();
    doSetViewportGeometry(m_viewport_rect);
    doSetGeometry(m_rect);
    doSetVisible(ShouldShowLayer());
}
Beispiel #17
0
bool wxRegion::DoUnionWithRegion( const wxRegion& region )
{
    if (region.IsNull())
        return FALSE;

    if (!m_refData)
    {
        m_refData = new wxRegionRefData();
        M_REGIONDATA->m_region = gdk_region_new();
    }
    else
    {
        AllocExclusive();
    }

    GdkRegion *reg = gdk_regions_union( M_REGIONDATA->m_region, region.GetRegion() );
    gdk_region_destroy( M_REGIONDATA->m_region );
    M_REGIONDATA->m_region = reg;

    return TRUE;
}
Beispiel #18
0
static GdkRegion *
window_get_shape (GdkScreen       *screen,
                  GdkNativeWindow  window)
{
  GdkRegion  *shape = NULL;

#if defined(GDK_WINDOWING_X11) && defined(HAVE_X11_EXTENSIONS_SHAPE_H)
  XRectangle *rects;
  gint        rect_count;
  gint        rect_order;

  rects = XShapeGetRectangles (GDK_SCREEN_XDISPLAY (screen), window,
                               ShapeBounding,
                               &rect_count, &rect_order);

  if (rects)
    {
      if (rect_count > 1)
        {
          gint i;

          shape = gdk_region_new ();

          for (i = 0; i < rect_count; i++)
            {
              GdkRectangle rect = { rects[i].x,
                                    rects[i].y,
                                    rects[i].width,
                                    rects[i].height };

              gdk_region_union_with_rect (shape, &rect);
            }
        }

      XFree (rects);
    }
#endif

  return shape;
}
Beispiel #19
0
static GdkRegion*
marker_calculate_region(HosOrnament *self)
{
  HosCanvas *canvas = HOS_CANVAS_ITEM(self)->canvas;
  HosMarker *marker = HOS_MARKER(self);
  gdouble x, y;

  if (marker_get_pos(HOS_MARKER(self), &x, &y))
    {
      canvas_world2view(canvas, &x, &y);

      GdkRectangle rect;
      rect.x = x - marker->size;
      rect.y = y - marker->size;
      rect.width = marker->size * 2;
      rect.height = marker->size * 2;
      
      return (gdk_region_rectangle(&rect));
    }
  else
    return gdk_region_new();
}
Beispiel #20
0
static GdkRegion*
cursor_calculate_region(HosOrnament *self)
{
  g_return_if_fail(HOS_IS_CURSOR(self));
  HosCursor *cursor = HOS_CURSOR(self);

  GtkAdjustment *adjustment = cursor->adjustment;
  HosCanvas *canvas = HOS_CANVAS_ITEM(self)->canvas;

  if (GTK_IS_ADJUSTMENT(adjustment))
    {

      /* recalculate the update region */
      GdkRectangle rect;
      gdouble pos = gtk_adjustment_get_value(adjustment);
      if (cursor->orientation == HOS_VERTICAL)
	{
	  canvas_world2view(canvas, &pos, NULL);
	  rect.x = pos - (CLICK_RADIUS / 2);
	  rect.width = CLICK_RADIUS;
	  rect.y = 0;
	  rect.height = G_MAXINT;
	}
      else /* HOS_HORIZONTAL */
	{
	  canvas_world2view(canvas, NULL, &pos);
	  rect.y = pos - (CLICK_RADIUS / 2);
	  rect.height = CLICK_RADIUS;
	  rect.x = 0;
	  rect.width = G_MAXINT;
	}

      return(gdk_region_rectangle(&rect));
    }
  else
    return gdk_region_new();
}
Beispiel #21
0
static GdkRegion *
get_selected_clip (GtkTextRenderState *render_state,
                   PangoLayout        *layout,
                   PangoLayoutLine    *line,
                   int                 x,
                   int                 y,
                   int                 height,
                   int                 start_index,
                   int                 end_index)
{
  gint *ranges;
  gint n_ranges, i;
  GdkRegion *clip_region = gdk_region_new ();
  GdkRegion *tmp_region;

  pango_layout_line_get_x_ranges (line, start_index, end_index, &ranges, &n_ranges);

  for (i=0; i < n_ranges; i++)
    {
      GdkRectangle rect;

      rect.x = x + PANGO_PIXELS (ranges[2*i]);
      rect.y = y;
      rect.width = PANGO_PIXELS (ranges[2*i + 1]) - PANGO_PIXELS (ranges[2*i]);
      rect.height = height;
      
      gdk_region_union_with_rect (clip_region, &rect);
    }

  tmp_region = gdk_region_rectangle (&render_state->clip_rect);
  gdk_region_intersect (clip_region, tmp_region);
  gdk_region_destroy (tmp_region);

  g_free (ranges);
  return clip_region;
}
Beispiel #22
0
static VALUE
gdkregion_initialize(int argc, VALUE *argv, VALUE self)
{
    VALUE points_or_rectangle, fill_rule;
    GdkRegion* region;
    GdkPoint *gpoints;
    int i;

    rb_scan_args(argc, argv, "02", &points_or_rectangle, &fill_rule);
    if (NIL_P(points_or_rectangle)){
        region = gdk_region_new();
    } else if (TYPE(points_or_rectangle) == T_ARRAY){
        gpoints = ALLOCA_N(GdkPoint, RARRAY_LEN(points_or_rectangle));

        for (i = 0; i < RARRAY_LEN(points_or_rectangle); i++) {
            Check_Type(RARRAY_PTR(points_or_rectangle)[i], T_ARRAY);
            if (RARRAY_LEN(RARRAY_PTR(points_or_rectangle)[i]) < 2) {
                rb_raise(rb_eArgError, "point %d should be array of size 2", i);
            }
            gpoints[i].x = NUM2INT(RARRAY_PTR(RARRAY_PTR(points_or_rectangle)[i])[0]);
            gpoints[i].y = NUM2INT(RARRAY_PTR(RARRAY_PTR(points_or_rectangle)[i])[1]);
        }
        region = gdk_region_polygon(gpoints, RARRAY_LEN(points_or_rectangle),
                                    RVAL2GENUM(fill_rule, GDK_TYPE_FILL_RULE));
    } else if (RVAL2GTYPE(points_or_rectangle) == GDK_TYPE_RECTANGLE){
        region = gdk_region_rectangle((GdkRectangle*)RVAL2BOXED(points_or_rectangle, 
                                                                GDK_TYPE_RECTANGLE));
    } else {
        rb_raise(rb_eArgError, 
                 "invalid argument %s (expect array of Gdk::Point or Gdk::Rectangle, nil)",
                 rb_class2name(CLASS_OF(points_or_rectangle)));
    }

    G_INITIALIZE(self, region);
    return Qnil;
}
Beispiel #23
0
GdkRegion *
nsRegionGTK::GetCopyRegion() {
    if (!copyRegion) copyRegion = gdk_region_new();
    return copyRegion;
}
Beispiel #24
0
/* static */
void gdk_superwin_handle_expose (GdkSuperWin *superwin, XEvent *xevent,
                                 GdkRegion **region, gboolean dont_recurse)
{
  GSList *tmp_list;
  gboolean send_event = TRUE;
  unsigned long serial = xevent->xany.serial;
  XEvent extra_event;
  GdkRectangle rect;
  GdkRegion *tmp_region = NULL;
  gboolean   is_special = TRUE;

  /* set up our rect for the damaged area */
  rect.x = xevent->xexpose.x;
  rect.y = xevent->xexpose.y;
  rect.width = xevent->xexpose.width;
  rect.height = xevent->xexpose.height;

  /* try to see if this is a special event that matches an antiexpose */
  tmp_list = superwin->translate_queue;
  while (tmp_list) {
    GdkSuperWinTranslate *xlate = tmp_list->data;
    if (xlate->type == GDK_SUPERWIN_ANTIEXPOSE && serial == xlate->serial) {
      GdkRegion *antiexpose_region = gdk_region_new();
      tmp_region = gdk_region_union_with_rect(antiexpose_region, 
                                              &xlate->data.antiexpose.rect);
      gdk_region_destroy(antiexpose_region);
      antiexpose_region = tmp_region;
      /* if the rect of the expose event is contained in the
         antiexpose then we should just drop it on the floor. */
      if (gdk_region_rect_in(antiexpose_region, &rect) == GDK_OVERLAP_RECTANGLE_IN) {
        gdk_region_destroy(antiexpose_region);
        goto end;
      }
      gdk_region_destroy(antiexpose_region);

    }
    tmp_list = tmp_list->next;
  }

  /* we walk the list looking for any transformations */
  tmp_list = superwin->translate_queue;
  while (tmp_list) {
    GdkSuperWinTranslate *xlate = tmp_list->data;
    /* apply translations to this event if we can. */
    if (xlate->type == GDK_SUPERWIN_TRANSLATION && serial < xlate->serial ) {
      rect.x += xlate->data.translation.dx;
      rect.y += xlate->data.translation.dy;
    }
    tmp_list = tmp_list->next;
  }

  /* add this expose area to our damaged rect */

  tmp_region = gdk_region_union_with_rect(*region, &rect);
  gdk_region_destroy(*region);
  *region = tmp_region;

 end:

  /* remove any events from the queue that are old */
  tmp_list = superwin->translate_queue;
  while (tmp_list) {
    GdkSuperWinTranslate *xlate = tmp_list->data;
    if (serial > xlate->serial) {
      GSList *tmp_link = tmp_list;
      tmp_list = tmp_list->next;
      superwin->translate_queue = g_slist_remove_link(superwin->translate_queue,
                                                      tmp_link);
      g_free(tmp_link->data);
      g_slist_free_1(tmp_link);
    }
    else {
      tmp_list = tmp_list->next;
    }
  }

  /* if we're not supposed to recurse or paint then return now */
  if (dont_recurse)
    return;

  /* try to do any expose event compression we can */
  while (XCheckTypedWindowEvent(xevent->xany.display,
                                xevent->xany.window,
                                Expose,
                                &extra_event) == True) {
    gdk_superwin_handle_expose(superwin, &extra_event, region, TRUE);
  }

  /* if the region isn't empty, send the paint event */
  if (gdk_region_empty(*region) == FALSE) {
      GdkRectangle clip_box;
      gdk_region_get_clipbox(*region, &clip_box);
      if (superwin->paint_func)
        superwin->paint_func(clip_box.x, clip_box.y,
                             clip_box.width, clip_box.height,
                             superwin->func_data);
  }

}
Beispiel #25
0
 wxGdkRegion() { m_region = gdk_region_new(); }
void GraphicsContext::drawFocusRing(const Vector<IntRect>& rects, int width, int /* offset */, const Color& color)
{
    if (paintingDisabled())
        return;

    unsigned rectCount = rects.size();

    cairo_t* cr = platformContext()->cr();
    cairo_save(cr);
    cairo_push_group(cr);
    cairo_new_path(cr);

#if PLATFORM(GTK)
#ifdef GTK_API_VERSION_2
    GdkRegion* reg = gdk_region_new();
#else
    cairo_region_t* reg = cairo_region_create();
#endif

    for (unsigned i = 0; i < rectCount; i++) {
#ifdef GTK_API_VERSION_2
        GdkRectangle rect = rects[i];
        gdk_region_union_with_rect(reg, &rect);
#else
        cairo_rectangle_int_t rect = rects[i];
        cairo_region_union_rectangle(reg, &rect);
#endif
    }
    gdk_cairo_region(cr, reg);
#ifdef GTK_API_VERSION_2
    gdk_region_destroy(reg);
#else
    cairo_region_destroy(reg);
#endif
#else
    int radius = (width - 1) / 2;
    Path path;
    for (unsigned i = 0; i < rectCount; ++i) {
        if (i > 0)
            path.clear();
        path.addRoundedRect(rects[i], FloatSize(radius, radius));
        appendWebCorePathToCairoContext(cr, path);
    }
#endif
    Color ringColor = color;
    adjustFocusRingColor(ringColor);
    adjustFocusRingLineWidth(width);
    setSourceRGBAFromColor(cr, ringColor);
    cairo_set_line_width(cr, width);
    setPlatformStrokeStyle(focusRingStrokeStyle());

    cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
    cairo_stroke_preserve(cr);

    cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
    cairo_set_fill_rule(cr, CAIRO_FILL_RULE_WINDING);
    cairo_fill(cr);

    cairo_pop_group_to_source(cr);
    cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
    cairo_paint(cr);
    cairo_restore(cr);
}
Beispiel #27
0
/*============================================================================*
 *                                   API                                      *
 *============================================================================*/
EAPI Egueb_Dom_Window * gegueb_window_new(Egueb_Dom_Node *doc,
		int x, int y, int w, int h)
{
	Gegueb_Window *thiz;
	Egueb_Dom_Window *ret = NULL;
	Egueb_Dom_Node *topmost;
	Egueb_Dom_Feature *f;
	GdkWindowAttr attr;
	gint event_mask;

	if (!doc) return NULL;

	topmost = egueb_dom_document_document_element_get(doc);
	if (!topmost)
	{
		ERR("The document does not have a topmost element");
		goto no_topmost; 
	}

	/* check it it has the render feature */
	f = egueb_dom_node_feature_get(topmost, EGUEB_DOM_FEATURE_RENDER_NAME, NULL);
	if (!f)
	{
		ERR("The topmost element does not have a render feature");
		goto no_feature;
	}
	egueb_dom_feature_unref(f);

	f = egueb_dom_node_feature_get(topmost, EGUEB_DOM_FEATURE_WINDOW_NAME, NULL);
	if (!f)
	{
		ERR("The topmost element does not have a window feature");
		goto no_feature;
	}

	/* sanitize the width/height */
	/* in case the user does not provide a size */
	if (w <= 0 || h <= 0)
	{
		Egueb_Dom_Feature_Window_Hint_Data wdata;
		int whints;

		whints = egueb_dom_feature_window_hints_get(f, &wdata);
		if (whints & EGUEB_DOM_FEATURE_WINDOW_HINT_PREFERRED)
		{
			if (wdata.pref_width != -1 && w == -1)
				w = wdata.pref_width;
			if (wdata.pref_height != -1 && h == -1)
				h = wdata.pref_height;
		}

		if (whints & EGUEB_DOM_FEATURE_WINDOW_HINT_MIN_MAX)
		{
			if (wdata.min_width != -1 && w < wdata.min_width)
				w = wdata.min_width;
			if (wdata.min_height != -1 && h < wdata.min_height)
				h = wdata.min_height;

			if (wdata.max_width != -1 && w > wdata.max_width)
				w = wdata.max_width;
			if (wdata.max_height != -1 && h > wdata.max_height)
				h = wdata.max_height;
		}
	}

	if (w <= 0 || h <= 0)
	{
		ERR("Invalid size of the window %d %d", w, h);
		egueb_dom_feature_unref(f);
		goto no_feature;
	}
	egueb_dom_feature_unref(f);
	egueb_dom_feature_window_size_set(f, w, h);

	thiz = g_new0(Gegueb_Window, 1);
	/* set the event mask */
	event_mask = GDK_EXPOSURE_MASK;

	f = egueb_dom_node_feature_get(topmost,
			EGUEB_DOM_FEATURE_UI_NAME, NULL);
	if (f)
	{
		event_mask |= GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK |
				GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK |
				GDK_KEY_RELEASE_MASK;
		egueb_dom_feature_unref(f);
	}

	/* set the window attributes */
	attr.width = w;
	attr.height = h;
	attr.window_type = GDK_WINDOW_TOPLEVEL;
	attr.event_mask = event_mask;

	thiz->doc = gegueb_document_new();
	gegueb_document_document_set(thiz->doc, doc);
	gegueb_document_damage_cb_set(thiz->doc, _gegueb_window_damages, thiz);

	thiz->regions = gdk_region_new();
	thiz->win = gdk_window_new(NULL, &attr, 0);
	thiz->ewin = egueb_dom_window_new(&_dom_descriptor, thiz);
	egueb_dom_window_document_set(thiz->ewin, doc);

	gdk_event_handler_set(_gegueb_event_cb, thiz, NULL);
	gdk_window_show(thiz->win);
	egueb_dom_node_unref(topmost);

	return thiz->ewin;

no_feature:
	egueb_dom_node_unref(topmost);
no_topmost:
	egueb_dom_node_unref(doc);

	return NULL;
}