void ChromeClient::scroll(const IntSize& delta, const IntRect& rectToScroll, const IntRect& clipRect) { GdkWindow* window = GTK_WIDGET(m_webView)->window; if (!window) return; // We cannot use gdk_window_scroll here because it is only able to // scroll the whole window at once, and we often need to scroll // portions of the window only (think frames). GdkRectangle area = clipRect; GdkRectangle moveRect; GdkRectangle sourceRect = area; sourceRect.x -= delta.width(); sourceRect.y -= delta.height(); GdkRegion* invalidRegion = gdk_region_rectangle(&area); if (gdk_rectangle_intersect(&area, &sourceRect, &moveRect)) { GdkRegion* moveRegion = gdk_region_rectangle(&moveRect); gdk_window_move_region(window, moveRegion, delta.width(), delta.height()); gdk_region_offset(moveRegion, delta.width(), delta.height()); gdk_region_subtract(invalidRegion, moveRegion); gdk_region_destroy(moveRegion); } gdk_window_invalidate_region(window, invalidRegion, FALSE); gdk_region_destroy(invalidRegion); }
void ChromeClient::scroll(const IntSize& delta, const IntRect& rectToScroll, const IntRect& clipRect) { if (!m_webView) return; GdkWindow* window = GTK_WIDGET(m_webView)->window; if (!window) return; GdkRectangle area = clipRect; GdkRectangle moveRect; GdkRectangle sourceRect = area; sourceRect.x -= delta.width(); sourceRect.y -= delta.height(); GdkRegion* invalidRegion = gdk_region_rectangle(&area); if (gdk_rectangle_intersect(&area, &sourceRect, &moveRect)) { GdkRegion* moveRegion = gdk_region_rectangle(&moveRect); gdk_window_move_region(window, moveRegion, delta.width(), delta.height()); gdk_region_offset(moveRegion, delta.width(), delta.height()); gdk_region_subtract(invalidRegion, moveRegion); gdk_region_destroy(moveRegion); } gdk_window_invalidate_region(window, invalidRegion, FALSE); gdk_region_destroy(invalidRegion); }
static void cdoffsetregion(cdCtxCanvas *ctxcanvas, int x, int y) { if (!ctxcanvas->new_rgn) return; gdk_region_offset(ctxcanvas->new_rgn, x, y); }
//__________________________________________________________________ void _HYPlatformButton::_Paint (Ptr p) { _HYButton * theParent = (_HYButton*)this; GdkRectangle cRect = HYRect2GDKRect(*(_HYRect*)p); if (!(theParent->settings.width&HY_COMPONENT_TRANSP_BG)) { if (theParent->parentWindow->window) { GdkGC *buttonGC = gdk_gc_new (theParent->parentWindow->window); gdk_gc_set_foreground(buttonGC,&bgColor); GdkRegion * r1 = gdk_region_rectangle(&cRect), * r2 = gdk_region_rectangle (&buttonRect); gdk_region_subtract (r1,r2); gdk_region_offset (r1,theParent->parentWindow->allocation.x,theParent->parentWindow->allocation.y); gdk_gc_set_clip_region (buttonGC,r1); gdk_draw_rectangle(theParent->parentWindow->window,buttonGC,true,cRect.x+theParent->parentWindow->allocation.x, cRect.y+theParent->parentWindow->allocation.y, cRect.width, cRect.height); gdk_region_destroy(r1); gdk_region_destroy(r2); g_object_unref (buttonGC); } } (*theParent)._HYPlatformComponent::_Paint(p); }
bool wxRegion::DoOffset( wxCoord x, wxCoord y ) { if (!m_refData) return FALSE; AllocExclusive(); gdk_region_offset( M_REGIONDATA->m_region, x, y ); return TRUE; }
bool wxRegion::DoOffset( wxCoord x, wxCoord y ) { wxCHECK_MSG( m_refData, false, wxS("invalid region") ); AllocExclusive(); #ifdef __WXGTK3__ cairo_region_translate(M_REGIONDATA->m_region, x, y); #else gdk_region_offset( M_REGIONDATA->m_region, x, y ); #endif return true; }
void ChromeClient::scroll(const IntSize& delta, const IntRect& rectToScroll, const IntRect& clipRect) { GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(m_webView)); if (!window) return; m_pendingScrollInvalidations = true; // We cannot use gdk_window_scroll here because it is only able to // scroll the whole window at once, and we often need to scroll // portions of the window only (think frames). GdkRectangle area = clipRect; GdkRectangle moveRect; GdkRectangle sourceRect = area; sourceRect.x -= delta.width(); sourceRect.y -= delta.height(); #ifdef GTK_API_VERSION_2 GdkRegion* invalidRegion = gdk_region_rectangle(&area); if (gdk_rectangle_intersect(&area, &sourceRect, &moveRect)) { GdkRegion* moveRegion = gdk_region_rectangle(&moveRect); gdk_window_move_region(window, moveRegion, delta.width(), delta.height()); gdk_region_offset(moveRegion, delta.width(), delta.height()); gdk_region_subtract(invalidRegion, moveRegion); gdk_region_destroy(moveRegion); } gdk_window_invalidate_region(window, invalidRegion, FALSE); gdk_region_destroy(invalidRegion); #else cairo_region_t* invalidRegion = cairo_region_create_rectangle(&area); if (gdk_rectangle_intersect(&area, &sourceRect, &moveRect)) { cairo_region_t* moveRegion = cairo_region_create_rectangle(&moveRect); gdk_window_move_region(window, moveRegion, delta.width(), delta.height()); cairo_region_translate(moveRegion, delta.width(), delta.height()); cairo_region_subtract(invalidRegion, moveRegion); cairo_region_destroy(moveRegion); } gdk_window_invalidate_region(window, invalidRegion, FALSE); cairo_region_destroy(invalidRegion); #endif }
/* Moves a region the specified distance. */ int clip_GDK_REGIONOFFSET(ClipMachine * ClipMachineMemory) { C_object *creg = _fetch_co_arg(ClipMachineMemory); gint dx = _clip_parni(ClipMachineMemory, 2); gint dy = _clip_parni(ClipMachineMemory, 3); CHECKCOBJ(creg, GDK_IS_REGION(creg->object)); CHECKOPT(2, NUMERIC_type_of_ClipVarType); CHECKOPT(3, NUMERIC_type_of_ClipVarType); gdk_region_offset(GDK_REGION(creg), dx, dy); return 0; err: return 1; }
static VALUE rg_offset(VALUE self, VALUE dx, VALUE dy) { gdk_region_offset(_SELF(self), NUM2INT(dx), NUM2INT(dy)); return self; }
static gint32 shoot (GdkScreen *screen) { GdkDisplay *display; GdkWindow *window; GdkPixbuf *screenshot; GdkRegion *shape = NULL; GdkRectangle rect; GdkRectangle screen_rect; gchar *name = NULL; gint32 image; gint screen_x; gint screen_y; gint x, y; /* use default screen if we are running non-interactively */ if (screen == NULL) screen = gdk_screen_get_default (); display = gdk_screen_get_display (screen); screen_rect.x = 0; screen_rect.y = 0; screen_rect.width = gdk_screen_get_width (screen); screen_rect.height = gdk_screen_get_height (screen); if (shootvals.shoot_type == SHOOT_REGION) { rect.x = MIN (shootvals.x1, shootvals.x2); rect.y = MIN (shootvals.y1, shootvals.y2); rect.width = ABS (shootvals.x2 - shootvals.x1); rect.height = ABS (shootvals.y2 - shootvals.y1); } else { if (shootvals.shoot_type == SHOOT_ROOT) { window = gdk_screen_get_root_window (screen); } else { window = gdk_window_foreign_new_for_display (display, shootvals.window_id); } if (! window) { g_message (_("Specified window not found")); return -1; } gdk_drawable_get_size (GDK_DRAWABLE (window), &rect.width, &rect.height); gdk_window_get_origin (window, &x, &y); rect.x = x; rect.y = y; } if (! gdk_rectangle_intersect (&rect, &screen_rect, &rect)) return -1; window = gdk_screen_get_root_window (screen); gdk_window_get_origin (window, &screen_x, &screen_y); screenshot = gdk_pixbuf_get_from_drawable (NULL, window, NULL, rect.x - screen_x, rect.y - screen_y, 0, 0, rect.width, rect.height); gdk_display_beep (display); gdk_flush (); if (! screenshot) { g_message (_("There was an error taking the screenshot.")); return -1; } if (shootvals.shoot_type == SHOOT_WINDOW) { name = window_get_title (display, shootvals.window_id); shape = window_get_shape (screen, shootvals.window_id); if (shape) gdk_region_offset (shape, x - rect.x, y - rect.y); } image = create_image (screenshot, shape, name); g_object_unref (screenshot); if (shape) gdk_region_destroy (shape); g_free (name); return image; }
void gdk_window_move_region (GdkWindow *window, GdkRegion *region, gint dx, gint dy) { GdkRegion *invalidate_region; GdkWindowImplWin32 *impl; GdkWindowObject *obj; GdkRectangle src_rect, dest_rect; HRGN hrgn; RECT clipRect, destRect; g_return_if_fail (GDK_IS_WINDOW (window)); if (GDK_WINDOW_DESTROYED (window)) return; obj = GDK_WINDOW_OBJECT (window); impl = GDK_WINDOW_IMPL_WIN32 (obj->impl); if (dx == 0 && dy == 0) return; /* Move the current invalid region */ if (obj->update_area) gdk_region_offset (obj->update_area, dx, dy); /* impl->position_info.clip_rect isn't meaningful for toplevels */ if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD) src_rect = impl->position_info.clip_rect; else { src_rect.x = 0; src_rect.y = 0; src_rect.width = impl->width; src_rect.height = impl->height; } invalidate_region = gdk_region_rectangle (&src_rect); dest_rect = src_rect; dest_rect.x += dx; dest_rect.y += dy; gdk_rectangle_intersect (&dest_rect, &src_rect, &dest_rect); if (dest_rect.width > 0 && dest_rect.height > 0) { GdkRegion *tmp_region; tmp_region = gdk_region_rectangle (&dest_rect); gdk_region_subtract (invalidate_region, tmp_region); gdk_region_destroy (tmp_region); } /* no guffaw scroll on win32 */ hrgn = _gdk_win32_gdkregion_to_hrgn(invalidate_region, 0, 0); gdk_region_destroy (invalidate_region); destRect.left = dest_rect.y; destRect.top = dest_rect.x; destRect.right = dest_rect.x + dest_rect.width; destRect.bottom = dest_rect.y + dest_rect.height; clipRect.left = src_rect.y; clipRect.top = src_rect.x; clipRect.right = src_rect.x + src_rect.width; clipRect.bottom = src_rect.y + src_rect.height; g_print ("ScrollWindowEx(%d, %d, ...) - if you see this work, remove trace;)\n", dx, dy); API_CALL(ScrollWindowEx, (GDK_WINDOW_HWND (window), dx, dy, /* in: scroll offsets */ NULL, /* in: scroll rect, NULL == entire client area */ &clipRect, /* in: restrict to */ hrgn, /* in: update region */ NULL, /* out: update rect */ SW_INVALIDATE)); API_CALL(DeleteObject, (hrgn)); }
void gdk_window_scroll (GdkWindow *window, gint dx, gint dy) { GdkRegion *invalidate_region; GdkWindowImplWin32 *impl; GdkWindowObject *obj; GList *tmp_list; GdkWindowParentPos parent_pos; HRGN native_invalidate_region; g_return_if_fail (GDK_IS_WINDOW (window)); if (GDK_WINDOW_DESTROYED (window)) return; GDK_NOTE (EVENTS, g_print ("gdk_window_scroll: %p %d,%d\n", GDK_WINDOW_HWND (window), dx, dy)); obj = GDK_WINDOW_OBJECT (window); impl = GDK_WINDOW_IMPL_WIN32 (obj->impl); if (dx == 0 && dy == 0) return; /* Move the current invalid region */ if (obj->update_area) gdk_region_offset (obj->update_area, dx, dy); gdk_window_compute_parent_pos (impl, &parent_pos); parent_pos.x += obj->x; parent_pos.y += obj->y; parent_pos.win32_x += impl->position_info.x; parent_pos.win32_y += impl->position_info.y; parent_pos.clip_rect = impl->position_info.clip_rect; gdk_window_tmp_unset_bg (window); native_invalidate_region = CreateRectRgn (0, 0, 0, 0); if (native_invalidate_region == NULL) WIN32_API_FAILED ("CreateRectRgn"); API_CALL (ScrollWindowEx, (GDK_WINDOW_HWND (window), dx, dy, NULL, NULL, native_invalidate_region, NULL, SW_SCROLLCHILDREN)); if (impl->position_info.no_bg) gdk_window_tmp_reset_bg (window); tmp_list = obj->children; while (tmp_list) { GDK_WINDOW_OBJECT(tmp_list->data)->x += dx; GDK_WINDOW_OBJECT(tmp_list->data)->y += dy; gdk_window_postmove (tmp_list->data, &parent_pos, FALSE); tmp_list = tmp_list->next; } if (native_invalidate_region != NULL) { invalidate_region = _gdk_win32_hrgn_to_region (native_invalidate_region); gdk_region_offset (invalidate_region, impl->position_info.x_offset, impl->position_info.y_offset); gdk_window_invalidate_region (window, invalidate_region, TRUE); gdk_region_destroy (invalidate_region); GDI_CALL (DeleteObject, (native_invalidate_region)); } }
/* 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; }