/* From gtkcontainer.c */ void _container_propagate_expose (GtkContainer *container, GtkWidget *child, GdkEventExpose *event) { GdkEvent *child_event; g_return_if_fail (GTK_IS_CONTAINER (container)); g_return_if_fail (GTK_IS_WIDGET (child)); g_return_if_fail (event != NULL); g_assert (child->parent == GTK_WIDGET (container)); if (GTK_WIDGET_DRAWABLE (child) && GTK_WIDGET_NO_WINDOW (child) && (child->window == event->window)&& AWN_IS_CAIRO_MENU_ITEM(child)) { child_event = gdk_event_new (GDK_EXPOSE); child_event->expose = *event; g_object_ref (child_event->expose.window); child_event->expose.region = gtk_widget_region_intersect (child, event->region); if (!gdk_region_empty (child_event->expose.region)) { gdk_region_get_clipbox (child_event->expose.region, &child_event->expose.area); gtk_widget_send_expose (child, child_event); } gdk_event_free (child_event); } }
bool wxRegion::IsEmpty() const { if (!m_refData) return TRUE; return gdk_region_empty( M_REGIONDATA->m_region ); }
/* * Strategy to painting a Widget: * 1.) do not paint if there is no GtkWidget set * 2.) We assume that GTK_NO_WINDOW is set and that geometryChanged positioned * the widget correctly. ATM we do not honor the GraphicsContext translation. */ void Widget::paint(GraphicsContext* context, const IntRect&) { if (!gtkWidget()) return; GtkWidget* widget = gtkWidget(); ASSERT(GTK_WIDGET_NO_WINDOW(widget)); GdkEvent* event = gdk_event_new(GDK_EXPOSE); event->expose = *context->gdkExposeEvent(); event->expose.region = gtk_widget_region_intersect(widget, event->expose.region); /* * This will be unref'ed by gdk_event_free. */ g_object_ref(event->expose.window); /* * If we are going to paint do the translation and GtkAllocation manipulation. */ if (!gdk_region_empty(event->expose.region)) { gdk_region_get_clipbox(event->expose.region, &event->expose.area); gtk_widget_send_expose(widget, event); } gdk_event_free(event); }
gboolean scenemanager_can_draw_rectangle(scenemanager_t* pSceneManager, GdkRectangle* pRect, gint nFlags) { // // 1) Enforce on-screen rules // if(nFlags & SCENEMANAGER_FLAG_FULLY_ON_SCREEN) { // basic rect1 contains rect2 test if((pRect->x) <= 0) return FALSE; if((pRect->y) <= 0) return FALSE; if((pRect->x + pRect->width) > pSceneManager->nWindowWidth) return FALSE; if((pRect->y + pRect->height) > pSceneManager->nWindowHeight) return FALSE; } else if(nFlags & SCENEMANAGER_FLAG_PARTLY_ON_SCREEN) { // basic rect intersect test if((pRect->x + pRect->width) <= 0) return FALSE; if((pRect->y + pRect->height) <= 0) return FALSE; if((pRect->x) > pSceneManager->nWindowWidth) return FALSE; if((pRect->y) > pSceneManager->nWindowHeight) return FALSE; } // // 2) Enforce overlap rules // GdkRegion* pNewRegion = gdk_region_rectangle(pRect); gdk_region_intersect(pNewRegion, pSceneManager->pTakenRegion); // sets pNewRegion to the intersection of itself and the 'taken region' gboolean bOK = gdk_region_empty(pNewRegion); // it's ok to draw here if the intersection is empty gdk_region_destroy(pNewRegion); return bOK; }
static gint32 create_image (GdkPixbuf *pixbuf, GdkRegion *shape, const gchar *name) { gint32 image; gint32 layer; gdouble xres, yres; gchar *comment; gint width, height; gboolean status; status = gimp_progress_init (_("Importing screenshot")); width = gdk_pixbuf_get_width (pixbuf); height = gdk_pixbuf_get_height (pixbuf); image = gimp_image_new (width, height, GIMP_RGB); gimp_image_undo_disable (image); gimp_get_monitor_resolution (&xres, &yres); gimp_image_set_resolution (image, xres, yres); comment = gimp_get_default_comment (); if (comment) { GimpParasite *parasite; parasite = gimp_parasite_new ("gimp-comment", GIMP_PARASITE_PERSISTENT, strlen (comment) + 1, comment); gimp_image_parasite_attach (image, parasite); gimp_parasite_free (parasite); g_free (comment); } layer = gimp_layer_new_from_pixbuf (image, name ? name : _("Screenshot"), pixbuf, 100, GIMP_NORMAL_MODE, 0.0, 1.0); gimp_image_add_layer (image, layer, 0); if (shape && ! gdk_region_empty (shape)) { image_select_shape (image, shape); if (! gimp_selection_is_empty (image)) { gimp_layer_add_alpha (layer); gimp_edit_clear (layer); gimp_selection_none (image); } } gimp_image_undo_enable (image); return image; }
bool wxRegion::IsEmpty() const { #ifdef __WXGTK3__ return m_refData == NULL || cairo_region_is_empty(M_REGIONDATA->m_region); #else return m_refData == NULL || gdk_region_empty(M_REGIONDATA->m_region); #endif }
/* Returns TRUE if the GdkRegion is empty. */ int clip_GDK_REGIONEMPTY(ClipMachine * ClipMachineMemory) { C_object *creg = _fetch_co_arg(ClipMachineMemory); CHECKCOBJ(creg, GDK_IS_REGION(creg->object)); _clip_retl(ClipMachineMemory, gdk_region_empty(GDK_REGION(creg))); return 0; err: return 1; }
static void _gegueb_window_draw(Gegueb_Window *thiz) { cairo_t *cr; //gdk_window_begin_paint_region(thiz->win, thiz->regions); cr = gdk_cairo_create(thiz->win); gdk_cairo_region(cr, thiz->regions); gegueb_document_draw(thiz->doc, cr, thiz->damages); gdk_region_empty(thiz->regions); //gdk_window_end_paint(thiz->win); //gdk_window_flush(thiz->win); cairo_destroy(cr); thiz->damages = NULL; }
static gint gtk_form_expose(GtkWidget *widget, GdkEventExpose *event) { GList *tmp_list; GtkForm *form; g_return_val_if_fail(GTK_IS_FORM(widget), FALSE); form = GTK_FORM(widget); if (event->window == form->bin_window) return FALSE; for (tmp_list = form->children; tmp_list; tmp_list = tmp_list->next) { #ifdef HAVE_GTK2 GtkFormChild *formchild = tmp_list->data; GtkWidget *child = formchild->widget; /* * The following chunk of code is taken from gtkcontainer.c. The * gtk1.x code synthesized expose events directly on the child widgets, * which can't be done in gtk2 */ if (GTK_WIDGET_DRAWABLE(child) && GTK_WIDGET_NO_WINDOW(child) && child->window == event->window) { GdkEventExpose child_event; child_event = *event; child_event.region = gtk_widget_region_intersect(child, event->region); if (!gdk_region_empty(child_event.region)) { gdk_region_get_clipbox(child_event.region, &child_event.area); gtk_widget_send_expose(child, (GdkEvent *)&child_event); } } #else /* !HAVE_GTK2 */ GtkFormChild *child = tmp_list->data; if (event->window == child->window) return gtk_widget_event(child->widget, (GdkEvent *) event); #endif /* !HAVE_GTK2 */ } return FALSE; }
gboolean scenemanager_can_draw_polygon(scenemanager_t* pSceneManager, GdkPoint *pPoints, gint nNumPoints, gint nFlags) { // // 1) Enforce on-screen rules // if(nFlags & SCENEMANAGER_FLAG_FULLY_ON_SCREEN) { // all points must be within screen box gint i; for(i=0 ; i<nNumPoints ; i++) { GdkPoint* pPoint = &pPoints[i]; if(pPoint->x < 0 || pPoint->x > pSceneManager->nWindowWidth) return FALSE; if(pPoint->y < 0 || pPoint->y > pSceneManager->nWindowHeight) return FALSE; } // else go on to test below } else if(nFlags & SCENEMANAGER_FLAG_PARTLY_ON_SCREEN) { // one point must be withing screen box XXX: handle polygon bigger than window case? gint i; gboolean bFound = FALSE; for(i=0 ; i<nNumPoints ; i++) { GdkPoint* pPoint = &pPoints[i]; if(pPoint->x > 0 && pPoint->x < pSceneManager->nWindowWidth) { bFound = TRUE; break; } if(pPoint->y > 0 && pPoint->y < pSceneManager->nWindowHeight) { bFound = TRUE; break; } } if(!bFound) return FALSE; // else go on to test below } // // 2) Enforce overlap rules // GdkRegion* pNewRegion = gdk_region_polygon(pPoints, nNumPoints, GDK_WINDING_RULE); gdk_region_intersect(pNewRegion, pSceneManager->pTakenRegion); // sets pNewRegion to the intersection of itself and the 'taken region' gboolean bOK = gdk_region_empty(pNewRegion); // it's ok to draw here if the intersection is empty gdk_region_destroy(pNewRegion); return bOK; }
void _gdk_window_process_expose (GdkWindow *window, GdkRegion *invalidate_region) { GdkWindowImplWin32 *impl; GdkRegion *clip_region; impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl); GDK_NOTE (EVENTS, g_print ("_gdk_window_process_expose: %p %s\n", GDK_WINDOW_HWND (window), _gdk_win32_gdkregion_to_string (invalidate_region))); clip_region = gdk_region_rectangle (&impl->position_info.clip_rect); gdk_region_intersect (invalidate_region, clip_region); if (!gdk_region_empty (invalidate_region)) gdk_window_invalidate_region (window, invalidate_region, FALSE); gdk_region_destroy (clip_region); }
/* Draw handler for the pixbuf canvas item */ static void foo_canvas_pixbuf_draw (FooCanvasItem *item, GdkDrawable *drawable, GdkEventExpose *expose) { FooCanvasPixbuf *gcp; PixbufPrivate *priv; GdkRectangle display_rect, draw_rect; GdkRegion *draw_region; int w, h; gcp = FOO_CANVAS_PIXBUF (item); priv = gcp->priv; if (!priv->pixbuf) return; /* Compute the area we need to repaint */ w = item->x2 - item->x1; h = item->y2 - item->y1; display_rect.x = item->x1; display_rect.y = item->y1; display_rect.width = w; display_rect.height = h; draw_region = gdk_region_rectangle (&display_rect); gdk_region_intersect (draw_region, expose->region); if (!gdk_region_empty (draw_region)) { gdk_region_get_clipbox (draw_region, &draw_rect); gdk_draw_pixbuf (drawable, NULL, priv->pixbuf_scaled, /* pixbuf 0, 0 is at pix_rect.x, pix_rect.y */ draw_rect.x - display_rect.x, draw_rect.y - display_rect.y, draw_rect.x, draw_rect.y, draw_rect.width, draw_rect.height, GDK_RGB_DITHER_NORMAL, 0, 0); } gdk_region_destroy (draw_region); }
static GdkRegion * gdk_window_clip_changed (GdkWindow *window, GdkRectangle *old_clip, GdkRectangle *new_clip) { GdkWindowImplWin32 *impl; GdkWindowObject *obj; GdkRegion *old_clip_region; GdkRegion *new_clip_region; if (((GdkWindowObject *)window)->input_only) return NULL; obj = (GdkWindowObject *) window; impl = GDK_WINDOW_IMPL_WIN32 (obj->impl); old_clip_region = gdk_region_rectangle (old_clip); new_clip_region = gdk_region_rectangle (new_clip); /* Trim invalid region of window to new clip rectangle */ if (obj->update_area) gdk_region_intersect (obj->update_area, new_clip_region); /* Invalidate newly exposed portion of window */ gdk_region_subtract (new_clip_region, old_clip_region); if (!gdk_region_empty (new_clip_region)) gdk_window_tmp_unset_bg (window); else { gdk_region_destroy (new_clip_region); new_clip_region = NULL; } gdk_region_destroy (old_clip_region); return new_clip_region; }
void GtkPluginWidget::paint(GraphicsContext* context, const IntRect& rect) { if (!context->gdkExposeEvent()) return; /* only paint widgets with NO_WINDOW this way */ if (!GTK_WIDGET_NO_WINDOW(platformWidget())) return; GtkWidget* widget = platformWidget(); ASSERT(GTK_WIDGET_NO_WINDOW(widget)); GdkEvent* event = gdk_event_new(GDK_EXPOSE); event->expose = *context->gdkExposeEvent(); event->expose.area = static_cast<GdkRectangle>(rect); IntPoint loc = parent()->contentsToWindow(rect.location()); event->expose.area.x = loc.x(); event->expose.area.y = loc.y(); event->expose.region = gdk_region_rectangle(&event->expose.area); /* * This will be unref'ed by gdk_event_free. */ g_object_ref(event->expose.window); /* * If we are going to paint do the translation and GtkAllocation manipulation. */ if (!gdk_region_empty(event->expose.region)) gtk_widget_send_expose(widget, event); gdk_event_free(event); }
/* 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); } }
static VALUE rg_empty_p(VALUE self) { return CBOOL2RVAL(gdk_region_empty(_SELF(self))); }
/* Doesn't handle HIPPO_WINDOW_STATE_ACTIVE - see comment below */ static HippoWindowState get_window_state(Display *display, Window window) { HippoWindowState result = HIPPO_WINDOW_STATE_HIDDEN; XWindowAttributes window_attributes; GdkRectangle rect; GdkRegion *visible_region = NULL; Window child = None; Window root; Window parent; Window *children = NULL; guint n_children; gdk_error_trap_push(); /* First check if the window and all ancestors are mapped */ if (!XGetWindowAttributes(display, window, &window_attributes)) { g_debug("XGetWindowAttributes failed\n"); goto out; } if (window_attributes.map_state != IsViewable) goto out; /* Get the area of the window in parent coordinates */ rect.x = window_attributes.x; rect.y = window_attributes.y; rect.width = window_attributes.width; rect.height = window_attributes.height; visible_region = gdk_region_rectangle(&rect); if (!XQueryTree(display, window, &root, &parent, &children, &n_children)) { g_debug("XQueryTree failed\n"); goto out; } XFree(children); children = NULL; child = window; window = parent; /* Walk up the hierarchy, clipping to parents, and subtracting * overlayed siblings (yuck!) */ while (TRUE) { GdkRegion *parent_region; gboolean seen_child = FALSE; int x, y; unsigned int width, height, border, depth; unsigned int i; gdk_region_get_clipbox(visible_region, &rect); /* Clip to parent */ if (!XGetGeometry(display, window, &root, &x, &y, &width, &height, &border, &depth)) { g_debug("XGetGeometry failed\n"); goto out; } rect.x = 0; rect.y = 0; rect.width = width; rect.height= height; parent_region = gdk_region_rectangle(&rect); gdk_region_intersect(visible_region, parent_region); gdk_region_destroy(parent_region); if (gdk_region_empty(visible_region)) goto out; if (!XQueryTree(display, window, &root, &parent, &children, &n_children)) { g_debug("XQueryTree failed\n"); goto out; } for (i = 0; i < n_children; i++) { if (seen_child) { /* A sibling above */ GdkRegion *child_region; XWindowAttributes child_attributes; if (!XGetWindowAttributes(display, children[i], &child_attributes)) { g_debug("XGetWindowAttributes failed for child\n"); goto out; } if (child_attributes.map_state == IsViewable) { rect.x = child_attributes.x - child_attributes.border_width; rect.y = child_attributes.y - child_attributes.border_width; rect.width = child_attributes.width + 2 * child_attributes.border_width; rect.height = child_attributes.height + 2 * child_attributes.border_width; child_region = gdk_region_rectangle(&rect); gdk_region_subtract(visible_region, child_region); gdk_region_destroy(child_region); if (gdk_region_empty(visible_region)) goto out; } } else if (children[i] == child) { seen_child = TRUE; } } XFree(children); children = NULL; if (window == root) break; child = window; window = parent; /* Translate to parent coordinates */ gdk_region_offset(visible_region, x, y); } if (!gdk_region_empty(visible_region)) result = HIPPO_WINDOW_STATE_ONSCREEN; out: gdk_error_trap_pop(); if (children) XFree(children); if (visible_region) gdk_region_destroy(visible_region); return result; }