📄 gdkgeometry-x11.c
字号:
gdk_window_postmove (tmp_list->data, &parent_pos); tmp_list = tmp_list->next; }}/** * gdk_window_scroll: * @window: a #GdkWindow * @dx: Amount to scroll in the X direction * @dy: Amount to scroll in the Y direction * * Scroll the contents of @window, both pixels and children, by the given * amount. @window itself does not move. Portions of the window that the scroll * operation brings in from offscreen areas are invalidated. The invalidated * region may be bigger than what would strictly be necessary. (For X11, a * minimum area will be invalidated if the window has no subwindows, or if the * edges of the window's parent do not extend beyond the edges of the window. In * other cases, a multi-step process is used to scroll the window which may * produce temporary visual artifacts and unnecessary invalidations.) **/voidgdk_window_scroll (GdkWindow *window, gint dx, gint dy){ gboolean can_guffaw_scroll = FALSE; GdkRegion *invalidate_region; GdkWindowImplX11 *impl; GdkWindowObject *obj; GdkRectangle src_rect, dest_rect; g_return_if_fail (GDK_IS_WINDOW (window)); if (GDK_WINDOW_DESTROYED (window)) return; obj = GDK_WINDOW_OBJECT (window); impl = GDK_WINDOW_IMPL_X11 (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); } gdk_window_invalidate_region (window, invalidate_region, TRUE); gdk_region_destroy (invalidate_region); /* We can guffaw scroll if we are a child window, and the parent * does not extend beyond our edges. Otherwise, we use XCopyArea, then * move any children later */ if (GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD) { GdkWindowImplX11 *parent_impl = GDK_WINDOW_IMPL_X11 (obj->parent->impl); can_guffaw_scroll = ((dx == 0 || (obj->x <= 0 && obj->x + impl->width >= parent_impl->width)) && (dy == 0 || (obj->y <= 0 && obj->y + impl->height >= parent_impl->height))); } if (!obj->children || !can_guffaw_scroll) gdk_window_copy_area_scroll (window, &dest_rect, dx, dy); else gdk_window_guffaw_scroll (window, dx, dy);}void_gdk_window_move_resize_child (GdkWindow *window, gint x, gint y, gint width, gint height){ GdkWindowImplX11 *impl; GdkWindowObject *obj; GdkXPositionInfo new_info; GdkWindowParentPos parent_pos; GList *tmp_list; gint d_xoffset, d_yoffset; gint dx, dy; gboolean is_move; gboolean is_resize; g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); impl = GDK_WINDOW_IMPL_X11 (GDK_WINDOW_OBJECT (window)->impl); obj = GDK_WINDOW_OBJECT (window); dx = x - obj->x; dy = y - obj->y; is_move = dx != 0 || dy != 0; is_resize = impl->width != width || impl->height != height; if (!is_move && !is_resize) return; obj->x = x; obj->y = y; impl->width = width; impl->height = height; gdk_window_compute_parent_pos (impl, &parent_pos); gdk_window_compute_position (impl, &parent_pos, &new_info); gdk_window_clip_changed (window, &impl->position_info.clip_rect, &new_info.clip_rect); parent_pos.x += obj->x; parent_pos.y += obj->y; parent_pos.x11_x += new_info.x; parent_pos.x11_y += new_info.y; parent_pos.clip_rect = new_info.clip_rect; d_xoffset = new_info.x_offset - impl->position_info.x_offset; d_yoffset = new_info.y_offset - impl->position_info.y_offset; if (d_xoffset != 0 || d_yoffset != 0) { GdkRectangle new_position; gdk_window_set_static_gravities (window, TRUE); if (d_xoffset < 0 || d_yoffset < 0) gdk_window_queue_translation (window, MIN (d_xoffset, 0), MIN (d_yoffset, 0)); compute_intermediate_position (&impl->position_info, &new_info, d_xoffset, d_yoffset, &new_position); XMoveResizeWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window), new_position.x, new_position.y, new_position.width, new_position.height); tmp_list = obj->children; while (tmp_list) { gdk_window_premove (tmp_list->data, &parent_pos); tmp_list = tmp_list->next; } XMoveWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window), new_position.x + dx, new_position.y + dy); if (d_xoffset > 0 || d_yoffset > 0) gdk_window_queue_translation (window, MAX (d_xoffset, 0), MAX (d_yoffset, 0)); XMoveResizeWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window), new_info.x, new_info.y, new_info.width, new_info.height); if (impl->position_info.no_bg) _gdk_x11_window_tmp_reset_bg (window, FALSE); if (!impl->position_info.mapped && new_info.mapped && GDK_WINDOW_IS_MAPPED (obj)) XMapWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window)); impl->position_info = new_info; tmp_list = obj->children; while (tmp_list) { gdk_window_postmove (tmp_list->data, &parent_pos); tmp_list = tmp_list->next; } } else { if (is_move && is_resize) gdk_window_set_static_gravities (window, FALSE); if (impl->position_info.mapped && !new_info.mapped) XUnmapWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window)); tmp_list = obj->children; while (tmp_list) { gdk_window_premove (tmp_list->data, &parent_pos); tmp_list = tmp_list->next; } if (is_resize) XMoveResizeWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window), new_info.x, new_info.y, new_info.width, new_info.height); else XMoveWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window), new_info.x, new_info.y); tmp_list = obj->children; while (tmp_list) { gdk_window_postmove (tmp_list->data, &parent_pos); tmp_list = tmp_list->next; } if (impl->position_info.no_bg) _gdk_x11_window_tmp_reset_bg (window, FALSE); if (!impl->position_info.mapped && new_info.mapped && GDK_WINDOW_IS_MAPPED (obj)) XMapWindow (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window)); impl->position_info = new_info; }}static voidgdk_window_compute_position (GdkWindowImplX11 *window, GdkWindowParentPos *parent_pos, GdkXPositionInfo *info){ GdkWindowObject *wrapper; int parent_x_offset; int parent_y_offset; g_return_if_fail (GDK_IS_WINDOW_IMPL_X11 (window)); wrapper = GDK_WINDOW_OBJECT (GDK_DRAWABLE_IMPL_X11 (window)->wrapper); info->big = FALSE; if (window->width <= 32767) { info->width = window->width; info->x = parent_pos->x + wrapper->x - parent_pos->x11_x; } else { info->big = TRUE; info->width = 32767; if (parent_pos->x + wrapper->x < -16384) { if (parent_pos->x + wrapper->x + window->width < 16384) info->x = parent_pos->x + wrapper->x + window->width - info->width - parent_pos->x11_x; else info->x = -16384 - parent_pos->x11_x; } else info->x = parent_pos->x + wrapper->x - parent_pos->x11_x; } if (window->height <= 32767) { info->height = window->height; info->y = parent_pos->y + wrapper->y - parent_pos->x11_y; } else { info->big = TRUE; info->height = 32767; if (parent_pos->y + wrapper->y < -16384) { if (parent_pos->y + wrapper->y + window->height < 16384) info->y = parent_pos->y + wrapper->y + window->height - info->height - parent_pos->x11_y; else info->y = -16384 - parent_pos->x11_y; } else info->y = parent_pos->y + wrapper->y - parent_pos->x11_y; } parent_x_offset = parent_pos->x11_x - parent_pos->x; parent_y_offset = parent_pos->x11_y - parent_pos->y; info->x_offset = parent_x_offset + info->x - wrapper->x; info->y_offset = parent_y_offset + info->y - wrapper->y; /* We don't considering the clipping of toplevel windows and their immediate children * by their parents, and simply always map those windows. */ if (parent_pos->clip_rect.width == G_MAXINT) info->mapped = TRUE; /* Check if the window would wrap around into the visible space in either direction */ else if (info->x + parent_x_offset < parent_pos->clip_rect.x + parent_pos->clip_rect.width - 65536 || info->x + info->width + parent_x_offset > parent_pos->clip_rect.x + 65536 || info->y + parent_y_offset < parent_pos->clip_rect.y + parent_pos->clip_rect.height - 65536 || info->y + info->height + parent_y_offset > parent_pos->clip_rect.y + 65536) info->mapped = FALSE; else info->mapped = TRUE; info->no_bg = FALSE; if (GDK_WINDOW_TYPE (wrapper) == GDK_WINDOW_CHILD) { info->clip_rect.x = wrapper->x; info->clip_rect.y = wrapper->y; info->clip_rect.width = window->width; info->clip_rect.height = window->height; gdk_rectangle_intersect (&info->clip_rect, &parent_pos->clip_rect, &info->clip_rect); info->clip_rect.x -= wrapper->x; info->clip_rect.y -= wrapper->y; } else { info->clip_rect.x = 0; info->clip_rect.y = 0; info->clip_rect.width = G_MAXINT; info->clip_rect.height = G_MAXINT; }}static voidgdk_window_compute_parent_pos (GdkWindowImplX11 *window, GdkWindowParentPos *parent_pos){ GdkWindowObject *wrapper; GdkWindowObject *parent; GdkRectangle tmp_clip; int clip_xoffset = 0; int clip_yoffset = 0; g_return_if_fail (GDK_IS_WINDOW_IMPL_X11 (window)); wrapper = GDK_WINDOW_OBJECT (GDK_DRAWABLE_IMPL_X11 (window)->wrapper); parent_pos->x = 0; parent_pos->y = 0; parent_pos->x11_x = 0; parent_pos->x11_y = 0; /* We take a simple approach here and simply consider toplevel * windows not to clip their children on the right/bottom, since the * size of toplevel windows is not directly under our * control. Clipping only really matters when scrolling and * generally we aren't going to be moving the immediate child of a * toplevel beyond the bounds of that toplevel. * * We could go ahead and recompute the clips of toplevel windows and * their descendents when we receive size notification, but it would * probably not be an improvement in most cases. */ parent_pos->clip_rect.x = 0; parent_pos->clip_rect.y = 0; parent_pos->clip_rect.width = G_MAXINT; parent_pos->clip_rect.height = G_MAXINT;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -